Reworking everything about shaders.
This commit is contained in:
src
CMakeLists.txt
display
file
games/poker
scene
vn
@ -35,7 +35,6 @@ add_subdirectory(physics)
|
|||||||
add_subdirectory(poker)
|
add_subdirectory(poker)
|
||||||
add_subdirectory(save)
|
add_subdirectory(save)
|
||||||
add_subdirectory(scene)
|
add_subdirectory(scene)
|
||||||
add_subdirectory(ui)
|
|
||||||
add_subdirectory(util)
|
add_subdirectory(util)
|
||||||
add_subdirectory(vn)
|
add_subdirectory(vn)
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ target_sources(${PROJECT_NAME}
|
|||||||
matrix.c
|
matrix.c
|
||||||
render.c
|
render.c
|
||||||
renderlist.c
|
renderlist.c
|
||||||
shader.c
|
shaderprogram.c
|
||||||
spritebatch.c
|
spritebatch.c
|
||||||
texture.c
|
texture.c
|
||||||
tileset.c
|
tileset.c
|
||||||
@ -21,4 +21,6 @@ target_sources(${PROJECT_NAME}
|
|||||||
|
|
||||||
# Subdirs
|
# Subdirs
|
||||||
add_subdirectory(animation)
|
add_subdirectory(animation)
|
||||||
add_subdirectory(primitive)
|
add_subdirectory(primitive)
|
||||||
|
add_subdirectory(shaders)
|
||||||
|
# add_subdirectory(ui)
|
@ -17,7 +17,7 @@ renderpass_t * renderListGetPass(renderlist_t *list, uint8_t pass) {
|
|||||||
return list->passes + pass;
|
return list->passes + pass;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t renderPassAdd(renderlist_t *list, shader_t *shader) {
|
uint8_t renderPassAdd(renderlist_t *list, shaderprogram_t *shader) {
|
||||||
uint8_t i;
|
uint8_t i;
|
||||||
renderpass_t *pass;
|
renderpass_t *pass;
|
||||||
|
|
||||||
@ -46,7 +46,7 @@ renderpass_t * renderListRenderPass(
|
|||||||
return renderPass;
|
return renderPass;
|
||||||
}
|
}
|
||||||
|
|
||||||
void renderListRender(renderlist_t *list, shader_t *shader) {
|
void renderListRender(renderlist_t *list, renderlistbackshader_t *backShader) {
|
||||||
camera_t camera;
|
camera_t camera;
|
||||||
int32_t i;
|
int32_t i;
|
||||||
renderpass_t *pass;
|
renderpass_t *pass;
|
||||||
@ -59,38 +59,21 @@ void renderListRender(renderlist_t *list, shader_t *shader) {
|
|||||||
frameBufferUse(&list->frame, true);
|
frameBufferUse(&list->frame, true);
|
||||||
|
|
||||||
// Set the shader
|
// Set the shader
|
||||||
shaderUse(shader);
|
shaderUse(backShader->program);
|
||||||
shaderUseCamera(shader, &camera);
|
shaderUseCamera(
|
||||||
shaderUsePosition(shader, 0,0,0, 0,0,0);
|
backShader->program, backShader->uniformView,
|
||||||
|
backShader->uniformProjection, &camera
|
||||||
|
);
|
||||||
|
shaderUsePosition(backShader->program, backShader->uniformPosition,
|
||||||
|
0,0,0, 0,0,0
|
||||||
|
);
|
||||||
|
|
||||||
// Render each pass.
|
// Render each pass.
|
||||||
for(i = 0; i < list->passCount; i++) {
|
for(i = 0; i < list->passCount; i++) {
|
||||||
pass = renderListGetPass(list, i);
|
pass = renderListGetPass(list, i);
|
||||||
shaderUseTexture(shader, &pass->frame.texture);
|
textureBind(&pass->frame.texture, i);
|
||||||
primitiveDraw(&list->quad, 0, -1);
|
shaderUseTexture(backShader->program, backShader->uniformTexture[i], i);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void renderListAsBackbuffer(
|
|
||||||
renderlist_t *list, engine_t *engine, shader_t *shader,
|
|
||||||
shaderuniform_t *uniforms
|
|
||||||
) {
|
|
||||||
camera_t camera;
|
|
||||||
|
|
||||||
// Reset to backbuffer
|
|
||||||
renderResetFramebuffer(&engine->render);
|
|
||||||
|
|
||||||
// Setup camera to look right at teh quad.
|
|
||||||
cameraLookAt(&camera, 0,0,1, 0,0,0);
|
|
||||||
cameraOrtho(&camera, 0,1, 0,1, 0.5f, 1.5f);
|
|
||||||
|
|
||||||
// Set up the shader.
|
|
||||||
shaderUse(shader);
|
|
||||||
shaderUseCamera(shader, &camera);
|
|
||||||
shaderUsePosition(shader, 0,0,0, 0,0,0);
|
|
||||||
shaderUseTexture(shader, &list->frame.texture);
|
|
||||||
|
|
||||||
// Render the quad to the back buffer.
|
|
||||||
primitiveDraw(&list->quad, 0, -1);
|
primitiveDraw(&list->quad, 0, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
#include "../libs.h"
|
#include "../libs.h"
|
||||||
#include "framebuffer.h"
|
#include "framebuffer.h"
|
||||||
#include "primitive/primitive.h"
|
#include "primitive/primitive.h"
|
||||||
#include "shader.h"
|
#include "shaderprogram.h"
|
||||||
#include "camera.h"
|
#include "camera.h"
|
||||||
#include "../engine/engine.h"
|
#include "../engine/engine.h"
|
||||||
#include "primitive/quad.h"
|
#include "primitive/quad.h"
|
||||||
@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
framebuffer_t frame;
|
framebuffer_t frame;
|
||||||
shader_t *shader;
|
shaderprogram_t *shader;
|
||||||
} renderpass_t;
|
} renderpass_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@ -32,11 +32,12 @@ typedef struct {
|
|||||||
} renderlist_t;
|
} renderlist_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
shader_t shader;
|
shaderprogram_t *program;
|
||||||
shaderuniform_t uniformTexture;
|
|
||||||
shaderuniform_t uniformView;
|
shaderuniform_t uniformView;
|
||||||
|
shaderuniform_t uniformPosition;
|
||||||
shaderuniform_t uniformProjection;
|
shaderuniform_t uniformProjection;
|
||||||
} renderlistbackbuffershader_t;
|
shaderuniform_t uniformTexture[RENDER_PASSES_MAX];
|
||||||
|
} renderlistbackshader_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize a render pass list.
|
* Initialize a render pass list.
|
||||||
@ -63,7 +64,7 @@ renderpass_t * renderListGetPass(renderlist_t *list, uint8_t pass);
|
|||||||
* @param shader Shader to use for the render pass.
|
* @param shader Shader to use for the render pass.
|
||||||
* @return The render pass index.
|
* @return The render pass index.
|
||||||
*/
|
*/
|
||||||
uint8_t renderPassAdd(renderlist_t *list, shader_t *shader);
|
uint8_t renderPassAdd(renderlist_t *list, shaderprogram_t *shader);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prepare the rendering for a specific render pass. This will set up the
|
* Prepare the rendering for a specific render pass. This will set up the
|
||||||
@ -85,24 +86,9 @@ renderpass_t * renderListRenderPass(
|
|||||||
* texture indexes.
|
* texture indexes.
|
||||||
*
|
*
|
||||||
* @param list List to render.
|
* @param list List to render.
|
||||||
* @param shader Shader to use while rendering.
|
* @param backShader Shader to use while rendering.
|
||||||
*/
|
*/
|
||||||
void renderListRender(renderlist_t *list, shader_t *shader);
|
void renderListRender(renderlist_t *list, renderlistbackshader_t *backShader);
|
||||||
|
|
||||||
/**
|
|
||||||
* Takes a previously rendered render list and renders it to the backbuffer.
|
|
||||||
* You could do this manually, but this method makes the assumption that the
|
|
||||||
* render list is the only thing to be rendered to the backbuffer (currently).
|
|
||||||
*
|
|
||||||
* @param list Render list to render to the backbuffer
|
|
||||||
* @param engine Engine to use when rendering.
|
|
||||||
* @param shader Shader to use to render to the backbuffer.
|
|
||||||
* @param uniforms Uniforms for the back buffer. [ view, proj, model, text ]
|
|
||||||
*/
|
|
||||||
void renderListAsBackbuffer(
|
|
||||||
renderlist_t *list, engine_t *engine, shader_t *shader,
|
|
||||||
shaderuniform_t *uniforms
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resize an existing render list and all its render pass frame buffers. This
|
* Resize an existing render list and all its render pass frame buffers. This
|
||||||
|
@ -5,21 +5,18 @@
|
|||||||
* https://opensource.org/licenses/MIT
|
* https://opensource.org/licenses/MIT
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "shader.h"
|
#include "shaderprogram.h"
|
||||||
|
|
||||||
void shaderInit(shader_t *shader,
|
void shaderInit(shaderprogram_t *shader,
|
||||||
char *vertexShaderSource, char* fragmentShaderSource
|
char *vertexShaderSource, char* fragmentShaderSource
|
||||||
) {
|
) {
|
||||||
int isSuccess, maxLength;
|
int isSuccess, maxLength;
|
||||||
char *error;
|
char *error;
|
||||||
GLuint shaderVertex, shaderFragment, shaderProgram;
|
GLuint shaderVertex, shaderFragment, shaderProgram;
|
||||||
|
|
||||||
GLchar const* filesVertex[] = { vertexShaderSource };
|
|
||||||
GLchar const* filesFragment[] = { fragmentShaderSource };
|
|
||||||
|
|
||||||
// Load the vertex shader first
|
// Load the vertex shader first
|
||||||
shaderVertex = glCreateShader(GL_VERTEX_SHADER);
|
shaderVertex = glCreateShader(GL_VERTEX_SHADER);
|
||||||
glShaderSource(shaderVertex, 1, filesVertex, 0);
|
glShaderSource(shaderVertex, 1, &vertexShaderSource, 0);
|
||||||
glCompileShader(shaderVertex);
|
glCompileShader(shaderVertex);
|
||||||
|
|
||||||
// Validate
|
// Validate
|
||||||
@ -35,7 +32,7 @@ void shaderInit(shader_t *shader,
|
|||||||
|
|
||||||
// Now load the Frag shader
|
// Now load the Frag shader
|
||||||
shaderFragment = glCreateShader(GL_FRAGMENT_SHADER);
|
shaderFragment = glCreateShader(GL_FRAGMENT_SHADER);
|
||||||
glShaderSource(shaderFragment, 1, filesFragment, 0);
|
glShaderSource(shaderFragment, 1, &fragmentShaderSource, 0);
|
||||||
glCompileShader(shaderFragment);
|
glCompileShader(shaderFragment);
|
||||||
glGetShaderiv(shaderFragment, GL_COMPILE_STATUS, &isSuccess);
|
glGetShaderiv(shaderFragment, GL_COMPILE_STATUS, &isSuccess);
|
||||||
if(!isSuccess) {
|
if(!isSuccess) {
|
||||||
@ -71,48 +68,42 @@ void shaderInit(shader_t *shader,
|
|||||||
shader->shaderVertex = shaderVertex;
|
shader->shaderVertex = shaderVertex;
|
||||||
shader->shaderFrag = shaderFragment;
|
shader->shaderFrag = shaderFragment;
|
||||||
shader->shaderProgram = shaderProgram;
|
shader->shaderProgram = shaderProgram;
|
||||||
|
|
||||||
shader->uniProj = glGetUniformLocation(shader->shaderProgram,SHADER_UNI_PROJ);
|
|
||||||
shader->uniView = glGetUniformLocation(shader->shaderProgram,SHADER_UNI_VIEW);
|
|
||||||
shader->uniText = glGetUniformLocation(shader->shaderProgram,SHADER_UNI_TEXT);
|
|
||||||
shader->uniModl = glGetUniformLocation(shader->shaderProgram,SHADER_UNI_MODL);
|
|
||||||
shader->uniColr = glGetUniformLocation(shader->shaderProgram,SHADER_UNI_COLR);
|
|
||||||
|
|
||||||
// Bind the shader
|
// Bind the shader
|
||||||
shaderUse(shader);
|
shaderUse(shader);
|
||||||
|
|
||||||
// Reset position
|
|
||||||
shaderUsePosition(shader, 0, 0, 0, 0, 0, 0);
|
|
||||||
shaderUseColor(shader, PIXEL_COLOR_WHITE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void shaderDispose(shader_t *shader) {
|
void shaderDispose(shaderprogram_t *shader) {
|
||||||
glDeleteProgram(shader->shaderProgram);
|
glDeleteProgram(shader->shaderProgram);
|
||||||
glDeleteShader(shader->shaderVertex);
|
glDeleteShader(shader->shaderVertex);
|
||||||
glDeleteShader(shader->shaderFrag);
|
glDeleteShader(shader->shaderFrag);
|
||||||
}
|
}
|
||||||
|
|
||||||
void shaderUse(shader_t *shader) {
|
void shaderUse(shaderprogram_t *shader) {
|
||||||
glUseProgram(shader->shaderProgram);
|
glUseProgram(shader->shaderProgram);
|
||||||
}
|
}
|
||||||
|
|
||||||
void shaderUseCamera(shader_t *shader, camera_t *camera) {
|
void shaderUseCamera(
|
||||||
shaderUseMatrix(shader, shader->uniView, &camera->view);
|
shaderprogram_t *shader, shaderuniform_t uniformView,
|
||||||
shaderUseMatrix(shader, shader->uniProj, &camera->projection);
|
shaderuniform_t uniformProjection, camera_t *camera
|
||||||
|
) {
|
||||||
|
shaderUseMatrix(shader, uniformView, &camera->view);
|
||||||
|
shaderUseMatrix(shader, uniformProjection, &camera->projection);
|
||||||
}
|
}
|
||||||
|
|
||||||
void shaderUseTexture(shader_t *shader, texture_t *texture) {
|
void shaderUseTexture(
|
||||||
// OpenGL requires us to set the active texure.
|
shaderprogram_t *shader, shaderuniform_t uniform, textureslot_t slot
|
||||||
glActiveTexture(GL_TEXTURE0);
|
) {
|
||||||
glBindTexture(GL_TEXTURE_2D, texture->id);
|
glUniform1i(uniform, slot);
|
||||||
glUniform1i(shader->uniText, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void shaderUseMatrix(shader_t *shader,shaderuniform_t uniform,matrix_t *matrix){
|
void shaderUseMatrix(
|
||||||
|
shaderprogram_t *shader, shaderuniform_t uniform, matrix_t *matrix
|
||||||
|
) {
|
||||||
glUniformMatrix4fv(uniform, 1, GL_FALSE, matrix->internalMatrix[0]);
|
glUniformMatrix4fv(uniform, 1, GL_FALSE, matrix->internalMatrix[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void shaderUsePosition(shader_t *shader,
|
void shaderUsePosition(shaderprogram_t *shader, shaderuniform_t uniform,
|
||||||
float x, float y, float z,
|
float x, float y, float z,
|
||||||
float pitch, float yaw, float roll
|
float pitch, float yaw, float roll
|
||||||
) {
|
) {
|
||||||
@ -125,10 +116,10 @@ void shaderUsePosition(shader_t *shader,
|
|||||||
matrixRotate(&matrix, yaw, 0, 1, 0);
|
matrixRotate(&matrix, yaw, 0, 1, 0);
|
||||||
matrixRotate(&matrix, roll, 0, 0, 1);
|
matrixRotate(&matrix, roll, 0, 0, 1);
|
||||||
matrixRotate(&matrix, pitch, 1, 0, 0);
|
matrixRotate(&matrix, pitch, 1, 0, 0);
|
||||||
shaderUseMatrix(shader, shader->uniModl, &matrix);
|
shaderUseMatrix(shader, uniform, &matrix);
|
||||||
}
|
}
|
||||||
|
|
||||||
void shaderUsePositionAndScale(shader_t *shader,
|
void shaderUsePositionAndScale(shaderprogram_t *shader, shaderuniform_t uniform,
|
||||||
float x, float y, float z,
|
float x, float y, float z,
|
||||||
float pitch, float yaw, float roll,
|
float pitch, float yaw, float roll,
|
||||||
float scaleX, float scaleY, float scaleZ
|
float scaleX, float scaleY, float scaleZ
|
||||||
@ -145,14 +136,20 @@ void shaderUsePositionAndScale(shader_t *shader,
|
|||||||
|
|
||||||
matrixScale(&matrix, scaleX, scaleY, scaleZ);
|
matrixScale(&matrix, scaleX, scaleY, scaleZ);
|
||||||
|
|
||||||
shaderUseMatrix(shader, shader->uniModl, &matrix);
|
shaderUseMatrix(shader, uniform, &matrix);
|
||||||
}
|
}
|
||||||
|
|
||||||
void shaderUseColor(shader_t *shader, pixel_t color) {
|
void shaderUseColor(
|
||||||
glUniform4f(shader->uniColr,
|
shaderprogram_t *shader, shaderuniform_t uniform, pixel_t color
|
||||||
|
) {
|
||||||
|
glUniform4f(uniform,
|
||||||
(float)color.r / 255.0f,
|
(float)color.r / 255.0f,
|
||||||
(float)color.g / 255.0f,
|
(float)color.g / 255.0f,
|
||||||
(float)color.b / 255.0f,
|
(float)color.b / 255.0f,
|
||||||
(float)color.a / 255.0f
|
(float)color.a / 255.0f
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
shaderuniform_t shaderGetUniformByName(shaderprogram_t *sp, const char *name) {
|
||||||
|
return glGetUniformLocation(sp->shaderProgram, name);
|
||||||
}
|
}
|
@ -11,12 +11,6 @@
|
|||||||
#include "camera.h"
|
#include "camera.h"
|
||||||
#include "texture.h"
|
#include "texture.h"
|
||||||
|
|
||||||
#define SHADER_UNI_VIEW "u_View"
|
|
||||||
#define SHADER_UNI_PROJ "u_Proj"
|
|
||||||
#define SHADER_UNI_TEXT "u_Text"
|
|
||||||
#define SHADER_UNI_MODL "u_Model"
|
|
||||||
#define SHADER_UNI_COLR "u_Colr"
|
|
||||||
|
|
||||||
/** Representation of a shader uniform */
|
/** Representation of a shader uniform */
|
||||||
typedef GLuint shaderuniform_t;
|
typedef GLuint shaderuniform_t;
|
||||||
|
|
||||||
@ -33,59 +27,56 @@ typedef struct {
|
|||||||
|
|
||||||
/** Pointer to an uploaded shader program linked */
|
/** Pointer to an uploaded shader program linked */
|
||||||
shaderuniform_t shaderProgram;
|
shaderuniform_t shaderProgram;
|
||||||
|
} shaderprogram_t;
|
||||||
/** Matrix for the view matrix */
|
|
||||||
shaderuniform_t uniView;
|
|
||||||
|
|
||||||
/** Matrix for the projection matrix */
|
|
||||||
shaderuniform_t uniProj;
|
|
||||||
|
|
||||||
/** Uniform for the current texture */
|
|
||||||
shaderuniform_t uniText;
|
|
||||||
|
|
||||||
/** Uniform for the current model world position */
|
|
||||||
shaderuniform_t uniModl;
|
|
||||||
|
|
||||||
/** Uniform for the color multiplier */
|
|
||||||
shaderuniform_t uniColr;
|
|
||||||
} shader_t;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compiles a shader from vertex and fragment shader code.
|
* Compiles a shader from vertex and fragment shader code.
|
||||||
|
*
|
||||||
* @param shader Shader to compile into.
|
* @param shader Shader to compile into.
|
||||||
* @param vertexShaderSource The raw vertex shader code.
|
* @param vertexShaderSource The raw vertex shader code.
|
||||||
* @param fragmentShaderSource The raw fragment shader code.
|
* @param fragmentShaderSource The raw fragment shader code.
|
||||||
*/
|
*/
|
||||||
void shaderInit(shader_t *shader,
|
void shaderInit(shaderprogram_t *shader,
|
||||||
char *vertexShaderSource, char* fragmentShaderSource
|
char *vertexShaderSource, char* fragmentShaderSource
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cleanup and unload a previously loaded shader.
|
* Cleanup and unload a previously loaded shader.
|
||||||
|
*
|
||||||
* @param shader The shader to unload
|
* @param shader The shader to unload
|
||||||
*/
|
*/
|
||||||
void shaderDispose(shader_t *shader);
|
void shaderDispose(shaderprogram_t *shader);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attaches the supplied shader as the current shader.
|
* Attaches the supplied shader as the current shader.
|
||||||
|
*
|
||||||
* @param shader The shader to attach
|
* @param shader The shader to attach
|
||||||
*/
|
*/
|
||||||
void shaderUse(shader_t *shader);
|
void shaderUse(shaderprogram_t *shader);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attaches a camera to the shader.
|
* Attaches a camera to the shader.
|
||||||
|
*
|
||||||
* @param shader Shader to attach to.
|
* @param shader Shader to attach to.
|
||||||
|
* @param uniformView Uniform for the view matrix
|
||||||
|
* @param uniformProjection Uniform for the projection matrix.
|
||||||
* @param camera Camera to attach.
|
* @param camera Camera to attach.
|
||||||
*/
|
*/
|
||||||
void shaderUseCamera(shader_t *shader, camera_t *camera);
|
void shaderUseCamera(
|
||||||
|
shaderprogram_t *shader, shaderuniform_t uniformView,
|
||||||
|
shaderuniform_t uniformProjection, camera_t *camera
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attaches a texture to the shader.
|
* Attaches a texture to the shader.
|
||||||
|
*
|
||||||
* @param shader Shader to attach to.
|
* @param shader Shader to attach to.
|
||||||
* @param texture Texture to attach.
|
* @param uniform Uniform to set the texture on to.
|
||||||
|
* @param slot Which texture slot to bind to the uniform.
|
||||||
*/
|
*/
|
||||||
void shaderUseTexture(shader_t *shader, texture_t *texture);
|
void shaderUseTexture(
|
||||||
|
shaderprogram_t *shader, shaderuniform_t uniform, textureslot_t slot
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set's a specific shader uniform to a matrix.
|
* Set's a specific shader uniform to a matrix.
|
||||||
@ -94,12 +85,15 @@ void shaderUseTexture(shader_t *shader, texture_t *texture);
|
|||||||
* @param uniform Uniform on the shader to set.
|
* @param uniform Uniform on the shader to set.
|
||||||
* @param matrix Matrix to apply.
|
* @param matrix Matrix to apply.
|
||||||
*/
|
*/
|
||||||
void shaderUseMatrix(shader_t *shader,shaderuniform_t uniform,matrix_t *matrix);
|
void shaderUseMatrix(
|
||||||
|
shaderprogram_t *shader, shaderuniform_t uniform, matrix_t *matrix
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set's the current translation matrix onto the shader for the next
|
* Set's the current translation matrix onto the shader for the next
|
||||||
* render to use. Rotation order is set to YZX.
|
* render to use. Rotation order is set to YZX.
|
||||||
* @param shader Shader to attach to.
|
* @param shader Shader to attach to.
|
||||||
|
* @param uniform Uniform to set the position on to.
|
||||||
* @param x X coordinate (world space).
|
* @param x X coordinate (world space).
|
||||||
* @param y Y coordinate (world space).
|
* @param y Y coordinate (world space).
|
||||||
* @param z Z coordinate (world space).
|
* @param z Z coordinate (world space).
|
||||||
@ -107,7 +101,7 @@ void shaderUseMatrix(shader_t *shader,shaderuniform_t uniform,matrix_t *matrix);
|
|||||||
* @param yaw Yaw of the object (local space).
|
* @param yaw Yaw of the object (local space).
|
||||||
* @param roll Roll of the object (local space).
|
* @param roll Roll of the object (local space).
|
||||||
*/
|
*/
|
||||||
void shaderUsePosition(shader_t *shader,
|
void shaderUsePosition(shaderprogram_t *shader, shaderuniform_t uniform,
|
||||||
float x, float y, float z,
|
float x, float y, float z,
|
||||||
float pitch, float yaw, float roll
|
float pitch, float yaw, float roll
|
||||||
);
|
);
|
||||||
@ -118,6 +112,7 @@ void shaderUsePosition(shader_t *shader,
|
|||||||
* render to use. Also provides scaling controls.
|
* render to use. Also provides scaling controls.
|
||||||
*
|
*
|
||||||
* @param shader Shader to attach to.
|
* @param shader Shader to attach to.
|
||||||
|
* @param uniform Uniform to set the position on to.
|
||||||
* @param x X coordinate (world space).
|
* @param x X coordinate (world space).
|
||||||
* @param y Y coordinate (world space).
|
* @param y Y coordinate (world space).
|
||||||
* @param z Z coordinate (world space).
|
* @param z Z coordinate (world space).
|
||||||
@ -128,11 +123,28 @@ void shaderUsePosition(shader_t *shader,
|
|||||||
* @param scaleY Y scale of model (1 being 100% scaled).
|
* @param scaleY Y scale of model (1 being 100% scaled).
|
||||||
* @param scaleZ Z scale of model (1 being 100% scaled).
|
* @param scaleZ Z scale of model (1 being 100% scaled).
|
||||||
*/
|
*/
|
||||||
void shaderUsePositionAndScale(shader_t *shader,
|
void shaderUsePositionAndScale(shaderprogram_t *shader, shaderuniform_t uniform,
|
||||||
float x, float y, float z,
|
float x, float y, float z,
|
||||||
float pitch, float yaw, float roll,
|
float pitch, float yaw, float roll,
|
||||||
float scaleX, float scaleY, float scaleZ
|
float scaleX, float scaleY, float scaleZ
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a color on to the shader.
|
||||||
|
*
|
||||||
|
* @param shader Shader to set the color on to.
|
||||||
|
* @param uniform Uniform to set the color to.
|
||||||
|
* @param color Color to set.
|
||||||
|
*/
|
||||||
|
void shaderUseColor(
|
||||||
|
shaderprogram_t *shader, shaderuniform_t uniform, pixel_t color
|
||||||
|
);
|
||||||
|
|
||||||
void shaderUseColor(shader_t *shader, pixel_t color);
|
/**
|
||||||
|
* Locate a shader uniform by its name.
|
||||||
|
*
|
||||||
|
* @param sp Shader program to get the uniform for.
|
||||||
|
* @param name Name of the uniform to get.
|
||||||
|
* @return The shader uniform.
|
||||||
|
*/
|
||||||
|
shaderuniform_t shaderGetUniformByName(shaderprogram_t *sp, const char *name);
|
11
src/display/shaders/CMakeLists.txt
Normal file
11
src/display/shaders/CMakeLists.txt
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# Copyright (c) 2021 Dominic Msters
|
||||||
|
#
|
||||||
|
# This software is released under the MIT License.
|
||||||
|
# https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
|
# Sources
|
||||||
|
# target_sources(${PROJECT_NAME}
|
||||||
|
# PRIVATE
|
||||||
|
# standardshader.c
|
||||||
|
# shaderui.c
|
||||||
|
# )
|
12
src/display/shaders/shaderui.c
Normal file
12
src/display/shaders/shaderui.c
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2021 Dominic Masters
|
||||||
|
*
|
||||||
|
* This software is released under the MIT License.
|
||||||
|
* https://opensource.org/licenses/MIT
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "shaderui.h"
|
||||||
|
|
||||||
|
void shaderUiInit(shaderprogram_t *program) {
|
||||||
|
|
||||||
|
}
|
22
src/display/shaders/shaderui.h
Normal file
22
src/display/shaders/shaderui.h
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2021 Dominic Masters
|
||||||
|
*
|
||||||
|
* This software is released under the MIT License.
|
||||||
|
* https://opensource.org/licenses/MIT
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include "../shaderprogram.h"
|
||||||
|
#include "../texture.h"
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
shaderprogram_t program;
|
||||||
|
texture_t texture;
|
||||||
|
|
||||||
|
shaderuniform_t uniProjection;
|
||||||
|
shaderuniform_t uniModel;
|
||||||
|
shaderuniform_t uniTexture;
|
||||||
|
shaderuniform_t uniColor;
|
||||||
|
} uishader_t;
|
||||||
|
|
||||||
|
void shaderUiInit(shaderprogram_t *program);
|
11
src/display/shaders/standardshader.c
Normal file
11
src/display/shaders/standardshader.c
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2021 Dominic Masters
|
||||||
|
*
|
||||||
|
* This software is released under the MIT License.
|
||||||
|
* https://opensource.org/licenses/MIT
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "standardshader.h"
|
||||||
|
|
||||||
|
void standardShaderInit(standardshader_t *stds, char *vert, char *frag) {
|
||||||
|
}
|
28
src/display/shaders/standardshader.h
Normal file
28
src/display/shaders/standardshader.h
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2021 Dominic Masters
|
||||||
|
*
|
||||||
|
* This software is released under the MIT License.
|
||||||
|
* https://opensource.org/licenses/MIT
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include "../../libs.h"
|
||||||
|
#include "../shaderprogram.h"
|
||||||
|
|
||||||
|
#define STANDARD_SHADER_UNIFORM_NAME_VIEW "u_View"
|
||||||
|
#define STANDARD_SHADER_UNIFORM_NAME_PROJ "u_Proj"
|
||||||
|
#define STANDARD_SHADER_UNIFORM_NAME_TEXT "u_Text"
|
||||||
|
#define STANDARD_SHADER_UNIFORM_NAME_MODEL "u_Model"
|
||||||
|
#define STANDARD_SHADER_UNIFORM_NAME_COLOR "u_Color"
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
shaderprogram_t shader;
|
||||||
|
|
||||||
|
shaderuniform_t uniformView;
|
||||||
|
shaderuniform_t uniformProjection;
|
||||||
|
shaderuniform_t uniformPosition;
|
||||||
|
shaderuniform_t uniformTexture;
|
||||||
|
shaderuniform_t uniformColor;
|
||||||
|
} standardshader_t;
|
||||||
|
|
||||||
|
void standardShaderInit(standardshader_t *stds, char *vert, char *frag);
|
@ -45,8 +45,13 @@ void textureInit(texture_t *texture, int32_t width, int32_t height,
|
|||||||
GL_RGBA, GL_UNSIGNED_BYTE, pixels
|
GL_RGBA, GL_UNSIGNED_BYTE, pixels
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
textureBind(texture, 0x00);
|
||||||
|
}
|
||||||
|
|
||||||
|
void textureBind(texture_t *texture, textureslot_t slot) {
|
||||||
|
glActiveTexture(GL_TEXTURE0 + slot);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, texture->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void textureBufferPixels(texture_t *texture,
|
void textureBufferPixels(texture_t *texture,
|
||||||
|
@ -6,6 +6,11 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "../libs.h"
|
#include "../libs.h"
|
||||||
|
|
||||||
|
#define TEXTURE_SLOTS_MAX 8
|
||||||
|
|
||||||
|
/** Texture slot that a texture can be bound to */
|
||||||
|
typedef GLuint textureslot_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Structure detailing information about a texture.
|
* Structure detailing information about a texture.
|
||||||
* Because we plan to upload the pixels of a texture into the GPU, we don't
|
* Because we plan to upload the pixels of a texture into the GPU, we don't
|
||||||
@ -45,6 +50,14 @@ void textureInit(texture_t *texture, int32_t width, int32_t height,
|
|||||||
pixel_t *pixels
|
pixel_t *pixels
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bind a texture on to a given texture slot.
|
||||||
|
*
|
||||||
|
* @param texture Texture to bind.
|
||||||
|
* @param slot Slot to bind the texture to.
|
||||||
|
*/
|
||||||
|
void textureBind(texture_t *texture, textureslot_t slot);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Buffer pixel data onto the GPU. Pixel buffering is rather costly so avoid
|
* Buffer pixel data onto the GPU. Pixel buffering is rather costly so avoid
|
||||||
* doing this too often.
|
* doing this too often.
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "../libs.h"
|
#include "../../libs.h"
|
||||||
#include "../util/flags.h"
|
#include "../../util/flags.h"
|
||||||
|
|
||||||
#define ALIGN_POS_CENTER flagDefine(0)
|
#define ALIGN_POS_CENTER flagDefine(0)
|
||||||
#define ALIGN_POS_START flagDefine(1)
|
#define ALIGN_POS_START flagDefine(1)
|
@ -4,7 +4,7 @@
|
|||||||
// https://opensource.org/licenses/MIT
|
// https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "../libs.h"
|
#include "../../libs.h"
|
||||||
|
|
||||||
/** Maximum breakpoints that the list can support. */
|
/** Maximum breakpoints that the list can support. */
|
||||||
#define BREAKPOINT_COUNT_MAX 0x04
|
#define BREAKPOINT_COUNT_MAX 0x04
|
@ -100,7 +100,7 @@ void frameSetInnerSize(frame_t *frame, float width, float height) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void frameRender(frame_t *frame, shader_t *shader, float x, float y) {
|
void frameRender(frame_t *frame, shaderprogram_t *shader, float x, float y) {
|
||||||
if(frame->texture == NULL) return;
|
if(frame->texture == NULL) return;
|
||||||
shaderUsePosition(shader, x, y, 0, 0, 0, 0);
|
shaderUsePosition(shader, x, y, 0, 0, 0, 0);
|
||||||
shaderUseTexture(shader, frame->texture);
|
shaderUseTexture(shader, frame->texture);
|
@ -6,11 +6,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "../libs.h"
|
#include "../../libs.h"
|
||||||
#include "../display/shader.h"
|
#include "../shaderprogram.h"
|
||||||
#include "../display/primitive/primitive.h"
|
#include "../primitive/primitive.h"
|
||||||
#include "../display/primitive/quad.h"
|
#include "../primitive/quad.h"
|
||||||
#include "../display/font.h"
|
#include "../font.h"
|
||||||
|
|
||||||
/** Size of the border (in pixels) on each edge */
|
/** Size of the border (in pixels) on each edge */
|
||||||
#define FRAME_BORDER_SIZE 16
|
#define FRAME_BORDER_SIZE 16
|
||||||
@ -57,7 +57,7 @@ void frameSetInnerSize(frame_t *frame, float width, float height);
|
|||||||
* @param x X position.
|
* @param x X position.
|
||||||
* @param y Y position.
|
* @param y Y position.
|
||||||
*/
|
*/
|
||||||
void frameRender(frame_t *frame, shader_t *shader, float x, float y);
|
void frameRender(frame_t *frame, shaderprogram_t *shader, float x, float y);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cleanup a previously initialized frame.
|
* Cleanup a previously initialized frame.
|
@ -30,7 +30,7 @@ void framedTextMenuUpdate(framedtextmenu_t *menu, engine_t *engine) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void framedTextMenuRender(
|
void framedTextMenuRender(
|
||||||
framedtextmenu_t *menu, shader_t *shader, float x, float y
|
framedtextmenu_t *menu, shaderprogram_t *shader, float x, float y
|
||||||
) {
|
) {
|
||||||
frameRender(&menu->frame, shader, x, y);
|
frameRender(&menu->frame, shader, x, y);
|
||||||
textMenuRender(&menu->menu, shader, x, y);
|
textMenuRender(&menu->menu, shader, x, y);
|
@ -56,7 +56,7 @@ void framedTextMenuUpdate(framedtextmenu_t *menu, engine_t *engine);
|
|||||||
* @param y Y Position.
|
* @param y Y Position.
|
||||||
*/
|
*/
|
||||||
void framedTextMenuRender(
|
void framedTextMenuRender(
|
||||||
framedtextmenu_t *menu, shader_t *shader, float x, float y
|
framedtextmenu_t *menu, shaderprogram_t *shader, float x, float y
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
@ -46,7 +46,7 @@ void imageSetTextureAndCrop(image_t *image, texture_t *texture,
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void imageRender(image_t *image, shader_t *shader, float x, float y) {
|
void imageRender(image_t *image, shaderprogram_t *shader, float x, float y) {
|
||||||
if(image->texture == NULL) return;
|
if(image->texture == NULL) return;
|
||||||
shaderUsePositionAndScale(shader,
|
shaderUsePositionAndScale(shader,
|
||||||
x,y,0,
|
x,y,0,
|
@ -10,7 +10,7 @@
|
|||||||
#include "../display/primitive/primitive.h"
|
#include "../display/primitive/primitive.h"
|
||||||
#include "../display/primitive/quad.h"
|
#include "../display/primitive/quad.h"
|
||||||
#include "../display/texture.h"
|
#include "../display/texture.h"
|
||||||
#include "../display/shader.h"
|
#include "../display/shaderprogram.h"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
texture_t *texture;
|
texture_t *texture;
|
||||||
@ -56,7 +56,7 @@ void imageSetTextureAndCrop(image_t *image, texture_t *texture,
|
|||||||
* @param x X position.
|
* @param x X position.
|
||||||
* @param y Y position.
|
* @param y Y position.
|
||||||
*/
|
*/
|
||||||
void imageRender(image_t *image, shader_t *shader, float x, float y);
|
void imageRender(image_t *image, shaderprogram_t *shader, float x, float y);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cleanup a previously initialized image.
|
* Cleanup a previously initialized image.
|
@ -27,7 +27,7 @@ void labelSetText(label_t *label, font_t *font, char *text) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void labelRender(label_t *label, shader_t *shader, float x, float y) {
|
void labelRender(label_t *label, shaderprogram_t *shader, float x, float y) {
|
||||||
if(label->primitive.verticeCount == 0) return;
|
if(label->primitive.verticeCount == 0) return;
|
||||||
shaderUsePosition(shader, x,y,0, 0,0,0);
|
shaderUsePosition(shader, x,y,0, 0,0,0);
|
||||||
shaderUseTexture(shader, &label->font->texture);
|
shaderUseTexture(shader, &label->font->texture);
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "../libs.h"
|
#include "../libs.h"
|
||||||
#include "../display/shader.h"
|
#include "../display/shaderprogram.h"
|
||||||
#include "../display/primitive/primitive.h"
|
#include "../display/primitive/primitive.h"
|
||||||
#include "../display/font.h"
|
#include "../display/font.h"
|
||||||
|
|
||||||
@ -41,7 +41,7 @@ void labelSetText(label_t *label, font_t *font, char *text);
|
|||||||
* @param x X position.
|
* @param x X position.
|
||||||
* @param y Y position.
|
* @param y Y position.
|
||||||
*/
|
*/
|
||||||
void labelRender(label_t *label, shader_t *shader, float x, float y);
|
void labelRender(label_t *label, shaderprogram_t *shader, float x, float y);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dispose a previously created label.
|
* Dispose a previously created label.
|
@ -20,7 +20,9 @@ void rectangleSetColor(rectangle_t *rectangle, pixel_t color) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void rectangleRender(rectangle_t *rect, shader_t *shader, float x, float y) {
|
void rectangleRender(
|
||||||
|
rectangle_t *rect, shaderprogram_t *shader, float x, float y
|
||||||
|
) {
|
||||||
shaderUsePositionAndScale(shader,
|
shaderUsePositionAndScale(shader,
|
||||||
x, y, 0,
|
x, y, 0,
|
||||||
0, 0, 0,
|
0, 0, 0,
|
@ -8,7 +8,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "../libs.h"
|
#include "../libs.h"
|
||||||
#include "../display/texture.h"
|
#include "../display/texture.h"
|
||||||
#include "../display/shader.h"
|
#include "../display/shaderprogram.h"
|
||||||
#include "../display/primitive/primitive.h"
|
#include "../display/primitive/primitive.h"
|
||||||
#include "../display/primitive/quad.h"
|
#include "../display/primitive/quad.h"
|
||||||
|
|
||||||
@ -23,7 +23,7 @@ void rectangleInit(rectangle_t *rectangle);
|
|||||||
void rectangleSetColor(rectangle_t *rectangle, pixel_t color);
|
void rectangleSetColor(rectangle_t *rectangle, pixel_t color);
|
||||||
|
|
||||||
void rectangleRender(
|
void rectangleRender(
|
||||||
rectangle_t *rect, shader_t *shader,
|
rectangle_t *rect, shaderprogram_t *shader,
|
||||||
float x, float y
|
float x, float y
|
||||||
);
|
);
|
||||||
|
|
@ -35,7 +35,9 @@ menuitem_t * textMenuAdd(textmenu_t *menu, char *item) {
|
|||||||
return menuAdd(&menu->menu);
|
return menuAdd(&menu->menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
void textMenuRender(textmenu_t *menu, shader_t *shader, float x, float y) {
|
void textMenuRender(
|
||||||
|
textmenu_t *menu, shaderprogram_t *shader, float x, float y
|
||||||
|
) {
|
||||||
uint8_t i;
|
uint8_t i;
|
||||||
label_t *label;
|
label_t *label;
|
||||||
menuitem_t *item;
|
menuitem_t *item;
|
@ -59,7 +59,7 @@ menuitem_t * textMenuAdd(textmenu_t *menu, char *item);
|
|||||||
* @param x X position of the menu.
|
* @param x X position of the menu.
|
||||||
* @param y Y position of the menu.
|
* @param y Y position of the menu.
|
||||||
*/
|
*/
|
||||||
void textMenuRender(textmenu_t *menu, shader_t *shader, float x, float y);
|
void textMenuRender(textmenu_t *menu, shaderprogram_t *shader,float x, float y);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dispose/Cleanup a text menu.
|
* Dispose/Cleanup a text menu.
|
@ -7,8 +7,6 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "../libs.h"
|
#include "../libs.h"
|
||||||
#include "../display/shader.h"
|
|
||||||
#include "../display/texture.h"
|
|
||||||
#include "../display/font.h"
|
#include "../display/font.h"
|
||||||
|
|
||||||
#if !defined(ASSET_PREFIX)
|
#if !defined(ASSET_PREFIX)
|
||||||
|
@ -5,10 +5,10 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "../../libs.h"
|
#include "../../libs.h"
|
||||||
#include "../../display/shader.h"
|
#include "../../display/shaderprogram.h"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
shader_t shader;
|
shaderprogram_t shader;
|
||||||
char *fileVert;
|
char *fileVert;
|
||||||
char *fileFrag;
|
char *fileFrag;
|
||||||
char *dataVert;
|
char *dataVert;
|
||||||
|
@ -11,12 +11,12 @@
|
|||||||
#include "../../display/primitive/primitive.h"
|
#include "../../display/primitive/primitive.h"
|
||||||
#include "../../display/primitive/quad.h"
|
#include "../../display/primitive/quad.h"
|
||||||
#include "../../display/primitive/cube.h"
|
#include "../../display/primitive/cube.h"
|
||||||
#include "../../display/shader.h"
|
#include "../../display/shaderprogram.h"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
engine_t engine;
|
engine_t engine;
|
||||||
camera_t camera;
|
camera_t camera;
|
||||||
shader_t shader;
|
shaderprogram_t shader;
|
||||||
primitive_t quad;
|
primitive_t quad;
|
||||||
assetmanagerowner_t owner;
|
assetmanagerowner_t owner;
|
||||||
assetmanageritem_t *item;
|
assetmanageritem_t *item;
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
#include "../file/assetmanager.h"
|
#include "../file/assetmanager.h"
|
||||||
#include "../engine/engine.h"
|
#include "../engine/engine.h"
|
||||||
#include "../display/renderlist.h"
|
#include "../display/renderlist.h"
|
||||||
#include "../display/shader.h"
|
#include "../display/shaderprogram.h"
|
||||||
|
|
||||||
// Forwarder for scene_t
|
// Forwarder for scene_t
|
||||||
typedef struct _scene_t scene_t;
|
typedef struct _scene_t scene_t;
|
||||||
|
@ -33,7 +33,7 @@ void vnConversationUpdate(vnconversation_t *convo, engine_t *engine) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void vnConversationRender(
|
void vnConversationRender(
|
||||||
vnconversation_t *convo, engine_t *engine, shader_t *shader
|
vnconversation_t *convo, engine_t *engine, shaderprogram_t *shader
|
||||||
) {
|
) {
|
||||||
vnTextBoxRender(
|
vnTextBoxRender(
|
||||||
&convo->textbox, shader,
|
&convo->textbox, shader,
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include "../../util/array.h"
|
#include "../../util/array.h"
|
||||||
#include "../../display/animation/timeline.h"
|
#include "../../display/animation/timeline.h"
|
||||||
#include "../../display/animation/queue.h"
|
#include "../../display/animation/queue.h"
|
||||||
|
#include "../../display/shaderprogram.h"
|
||||||
#include "../vncharacter.h"
|
#include "../vncharacter.h"
|
||||||
#include "../../engine/engine.h"
|
#include "../../engine/engine.h"
|
||||||
|
|
||||||
@ -69,7 +70,7 @@ void vnConversationUpdate(vnconversation_t *convo, engine_t *engine);
|
|||||||
* @param shader Shader to use while rendering.
|
* @param shader Shader to use while rendering.
|
||||||
*/
|
*/
|
||||||
void vnConversationRender(
|
void vnConversationRender(
|
||||||
vnconversation_t *convo, engine_t *engine, shader_t *shader
|
vnconversation_t *convo, engine_t *engine, shaderprogram_t *shader
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -77,7 +77,9 @@ void vnTextBoxUpdate(vntextbox_t *box, engine_t *engine) {
|
|||||||
box->lineCurrent += box->linesMax;
|
box->lineCurrent += box->linesMax;
|
||||||
}
|
}
|
||||||
|
|
||||||
void vnTextBoxRender(vntextbox_t *box, shader_t *shader, float x, float y) {
|
void vnTextBoxRender(
|
||||||
|
vntextbox_t *box, shaderprogram_t *shader, float x, float y
|
||||||
|
) {
|
||||||
int32_t charStart, charCount;
|
int32_t charStart, charCount;
|
||||||
float yOffset;
|
float yOffset;
|
||||||
if(box->text == NULL || box->state & VN_TEXTBOX_STATE_CLOSED) return;
|
if(box->text == NULL || box->state & VN_TEXTBOX_STATE_CLOSED) return;
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "../../libs.h"
|
#include "../../libs.h"
|
||||||
#include "../../display/primitive/primitive.h"
|
#include "../../display/primitive/primitive.h"
|
||||||
#include "../../display/shader.h"
|
#include "../../display/shaderprogram.h"
|
||||||
#include "../../display/animation/timeline.h"
|
#include "../../display/animation/timeline.h"
|
||||||
#include "../../display/font.h"
|
#include "../../display/font.h"
|
||||||
#include "../../display/primitive/quad.h"
|
#include "../../display/primitive/quad.h"
|
||||||
@ -97,7 +97,7 @@ void vnTextBoxUpdate(vntextbox_t *box, engine_t *engine);
|
|||||||
* @param x X position.
|
* @param x X position.
|
||||||
* @param y Y position.
|
* @param y Y position.
|
||||||
*/
|
*/
|
||||||
void vnTextBoxRender(vntextbox_t *box, shader_t *shader, float x, float y);
|
void vnTextBoxRender(vntextbox_t *box, shaderprogram_t *shader, float x, float y);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disposes a previously created Visual Novel Text Box.
|
* Disposes a previously created Visual Novel Text Box.
|
||||||
|
@ -165,7 +165,7 @@ void vnCharacterLayerSetFrame(vncharacter_t *character, uint8_t l, uint8_t f) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void vnCharacterRender(vncharacter_t *character, shader_t *shader) {
|
void vnCharacterRender(vncharacter_t *character, shaderprogram_t *shader) {
|
||||||
shaderUsePositionAndScale(shader,
|
shaderUsePositionAndScale(shader,
|
||||||
character->x, character->y, character->z,
|
character->x, character->y, character->z,
|
||||||
character->pitch, character->yaw, character->roll,
|
character->pitch, character->yaw, character->roll,
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
#include "../display/texture.h"
|
#include "../display/texture.h"
|
||||||
#include "../display/tileset.h"
|
#include "../display/tileset.h"
|
||||||
#include "../display/primitive/primitive.h"
|
#include "../display/primitive/primitive.h"
|
||||||
#include "../display/shader.h"
|
#include "../display/shaderprogram.h"
|
||||||
#include "../display/primitive/quad.h"
|
#include "../display/primitive/quad.h"
|
||||||
#include "../display/animation/animation.h"
|
#include "../display/animation/animation.h"
|
||||||
#include "../engine/engine.h"
|
#include "../engine/engine.h"
|
||||||
@ -58,6 +58,6 @@ uint8_t vnCharacterLayerAdd(vncharacter_t *character,
|
|||||||
void vnCharacterLayerSetFrame(vncharacter_t *character, uint8_t l, uint8_t f);
|
void vnCharacterLayerSetFrame(vncharacter_t *character, uint8_t l, uint8_t f);
|
||||||
|
|
||||||
void vnCharacterUpdate(vncharacter_t *character, engine_t *engine);
|
void vnCharacterUpdate(vncharacter_t *character, engine_t *engine);
|
||||||
void vnCharacterRender(vncharacter_t *character, shader_t *shader);
|
void vnCharacterRender(vncharacter_t *character, shaderprogram_t *shader);
|
||||||
|
|
||||||
void vnCharacterDispose(vncharacter_t *character);
|
void vnCharacterDispose(vncharacter_t *character);
|
@ -47,7 +47,9 @@ void vnSceneDispose(vnscene_t *scene) {
|
|||||||
vnConversationDispose(&scene->conversation);
|
vnConversationDispose(&scene->conversation);
|
||||||
}
|
}
|
||||||
|
|
||||||
void vnSceneRenderWorld(vnscene_t *scene, engine_t *engine, shader_t *shader) {
|
void vnSceneRenderWorld(
|
||||||
|
vnscene_t *scene, engine_t *engine, shaderprogram_t *shader
|
||||||
|
) {
|
||||||
// Adjust Camera Position.
|
// Adjust Camera Position.
|
||||||
cameraLookAtStruct(&scene->camera, scene->cameraLook);
|
cameraLookAtStruct(&scene->camera, scene->cameraLook);
|
||||||
|
|
||||||
@ -61,7 +63,7 @@ void vnSceneRenderWorld(vnscene_t *scene, engine_t *engine, shader_t *shader) {
|
|||||||
shaderUseCamera(shader, &scene->camera);
|
shaderUseCamera(shader, &scene->camera);
|
||||||
}
|
}
|
||||||
|
|
||||||
void vnSceneRenderCharacters(vnscene_t *scene, shader_t *shader) {
|
void vnSceneRenderCharacters(vnscene_t *scene, shaderprogram_t *shader) {
|
||||||
uint8_t i;
|
uint8_t i;
|
||||||
|
|
||||||
// Render each character
|
// Render each character
|
||||||
@ -70,7 +72,9 @@ void vnSceneRenderCharacters(vnscene_t *scene, shader_t *shader) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void vnSceneRenderGui(vnscene_t *scene, engine_t *engine, shader_t *shader) {
|
void vnSceneRenderGui(
|
||||||
|
vnscene_t *scene, engine_t *engine, shaderprogram_t *shader
|
||||||
|
) {
|
||||||
// Do we need to update the width of the GUI element(s) ?
|
// Do we need to update the width of the GUI element(s) ?
|
||||||
if(engine->render.width != scene->conversation.textbox.widthMax) {
|
if(engine->render.width != scene->conversation.textbox.widthMax) {
|
||||||
scene->conversation.textbox.widthMax = engine->render.width;
|
scene->conversation.textbox.widthMax = engine->render.width;
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
#include "conversation/vnconversation.h"
|
#include "conversation/vnconversation.h"
|
||||||
#include "ui/vntextbox.h"
|
#include "ui/vntextbox.h"
|
||||||
#include "../display/camera.h"
|
#include "../display/camera.h"
|
||||||
#include "../display/shader.h"
|
#include "../display/shaderprogram.h"
|
||||||
#include "../display/animation/timeline.h"
|
#include "../display/animation/timeline.h"
|
||||||
#include "../display/animation/easing.h"
|
#include "../display/animation/easing.h"
|
||||||
#include "../util/math.h"
|
#include "../util/math.h"
|
||||||
@ -44,11 +44,15 @@ void vnSceneUpdate(vnscene_t *scene, engine_t *engine);
|
|||||||
|
|
||||||
void vnSceneDispose(vnscene_t *scene);
|
void vnSceneDispose(vnscene_t *scene);
|
||||||
|
|
||||||
void vnSceneRenderWorld(vnscene_t *scene, engine_t *engine, shader_t *shader);
|
void vnSceneRenderWorld(
|
||||||
|
vnscene_t *scene, engine_t *engine, shaderprogram_t *shader
|
||||||
|
);
|
||||||
|
|
||||||
void vnSceneRenderCharacters(vnscene_t *scene, shader_t *shader);
|
void vnSceneRenderCharacters(vnscene_t *scene, shaderprogram_t *shader);
|
||||||
|
|
||||||
void vnSceneRenderGui(vnscene_t *scene, engine_t *engine, shader_t *shader);
|
void vnSceneRenderGui(
|
||||||
|
vnscene_t *scene, engine_t *engine, shaderprogram_t *shader
|
||||||
|
);
|
||||||
|
|
||||||
void vnSceneLookAt(vnscene_t *scene,
|
void vnSceneLookAt(vnscene_t *scene,
|
||||||
float x, float y, float z, float lookX, float lookY, float lookZ
|
float x, float y, float z, float lookX, float lookY, float lookZ
|
||||||
|
Reference in New Issue
Block a user