Nuked old scene code.
This commit is contained in:
@ -1,57 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include "scene.h"
|
||||
|
||||
void sceneInit(scene_t *scene) {
|
||||
scene->itemCount = 0;
|
||||
|
||||
cameraLookAt(&scene->camera, 3,3,3, 0,0,0);
|
||||
cameraPerspective(&scene->camera, 75, 16.0f/9.0f, 0.01f, 100.0f);
|
||||
}
|
||||
|
||||
sceneitem_t * sceneAdd(scene_t *scene) {
|
||||
sceneitem_t *item = scene->items + scene->itemCount;
|
||||
scene->itemCount++;
|
||||
return item;
|
||||
}
|
||||
|
||||
void sceneUpdate(scene_t *scene, engine_t *engine) {
|
||||
int32_t i;
|
||||
sceneitem_t *item;
|
||||
|
||||
for(i = 0; i < scene->itemCount; i++) {
|
||||
item = scene->items + i;
|
||||
if(item->onUpdate == NULL) continue;
|
||||
item->onUpdate(scene, i, engine);
|
||||
}
|
||||
}
|
||||
|
||||
void sceneRender(scene_t *scene, engine_t *engine, shader_t *shader) {
|
||||
int32_t i;
|
||||
sceneitem_t *item;
|
||||
|
||||
shaderUse(shader);
|
||||
shaderUseCamera(shader, &scene->camera);
|
||||
|
||||
for(i = 0; i < scene->itemCount; i++) {
|
||||
item = scene->items + i;
|
||||
if(item->onRender == NULL) continue;
|
||||
item->onRender(scene, i, engine);
|
||||
}
|
||||
}
|
||||
|
||||
void sceneDispose(scene_t *scene) {
|
||||
int32_t i;
|
||||
sceneitem_t *item;
|
||||
|
||||
for(i = 0; i < scene->itemCount; i++) {
|
||||
item = scene->items + i;
|
||||
if(item->onDispose == NULL) continue;
|
||||
item->onDispose(scene, i, NULL);
|
||||
}
|
||||
}
|
@ -1,58 +0,0 @@
|
||||
/**
|
||||
* 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);
|
@ -24,7 +24,7 @@ bool sandboxGameInit(sandboxgame_t *game) {
|
||||
&game->engine.assetManager, game->assetOwner,
|
||||
&game->st, "poker/characters/sammy", "sprite"
|
||||
);
|
||||
assetManagerLoadTextureScale(
|
||||
assetManagerLoadTextureScale(
|
||||
&game->engine.assetManager, game->assetOwner,
|
||||
&game->st, &game->texture, 0
|
||||
);
|
||||
|
Reference in New Issue
Block a user