Actually compiled

This commit is contained in:
2026-02-04 17:44:53 -06:00
parent 708c4d0ec3
commit dd910a31aa
20 changed files with 80 additions and 430 deletions

View File

@@ -41,7 +41,6 @@ elseif(DUSK_TARGET_SYSTEM STREQUAL "psp")
elseif(DUSK_TARGET_SYSTEM STREQUAL "gamecube" OR DUSK_TARGET_SYSTEM STREQUAL "wii")
target_compile_definitions(${DUSK_LIBRARY_TARGET_NAME}
PUBLIC
DISPLAY_SDL2=1
DISPLAY_WINDOW_WIDTH_DEFAULT=640
DISPLAY_WINDOW_HEIGHT_DEFAULT=480
DISPLAY_WIDTH=640

View File

@@ -133,12 +133,13 @@ errorret_t displayUpdate(void) {
#if DISPLAY_SDL2
SDL_GL_SwapWindow(DISPLAY.window);
GLenum err;
while((err = glGetError()) != GL_NO_ERROR) {
debugPrint("GL Error: %d\n", err);
}
#endif
GLenum err;
while((err = glGetError()) != GL_NO_ERROR) {
debugPrint("GL Error: %d\n", err);
}
// For now, we just return an OK error.
errorOk();

View File

@@ -8,25 +8,17 @@
#pragma once
#if DISPLAY_SDL2
#if DOLPHIN
#include "dusk.h"
#include <GL/glu.h>
#include <SDL.h>
#include <SDL_opengl.h>
#define GL_COLOR_INDEX8_EXT GX_RGBA8
#include <SDL2/SDL.h>
#else
#include <SDL2/SDL.h>
#define GL_GLEXT_PROTOTYPES
#include <GL/gl.h>
#include <GL/glext.h>
#endif
#define GL_GLEXT_PROTOTYPES
#include <GL/gl.h>
#include <GL/glext.h>
#ifndef DISPLAY_SIZE_DYNAMIC
#define DISPLAY_SIZE_DYNAMIC 1
#endif
#elif DOLPHIN
// Dolphin.
#else
#error "Need to specify display backend."
#endif

View File

@@ -102,16 +102,12 @@ void frameBufferBind(const framebuffer_t *framebuffer) {
if(framebuffer == &FRAMEBUFFER_BACKBUFFER) {
#if PSP
#elif DOLPHIN
#else
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
#endif
} else {
#if PSP
assertUnreachable("Framebuffers not supported on PSP");
#elif DOLPHIN
assertUnreachable("Framebuffers not supported on DOLPHIN");
#else
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framebuffer->id);
#endif
@@ -144,11 +140,7 @@ void frameBufferClear(uint8_t flags, color_t color) {
glFlags |= GL_DEPTH_BUFFER_BIT;
}
#if DOLPHIN
assertUnreachable("Framebuffers not supported on DOLPHIN");
#else
glClear(glFlags);
#endif
glClear(glFlags);
#endif
}

View File

@@ -16,6 +16,9 @@ typedef struct {
// OpenGL Framebuffer Object ID
GLuint id;
texture_t texture;
#elif DOLPHIN
// --- IGNORE ---
uint8_t id;
#else
#error "Framebuffers not implemented on this platform."
#endif

View File

@@ -12,6 +12,10 @@ typedef enum {
MESH_PRIMITIVE_TRIANGLES = GL_TRIANGLES,
MESH_PRIMITIVE_LINES = GL_LINES,
MESH_PRIMITIVE_POINTS = GL_POINTS,
#elif DOLPHIN
MESH_PRIMITIVE_TRIANGLES = GX_TRIANGLES,
MESH_PRIMITIVE_LINES = GX_LINES,
MESH_PRIMITIVE_POINTS = GX_POINTS,
#endif
} meshprimitivetype_t;
@@ -19,11 +23,9 @@ typedef enum {
#define MESH_VERTEX_POS_SIZE 3
typedef struct {
#if DISPLAY_SDL2
color4b_t color;
GLfloat uv[MESH_VERTEX_UV_SIZE];
GLfloat pos[MESH_VERTEX_POS_SIZE];
#endif
color4b_t color;
float uv[MESH_VERTEX_UV_SIZE];
float pos[MESH_VERTEX_POS_SIZE];
} meshvertex_t;
typedef struct {

View File

@@ -77,8 +77,6 @@ void textureInit(
#if PSP
havePalTex = true;
#elif DOLPHIN
havePalTex = false;
#else
GLint mask = 0;
glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &mask);
@@ -127,14 +125,10 @@ void textureInit(
GL_UNSIGNED_BYTE, (void*)data.palette.data
);
#if DOLPHIN
assertUnreachable("Paletted textures not supported on DOLPHIN");
#else
glColorTableEXT(
GL_TEXTURE_2D, GL_RGBA, pal->colorCount, GL_RGBA,
GL_UNSIGNED_BYTE, (const void*)pal->colors
);
#endif
glColorTableEXT(
GL_TEXTURE_2D, GL_RGBA, pal->colorCount, GL_RGBA,
GL_UNSIGNED_BYTE, (const void*)pal->colors
);
}
break;

View File

@@ -14,12 +14,18 @@ typedef enum {
TEXTURE_FORMAT_RGBA = GL_RGBA,
TEXTURE_FORMAT_ALPHA = GL_ALPHA,
TEXTURE_FORMAT_PALETTE = GL_COLOR_INDEX8_EXT,
#elif DOLPHIN
TEXTURE_FORMAT_RGBA = GX_TF_RGBA8,
TEXTURE_FORMAT_ALPHA = GX_TF_A8,
TEXTURE_FORMAT_PALETTE = GX_TF_CI8,
#endif
} textureformat_t;
typedef struct {
#if DISPLAY_SDL2
GLuint id;
#elif DOLPHIN
uint8_t id;
#endif
int32_t width;

View File

@@ -19,16 +19,17 @@ if(DUSK_TARGET_SYSTEM STREQUAL "linux")
INPUT_MOUSE=1
INPUT_GAMEPAD=1
)
elseif(DUSK_TARGET_SYSTEM STREQUAL "psp")
target_compile_definitions(${DUSK_LIBRARY_TARGET_NAME}
PUBLIC
INPUT_SDL2=1
INPUT_GAMEPAD=1
)
elseif(DUSK_TARGET_SYSTEM STREQUAL "gamecube" OR DUSK_TARGET_SYSTEM STREQUAL "wii")
target_compile_definitions(${DUSK_LIBRARY_TARGET_NAME}
PUBLIC
INPUT_SDL2=1
INPUT_GAMEPAD=1
)
endif()

View File

@@ -31,7 +31,6 @@ inputbuttondata_t INPUT_BUTTON_DATA[] = {
{ .name = "lstick_negative_x", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = SDL_CONTROLLER_AXIS_LEFTX, .positive = false } } },
{ .name = "lstick_positive_y", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = SDL_CONTROLLER_AXIS_LEFTY, .positive = true } } },
{ .name = "lstick_negative_y", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = SDL_CONTROLLER_AXIS_LEFTY, .positive = false } } },
#else
#endif
#endif
@@ -172,6 +171,30 @@ inputbuttondata_t INPUT_BUTTON_DATA[] = {
{ .name = "kp_enter", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_KP_ENTER } },
{ .name = "kp_equals", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_KP_EQUALS } },
#endif
#elif DOLPHIN
#if INPUT_GAMEPAD == 1
{ .name = "a", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = PAD_BUTTON_A } },
{ .name = "b", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = PAD_BUTTON_B } },
{ .name = "x", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = PAD_BUTTON_X } },
{ .name = "y", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = PAD_BUTTON_Y } },
{ .name = "start", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = PAD_BUTTON_START } },
{ .name = "dpad_up", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = PAD_BUTTON_UP } },
{ .name = "dpad_down", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = PAD_BUTTON_DOWN } },
{ .name = "dpad_left", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = PAD_BUTTON_LEFT } },
{ .name = "dpad_right", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = PAD_BUTTON_RIGHT } },
{ .name = "l", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = PAD_TRIGGER_L } },
{ .name = "r", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = PAD_TRIGGER_R } },
{ .name = "z", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = PAD_TRIGGER_Z } },
{ .name = "lstick_positive_x", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = INPUT_GAMEPAD_AXIS_LEFT_X, .positive = true } } },
{ .name = "lstick_negative_x", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = INPUT_GAMEPAD_AXIS_LEFT_X, .positive = false } } },
{ .name = "lstick_positive_y", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = INPUT_GAMEPAD_AXIS_LEFT_Y, .positive = true } } },
{ .name = "lstick_negative_y", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = INPUT_GAMEPAD_AXIS_LEFT_Y, .positive = false } } },
{ .name = "cstick_positive_x", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = INPUT_GAMEPAD_AXIS_C_X, .positive = true } } },
{ .name = "cstick_negative_x", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = INPUT_GAMEPAD_AXIS_C_X, .positive = false } } },
{ .name = "cstick_positive_y", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = INPUT_GAMEPAD_AXIS_C_Y, .positive = true } } },
{ .name = "cstick_negative_y", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = INPUT_GAMEPAD_AXIS_C_Y, .positive = false } } },
#endif
#endif
{ .name = NULL }

