Sample Scene

Simple application - 3D scene example

Let's #1. Setup includes and global resources

demo_scene.cpp
// engine includes
#include "app/Application.hpp"
#include "graphics/shaders/GLSLProgram.hpp"
#include "graphics/Mesh.hpp"

// std includes
#include <iostream>
#include <array>

// using namespaces for testing purposes-only
using namespace VAPE;
using namespace graphics;
using namespace camera;

// TimeStep global init. (provides time and deltaTime)
TimeStep time;
// the size of the meshes for the scene
constexpr size_t meshCount = 3;
// global resource objects
// to be added in the appplication class (this is just for example)
GLSLProgram basic;
std::array<std::shared_ptr<Mesh>, meshCount> meshes;

Let's #2. Setting up the main() function

setLoad(), setUpdate() and setRender() accept a lambda / std::function as an argument inside their bodies.

Let's #3. Define the load() function body Its purpose is for initialization of shaders, meshes and resources in general.

Let's #4. Define the update() function body Its purpose is for updating the meshes' transform matrix in world and local coordinates.

Let's #5. Define the render() function body Its purpose is for managing the current shader and the renderer queue.

Last updated