Builds on knulli

This commit is contained in:
2026-03-27 20:48:43 -05:00
parent a2113442cb
commit 09c35f0aa6
6 changed files with 90 additions and 10 deletions

View File

@@ -9,6 +9,45 @@
#ifdef DUSK_OPENGL_LEGACY
shaderdefinition_t SHADER_UNLIT_DEFINITION = { 0 };
#elifdef DUSK_OPENGL_ES
shaderdefinition_t SHADER_UNLIT_DEFINITION = {
.vert =
"#version 300 es\n"
"layout(location = 0) in vec3 a_Pos;\n"
"layout(location = 1) in vec2 a_TexCoord;\n"
"layout(location = 2) in vec4 a_Color;\n"
"uniform mat4 u_Proj;\n"
"uniform mat4 u_View;\n"
"uniform mat4 u_Model;\n"
"out vec4 v_Color;\n"
"out vec2 v_TexCoord;\n"
"void main() {\n"
" gl_Position = u_Proj * u_View * u_Model * vec4(a_Pos, 1.0);\n"
" v_Color = a_Color;\n"
" v_TexCoord = a_TexCoord;\n"
"}\n",
.frag =
"#version 300 es\n"
"precision mediump float;\n"
"uniform sampler2D u_Texture;\n"
"uniform uint u_Colors[256];\n"
"uniform int u_ColorCount;\n"
"in vec4 v_Color;\n"
"in vec2 v_TexCoord;\n"
"out vec4 FragColor;\n"
"void main() {\n"
" vec4 texColor = texture(u_Texture, v_TexCoord);\n"
" uint index = uint(floor(texColor.r * 255.0));\n"
" uint palColor = u_Colors[index];\n"
" float r = float((palColor >> 24) & 0xFFu) / 255.0;\n"
" float g = float((palColor >> 16) & 0xFFu) / 255.0;\n"
" float b = float((palColor >> 8) & 0xFFu) / 255.0;\n"
" float a = float((palColor >> 0) & 0xFFu) / 255.0;\n"
" vec4 paletteColor = vec4(r, g, b, a);\n"
" FragColor = paletteColor;\n"
"}\n"
};
#else
shaderdefinition_t SHADER_UNLIT_DEFINITION = {
.vert =

View File

@@ -6,6 +6,20 @@
*/
#pragma once
#define GL_GLEXT_PROTOTYPES
#include <GL/gl.h>
#include <GL/glext.h>
#ifdef DUSK_OPENGL_ES
#include <GLES3/gl3.h>
#define GL_COLOR_INDEX8_EXT 0x80E5
#define GL_FRAMEBUFFER_EXT GL_FRAMEBUFFER
#define GL_FRAMEBUFFER_COMPLETE_EXT GL_FRAMEBUFFER_COMPLETE
#define glCheckFramebufferStatusEXT glCheckFramebufferStatus
#define glDeleteFramebuffersEXT glDeleteFramebuffers
#define glGenFramebuffersEXT glGenFramebuffers
#define glBindFramebufferEXT glBindFramebuffer
#define glFramebufferTexture2DEXT glFramebufferTexture2D
#define GL_COLOR_ATTACHMENT0_EXT GL_COLOR_ATTACHMENT0
#define glClearDepth(depth) glClearDepthf(depth)
#else
#define GL_GLEXT_PROTOTYPES
#include <GL/gl.h>
#include <GL/glext.h>
#endif

View File

@@ -19,4 +19,5 @@ void logError(const char_t *message, ...) {
va_start(args, message);
vprintf(message, args);
va_end(args);
fflush(stdout);
}