Prepping for overworld rendering.
This commit is contained in:
		@@ -9,7 +9,7 @@
 | 
				
			|||||||
#include "assert/assert.h"
 | 
					#include "assert/assert.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
entitycallback_t ENTITY_CALLBACKS[ENTITY_TYPE_COUNT] = {
 | 
					entitycallback_t ENTITY_CALLBACKS[ENTITY_TYPE_COUNT] = {
 | 
				
			||||||
  { NULL },
 | 
					  { NULL, NULL },
 | 
				
			||||||
  { playerInit, playerUpdate }
 | 
					  { playerInit, playerUpdate }
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -26,6 +26,7 @@ void entityInit(
 | 
				
			|||||||
  memset(ent, 0, sizeof(entity_t));
 | 
					  memset(ent, 0, sizeof(entity_t));
 | 
				
			||||||
  ent->type = type;
 | 
					  ent->type = type;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // Call init
 | 
				
			||||||
  assertNotNull(ENTITY_CALLBACKS[type].init, "Entity type init callback err.");
 | 
					  assertNotNull(ENTITY_CALLBACKS[type].init, "Entity type init callback err.");
 | 
				
			||||||
  ENTITY_CALLBACKS[type].init(ent);
 | 
					  ENTITY_CALLBACKS[type].init(ent);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -17,7 +17,28 @@ typedef struct {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
extern overworld_t overworld;
 | 
					extern overworld_t overworld;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Initializes the overworld.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
void overworldInit();
 | 
					void overworldInit();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Called by the scene system when the overworld scene is made to be the 
 | 
				
			||||||
 | 
					 * active scene.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
void overworldSceneInit();
 | 
					void overworldSceneInit();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Called by the scene system when the overworld scene is made to be inactive.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
void overworldSceneDeinit();
 | 
					void overworldSceneDeinit();
 | 
				
			||||||
void overworldUpdate();
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Called by the scene system when the overworld scene is to perform a tick.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					void overworldUpdate();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Platform level render method. Refer to sceneRender for information.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					void overworldRender();
 | 
				
			||||||
@@ -10,8 +10,17 @@
 | 
				
			|||||||
#include "overworld/overworld.h"
 | 
					#include "overworld/overworld.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
scenetypecallback_t SCENE_CALLBACKS[] = {
 | 
					scenetypecallback_t SCENE_CALLBACKS[] = {
 | 
				
			||||||
  { NULL, NULL, NULL, NULL },// SCENE_TYPE_INITIAL
 | 
					  // SCENE_TYPE_INITIAL
 | 
				
			||||||
  { overworldInit, overworldSceneInit, overworldSceneDeinit, overworldUpdate },
 | 
					  { NULL, NULL, NULL, NULL, NULL },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // SCENE_TYPE_OVERWORLD
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    overworldInit,
 | 
				
			||||||
 | 
					    overworldSceneInit,
 | 
				
			||||||
 | 
					    overworldSceneDeinit,
 | 
				
			||||||
 | 
					    overworldUpdate,
 | 
				
			||||||
 | 
					    overworldRender
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
scene_t SCENE;
 | 
					scene_t SCENE;
 | 
				
			||||||
@@ -41,6 +50,14 @@ void sceneUpdate() {
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void sceneRender() {
 | 
				
			||||||
 | 
					  assertTrue(SCENE.current < SCENE_TYPE_COUNT, "Invalid Scene Type");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if(SCENE_CALLBACKS[SCENE.current].onRender) {
 | 
				
			||||||
 | 
					    SCENE_CALLBACKS[SCENE.current].onRender();
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void sceneSet(const scenetype_t scene) {
 | 
					void sceneSet(const scenetype_t scene) {
 | 
				
			||||||
  assertTrue(SCENE.next < SCENE_TYPE_COUNT, "Invalid Scene Type");
 | 
					  assertTrue(SCENE.next < SCENE_TYPE_COUNT, "Invalid Scene Type");
 | 
				
			||||||
  SCENE.next = scene;
 | 
					  SCENE.next = scene;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -25,6 +25,7 @@ typedef struct {
 | 
				
			|||||||
  void (*onActive)();
 | 
					  void (*onActive)();
 | 
				
			||||||
  void (*onInactive)();
 | 
					  void (*onInactive)();
 | 
				
			||||||
  void (*onUpdate)();
 | 
					  void (*onUpdate)();
 | 
				
			||||||
 | 
					  void (*onRender)();
 | 
				
			||||||
} scenetypecallback_t;
 | 
					} scenetypecallback_t;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern scene_t SCENE;
 | 
					extern scene_t SCENE;
 | 
				
			||||||
@@ -39,6 +40,16 @@ void sceneInit();
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
void sceneUpdate();
 | 
					void sceneUpdate();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Renders the scene system.
 | 
				
			||||||
 | 
					 * 
 | 
				
			||||||
 | 
					 * Scene rendering is really just an abstraction meant to simplify things for
 | 
				
			||||||
 | 
					 * the render host. It is not REQUIRED to be called at all and is not actually
 | 
				
			||||||
 | 
					 * implemented in the dusk dir itself, it is overriden somewhere within the
 | 
				
			||||||
 | 
					 * render host.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					void sceneRender();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Sets the current scene. This will happen at the start of the next tick.
 | 
					 * Sets the current scene. This will happen at the start of the next tick.
 | 
				
			||||||
 * 
 | 
					 * 
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -26,4 +26,5 @@ target_sources(${DUSK_TARGET_NAME}
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
# Subdirs
 | 
					# Subdirs
 | 
				
			||||||
add_subdirectory(assert)
 | 
					add_subdirectory(assert)
 | 
				
			||||||
add_subdirectory(display)
 | 
					add_subdirectory(display)
 | 
				
			||||||
 | 
					add_subdirectory(overworld)
 | 
				
			||||||
@@ -7,6 +7,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include "assert/assertgl.h"
 | 
					#include "assert/assertgl.h"
 | 
				
			||||||
#include "render.h"
 | 
					#include "render.h"
 | 
				
			||||||
 | 
					#include "render/scene.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
render_t RENDER;
 | 
					render_t RENDER;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -15,10 +16,10 @@ void renderInit() {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void renderUpdate() {
 | 
					void renderUpdate() {
 | 
				
			||||||
}
 | 
					  // Hand off to the scene to do its rendering.
 | 
				
			||||||
 | 
					  sceneRender();
 | 
				
			||||||
void renderOverworld() {
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void renderDispose() {
 | 
					void renderDispose() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
							
								
								
									
										12
									
								
								src/duskgl/overworld/CMakeLists.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								src/duskgl/overworld/CMakeLists.txt
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,12 @@
 | 
				
			|||||||
 | 
					# Copyright (c) 2025 Dominic Masters
 | 
				
			||||||
 | 
					# 
 | 
				
			||||||
 | 
					# This software is released under the MIT License.
 | 
				
			||||||
 | 
					# https://opensource.org/licenses/MIT
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Sources
 | 
				
			||||||
 | 
					target_sources(${DUSK_TARGET_NAME}
 | 
				
			||||||
 | 
					  PRIVATE
 | 
				
			||||||
 | 
					    overworld.c
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Subdirs
 | 
				
			||||||
							
								
								
									
										12
									
								
								src/duskgl/overworld/overworld.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								src/duskgl/overworld/overworld.c
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,12 @@
 | 
				
			|||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Copyright (c) 2025 Dominic Masters
 | 
				
			||||||
 | 
					 * 
 | 
				
			||||||
 | 
					 * This software is released under the MIT License.
 | 
				
			||||||
 | 
					 * https://opensource.org/licenses/MIT
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "overworld/overworld.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void overworldRender() {
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Reference in New Issue
	
	Block a user