Skip to content

Entry Point

Shahriar Shahrabi edited this page May 11, 2020 · 2 revisions

Entry Point

The Entry Point is the main function of the application. It is the function which is called when the game is lunched. Entry point is defined in a header file called EntryPoint.h on the engine side. This is so that the running of the game is handled by the engine and not the client. However the function lives in your game project. By including the header file in your main game's cpp file, this function is copied over in the code base of your game. That is why EntryPoint.h should be included only once in your game project, preferably in your main cpp file where you create your game application.

Entry point might vary platform to platform, or change over time, these changes will come with new engine updates. Here is how the entry point works at the moment:

extern ToyRenderer::ToyRendererApp* ToyRenderer::CreateApplication();
 void main(int argc, char** argv) {
	auto app = ToyRenderer::CreateApplication();
	app->Run();
	delete app;
}

ToyRenderer::CreateApplication

This function is responsible for actually creating a ToyRendererApplication. The engine receives this application and runs your game through it. The function body is to be defined on the side of the game. Best would be in the same file where the entry point is included. An example of CreateApplication definition is:

class Sandbox : public ToyRenderer::ToyRendererApp {
public: 
	Sandbox() {
			CLIENT_LOG_INFO("sand box has been initialized");
     	    activeScene = new Scene();
	}
	~Sandbox() {
	}
};

ToyRenderer::ToyRendererApp* ToyRenderer::CreateApplication() 
{
	return new Sandbox();
}

This function will create of course only an empty screen, since there is no camera in the scene. Look at the Starter Scene as an example of a more complicated scene set up.

Clone this wiki locally