played around with color, will likely stick to textures.
Some checks failed
Build Dusk / run-tests (push) Failing after 13s
Build Dusk / build-linux (push) Failing after 15s
Build Dusk / build-psp (push) Failing after 14s
Build Dusk / build-gamecube (push) Failing after 13s
Build Dusk / build-wii (push) Failing after 14s

This commit is contained in:
2026-03-22 23:53:23 -05:00
parent c0cff40628
commit b23c4b83ae
7 changed files with 82 additions and 1 deletions

View File

@@ -32,6 +32,17 @@ errorret_t shaderSetMatrix(
errorOk(); errorOk();
} }
// errorret_t shaderSetColor(
// shader_t *shader,
// const char_t *name,
// color_t color
// ) {
// assertNotNull(shader, "Shader cannot be null");
// assertStrLenMin(name, 1, "Uniform name cannot be empty");
// errorChain(shaderSetColorPlatform(shader, name, color));
// errorOk();
// }
errorret_t shaderDispose(shader_t *shader) { errorret_t shaderDispose(shader_t *shader) {
assertNotNull(shader, "Shader cannot be null"); assertNotNull(shader, "Shader cannot be null");
errorChain(shaderDisposePlatform(shader)); errorChain(shaderDisposePlatform(shader));

View File

@@ -71,6 +71,20 @@ errorret_t shaderSetTexture(
texture_t *texture texture_t *texture
); );
/**
* Sets a color uniform in the shader. This is platform dependant.
*
* @param shader Shader to set the color in
* @param name Name of the uniform to set
* @param color Color to set
* @return Error if failure, otherwise errorOk
*/
// errorret_t shaderSetColor(
// shader_t *shader,
// const char_t *name,
// color_t color
// );
/** /**
* Disposes of a shader. This is platform dependant. * Disposes of a shader. This is platform dependant.
* *

View File

@@ -11,6 +11,7 @@
#define SHADER_UNLIT_PROJECTION "u_Proj" #define SHADER_UNLIT_PROJECTION "u_Proj"
#define SHADER_UNLIT_VIEW "u_View" #define SHADER_UNLIT_VIEW "u_View"
#define SHADER_UNLIT_MODEL "u_Model" #define SHADER_UNLIT_MODEL "u_Model"
// #define SHADER_UNLIT_COLOR "u_Color"
extern shaderdefinition_t SHADER_UNLIT_DEFINITION; extern shaderdefinition_t SHADER_UNLIT_DEFINITION;
static shader_t SHADER_UNLIT; static shader_t SHADER_UNLIT;

View File

@@ -203,6 +203,26 @@ errorret_t shaderSetMatrixGL(
errorOk(); errorOk();
} }
// errorret_t shaderSetColorGL(
// shadergl_t *shader,
// const char_t *name,
// color_t color
// ) {
// assertNotNull(shader, "Shader cannot be null");
// assertStrLenMin(name, 1, "Uniform name cannot be empty");
// #ifdef DUSK_OPENGL_LEGACY
// assertUnreachable("Cannot set colors on legacy opengl.");
// #else
// GLint location;
// errorChain(shaderParamGetLocationGL(shader, name, &location));
// glUniform4f(location, color.r, color.g, color.b, color.a);
// errorChain(errorGLCheck());
// #endif
// errorOk();
// }
errorret_t shaderBindGL(shadergl_t *shader) { errorret_t shaderBindGL(shadergl_t *shader) {
#ifdef DUSK_OPENGL_LEGACY #ifdef DUSK_OPENGL_LEGACY

View File

@@ -7,6 +7,7 @@
#pragma once #pragma once
#include "error/errorgl.h" #include "error/errorgl.h"
#include "display/color.h"
typedef struct { typedef struct {
#ifdef DUSK_OPENGL_LEGACY #ifdef DUSK_OPENGL_LEGACY
@@ -91,6 +92,34 @@ errorret_t shaderSetMatrixGL(
mat4 matrix mat4 matrix
); );
/**
* Sets a color uniform parameter in the shader.
*
* @param shader The shader to update.
* @param name The name of the uniform parameter.
* @param color The color data to set.
* @return An errorret_t indicating success or failure.
*/
// errorret_t shaderSetTextureGL(
// shadergl_t *shader,
// const char_t *name,
// texture_t *texture
// );
/**
* Sets a color uniform parameter in the shader.
*
* @param shader The shader to update.
* @param name The name of the uniform parameter.
* @param color The color data to set.
* @return An errorret_t indicating success or failure.
*/
// errorret_t shaderSetColorGL(
// shadergl_t *shader,
// const char_t *name,
// color_t color
// );
/** /**
* Disposes of a shader, freeing any associated resources. * Disposes of a shader, freeing any associated resources.
* *

View File

@@ -15,4 +15,5 @@ typedef shaderdefinitiongl_t shaderdefinitionplatform_t;
#define shaderBindPlatform shaderBindGL #define shaderBindPlatform shaderBindGL
#define shaderSetMatrixPlatform shaderSetMatrixGL #define shaderSetMatrixPlatform shaderSetMatrixGL
// #define shaderSetTexturePlatform shaderSetTextureGL // #define shaderSetTexturePlatform shaderSetTextureGL
// #define shaderSetColorPlatform shaderSetColorGL
#define shaderDisposePlatform shaderDisposeGL #define shaderDisposePlatform shaderDisposeGL

View File

@@ -14,18 +14,23 @@
.vert = .vert =
"#version 330 core\n" "#version 330 core\n"
"layout(location = 0) in vec3 aPos;\n" "layout(location = 0) in vec3 aPos;\n"
"layout(location = 1) in vec2 aTexCoord;\n"
"layout(location = 2) in vec4 aColor;\n"
"uniform mat4 u_Proj;\n" "uniform mat4 u_Proj;\n"
"uniform mat4 u_View;\n" "uniform mat4 u_View;\n"
"uniform mat4 u_Model;\n" "uniform mat4 u_Model;\n"
"out vec4 v_Color;\n"
"void main() {\n" "void main() {\n"
" gl_Position = u_Proj * u_View * u_Model * vec4(aPos, 1.0);\n" " gl_Position = u_Proj * u_View * u_Model * vec4(aPos, 1.0);\n"
" v_Color = aColor;\n"
"}\n", "}\n",
.frag = .frag =
"#version 330 core\n" "#version 330 core\n"
"in vec4 v_Color;\n"
"out vec4 FragColor;\n" "out vec4 FragColor;\n"
"void main() {\n" "void main() {\n"
" FragColor = vec4(1.0, 0.0, 0.0, 1.0);\n" " FragColor = v_Color;\n"
"}\n" "}\n"
}; };
#endif #endif