Setting up a build pipeline
- itzvnodm
- Sep 7, 2014
- 3 min read
Purpose:
The assignment was about setting up visual studio solution as base for my future assignments. Overall purpose was to,
Understand how to create initial projects paths and folder structure.
Learning about property macros in Visual Studio and creating a solution which when compiled puts all the intermediate files and folders in a temp folder, rather than having them generate in each project folders (Which visual studio defaults to).
Learning and using the precompiled headers.
Architecting the code.
I have pretty much modularized all of the code, where MainGame class is the first object that is created in WinMain which handles windows loop and graphics loop. Both GraphicsSystem and WindowsManager are singletons.
Parts that I could have done in different ways but chose this way:
I wanted to have one centralized class (MainGame Class) that handled the loop of every other modules. I think doing it that way helps in handling initialization and shutdown better, while improving the readability of the code.
How did I handle MainGame loop to call windows loop? I chose to create a bool reference variable that returned true once the user has pressed X or ESC. I got this design choice by looking at JBarnes’s cheesy rendering engine.
How did I handle sharing g_windowWidth, g_windowHeight, g_shouldRenderFullScreen across GraphicsSystem and WindowsManager? I initially had shared them using precompiled.h but later changed it so that both the systems have their own class variables which stored the values after receiving it form the MainGame class at the time of object creation.
Parts that gave me trouble:
OutputPath property not set,
There was one instance when the asset builder project wouldn’t compile and logged an error as above.
Fix: I had to eventually recreated the project from scratch, but this time the only change being the import order of SolutionMacros.props before DefaultLocations.props, which fixed the issue.
Creating the windows loop as a class: gave me a compilation error,
error C3867: 'WindowsManager::OnMessageReceived': function call missing argument list; use & WindowsManager::OnMessageReceived' to create a pointer to member
error C2440: '=' : cannot convert from 'LRESULT (__stdcall WindowsManager::* )(HWND,UINT,WPARAM,LPARAM)' to 'WNDPROC'
I found out that I had defined OnMessageReceived callback as a non-static member function of WindowsManager class. I later realized that any function that is a non-static member of class has a hidden parameter, this, in it. This made the function prototype different from windows function pointer type and hence created the compilation error.
Fix: This led me to change the function from non-static to static. Which further created the issue that m_mainWindow being a non-static member variable of class could not be accessed by a static function. On further looking into the issue, I found out that when windows calls OnMesageReceived, it also sends a valid Handle i_window which can be used in the function logic instead of m_mainWindow. Now that, in switch case WM_NCDESTROY we are setting i_window to null, I was expecting m_mainWindow handle to change to null as well. But in the end, when MainGame tries to destroy the WindowsManager by calling ShutdownMainWindow, it finds a non null m_mainWindow handle which was invalid at the same time (since windows had already cleared it in PostQuitMessage). This in turn created an error on calling DestroyWindow.
Final Fix: Made the m_mainWindow static to the class, and set it to null in OnMessageReceived, on receiving WM_NCDESTROY.
Extra:
I added the logger function that I had for my game engine from JBarnes’s class.
Anything I would be interested adding in the future:
I would definitely want to use Memory Pool and shared pointers as we go on further.
Time Spent:
Git setup: 0.5 Hrs.
Initial Reading and understanding of all the example projects and assignment links: 4 Hrs.
Bare bone setup that compiled and produced a working output: 3 Hrs.
Architecting the code: 4 Hrs.
Cleanup and Extra: 0.5 Hrs.
Writing and Webpage setup: 3 Hrs.
Total: 15 Hours
Kommentare