/** * 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, engine_t *engine, void *user) { scene->engine = engine; scene->assetOwner = assetManagerHolderCreate(&engine->assetManager); scene->user = user; scene->onLoaded = NULL; scene->onRender = NULL; scene->loaded = false; renderListInit(&scene->renderList, (int32_t)1, (int32_t)1); } float sceneUpdate( scene_t *scene, int32_t width, int32_t height, shader_t *shader, shaderuniform_t *uniforms ) { // First, lets check how loading has been going float n = assetManagerProgressGetForHolder( &scene->engine->assetManager, scene->assetOwner ); // TODO: Loading screen if(n < 1.0f) return n; // Fire event if(!scene->loaded) { scene->loaded = true; if(scene->onLoaded != NULL) scene->onLoaded(scene); } // Resize the render list renderListResize(&scene->renderList, width, height); // Fire callback if(scene->onRender != NULL) scene->onRender(scene); // Render the render list itself. renderListRender(&scene->renderList, shader, uniforms); return n; } void sceneUpdateToBackbuffer(scene_t *scene, shader_t *shaderRenderList, shaderuniform_t *listUniforms, shader_t *shaderBackBuffer, shaderuniform_t *backUniforms ) { float n = sceneUpdate(scene, (int32_t)scene->engine->render.width, (int32_t)scene->engine->render.height, shaderRenderList, listUniforms ); if(n < 1.0f) return; renderListAsBackbuffer(&scene->renderList, scene->engine, shaderBackBuffer, backUniforms ); } void sceneDispose(scene_t *scene) { assetManagerHolderRelease(&scene->engine->assetManager, scene->assetOwner); renderListDispose(&scene->renderList); } renderpass_t * sceneUsePass(scene_t *scene, uint8_t i) { return renderListRenderPass(&scene->renderList, scene->engine, i); }