Whatewver
Some checks failed
Build Dusk / run-tests (push) Successful in 1m26s
Build Dusk / build-linux (push) Successful in 1m26s
Build Dusk / build-psp (push) Failing after 1m28s
Build Dusk / build-dolphin (push) Failing after 1m28s

This commit is contained in:
2026-03-02 20:14:21 -06:00
parent d0a057e0ee
commit e9b02c2acf
9 changed files with 221 additions and 133 deletions

View File

@@ -8,6 +8,18 @@
#pragma once
#include "display/color.h"
#if DISPLAY_SDL2
#if DISPLAY_SHADER == 1
#elif DISPLAY_COLOR_TABLE == 1
#else
#error "Unsupported palette mode"
#endif
#else
#error "Unsupported palette mode"
#endif
#define PALETTE_COUNT_MAX 4
#define PALETTE_COLOR_COUNT_MAX 0xFF

View File

@@ -0,0 +1,51 @@
/**
* Copyright (c) 2026 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "palettetexture.h"
#include "assert/assert.h"
void paletteTextureInit(
palettetexture_t *texture,
const int32_t width,
const int32_t height,
const uint8_t *data
) {
assertNotNull(texture, "Palette texture cannot be NULL");
assertTrue(width > 0 && height > 0, "width/height must be greater than 0");
assertNotNull(data, "Palette texture data cannot be NULL");
#if DISPLAY_SDL2
#if DISPLAY_SHADER == 1
// Palette textures not supported, convert to GL_RED style texture
// so shader can perform the lookup.
uint8_t formatted[width * height];
for(int32_t i = 0; i < width * height; i++) {
uint8_t index = data.paletteData[i];
formatted[i] = index * 128;
}
glTexImage2D(
GL_TEXTURE_2D, 0, GL_R8, width, height, 0,
GL_RED, GL_UNSIGNED_BYTE, (void*)formatted
);
#else
glTexImage2D(
GL_TEXTURE_2D,
0, GL_COLOR_INDEX8_EXT,
width, height,
0, GL_COLOR_INDEX8_EXT,
GL_UNSIGNED_BYTE, (void*)data.paletteData
);
// glColorTableEXT(
// GL_TEXTURE_2D, GL_RGBA, data.palette.palette->colorCount, GL_RGBA,
// GL_UNSIGNED_BYTE, (const void*)data.palette.palette->colors
// );
#endif
#else
#error "Palette textures not supported on this platform"
#endif
}

View File

@@ -0,0 +1,28 @@
/**
* Copyright (c) 2026 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include "dusk.h"
typedef struct {
} palettetexture_t;
/**
* Initializes a palette texture.
*
* @param texture The palette texture to initialize.
* @param width The width of the texture. Must be a power of 2.
* @param height The height of the texture. Must be a power of 2.
* @param data The palette index data for the texture.
*/
void paletteTextureInit(
palettetexture_t *texture,
const int32_t width,
const int32_t height,
const uint8_t *data
);