More fixes
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
|
||||
#pragma once
|
||||
#include "type/assettexture.h"
|
||||
#include "type/assetpalette.h"
|
||||
// #include "type/assetpalette.h"
|
||||
#include "type/assettileset.h"
|
||||
#include "type/assetlanguage.h"
|
||||
#include "type/assetscript.h"
|
||||
@@ -19,7 +19,7 @@ typedef enum {
|
||||
ASSET_TYPE_NULL,
|
||||
|
||||
ASSET_TYPE_TEXTURE,
|
||||
ASSET_TYPE_PALETTE,
|
||||
// ASSET_TYPE_PALETTE,
|
||||
ASSET_TYPE_TILESET,
|
||||
ASSET_TYPE_LANGUAGE,
|
||||
ASSET_TYPE_SCRIPT,
|
||||
@@ -66,12 +66,12 @@ static const assettypedef_t ASSET_TYPE_DEFINITIONS[ASSET_TYPE_COUNT] = {
|
||||
.entire = assetTextureLoad
|
||||
},
|
||||
|
||||
[ASSET_TYPE_PALETTE] = {
|
||||
.extension = "dpf",
|
||||
.loadStrategy = ASSET_LOAD_STRAT_ENTIRE,
|
||||
.dataSize = sizeof(palette_t),
|
||||
.entire = assetPaletteLoad
|
||||
},
|
||||
// [ASSET_TYPE_PALETTE] = {
|
||||
// .extension = "dpf",
|
||||
// .loadStrategy = ASSET_LOAD_STRAT_ENTIRE,
|
||||
// .dataSize = sizeof(palette_t),
|
||||
// .entire = assetPaletteLoad
|
||||
// },
|
||||
|
||||
[ASSET_TYPE_TILESET] = {
|
||||
.extension = "dtf",
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
target_sources(${DUSK_LIBRARY_TARGET_NAME}
|
||||
PUBLIC
|
||||
assettexture.c
|
||||
assetpalette.c
|
||||
assettileset.c
|
||||
assetlanguage.c
|
||||
assetscript.c
|
||||
|
||||
@@ -138,14 +138,14 @@ errorret_t assetMapChunkHandler(assetcustom_t custom) {
|
||||
mesh_t *mesh = &chunk->meshes[i];
|
||||
meshInit(
|
||||
mesh,
|
||||
MESH_PRIMITIVE_TRIANGLES,
|
||||
MESH_PRIMITIVE_TYPE_TRIANGLES,
|
||||
modelHeader.vertexCount,
|
||||
&chunk->vertices[vertexIndex]
|
||||
);
|
||||
|
||||
vertexIndex += modelHeader.vertexCount;
|
||||
} else {
|
||||
chunk->meshes[i].vertexCount = 0;
|
||||
// chunk->meshes[i].vertexCount = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ target_sources(${DUSK_LIBRARY_TARGET_NAME}
|
||||
|
||||
# Subdirectories
|
||||
add_subdirectory(camera)
|
||||
add_subdirectory(framebuffer)
|
||||
add_subdirectory(mesh)
|
||||
add_subdirectory(texture)
|
||||
|
||||
|
||||
@@ -30,10 +30,10 @@ errorret_t displayInit(void) {
|
||||
#endif
|
||||
|
||||
errorChain(quadInit());
|
||||
errorChain(frameBufferInitBackbuffer());
|
||||
errorChain(frameBufferInitBackBuffer());
|
||||
spriteBatchInit();
|
||||
errorChain(textInit());
|
||||
errorChain(assetLoad("main_palette.dpf", &PALETTES[0]));
|
||||
// errorChain(assetLoad("main_palette.dpf", &PALETTES[0]));
|
||||
screenInit();
|
||||
|
||||
errorOk();
|
||||
|
||||
10
src/dusk/display/framebuffer/CMakeLists.txt
Normal file
10
src/dusk/display/framebuffer/CMakeLists.txt
Normal file
@@ -0,0 +1,10 @@
|
||||
# Copyright (c) 2025 Dominic Masters
|
||||
#
|
||||
# This software is released under the MIT License.
|
||||
# https://opensource.org/licenses/MIT
|
||||
|
||||
# Sources
|
||||
target_sources(${DUSK_LIBRARY_TARGET_NAME}
|
||||
PUBLIC
|
||||
framebuffer.c
|
||||
)
|
||||
@@ -13,9 +13,9 @@
|
||||
framebuffer_t FRAMEBUFFER_BACKBUFFER = {0};
|
||||
const framebuffer_t *FRAMEBUFFER_BOUND = &FRAMEBUFFER_BACKBUFFER;
|
||||
|
||||
errorret_t frameBufferInitBackbuffer() {
|
||||
errorret_t frameBufferInitBackBuffer() {
|
||||
memoryZero(&FRAMEBUFFER_BACKBUFFER, sizeof(framebuffer_t));
|
||||
errorChain(frameBufferPlatformInitBackbuffer());
|
||||
errorChain(frameBufferPlatformInitBackBuffer());
|
||||
FRAMEBUFFER_BOUND = &FRAMEBUFFER_BACKBUFFER;
|
||||
errorOk();
|
||||
}
|
||||
@@ -24,7 +24,7 @@ errorret_t frameBufferBind(framebuffer_t *framebuffer) {
|
||||
if(framebuffer == NULL) {
|
||||
frameBufferBind(&FRAMEBUFFER_BACKBUFFER);
|
||||
FRAMEBUFFER_BOUND = &FRAMEBUFFER_BACKBUFFER;
|
||||
return;
|
||||
errorOk();
|
||||
}
|
||||
|
||||
errorChain(frameBufferPlatformBind(framebuffer));
|
||||
@@ -32,21 +32,12 @@ errorret_t frameBufferBind(framebuffer_t *framebuffer) {
|
||||
errorOk();
|
||||
}
|
||||
|
||||
void frameBufferDispose(framebuffer_t *framebuffer) {
|
||||
assertNotNull(framebuffer, "Framebuffer cannot be NULL");
|
||||
uint32_t frameBufferGetWidth(const framebuffer_t *framebuffer) {
|
||||
return frameBufferPlatformGetWidth(framebuffer);
|
||||
}
|
||||
|
||||
#if DISPLAY_SDL2
|
||||
if(framebuffer == &FRAMEBUFFER_BACKBUFFER) {
|
||||
assertUnreachable("Cannot dispose of backbuffer");
|
||||
}
|
||||
|
||||
#if DISPLAY_SIZE_DYNAMIC == 0
|
||||
assertUnreachable("Dynamic size framebuffers not supported");
|
||||
#else
|
||||
textureDispose(&framebuffer->texture);
|
||||
glDeleteFramebuffersEXT(1, &framebuffer->id);
|
||||
#endif
|
||||
#endif
|
||||
uint32_t frameBufferGetHeight(const framebuffer_t *framebuffer) {
|
||||
return frameBufferPlatformGetHeight(framebuffer);
|
||||
}
|
||||
|
||||
#ifdef DUSK_DISPLAY_SIZE_DYNAMIC
|
||||
@@ -62,4 +53,10 @@ void frameBufferDispose(framebuffer_t *framebuffer) {
|
||||
errorChain(frameBufferPlatformInit(fb, width, height));
|
||||
errorOk();
|
||||
}
|
||||
|
||||
errorret_t frameBufferDispose(framebuffer_t *framebuffer) {
|
||||
assertNotNull(framebuffer, "Framebuffer cannot be NULL");
|
||||
errorChain(frameBufferPlatformDispose(framebuffer));
|
||||
errorOk();
|
||||
}
|
||||
#endif
|
||||
@@ -56,7 +56,7 @@ uint32_t frameBufferGetHeight(const framebuffer_t *framebuffer);
|
||||
* @param framebuffer The framebuffer to bind, or NULL to bind the backbuffer.
|
||||
* @return Error for binding the framebuffer.
|
||||
*/
|
||||
errorret_t frameBufferBind(const framebuffer_t *framebuffer);
|
||||
errorret_t frameBufferBind(framebuffer_t *framebuffer);
|
||||
|
||||
/**
|
||||
* Clears the currently bound framebuffer.
|
||||
@@ -66,19 +66,15 @@ errorret_t frameBufferBind(const framebuffer_t *framebuffer);
|
||||
*/
|
||||
void frameBufferClear(uint8_t flags, color_t color);
|
||||
|
||||
/**
|
||||
* Disposes of the framebuffer. Will also be used for request disposing of the
|
||||
* backbuffer.
|
||||
*
|
||||
* @param framebuffer The framebuffer to dispose of.
|
||||
*/
|
||||
void frameBufferDispose(framebuffer_t *framebuffer);
|
||||
|
||||
#ifdef DUSK_DISPLAY_SIZE_DYNAMIC
|
||||
#ifndef frameBufferPlatformInit
|
||||
#error "frameBufferPlatformInit not defined for this platform"
|
||||
#endif
|
||||
|
||||
#ifndef frameBufferPlatformDispose
|
||||
#error "frameBufferPlatformDispose not defined for this platform"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Initializes a framebuffer.
|
||||
*
|
||||
@@ -92,4 +88,12 @@ void frameBufferDispose(framebuffer_t *framebuffer);
|
||||
const uint32_t width,
|
||||
const uint32_t height
|
||||
);
|
||||
|
||||
/**
|
||||
* Disposes of the framebuffer. Will also be used for request disposing of the
|
||||
* backbuffer.
|
||||
*
|
||||
* @param framebuffer The framebuffer to dispose of.
|
||||
*/
|
||||
errorret_t frameBufferDispose(framebuffer_t *framebuffer);
|
||||
#endif
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "text.h"
|
||||
#include "assert/assert.h"
|
||||
#include "util/memory.h"
|
||||
#include "display/spritebatch.h"
|
||||
#include "display/spritebatch/spritebatch.h"
|
||||
#include "asset/asset.h"
|
||||
|
||||
texture_t DEFAULT_FONT_TEXTURE;
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "util/memory.h"
|
||||
#include "assert/assert.h"
|
||||
#include "asset/asset.h"
|
||||
#include "display/texture/texture.h"
|
||||
// #include "entity/entity.h"
|
||||
#include "util/string.h"
|
||||
#include "time/time.h"
|
||||
@@ -195,8 +196,8 @@ void mapChunkUnload(mapchunk_t* chunk) {
|
||||
// }
|
||||
|
||||
for(uint8_t i = 0; i < chunk->meshCount; i++) {
|
||||
if(chunk->meshes[i].vertexCount == 0) continue;
|
||||
meshDispose(&chunk->meshes[i]);
|
||||
// if(chunk->meshes[i].vertexCount == 0) continue;
|
||||
// meshDispose(&chunk->meshes[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,9 +8,8 @@
|
||||
#include "util/memory.h"
|
||||
#include "debug/debug.h"
|
||||
#include "time/time.h"
|
||||
|
||||
#include "display/camera/camera.h"
|
||||
#include "display/screen.h"
|
||||
#include "display/screen/screen.h"
|
||||
|
||||
scene_t SCENE;
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "modulescreen.h"
|
||||
#include "assert/assert.h"
|
||||
#include "display/screen.h"
|
||||
#include "display/screen/screen.h"
|
||||
|
||||
void moduleScreen(scriptcontext_t *context) {
|
||||
assertNotNull(context, "Context cannot be NULL.");
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*/
|
||||
|
||||
#include "modulespritebatch.h"
|
||||
#include "display/spritebatch.h"
|
||||
#include "display/spritebatch/spritebatch.h"
|
||||
#include "assert/assert.h"
|
||||
|
||||
void moduleSpriteBatch(scriptcontext_t *context) {
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "moduletext.h"
|
||||
#include "assert/assert.h"
|
||||
#include "display/text.h"
|
||||
#include "display/spritebatch.h"
|
||||
#include "display/spritebatch/spritebatch.h"
|
||||
|
||||
void moduleText(scriptcontext_t *context) {
|
||||
assertNotNull(context, "Script context is null");
|
||||
|
||||
@@ -130,4 +130,17 @@ void frameBufferClear(const uint8_t flags, const color_t color) {
|
||||
errorChain(errorGLCheck());
|
||||
errorOk();
|
||||
}
|
||||
|
||||
errorret_t frameBufferGLDispose(framebuffer_t *framebuffer) {
|
||||
assertNotNull(framebuffer, "Framebuffer cannot be NULL");
|
||||
|
||||
if(framebuffer == &FRAMEBUFFER_BACKBUFFER) {
|
||||
assertUnreachable("Cannot dispose of backbuffer");
|
||||
}
|
||||
|
||||
errorChain(textureDispose(&framebuffer->texture));
|
||||
glDeleteFramebuffersEXT(1, &framebuffer->id);
|
||||
errorChain(errorGLCheck());
|
||||
errorOk();
|
||||
}
|
||||
#endif
|
||||
@@ -19,6 +19,32 @@ typedef struct {
|
||||
*/
|
||||
errorret_t frameBufferGLInitBackBuffer(void);
|
||||
|
||||
/**
|
||||
* Gets the height of the framebuffer. (OpenGL implementation).
|
||||
*
|
||||
* @param framebuffer The framebuffer to get the height of.
|
||||
* @return The height of the framebuffer, or 0 if the framebuffer is NULL.
|
||||
*/
|
||||
uint32_t frameBufferGLGetWidth(const framebuffergl_t *framebuffer);
|
||||
|
||||
/**
|
||||
* Initializes an OpenGL style framebuffer.
|
||||
*
|
||||
* @param fb The framebuffer to initialize.
|
||||
* @param width The width of the framebuffer.
|
||||
* @param height The height of the framebuffer.
|
||||
* @return Either error or not.
|
||||
*/
|
||||
uint32_t frameBufferGLGetHeight(const framebuffergl_t *framebuffer);
|
||||
|
||||
/**
|
||||
* Gets the width of the framebuffer. (OpenGL implementation).
|
||||
*
|
||||
* @param framebuffer The framebuffer to get the width of.
|
||||
* @return The width of the framebuffer, or 0 if the framebuffer is NULL.
|
||||
*/
|
||||
errorret_t frameBufferGLBind(framebuffergl_t *framebuffer);
|
||||
|
||||
#ifdef DUSK_DISPLAY_SIZE_DYNAMIC
|
||||
/**
|
||||
* Initializes an OpenGL style framebuffer.
|
||||
@@ -33,4 +59,12 @@ errorret_t frameBufferGLInitBackBuffer(void);
|
||||
const uint32_t width,
|
||||
const uint32_t height
|
||||
);
|
||||
|
||||
/**
|
||||
* Disposes of the framebuffer. Will also be used for request disposing of the
|
||||
* backbuffer.
|
||||
*
|
||||
* @param framebuffer The framebuffer to dispose of.
|
||||
*/
|
||||
errorret_t frameBufferGLDispose(framebuffergl_t *framebuffer);
|
||||
#endif
|
||||
@@ -10,5 +10,11 @@
|
||||
typedef framebuffergl_t framebufferplatform_t;
|
||||
|
||||
#define frameBufferPlatformInitBackBuffer frameBufferGLInitBackBuffer
|
||||
#define frameBufferPlatformInit frameBufferGLInit
|
||||
#define frameBufferPlatformGetWidth frameBufferGLGetWidth
|
||||
#define frameBufferPlatformGetHeight frameBufferGLGetHeight
|
||||
#define frameBufferPlatformBind frameBufferGLBind
|
||||
|
||||
#if DUSK_DISPLAY_SIZE_DYNAMIC
|
||||
#define frameBufferPlatformInit frameBufferGLInit
|
||||
#define frameBufferPlatformDispose frameBufferGLDispose
|
||||
#endif
|
||||
Reference in New Issue
Block a user