

The class definition for the D3DClass is kept as simple as possible here. The next thing we do is include the headers for those libraries that we are linking to this object moduleĪs well as headers for DirectX type definitions and such. This is because those libraries were never upgraded for DirectX 11 as their functionality did not need to change. You will notice that some DirectX 10 libraries are still used, These libraries contain all the Direct3D functionality for setting up and drawing 3D graphics in DirectXĪs well as tools to interface with the hardware on the computer to obtain information about the refresh rate of the monitor, Present the rendered scene to the screen. We call the D3D object to clear the screen to a grey color.Īfter that we call EndScene so that the grey color is presented to the window. The final change to this class is in the Render function. The Frame function has been updated so that it now calls the Render function each frame. If it does find the pointer has been initialized then it will attempt to shut down the D3DClass and then clean up the pointer afterwards. That is why it is important to set all the pointers to null in the class constructor. If it wasn't we can assume it was never set up and not try to shut it down. Note that I check to see if the pointer was initialized or not. Shut down of all graphics objects occur here so we have placed the D3DClass shutdown in this function. The next change is in the Shutdown function in the GraphicsClass.

MessageBox(hwnd, L"Could not initialize Direct3D", L"Error", MB_OK)

Result = m_D3D->Initialize(screenWidth, screenHeight, VSYNC_ENABLED, hwnd, FULL_SCREEN, SCREEN_DEPTH, SCREEN_NEAR) We'll go into more detail about that once we look at the d3dclass.cpp file.īool GraphicsClass::Initialize(int screenWidth, int screenHeight, HWND hwnd) The D3DClass will use all these variables to setup the Direct3D system. We send this function the screen width, screen height, handle to the window, and the four global variables from the Graphicsclass.h file. Here we create the D3DClass object and then call the D3DClass Initialize function. The second change is in the Initialize function inside the GraphicsClass. Here we initialize the pointer to null for safety reasons as we do with all class pointers. So the very first change is in the class constructor. We will also add calls to BeginScene and EndScene in the Render function so that we are now drawing to the window using Direct3D.
ZMODELER 3 LOCKING FUNCTION CODE
Now that we have a D3DClass member we will start to fill out some code inside the GraphicsClass to initialize and shutdown the D3DClass object. If you'll remember from the previous tutorial this class was entirely empty with no code in it at all. That way when I'm coding I can remember quickly what variables are members of the class and which are not. In case you were wondering I use the prefix m_ on all class variables. We have taken out the include for windows.h and instead included the new d3dclass.h.Īnd the second change is the new private pointer to the D3DClass which we have called m_D3D. Now lets take a look at the changes made to the GraphicsClass: The previous tutorial mentioned that all new graphics related classes will be encapsulated in the GraphicsClass and that is why it is the best location for the new D3DClass. I have updated the framework diagram below:Īs you can see the D3DClass will be located inside the GraphicsClass. We are going to add another class to the framework which will handle all the Direct3D system functions.
ZMODELER 3 LOCKING FUNCTION HOW TO
We will address how to initialize and shut down Direct3D as well as how to render to a window. This tutorial will be the first introduction to working with DirectX 11.