View File

@@ -10,6 +10,8 @@
#if INPUT_SDL2 == 1
#include <SDL2/SDL.h>
#elif DOLPHIN
#else
#error "No input backend defined"
#endif
@@ -26,6 +28,16 @@
#if INPUT_SDL2 == 1
typedef SDL_GameControllerButton inputgamepadbutton_t;
typedef SDL_GameControllerAxis inputgamepadaxis_t;
#elif DOLPHIN == 1
typedef u16 inputgamepadbutton_t;
typedef enum {
INPUT_GAMEPAD_AXIS_LEFT_X,
INPUT_GAMEPAD_AXIS_LEFT_Y,
INPUT_GAMEPAD_AXIS_C_X,
INPUT_GAMEPAD_AXIS_C_Y,
INPUT_GAMEPAD_AXIS_TRIGGER_LEFT,
INPUT_GAMEPAD_AXIS_TRIGGER_RIGHT
} inputgamepadaxis_t;
#endif
#endif
@@ -35,6 +47,7 @@ typedef enum {
#if INPUT_KEYBOARD == 1
INPUT_BUTTON_TYPE_KEYBOARD,
#endif
#if INPUT_GAMEPAD == 1
INPUT_BUTTON_TYPE_GAMEPAD,
INPUT_BUTTON_TYPE_GAMEPAD_AXIS,