Skip to content
Nick McDonald edited this page Jan 26, 2022 · 5 revisions

TinyEngine Wiki

This is a small document that will explain how to use TinyEngine.

Since the code is very brief, I recommend reading through the relevant portions to understand how it works. Particularly the utility classes and how they wrap boilerplate OpenGL, as well as the helper namespaces to see what built in features you can use (for instance camera matrix creation or image / object loading).

The relevant code sections are also explained in dedicated wiki pages so you know how to apply them.

Below, I will show how to build a basic program using TinyEngine. More information can be found in dedicated Wiki pages.

Simple Program

Include the main file TinyEngine.h and construct the problem as described below.

#include <TinyEngine/TinyEngine>
int main( int argc, char* args[] ) {
  //...
  return 0;
}

Open a window using:

Tiny::window("Example Window", 500, 500);

Add an event handler:

//Event Handler
Tiny::event.handler = [&](){ /* ... triggers are in Tiny::event ... */ 
	if(Tiny::event.press["SDLK_a"])
	std::cout<<"A is being pressed!"<<std::endl;
	
//...
};

Define a user interface (by default visibility is toggled with ESC):

//Graphical User Interface
Tiny::view.interface = [&](){ /* ... your IMGUI code here... */ 
	  ImGui::Begin("Example Interface", NULL, ImGuiWindowFlags_None);
  
  //...
  
  ImGui::End();
};

Define a rendering pipeline (after defining your utility classes to be used in the pipeline):

//Rendering Pipeline
Tiny::view.pipeline = [&](){ /* ... */ };

Execute the full game loop with any additional code:

//Execute the render loop
Tiny::loop([&](){
	  //Your additional code here...
});

Close the program using:

Tiny::quit();
//...

Note that the relevant functions should be defined before starting the game loop.

All of these elements can be defined directly using lambdas, or set using functionals. Just make sure context is always available, and it will work. Access the audio interface using Tiny::audio. Any additional parameters in the view or event class should be set before opening the window.

See the example programs (they are very brief) to see how a typical program is constructed, and what utility classes are applied.

Rendering Pipeline

The rendering pipeline can be constructed in any way, but generally consists of the following steps:

  • Choose rendering target (Tiny.view, Target object)
  • Setup shader (use, set uniforms)
  • Render models (models, textures with primitives, particle systems)
  • Repeat!

The rendering pipeline is constructed using the utility classes. Utility class objects are be constructed from any data you wish. Look at the example programs to see how the rendering pipeline is constructed to get different types of programs.

Clone this wiki locally