Skip to content

Guerrilla Renderer

Twarit Waikar edited this page Aug 1, 2018 · 13 revisions

The GraphicComponents namespace of this engine is hugely inspired by other modern game engines.

  • The OpenGL rendering pipeline
    • Layers
      • Each layer is a completely different collection of groups of game objects.
      • Each group is a collection of game objects that can be sent to the Guerrilla Renderer.
      • The layer is drawn to the screen in a single draw call per frame, which effectively means that more the number of layers, more the number of draw calls(which can reduce performance).
    • Sprites
      • Sprite is a collection of all the data required to approximate a particular 2D image or colour on the screen within some specified bounds.
      • These sprites are added directly to group objects, and these group objects are in turn sent to the Guerrilla Renderer and nothing else is required by the user to be done as such.

Usage in C++:

using namespace Rubeus;
// Adds Rubeus sub-systems to active scope

using namespace GraphicComponents;
// Adds Rendering components and helper objects

using namespace RML;
// Adds a custom maths library, being developed to work for Rubeus

RShaderComponent * shader = new RShaderComponent("Shaders/basic.vert", "Shaders/basic.frag");
/* 
These shaders are present in the repository. These are very simple shaders that just display textures/colours on the screen without any contextual modifications.
*/

RStaticLayer * layer = new RStaticLayer(*shader);
/*
StaticLayer class is an implementation of the Layer class that is customised for 2D projections.
*/

RGroup * g = new RGroup(Matrix4::translation(Vector3D(0.0f, 0.0f, 0.0f)) * Matrix4::rotation(0, Vector3D(0, 0, 1)));
/*
Each of the group objects can be displaced from the origin in such a way that the objects contained inside the group are also displaced simultaneously. Thus the transform matrices being sent in to the Group constructor help specify the initial trnasform matrix.
*/

RTexture * texture = new RTexture("Assets/test8.png");
/*
Loads a texture which needs to be passed in to Sprite objects to apply textures to sprites
*/

g->add(new RSprite(3.0f, 3.0f, 3.0f, 3.0f, texture));
/*
Adds a sprite object that uses the image Assets/test8.png.
Look up Sprite.h for specific parameter documentation
*/

layer0->addGroup(*g);
// Prepare a group to be added to the rendering queue

RWindowComponent * GameWindow = new RWindowComponent("Hello World",
						      1280, 720,							 
                                                      EWindowParameters::WINDOWED_MODE,
						      EWindowParameters::NON_RESIZABLE_WINDOW,
						      0);
// Initialises a window. Look up RWindowComponent for now details.
while(!GameWindow->closed())
{
	GameWindow->clearWindow();

        layer->draw();
        // Draws the layer contents to the screen

	GameWindow->updateWindow();

}

The naive game loop implemented above will be hidden into the engine implementation later when the architecture has been decided.