diff --git a/Escape-the-Dawn.sln b/Escape-the-Dawn.sln index 8827c46..9702c5a 100644 --- a/Escape-the-Dawn.sln +++ b/Escape-the-Dawn.sln @@ -1,18 +1,24 @@  -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Escape-the-Dawn", "Escape-the-Dawn\Escape-the-Dawn.vcxproj", "{FE405CFA-8FCE-4867-92CF-797E73B36482}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 + MinSizeRel|Win32 = MinSizeRel|Win32 Release|Win32 = Release|Win32 + RelWithDebInfo|Win32 = RelWithDebInfo|Win32 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {FE405CFA-8FCE-4867-92CF-797E73B36482}.Debug|Win32.ActiveCfg = Debug|Win32 {FE405CFA-8FCE-4867-92CF-797E73B36482}.Debug|Win32.Build.0 = Debug|Win32 + {FE405CFA-8FCE-4867-92CF-797E73B36482}.MinSizeRel|Win32.ActiveCfg = Release|Win32 + {FE405CFA-8FCE-4867-92CF-797E73B36482}.MinSizeRel|Win32.Build.0 = Release|Win32 {FE405CFA-8FCE-4867-92CF-797E73B36482}.Release|Win32.ActiveCfg = Release|Win32 {FE405CFA-8FCE-4867-92CF-797E73B36482}.Release|Win32.Build.0 = Release|Win32 + {FE405CFA-8FCE-4867-92CF-797E73B36482}.RelWithDebInfo|Win32.ActiveCfg = Release|Win32 + {FE405CFA-8FCE-4867-92CF-797E73B36482}.RelWithDebInfo|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Escape-the-Dawn/Direct3D.cpp b/Escape-the-Dawn/Direct3D.cpp deleted file mode 100644 index 5e2a0c0..0000000 --- a/Escape-the-Dawn/Direct3D.cpp +++ /dev/null @@ -1,76 +0,0 @@ -#include "Direct3D.h" - -void Direct3D::Initialize(Window* window) -{ - m_Window = window; - - DXGI_SWAP_CHAIN_DESC scd = { 0 }; - scd.BufferCount = 1; - scd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; - scd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; - scd.OutputWindow = window->GetHandle(); - scd.SampleDesc.Count = 4; - scd.Windowed = TRUE; - scd.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH; - - D3D11CreateDeviceAndSwapChain( - NULL, - D3D_DRIVER_TYPE_HARDWARE, - NULL, - NULL, - NULL, - NULL, - D3D11_SDK_VERSION, - &scd, - &SwapChain, - &Device, - NULL, - &DeviceContext); - - // Set the back buffer render target - ID3D11Texture2D* pBackBuffer; - SwapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), (void**)&pBackBuffer); - Device->CreateRenderTargetView(pBackBuffer, NULL, &BackBuffer); - pBackBuffer->Release(); - DeviceContext->OMSetRenderTargets(1, &BackBuffer, NULL); - - // Set the viewport - D3D11_VIEWPORT viewport = { 0 }; - viewport.TopLeftX = 0; - viewport.TopLeftY = 0; - viewport.Width = window->GetWidth(); - viewport.Height = window->GetHeight(); - DeviceContext->RSSetViewports(1, &viewport); -} - -void Direct3D::Resize(int width, int height) -{ - DeviceContext->OMSetRenderTargets(0, 0, 0); - BackBuffer->Release(); - - HRESULT hr; // TODO: Error handling - // Preserve the existing buffer count and format. - hr = SwapChain->ResizeBuffers(0, width, height, DXGI_FORMAT_UNKNOWN, 0); - - ID3D11Texture2D* pBuffer; - hr = SwapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), (void**)&pBuffer); - hr = Device->CreateRenderTargetView(pBuffer, NULL, &BackBuffer); - pBuffer->Release(); - DeviceContext->OMSetRenderTargets(1, &BackBuffer, NULL); - - // Set the viewport - D3D11_VIEWPORT viewport = { 0 }; - viewport.TopLeftX = 0; - viewport.TopLeftY = 0; - viewport.Width = width; - viewport.Height = height; - DeviceContext->RSSetViewports(1, &viewport); -} - -Direct3D::~Direct3D() -{ - SwapChain->Release(); - BackBuffer->Release(); - Device->Release(); - DeviceContext->Release(); -} \ No newline at end of file diff --git a/Escape-the-Dawn/Direct3D.h b/Escape-the-Dawn/Direct3D.h deleted file mode 100644 index b2338bd..0000000 --- a/Escape-the-Dawn/Direct3D.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef Direct3D_h__ -#define Direct3D_h__ - -#include -#include -#include -#pragma comment (lib, "d3d11.lib") -#pragma comment (lib, "d3dx11.lib") -#pragma comment (lib, "d3dx10.lib") - -#include "Window.h" - -class Direct3D -{ -public: - Direct3D() { } - ~Direct3D(); - - IDXGISwapChain* SwapChain; - ID3D11Device* Device; - ID3D11DeviceContext* DeviceContext; - ID3D11RenderTargetView* BackBuffer; - - void Initialize(Window* window); - void Resize(int width, int height); - -private: - Window* m_Window; -}; - -#endif // Direct3D_h__ \ No newline at end of file diff --git a/Escape-the-Dawn/Escape-the-Dawn.vcxproj b/Escape-the-Dawn/Escape-the-Dawn.vcxproj index 6dcf58e..8e7f207 100644 --- a/Escape-the-Dawn/Escape-the-Dawn.vcxproj +++ b/Escape-the-Dawn/Escape-the-Dawn.vcxproj @@ -19,12 +19,14 @@ Application true MultiByte + v110 Application false true MultiByte + v110 @@ -72,13 +74,7 @@ - - - - - - diff --git a/Escape-the-Dawn/Escape-the-Dawn.vcxproj.filters b/Escape-the-Dawn/Escape-the-Dawn.vcxproj.filters index 8ab4e70..8755a3a 100644 --- a/Escape-the-Dawn/Escape-the-Dawn.vcxproj.filters +++ b/Escape-the-Dawn/Escape-the-Dawn.vcxproj.filters @@ -18,19 +18,5 @@ Source Files - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - \ No newline at end of file diff --git a/Escape-the-Dawn/Window.cpp b/Escape-the-Dawn/Window.cpp deleted file mode 100644 index 745198a..0000000 --- a/Escape-the-Dawn/Window.cpp +++ /dev/null @@ -1,69 +0,0 @@ -#include "Window.h" - -LRESULT CALLBACK Window::MsgRouter(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - if (msg == WM_CREATE) - SetWindowLong(hWnd, GWL_USERDATA, reinterpret_cast(LPCREATESTRUCT(lParam)->lpCreateParams)); - - Window* wnd = reinterpret_cast(GetWindowLong(hWnd, GWL_USERDATA)); - - if (wnd) - return wnd->WndProc(msg, wParam, lParam); - else - return DefWindowProc(hWnd, msg, wParam, lParam); -} - -void Window::Create(std::string title, int width, int height) -{ - m_Width = width; - m_Height = height; - - WNDCLASSEX wc = { 0 }; - wc.cbSize = sizeof(WNDCLASSEX); - wc.style = CS_HREDRAW | CS_VREDRAW; - wc.lpfnWndProc = Window::MsgRouter; - wc.hInstance = m_hInstance; - wc.hCursor = LoadCursor(NULL, IDC_ARROW); - wc.hbrBackground = (HBRUSH)COLOR_WINDOW; - wc.lpszClassName = "WindowClass1"; - - // register the window class - RegisterClassEx(&wc); - - // create the window and use the result as the handle - m_hWnd = CreateWindowEx( - NULL, - "WindowClass1", - title.c_str(), - WS_OVERLAPPEDWINDOW, - CW_USEDEFAULT, - CW_USEDEFAULT, - width, - height, - NULL, - NULL, - m_hInstance, - reinterpret_cast(this)); -} - -void Window::Show(int nCmdShow /*= SW_SHOW*/) -{ - ShowWindow(m_hWnd, nCmdShow); -} - -LRESULT CALLBACK Window::WndProc(UINT msg, WPARAM wParam, LPARAM lParam) -{ - switch (msg) - { - case WM_CREATE: - OutputDebugString("WM_CREATE\n"); - case WM_CLOSE: - DestroyWindow(m_hWnd); - return 0; - case WM_DESTROY: - PostQuitMessage(0); - return 0; - default: - return DefWindowProc(m_hWnd, msg, wParam, lParam); - } -} \ No newline at end of file diff --git a/Escape-the-Dawn/Window.h b/Escape-the-Dawn/Window.h deleted file mode 100644 index d738dec..0000000 --- a/Escape-the-Dawn/Window.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef Window_h__ -#define Window_h__ - -#include - -#include - -class Window -{ -public: - Window(HINSTANCE hInstance) - : m_hInstance(hInstance) { } - - HWND GetHandle() { return m_hWnd; } - int GetWidth() { return m_Width; } - int GetHeight() { return m_Height; } - - void Create(std::string title, int width, int height); - void Show(int nCmdShow = SW_SHOW); - - static LRESULT CALLBACK MsgRouter(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); - -protected: - HWND m_hWnd; - HINSTANCE m_hInstance; - int m_Width; - int m_Height; - - virtual LRESULT CALLBACK WndProc(UINT msg, WPARAM wParam, LPARAM lParam); -}; - -#endif // Window_h__ \ No newline at end of file diff --git a/Escape-the-Dawn/main.cpp b/Escape-the-Dawn/main.cpp index 499906a..d2edf5e 100644 --- a/Escape-the-Dawn/main.cpp +++ b/Escape-the-Dawn/main.cpp @@ -1,57 +1,4 @@ -#include -#include - -#include "Direct3D.h" -#include "Window.h" - -Direct3D* d3d; - -void Update(); -void Draw(); - -//int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) int main(int argc, char* argv[]) { - HINSTANCE hInstance = GetModuleHandle(NULL); - - d3d = new Direct3D(); - - Window wnd(hInstance); - wnd.Create("Escape the Dawn", 1280, 720); - d3d->Initialize(&wnd); - wnd.Show(); - - MSG msg = { 0 }; - while (true) - { - // Check to see if any messages are waiting in the queue - if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) - { - TranslateMessage(&msg); - DispatchMessage(&msg); - - if (msg.message == WM_QUIT) - break; - } - else - { - Update(); - Draw(); - } - } - - // return this part of the WM_QUIT message to Windows - return msg.wParam; -} - -void Update() -{ - -} - -void Draw() -{ - d3d->DeviceContext->ClearRenderTargetView(d3d->BackBuffer, D3DXCOLOR(0.0f, 0.2f, 0.4f, 1.0f)); - - d3d->SwapChain->Present(0, 0); + return 0; } \ No newline at end of file