Progress on PSP paletted textures
Some checks failed
Build Dusk / run-tests (push) Failing after 19s
Build Dusk / build-linux (push) Failing after 17s
Build Dusk / build-psp (push) Failing after 21s
Build Dusk / build-gamecube (push) Failing after 19s
Build Dusk / build-wii (push) Failing after 15s
Some checks failed
Build Dusk / run-tests (push) Failing after 19s
Build Dusk / build-linux (push) Failing after 17s
Build Dusk / build-psp (push) Failing after 21s
Build Dusk / build-gamecube (push) Failing after 19s
Build Dusk / build-wii (push) Failing after 15s
This commit is contained in:
@@ -24,6 +24,11 @@ display_t DISPLAY = { 0 };
|
|||||||
|
|
||||||
texture_t TEXTURE;
|
texture_t TEXTURE;
|
||||||
|
|
||||||
|
uint8_t indices[2 * 2] = {
|
||||||
|
0, 1,
|
||||||
|
2, 3
|
||||||
|
};
|
||||||
|
|
||||||
errorret_t displayInit(void) {
|
errorret_t displayInit(void) {
|
||||||
memoryZero(&DISPLAY, sizeof(DISPLAY));
|
memoryZero(&DISPLAY, sizeof(DISPLAY));
|
||||||
|
|
||||||
@@ -44,15 +49,9 @@ errorret_t displayInit(void) {
|
|||||||
PALETTES[0].colors[3] = COLOR_WHITE;
|
PALETTES[0].colors[3] = COLOR_WHITE;
|
||||||
PALETTES[0].count = 4;
|
PALETTES[0].count = 4;
|
||||||
|
|
||||||
uint8_t indices[4 * 4] = {
|
|
||||||
0, 1, 2, 3,
|
|
||||||
3, 2, 1, 0,
|
|
||||||
0, 1, 2, 3,
|
|
||||||
3, 2, 1, 0,
|
|
||||||
};
|
|
||||||
errorChain(textureInit(
|
errorChain(textureInit(
|
||||||
&TEXTURE,
|
&TEXTURE,
|
||||||
4, 4,
|
2, 2,
|
||||||
TEXTURE_FORMAT_PALETTE,
|
TEXTURE_FORMAT_PALETTE,
|
||||||
(texturedata_t){
|
(texturedata_t){
|
||||||
.paletted = {
|
.paletted = {
|
||||||
@@ -81,8 +80,6 @@ errorret_t displayUpdate(void) {
|
|||||||
SCREEN.background
|
SCREEN.background
|
||||||
);
|
);
|
||||||
|
|
||||||
errorChain(shaderBind(&SHADER_UNLIT));
|
|
||||||
|
|
||||||
camera_t camera;
|
camera_t camera;
|
||||||
// cameraInitOrthographic(&camera);
|
// cameraInitOrthographic(&camera);
|
||||||
// camera.orthographic.left = 0.0f;
|
// camera.orthographic.left = 0.0f;
|
||||||
@@ -99,6 +96,7 @@ errorret_t displayUpdate(void) {
|
|||||||
cameraGetViewMatrix(&camera, view);
|
cameraGetViewMatrix(&camera, view);
|
||||||
glm_mat4_identity(model);
|
glm_mat4_identity(model);
|
||||||
|
|
||||||
|
errorChain(shaderBind(&SHADER_UNLIT));
|
||||||
errorChain(shaderSetMatrix(&SHADER_UNLIT, SHADER_UNLIT_PROJECTION, proj));
|
errorChain(shaderSetMatrix(&SHADER_UNLIT, SHADER_UNLIT_PROJECTION, proj));
|
||||||
errorChain(shaderSetMatrix(&SHADER_UNLIT, SHADER_UNLIT_VIEW, view));
|
errorChain(shaderSetMatrix(&SHADER_UNLIT, SHADER_UNLIT_VIEW, view));
|
||||||
errorChain(shaderSetMatrix(&SHADER_UNLIT, SHADER_UNLIT_MODEL, model));
|
errorChain(shaderSetMatrix(&SHADER_UNLIT, SHADER_UNLIT_MODEL, model));
|
||||||
|
|||||||
@@ -8,12 +8,12 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "display/color.h"
|
#include "display/color.h"
|
||||||
|
|
||||||
#define PALETTE_COLOR_COUNT 256
|
#define PALETTE_COLOR_COUNT 0xFF
|
||||||
#define PALETTE_COUNT 6
|
#define PALETTE_COUNT 6
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
color_t colors[PALETTE_COLOR_COUNT];
|
|
||||||
uint8_t count;
|
uint8_t count;
|
||||||
|
color_t colors[PALETTE_COLOR_COUNT];
|
||||||
} palette_t;
|
} palette_t;
|
||||||
|
|
||||||
extern palette_t PALETTES[PALETTE_COUNT];
|
extern palette_t PALETTES[PALETTE_COUNT];
|
||||||
@@ -23,6 +23,18 @@ errorret_t textureInit(
|
|||||||
assertTrue(width == mathNextPowTwo(width), "Width must be a power of 2.");
|
assertTrue(width == mathNextPowTwo(width), "Width must be a power of 2.");
|
||||||
assertTrue(height == mathNextPowTwo(height), "Height must be a power of 2.");
|
assertTrue(height == mathNextPowTwo(height), "Height must be a power of 2.");
|
||||||
|
|
||||||
|
if(texture->format == TEXTURE_FORMAT_RGBA) {
|
||||||
|
assertNotNull(data.rgbaColors, "RGBA color data cannot be NULL");
|
||||||
|
} else if(texture->format == TEXTURE_FORMAT_PALETTE) {
|
||||||
|
assertNotNull(data.paletted.indices, "Palette indices cannot be NULL");
|
||||||
|
assertNotNull(data.paletted.palette, "Palette colors cannot be NULL");
|
||||||
|
assertTrue(
|
||||||
|
data.paletted.palette->count ==
|
||||||
|
mathNextPowTwo(data.paletted.palette->count),
|
||||||
|
"Palette color count must be a power of 2"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
memoryZero(texture, sizeof(texture_t));
|
memoryZero(texture, sizeof(texture_t));
|
||||||
texture->width = width;
|
texture->width = width;
|
||||||
texture->height = height;
|
texture->height = height;
|
||||||
|
|||||||
@@ -20,13 +20,11 @@
|
|||||||
typedef textureformatplatform_t textureformat_t;
|
typedef textureformatplatform_t textureformat_t;
|
||||||
typedef textureplatform_t texture_t;
|
typedef textureplatform_t texture_t;
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
uint8_t *indices;
|
|
||||||
palette_t *palette;
|
|
||||||
} texturepalettedata_t;
|
|
||||||
|
|
||||||
typedef union texturedata_u {
|
typedef union texturedata_u {
|
||||||
texturepalettedata_t paletted;
|
struct {
|
||||||
|
uint8_t *indices;
|
||||||
|
palette_t *palette;
|
||||||
|
} paletted;
|
||||||
color_t *rgbaColors;
|
color_t *rgbaColors;
|
||||||
} texturedata_t;
|
} texturedata_t;
|
||||||
|
|
||||||
|
|||||||
@@ -9,20 +9,33 @@
|
|||||||
|
|
||||||
errorret_t displayOpenGLInit(void) {
|
errorret_t displayOpenGLInit(void) {
|
||||||
glDisable(GL_CULL_FACE);
|
glDisable(GL_CULL_FACE);
|
||||||
// glDisable(GL_LIGHTING);// PSP defaults this on?
|
|
||||||
// glShadeModel(GL_SMOOTH); // Fixes color on PSP?
|
|
||||||
errorChain(errorGLCheck());
|
errorChain(errorGLCheck());
|
||||||
|
|
||||||
|
#if DUSK_OPENGL_LEGACY
|
||||||
|
glDisable(GL_LIGHTING);// PSP defaults this on?
|
||||||
|
errorChain(errorGLCheck());
|
||||||
|
glShadeModel(GL_SMOOTH); // Fixes color on PSP?
|
||||||
|
errorChain(errorGLCheck());
|
||||||
|
#endif
|
||||||
|
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
errorChain(errorGLCheck());
|
||||||
glDepthFunc(GL_LEQUAL);
|
glDepthFunc(GL_LEQUAL);
|
||||||
|
errorChain(errorGLCheck());
|
||||||
glClearDepth(1.0f);
|
glClearDepth(1.0f);
|
||||||
errorChain(errorGLCheck());
|
errorChain(errorGLCheck());
|
||||||
|
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
|
errorChain(errorGLCheck());
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
errorChain(errorGLCheck());
|
||||||
glPixelStorei(GL_PACK_ALIGNMENT, 1);
|
glPixelStorei(GL_PACK_ALIGNMENT, 1);
|
||||||
|
errorChain(errorGLCheck());
|
||||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||||
errorChain(errorGLCheck());
|
errorChain(errorGLCheck());
|
||||||
|
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
||||||
|
glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
|
||||||
|
glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
|
||||||
|
|
||||||
errorOk();
|
errorOk();
|
||||||
}
|
}
|
||||||
@@ -27,7 +27,9 @@ errorret_t meshInitGL(
|
|||||||
#ifdef DUSK_OPENGL_LEGACY
|
#ifdef DUSK_OPENGL_LEGACY
|
||||||
// Nothing needed.
|
// Nothing needed.
|
||||||
glEnableClientState(GL_COLOR_ARRAY);
|
glEnableClientState(GL_COLOR_ARRAY);
|
||||||
|
errorChain(errorGLCheck());
|
||||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
|
errorChain(errorGLCheck());
|
||||||
glEnableClientState(GL_VERTEX_ARRAY);
|
glEnableClientState(GL_VERTEX_ARRAY);
|
||||||
errorChain(errorGLCheck());
|
errorChain(errorGLCheck());
|
||||||
#else
|
#else
|
||||||
|
|||||||
@@ -213,7 +213,10 @@ errorret_t shaderSetTextureGL(
|
|||||||
assertStrLenMin(name, 1, "Uniform name cannot be empty");
|
assertStrLenMin(name, 1, "Uniform name cannot be empty");
|
||||||
|
|
||||||
#ifdef DUSK_OPENGL_LEGACY
|
#ifdef DUSK_OPENGL_LEGACY
|
||||||
assertUnreachable("Cannot set textures on legacy opengl.");
|
glEnable(GL_TEXTURE_2D);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, texture->id);
|
||||||
|
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
GLint location;
|
GLint location;
|
||||||
errorChain(shaderParamGetLocationGL(shader, name, &location));
|
errorChain(shaderParamGetLocationGL(shader, name, &location));
|
||||||
@@ -244,13 +247,7 @@ errorret_t shaderSetTextureGL(
|
|||||||
glUniform1uiv(location, texture->palette->count, paletteData);
|
glUniform1uiv(location, texture->palette->count, paletteData);
|
||||||
errorChain(errorGLCheck());
|
errorChain(errorGLCheck());
|
||||||
}
|
}
|
||||||
|
|
||||||
// PALETTE TEST
|
|
||||||
// errorChain(shaderParamGetLocationGL(shader, "u_Palette", &location));
|
|
||||||
// glActiveTexture(GL_TEXTURE1);
|
|
||||||
// errorChain(errorGLCheck());
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
errorOk();
|
errorOk();
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ errorret_t textureInitGL(
|
|||||||
const texturedata_t data
|
const texturedata_t data
|
||||||
) {
|
) {
|
||||||
glGenTextures(1, &texture->id);
|
glGenTextures(1, &texture->id);
|
||||||
|
errorChain(errorGLCheck());
|
||||||
glBindTexture(GL_TEXTURE_2D, texture->id);
|
glBindTexture(GL_TEXTURE_2D, texture->id);
|
||||||
errorChain(errorGLCheck());
|
errorChain(errorGLCheck());
|
||||||
|
|
||||||
@@ -27,11 +28,12 @@ errorret_t textureInitGL(
|
|||||||
GL_TEXTURE_2D, 0, format, width, height, 0,
|
GL_TEXTURE_2D, 0, format, width, height, 0,
|
||||||
format, GL_UNSIGNED_BYTE, (void*)data.rgbaColors
|
format, GL_UNSIGNED_BYTE, (void*)data.rgbaColors
|
||||||
);
|
);
|
||||||
|
errorChain(errorGLCheck());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TEXTURE_FORMAT_PALETTE:
|
case TEXTURE_FORMAT_PALETTE:
|
||||||
assertNotNull(data.paletted.indices, "Palette indices cannot be NULL");
|
texture->palette = data.paletted.palette;
|
||||||
assertNotNull(data.paletted.palette, "Palette colors cannot be NULL");
|
|
||||||
#ifdef DUSK_OPENGL_LEGACY
|
#ifdef DUSK_OPENGL_LEGACY
|
||||||
glTexImage2D(
|
glTexImage2D(
|
||||||
GL_TEXTURE_2D,
|
GL_TEXTURE_2D,
|
||||||
@@ -40,12 +42,13 @@ errorret_t textureInitGL(
|
|||||||
0, GL_COLOR_INDEX8_EXT,
|
0, GL_COLOR_INDEX8_EXT,
|
||||||
GL_UNSIGNED_BYTE, (void*)data.paletted.indices
|
GL_UNSIGNED_BYTE, (void*)data.paletted.indices
|
||||||
);
|
);
|
||||||
errorChain(errorGLCheck());
|
|
||||||
glColorTableEXT(
|
glColorTableEXT(
|
||||||
GL_TEXTURE_2D, GL_RGBA, data.paletted.palette->count, GL_RGBA,
|
GL_TEXTURE_2D, GL_RGBA, texture->palette->count, GL_RGBA,
|
||||||
GL_UNSIGNED_BYTE, (const void*)data.paletted.palette->colors
|
GL_UNSIGNED_BYTE, (const void*)texture->palette->colors
|
||||||
);
|
);
|
||||||
errorChain(errorGLCheck());
|
errorChain(errorGLCheck());
|
||||||
|
|
||||||
#else
|
#else
|
||||||
// For modern systems we send to only the R channel and the shader does
|
// For modern systems we send to only the R channel and the shader does
|
||||||
// the rest.
|
// the rest.
|
||||||
@@ -54,7 +57,6 @@ errorret_t textureInitGL(
|
|||||||
GL_RED, GL_UNSIGNED_BYTE, (void*)data.paletted.indices
|
GL_RED, GL_UNSIGNED_BYTE, (void*)data.paletted.indices
|
||||||
);
|
);
|
||||||
errorChain(errorGLCheck());
|
errorChain(errorGLCheck());
|
||||||
texture->palette = data.paletted.palette;
|
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -65,8 +67,11 @@ errorret_t textureInitGL(
|
|||||||
errorChain(errorGLCheck());
|
errorChain(errorGLCheck());
|
||||||
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||||
|
errorChain(errorGLCheck());
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||||
|
errorChain(errorGLCheck());
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||||
|
errorChain(errorGLCheck());
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||||
errorChain(errorGLCheck());
|
errorChain(errorGLCheck());
|
||||||
|
|
||||||
|
|||||||
@@ -21,11 +21,9 @@ errorret_t displaySDL2Init(void) {
|
|||||||
|
|
||||||
// Set OpenGL attributes (Needs to be done now or later?)
|
// Set OpenGL attributes (Needs to be done now or later?)
|
||||||
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
|
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
|
||||||
// SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
|
|
||||||
// SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8);
|
|
||||||
|
|
||||||
#ifdef DUSK_OPENGL_LEGACY
|
#ifdef DUSK_OPENGL_LEGACY
|
||||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_COMPATIBILITY);
|
// SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_COMPATIBILITY);
|
||||||
#else
|
#else
|
||||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
|
||||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
|
||||||
@@ -91,9 +89,8 @@ errorret_t displaySDL2Update(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SDL_GL_MakeCurrent(DISPLAY.window, DISPLAY.glContext);
|
SDL_GL_MakeCurrent(DISPLAY.window, DISPLAY.glContext);
|
||||||
|
errorChain(errorGLCheck());
|
||||||
// errorChain(shaderPaletteTextureBindGL(&testShader));
|
// errorChain(shaderPaletteTextureBindGL(&testShader));
|
||||||
|
|
||||||
errorOk();
|
errorOk();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user