Using a renderer

Beginner Getting started

While method submit is the easier method to draw a model, BBMOD offers another method render, which requires a little more to set up, but it allows you to utilize BBMOD to its maximum potential.

Contents

Method render

What render does is that it only puts render commands into render queues, those can be then traversed and executed multiple times, using a different shader, different configuration, different render target (like an off-screen surface) etc. Method render takes the same arguments as submit, so it is easy to switch from one to another. Additionally, since render does not draw the model right away (and so it does not immediately apply materials), you do not have to (and you should not) call bbmod_material_reset before and after render.

For example

/// @desc Draw event
matrix_set(matrix_world, matrix_build(x, y, z, 0, 0, 0, 1, 1, 1));
bbmod_material_reset();
model.submit();
bbmod_material_reset();

becomes

/// @desc Draw event
matrix_set(matrix_world, matrix_build(x, y, z, 0, 0, 0, 1, 1, 1));
model.render();

Adding a renderer

If you run your game at this point, you will not see anything on the screen just yet. First you need to create a renderer, which goes through existing render queues and executes them. We recommend you to create a renderer in a special controller object like OMain, ORenderer or OGameController, based on your likings.

/// @desc Create event
renderer = new BBMOD_DefaultRenderer();
/// @desc Step event
renderer.update(delta_time);
/// @desc Draw event
// If you are using a camera, do not forget to apply it here, otherwise the
// models will not be rendered from its perspective!
OPlayer.camera.apply();
// This is what actually executes the render commands:
renderer.render();
/// @desc Clean Up event
renderer.destroy();

At this point, your game should look exactly the same as when you used submit.

Note: The controller object should execute its draw event after all render commands are created! To ensure this, you can for example place it into a special layer with the lowest depth.

Taking control over the application surface

Using a renderer also allows you to for example use post-processing effects. You will learn how to enable them in a separate tutorial, but first you will need to give control over the application surface to the renderer. This is done by setting its UseAppSurface property to true. The renderer then makes sure the application surface is enabled and automatically resizes it to the size of the window. If you do enable this property, you need to draw the application surface on the screen using the renderer's present method.

/// @desc Create event
renderer = new BBMOD_DefaultRenderer();
// Enable control over the application surface
renderer.UseAppSurface = true;
/// @desc Post-Draw event
// When UseAppSurface is enabled, you need to call this to draw the application
// surface on screen!
renderer.present();

You can also render your game at a lower or a higher resolution than the window has by changing the RenderScale property.

/// @desc Create event
// Render game at 75% resolution
renderer.RenderScale = 0.75;

If you would like to see a full list of the renderer's properties, please have a look at its documentation.

Could not find what you were looking for?

We are still working on more tutorials. If you need additional help with BBMOD, please have a look at the documentation or join our Discord community. Thank you for your patience.

Support the development

Support us in developing BBMOD, get priority assistance and more of our amazing tools as a reward!

Become Patron

Don't miss out on a thing!

Create an account, subscribe to newsletter and get notified on new releases, tutorials and special offers.

Register Log in