Brenta Engine 1.1
|
In this section we will see how to use various features of the engine.
To initialize any subsystem, you can use the Engine class. This is not mandatory, you can initialize and destroy the subsystems manually, but the Engine class provides a nice way to do it.
To create an engine, you can use the Builder class:
You can read every option in the brenta::engine::builder
class. Let's go through some subsystems.
You can register callback functions for the input. Those functions are called when the specified key
is pressed, or the mouse is moved, depending on the callback you register.
In this example we register a keyboard callback that toggles the wireframe mode when the F
key is pressed. You can use Brenta::Input::AddMousePosCallback
to register a mouse callback, this ill be called with the x and y position of the mouse.
You can also remove the callbacks with brenta::input::remove_keyboard_callback
and brenta::input::remove_mouse_pos_callback
.
The audio subsystem is very simple: there are audio streams and audio files, you can play an audio file on a stream (not more) and stop it, so you need to have multiple streams if you want to play multiple audio files at the same time.
You can load an audio file like so:
We are identifying this audio file with the name guitar
.
You can create a stream with the name "music" like so:
And finally play the "guitar" audio like so:
The subsystem will provide you a default stream named "default" if you don't want to create a stream.
You can Pause and Resume streams with brenta::audio::pause_stream
and brenta::audio::resume_stream
, set the volume and stop it. You can find the API in Brenta::Audio
.
You can create and customize particles via the brenta::particle_emitter
class. All the computation is done in the GPU so the engine can handle lots and lots of particles. Here's a quick look on the API:
Check out oak! The engine uses oak as the logger, you can set the log level and the log file in the engine builder. You can log messages like so:
Oak has many more advanced features, I suggest you check out the repository.
The brenta::text
subsystem allows you to render text on the screen. You can set the font and font size of your text, and render it in the main loop like this:
This is just a small part of the engine, you can find more features in the documentation of the classes. If you want to contribute to the engine, check out Contributing.