Quick Start Guide¶
If you’re here, that means you’ve beaten the remarkable odds of not actually being interested in this project. Congratulations. Now, let’s get started.
First, install SGE using the intructions outlined in the Installation Guide. Now you’ve got a functional and up-to-date version of SGE.
Example Code¶
If you open the file “test.cpp”, you’ll see the main()
function.
The code here sets up SGE by calling sge::Renderer::init(...)
and creating a simple scene using physics and instancing.
It also enables the FPS camera to allow the player to move.
This demonstrates a very simple SGE program. If you want more details, carry on reading.
Details¶
You may be wondering how to create your own games/programs.
First off, include the SGE.h
header.
Everything SGE provides is placed in the aptly named sge
namespace (except GUI, which is in the sgeui
namespace).
Before using anything from those namespaces, call
sge::Renderer::init(int w, int h, std::string title, bool fullscreen);
function, which will initialize SGE and open a window.
When creating 3D objects, (currently) you there are static and instanced objects: doc:StaticObject <../classes/objects/staticobject>, doc:StaticInstancedObject <../classes/objects/staticinstancedobject>
To create a StaticObject from a file, call
sge::StaticObject::StaticObject(fs::path filename);
//eg.
auto object = sge::StaticObject("path/to/file.obj");
This will load the model from filename
and render it every frame.
Nearly all model formats are supported (through Assimp).
To create an instanced object (used when you have to render multiple identical objects), check out its documentation.
If you don’t want an object to render, set the renderObject flag to false.
someObject.renderObject = false;
Set it back to true if you want to render it again.
A Camera has to be created to describe the positon and rotation of the viewer:
sge::Camera::Camera();
//eg.
auto camera = sge::Camera();
The Camera then has to be set as the current one in Renderer:
sge::Renderer::setCurrentCamera(camera);
All done! Now, in a loop, do:
sge::Renderer::renderFrame();
Note
If you want a simple FPS camera, you can enable it by calling:
sge::FPSCamera::enable();
Putting it all together, it could look something like:
...
sge::Renderer::init(1024, 768, "Exempli gratia", false);
auto camera = sge::Camera();
sge::Renderer::setCurrentCamera(camera);
auto myObject = sge::StaticObject("path/to/file.obj");
while (true) {
sge::Renderer::renderFrame();
}
...
See also