Creating a game
Initial setup
To start off you will need a main.cpp file and that will typically contain:
Then you will want the include headers of the game engine at the top of this file:
What this then allows you to do is start initialising the game. Here is an example setup followed by an explanation of each setting.
The global conifg of VersionMajor
and VersionMinor
are fine to be left at 4.6 assuming that your system is fairly new and supports the OpenGL version 4.6 which most do. If you end up with errors around graphical functions when you try to run the code, you may need to adjust this value. You can find the latest version supported on your GPUs info site.
UnifiedEngine::__INIT__ENGINE();
is vital for the setup of all the OpenGL configuration and will not allow the game to function if not ran! It will create a UnifiedEngine::__GAME_GLOBAL_INSTANCE__
object that can be reference and accessed from anywhere. However, by default no window is attached to it.
The Window Config variable goes into more depth on the documentation, the purpose is to define what the window should show as when the GameWindow is created, this automatically hooks onto the global game instance.
Now, when you run the game you will find it closes instantly. This is because we now need a game loop. So after the configuration you will want to add:
To start it will loop whilst the game is still marked as active, if not it runs a terminate command to close and unload all buffers.
There are two main functions needed Update
and Render
. Update is used to allow the game engine to process all internal actions, such as the camera moving/rotating, physics and polling for any inputs received by the user. Render does what it says and will allow rendering of all the components to the screen and controlling FPS.
Now you have the game part setup. However, we still can't run just yet as there is no Camera for rendering.
Last updated