Advertisement
Guest User

main.cpp

a guest
Aug 19th, 2015
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.58 KB | None | 0 0
  1. #pragma once
  2. #include "window.h"
  3. #include "dxmanager.h"
  4. #include <Windows.h>
  5. #include <d3d10.h>
  6. int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
  7. {
  8.     //creates a pointer for the window
  9.     Window* window = new Window();
  10.     //creates a pointer for DirectX
  11.     DXManager* DXM = new DXManager();
  12.     ID3D10Device* d3dDevice = NULL; //sofrware controller to the graphics device
  13.     IDXGISwapChain* swapChain = NULL; //buffer to stop screen flickering (multilayered visuals)
  14.     ID3D10RenderTargetView* renderTargetView = NULL; //render target for back buffer
  15.     int width = 1024; //window width
  16.     int height = 768; //window height
  17.     bool windowed = true; //windowed (T/F)
  18.     HWND hwnd = NULL; //window instance
  19.     LPCTSTR wndClassName = "Perception"; //class name
  20.     LPCSTR wndTitle = "Perception - Pre-game"; //window title
  21.  
  22.  
  23.  
  24.     //initializes the window, and if it fails, quits and sends a message.
  25.     if (!window->InitializeWindow(&hInstance, &hwnd, wndClassName, wndTitle, nShowCmd, &width, &height, &windowed))
  26.     {
  27.         MessageBox(0, "Window Initialization - Failed", "Error", MB_OK);
  28.         return 0;
  29.     }
  30.     //Initializes Direct3D
  31.     if (!DXM->InitializeDirect3dApp(&hInstance, &hwnd, d3dDevice, swapChain, renderTargetView, &width, &height, &windowed))
  32.     {
  33.         MessageBox(0, "Direct3D Initialization - Failed", "Error", MB_OK);
  34.         return 0;
  35.     }
  36.     //If all else succeeds, Initializes the scene.
  37.     if (!DXM->InitScene())
  38.     {
  39.         MessageBox(0, "Scene Initialization - Failed", "Error", MB_OK);
  40.         return 0;
  41.     }
  42.     window->messageLoop(DXM,d3dDevice, swapChain, renderTargetView);
  43.     return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement