Shader first pass
This commit is contained in:
72
src/duskgl/display/shader/shadergl.h
Normal file
72
src/duskgl/display/shader/shadergl.h
Normal file
@@ -0,0 +1,72 @@
|
||||
/**
|
||||
* Copyright (c) 2026 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "error/errorgl.h"
|
||||
|
||||
typedef struct {
|
||||
GLuint shaderProgramId;
|
||||
GLuint vertexShaderId;
|
||||
GLuint fragmentShaderId;
|
||||
} shadergl_t;
|
||||
|
||||
typedef struct {
|
||||
const char_t *vert;
|
||||
const char_t *frag;
|
||||
} shaderdefinitiongl_t;
|
||||
|
||||
/**
|
||||
* Initializes a shader.
|
||||
*
|
||||
* @param shader The shader to initialize.
|
||||
* @param def The definition of the shader to initialize with.
|
||||
* @return An errorret_t indicating success or failure.
|
||||
*/
|
||||
errorret_t shaderInitGL(shadergl_t *shader, const shaderdefinitiongl_t *def);
|
||||
|
||||
/**
|
||||
* Binds a shader for use in rendering.
|
||||
*
|
||||
* @param shader The shader to bind.
|
||||
* @return An errorret_t indicating success or failure.
|
||||
*/
|
||||
errorret_t shaderBindGL(shadergl_t *shader);
|
||||
|
||||
/**
|
||||
* Retrieves the location of a shader uniform parameter.
|
||||
*
|
||||
* @param shader The shader to query.
|
||||
* @param name The name of the uniform parameter.
|
||||
* @param location Output parameter to receive the location of the uniform.
|
||||
* @return An errorret_t indicating success or failure.
|
||||
*/
|
||||
errorret_t shaderParamGetLocationGL(
|
||||
shadergl_t *shader,
|
||||
const char_t *name,
|
||||
GLint *location
|
||||
);
|
||||
|
||||
/**
|
||||
* Sets a mat4 uniform parameter in the shader.
|
||||
*
|
||||
* @param shader The shader to update.
|
||||
* @param name The name of the uniform parameter.
|
||||
* @param mat The 4x4 matrix data to set.
|
||||
* @return An errorret_t indicating success or failure.
|
||||
*/
|
||||
errorret_t shaderSetMatrixGL(
|
||||
shadergl_t *shader,
|
||||
const char_t *name,
|
||||
const mat4 matrix
|
||||
);
|
||||
|
||||
/**
|
||||
* Disposes of a shader, freeing any associated resources.
|
||||
*
|
||||
* @param shader The shader to dispose.
|
||||
*/
|
||||
errorret_t shaderDisposeGL(shadergl_t *shader);
|
||||
Reference in New Issue
Block a user