Dawn/src/display/scene.h
2021-09-18 23:13:05 -07:00

58 lines
1.3 KiB
C

/**
* Copyright (c) 2021 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include "../libs.h"
#include "camera.h"
#include "shader.h"
#include "../engine/engine.h"
/** Maximum number of items a scene can support */
#define SCENE_ITEMS_MAX 32
typedef struct _scene_t scene_t;
typedef struct _sceneitem_t sceneitem_t;
/**
* Callback for when scene events occur.
*
* @param scene The scene that is being evented.
* @param i The index of the current scene item.
* @param engine The game's engine.
*/
typedef void sceneitemcallback_t(
scene_t *scene, int32_t i, engine_t *engine
);
typedef struct _sceneitem_t {
sceneitemcallback_t *onUpdate;
sceneitemcallback_t *onRender;
sceneitemcallback_t *onDispose;
} sceneitem_t;
typedef struct _scene_t {
/** Camera that is used to render the scene */
camera_t camera;
/** Any custom user data pointer */
void *user;
/** Items within the scene */
sceneitem_t items[SCENE_ITEMS_MAX];
int32_t itemCount;
} scene_t;
void sceneInit(scene_t *scene);
sceneitem_t * sceneAdd(scene_t *scene);
void sceneUpdate(scene_t *scene, engine_t *engine);
void sceneRender(scene_t *scene, engine_t *engine, shader_t *shader);
void sceneDispose(scene_t *scene);