C -> CPP
Some checks failed
Build Dusk / build-linux (push) Failing after 1m47s
Build Dusk / build-psp (push) Failing after 1m40s

This commit is contained in:
2025-12-22 11:41:49 +10:00
parent a495179e5f
commit 76b5c51ab6
162 changed files with 751 additions and 740 deletions

View File

@@ -6,12 +6,12 @@
# Sources
target_sources(${DUSK_TARGET_NAME}
PRIVATE
display.c
framebuffer.c
camera.c
screen.c
texture.c
spritebatch.c
display.cpp
framebuffer.cpp
camera.cpp
screen.cpp
texture.cpp
spritebatch.cpp
)
# Subdirectories

View File

@@ -5,11 +5,11 @@
* https://opensource.org/licenses/MIT
*/
#include "camera.h"
#include "display/display.h"
#include "assert/assert.h"
#include "display/framebuffer.h"
#include "display/screen.h"
#include "camera.hpp"
#include "display/display.hpp"
#include "assert/assert.hpp"
#include "display/framebuffer.hpp"
#include "display/screen.hpp"
void cameraInit(camera_t *camera) {
cameraInitPerspective(camera);
@@ -93,11 +93,12 @@ void cameraPushMatrix(camera_t *camera) {
}
switch(camera->viewType) {
case CAMERA_VIEW_TYPE_MATRIX:
case CAMERA_VIEW_TYPE_MATRIX: {
glm_mat4_copy(camera->view, view);
break;
}
case CAMERA_VIEW_TYPE_LOOKAT:
case CAMERA_VIEW_TYPE_LOOKAT: {
glm_lookat(
camera->lookat.position,
camera->lookat.target,
@@ -105,8 +106,9 @@ void cameraPushMatrix(camera_t *camera) {
view
);
break;
}
case CAMERA_VIEW_TYPE_LOOKAT_PIXEL_PERFECT:
case CAMERA_VIEW_TYPE_LOOKAT_PIXEL_PERFECT: {
assertTrue(
camera->projType == CAMERA_PROJECTION_TYPE_PERSPECTIVE ||
camera->projType == CAMERA_PROJECTION_TYPE_PERSPECTIVE_FLIPPED,
@@ -133,8 +135,9 @@ void cameraPushMatrix(camera_t *camera) {
view
);
break;
}
case CAMERA_VIEW_TYPE_2D:
case CAMERA_VIEW_TYPE_2D: {
glm_mat4_identity(view);
glm_translate(view, (vec3){
-camera->_2d.position[0],
@@ -147,6 +150,7 @@ void cameraPushMatrix(camera_t *camera) {
1.0f
});
break;
}
default:
assertUnreachable("Invalid camera view type");

View File

@@ -6,8 +6,8 @@
*/
#pragma once
#include "dusk.h"
#include "display/color.h"
#include "dusk.hpp"
#include "display/color.hpp"
#define CAMERA_COUNT_MAX 4
@@ -17,12 +17,11 @@ typedef enum {
CAMERA_PROJECTION_TYPE_ORTHOGRAPHIC
} cameraprojectiontype_t;
typedef enum {
CAMERA_VIEW_TYPE_MATRIX,
CAMERA_VIEW_TYPE_LOOKAT,
CAMERA_VIEW_TYPE_2D,
CAMERA_VIEW_TYPE_LOOKAT_PIXEL_PERFECT
} cameraviewtype_t;
typedef uint8_t cameraviewtype_t;
#define CAMERA_VIEW_TYPE_MATRIX 0x00
#define CAMERA_VIEW_TYPE_LOOKAT 0x01
#define CAMERA_VIEW_TYPE_2D 0x02
#define CAMERA_VIEW_TYPE_LOOKAT_PIXEL_PERFECT 0x03
typedef struct {
cameraprojectiontype_t projType;

View File

@@ -6,7 +6,7 @@
*/
#pragma once
#include "dusk.h"
#include "dusk.hpp"
typedef float_t colorchannelf_t;
typedef uint8_t colorchannelb_t;

View File

@@ -5,15 +5,15 @@
* https://opensource.org/licenses/MIT
*/
#include "display/display.h"
#include "engine/engine.h"
#include "display/framebuffer.h"
#include "scene/scenemanager.h"
#include "display/spritebatch.h"
#include "display/mesh/quad.h"
#include "display/screen.h"
#include "ui/ui.h"
#include "debug/debug.h"
#include "display/display.hpp"
#include "engine/engine.hpp"
#include "display/framebuffer.hpp"
#include "scene/scenemanager.hpp"
#include "display/spritebatch.hpp"
#include "display/mesh/quad.hpp"
#include "display/screen.hpp"
#include "ui/ui.hpp"
#include "debug/debug.hpp"
display_t DISPLAY;

View File

@@ -6,10 +6,10 @@
*/
#pragma once
#include "displaydefs.h"
#include "error/error.h"
#include "display/camera.h"
#include "display/framebuffer.h"
#include "displaydefs.hpp"
#include "error/error.hpp"
#include "display/camera.hpp"
#include "display/framebuffer.hpp"
typedef struct {
#if DISPLAY_SDL2

View File

@@ -5,10 +5,10 @@
* https://opensource.org/licenses/MIT
*/
#include "framebuffer.h"
#include "display/display.h"
#include "assert/assert.h"
#include "util/memory.h"
#include "framebuffer.hpp"
#include "display/display.hpp"
#include "assert/assert.hpp"
#include "util/memory.hpp"
framebuffer_t FRAMEBUFFER_BACKBUFFER = {0};
const framebuffer_t *FRAMEBUFFER_BOUND = &FRAMEBUFFER_BACKBUFFER;
@@ -31,9 +31,11 @@ void frameBufferInitBackbuffer() {
assertTrue(width > 0 && height > 0, "W/H must be greater than 0");
memoryZero(framebuffer, sizeof(framebuffer_t));
textureInit(&framebuffer->texture, width, height, GL_RGBA,(texturedata_t){
.rgba = { .colors = NULL }
});
textureInit(
&framebuffer->texture,
width, height, TEXTURE_FORMAT_RGBA,
(texturedata_t){ .rgba = { .colors = NULL } }
);
glGenFramebuffersEXT(1, &framebuffer->id);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framebuffer->id);

View File

@@ -6,7 +6,7 @@
*/
#pragma once
#include "display/texture.h"
#include "display/texture.hpp"
#define FRAMEBUFFER_CLEAR_COLOR (1 << 0)
#define FRAMEBUFFER_CLEAR_DEPTH (1 << 1)

View File

@@ -6,6 +6,6 @@
# Sources
target_sources(${DUSK_TARGET_NAME}
PRIVATE
mesh.c
quad.c
mesh.cpp
quad.cpp
)

View File

@@ -5,9 +5,9 @@
* https://opensource.org/licenses/MIT
*/
#include "mesh.h"
#include "util/memory.h"
#include "assert/assert.h"
#include "mesh.hpp"
#include "util/memory.hpp"
#include "assert/assert.hpp"
void meshInit(
mesh_t *mesh,

View File

@@ -4,8 +4,8 @@
// https://opensource.org/licenses/MIT
#pragma once
#include "display/display.h"
#include "display/color.h"
#include "display/display.hpp"
#include "display/color.hpp"
typedef enum {
#if DISPLAY_SDL2

View File

@@ -5,8 +5,8 @@
* https://opensource.org/licenses/MIT
*/
#include "quad.h"
#include "assert/assert.h"
#include "quad.hpp"
#include "assert/assert.hpp"
mesh_t QUAD_MESH_SIMPLE;
meshvertex_t QUAD_MESH_SIMPLE_VERTICES[QUAD_VERTEX_COUNT] = {

View File

@@ -6,8 +6,8 @@
*/
#pragma once
#include "mesh.h"
#include "display/color.h"
#include "mesh.hpp"
#include "display/color.hpp"
#define QUAD_VERTEX_COUNT 6
#define QUAD_PRIMITIVE_TYPE MESH_PRIMITIVE_TRIANGLES

View File

@@ -6,7 +6,7 @@
*/
#pragma once
#include "display/color.h"
#include "display/color.hpp"
typedef struct {
const uint8_t colorCount;

View File

@@ -5,10 +5,10 @@
* https://opensource.org/licenses/MIT
*/
#include "screen.h"
#include "assert/assert.h"
#include "util/memory.h"
#include "display/mesh/quad.h"
#include "screen.hpp"
#include "assert/assert.hpp"
#include "util/memory.hpp"
#include "display/mesh/quad.hpp"
screen_t SCREEN;

View File

@@ -6,10 +6,10 @@
*/
#pragma once
#include "dusk.h"
#include "display/framebuffer.h"
#include "display/camera.h"
#include "display/mesh/quad.h"
#include "dusk.hpp"
#include "display/framebuffer.hpp"
#include "display/camera.hpp"
#include "display/mesh/quad.hpp"
#if DISPLAY_SIZE_DYNAMIC == 1
#ifndef DISPLAY_SCREEN_HEIGHT_DEFAULT

View File

@@ -5,9 +5,9 @@
* https://opensource.org/licenses/MIT
*/
#include "spritebatch.h"
#include "assert/assert.h"
#include "util/memory.h"
#include "spritebatch.hpp"
#include "assert/assert.hpp"
#include "util/memory.hpp"
spritebatch_t SPRITEBATCH;

View File

@@ -6,8 +6,8 @@
*/
#pragma once
#include "display/mesh/quad.h"
#include "display/texture.h"
#include "display/mesh/quad.hpp"
#include "display/texture.hpp"
#define SPRITEBATCH_SPRITES_MAX 1
#define SPRITEBATCH_VERTEX_COUNT (SPRITEBATCH_SPRITES_MAX * QUAD_VERTEX_COUNT)

View File

@@ -5,11 +5,11 @@
* https://opensource.org/licenses/MIT
*/
#include "texture.h"
#include "assert/assert.h"
#include "util/memory.h"
#include "util/math.h"
#include "display/palette/palettelist.h"
#include "texture.hpp"
#include "assert/assert.hpp"
#include "util/memory.hpp"
#include "util/math.hpp"
#include "display/palette/palettelist.hpp"
const texture_t *TEXTURE_BOUND = NULL;
@@ -43,21 +43,23 @@ void textureInit(
glBindTexture(GL_TEXTURE_2D, texture->id);
switch(format) {
case TEXTURE_FORMAT_RGBA:
case TEXTURE_FORMAT_RGBA: {
glTexImage2D(
GL_TEXTURE_2D, 0, format, width, height, 0,
format, GL_UNSIGNED_BYTE, (void*)data.rgba.colors
);
break;
}
case TEXTURE_FORMAT_ALPHA:
case TEXTURE_FORMAT_ALPHA: {
glTexImage2D(
GL_TEXTURE_2D, 0, format, width, height, 0,
format, GL_UNSIGNED_BYTE, (void*)data.alpha.data
);
break;
}
case TEXTURE_FORMAT_PALETTE:
case TEXTURE_FORMAT_PALETTE: {
assertNotNull(data.palette.data, "Palette texture data cannot be NULL");
assertTrue(
data.palette.palette < PALETTE_LIST_COUNT,
@@ -130,8 +132,8 @@ void textureInit(
GL_UNSIGNED_BYTE, (const void*)pal->colors
);
}
break;
}
default:
assertUnreachable("Unknown texture format");

View File

@@ -6,8 +6,8 @@
*/
#pragma once
#include "display/color.h"
#include "display/displaydefs.h"
#include "display/color.hpp"
#include "display/displaydefs.hpp"
typedef enum {
#if DISPLAY_SDL2

View File

@@ -6,5 +6,5 @@
# Sources
target_sources(${DUSK_TARGET_NAME}
PRIVATE
tileset.c
tileset.cpp
)

View File

@@ -5,7 +5,7 @@
* https://opensource.org/licenses/MIT
*/
#include "tileset.h"
#include "tileset.hpp"
void tilesetTileGetUV(
const tileset_t *tileset,

View File

@@ -6,7 +6,7 @@
*/
#pragma once
#include "dusk.h"
#include "dusk.hpp"
typedef struct tileset_s {
const uint16_t tileWidth;