-
Notifications
You must be signed in to change notification settings - Fork 65
Home
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 how
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.
Include the main file TinyEngine.h
and construct the problem as described below.
#include "TinyEngine.h"
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.
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.