Advertisement
Guest User

dxSystem.h

a guest
Dec 1st, 2011
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.06 KB | None | 0 0
  1. #ifndef DXSYSTEM
  2. #define DXSYSTEM
  3.  
  4. #include "dxD3D.h"
  5.  
  6. const bool FULL_SCREEN = false;
  7. const float SCREEN_DEPTH = 1000.0f;
  8. const float SCREEN_NEAR = 0.1f;
  9.  
  10. /**************************************************************************************
  11. * dxSystem
  12. * Simon GL Jordan
  13.  
  14. * Description:
  15. * The main workhorse of the directX to Windows interface in the engine.
  16. * Handles safe construction and deletion of DirectX resources.
  17. *
  18. * Use:
  19. * All main elements are included here, dxSystem pieces together parts of the engine.
  20. * All rendering and processing is done here of other engine elements, before being
  21. * parsed into winMain
  22. *
  23. * Future Implementations:
  24. * 1. Input system
  25. * 2.System timer
  26. * 3.System resources analysis(memory, disk space)
  27. ***************************************************************************************/
  28. dxD3D * m_dxD3D;
  29.  
  30. class dxSystem
  31. {
  32. private:
  33.     HWND*               hWnd;
  34. public:
  35.     dxSystem();
  36.     dxSystem(const dxSystem&);
  37.     ~dxSystem();
  38.  
  39.     bool initialise(int in_screenWidth, int in_screenHeight, HWND* hW);
  40.     bool initialiseObjects(int screenWidth, int screenHeight, HWND hwnd);
  41.  
  42.     void shutDown(){
  43.         // Release the m_dxD3D object.
  44.         if(m_dxD3D)
  45.         {
  46.             m_dxD3D->shutDown();
  47.             delete m_dxD3D;
  48.             m_dxD3D = 0;
  49.         }
  50.     }
  51.  
  52.     bool render(){
  53.         m_dxD3D->beginScene(0.0f, 0.0f, 0.0f, 1.0f);
  54.  
  55.  
  56.  
  57.         m_dxD3D->endScene();
  58.  
  59.         return true;
  60.     }
  61.    
  62. };
  63.  
  64. dxSystem::dxSystem()
  65. {
  66.  
  67. }
  68. dxSystem::dxSystem(const dxSystem& other)
  69. {
  70.    
  71. }
  72. dxSystem::~dxSystem()
  73. {}
  74.  
  75.  
  76. bool dxSystem::initialise(int in_screenWidth, int in_screenHeight,  HWND* hW)
  77. {
  78.     m_dxD3D = new dxD3D;
  79.     //hWnd = hW;
  80.  
  81.     bool result;
  82.     ////get window dimensions
  83.     //RECT rc;
  84.  //   GetClientRect( in_hwnd, &rc );
  85.  //   UINT width = rc.right - rc.left;
  86.  //   UINT height = rc.bottom - rc.top;
  87.  
  88.     // CREATE DEVICE
  89.     //*****************************************************************************
  90.     /*if ( !m_dxD3D->createSwapChainAndDevice(width, height, in_hwnd) ) return false;*/
  91.     result = m_dxD3D->createSwapChainAndDevice(in_screenWidth, in_screenHeight);
  92.     if(FAILED(result))
  93.     {
  94.         MessageBox(NULL, L"Failed to create the device", NULL, NULL);
  95.         return false;
  96.     }
  97.     // INPUT ASSEMBLY STAGE
  98.     //*****************************************************************************
  99.     /*if ( !m_dxD3D->loadShadersAndCreateInputLayouts() ) return false;*/
  100.     result = m_dxD3D->loadShadersAndCreateInputLayouts();
  101.     if(FAILED(result))
  102.     {
  103.         MessageBox(NULL, L"Failed to create the input assembly stage", NULL, NULL);
  104.         return false;
  105.     }
  106.     // RASTERIZER STAGE SETUP
  107.     //*****************************************************************************
  108.     m_dxD3D->initRasterizerState();
  109.     // OUTPUT-MERGER STAGE
  110.     //*****************************************************************************
  111.     /*if ( !m_dxD3D->createRenderTargetsAndDepthBuffer(width, height)) return false;*/
  112.     result = m_dxD3D->createRenderTargetsAndDepthBuffer(in_screenWidth, in_screenHeight);
  113.     if(FAILED(result))
  114.     {
  115.         MessageBox(NULL, L"Failed to create the output merger stage", NULL, NULL);
  116.         return false;
  117.     }
  118.     return true;
  119. }
  120.  
  121. #endif
  122.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement