Dolphin shader handler
This commit is contained in:
@@ -22,6 +22,8 @@ errorret_t shaderInitDolphin(
|
||||
|
||||
memoryZero(shader, sizeof(shaderdolphin_t));
|
||||
|
||||
shader->definition = def;
|
||||
|
||||
glm_mat4_identity(shader->view);
|
||||
glm_mat4_identity(shader->proj);
|
||||
glm_mat4_identity(shader->model);
|
||||
@@ -87,22 +89,19 @@ errorret_t shaderSetTextureDolphin(
|
||||
assertStrLenMin(name, 1, "Uniform name cannot be empty");
|
||||
|
||||
if(texture == NULL) {
|
||||
// GX_SetNumChans(0);
|
||||
GX_SetNumChans(1);
|
||||
GX_SetChanCtrl(
|
||||
GX_COLOR0A0,
|
||||
GX_DISABLE,
|
||||
GX_SRC_REG,
|
||||
GX_SRC_VTX,
|
||||
GX_SRC_REG,
|
||||
GX_LIGHTNULL,
|
||||
GX_DF_NONE,
|
||||
GX_AF_NONE
|
||||
);
|
||||
GX_SetChanAmbColor(GX_COLOR0A0, (GXColor){ 0, 0, 0, 0 });
|
||||
GX_SetChanMatColor(GX_COLOR0A0, (GXColor){ 255, 255, 255, 255 });
|
||||
GX_SetChanAmbColor(GX_COLOR0A0, (GXColor){0,0,0,0});
|
||||
|
||||
GX_SetNumTexGens(0);
|
||||
|
||||
GX_SetNumTevStages(1);
|
||||
GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORDNULL, GX_TEXMAP_NULL, GX_COLOR0A0);
|
||||
GX_SetTevOp(GX_TEVSTAGE0, GX_PASSCLR);
|
||||
@@ -117,13 +116,13 @@ errorret_t shaderSetTextureDolphin(
|
||||
GX_LoadTexObj(&texture->texObj, GX_TEXMAP0);
|
||||
GX_SetNumChans(1);
|
||||
GX_SetChanCtrl(
|
||||
GX_COLOR0A0,// Store in color channel 0
|
||||
GX_DISABLE,// Lighting disabled
|
||||
GX_SRC_REG,// Ambient color?
|
||||
GX_SRC_VTX,// Material color?
|
||||
GX_LIGHTNULL,// Light Mask
|
||||
GX_DF_NONE,// Diffuse function
|
||||
GX_AF_NONE// Attenuation function
|
||||
GX_COLOR0A0,
|
||||
GX_DISABLE,
|
||||
GX_SRC_REG,
|
||||
GX_SRC_REG,
|
||||
GX_LIGHTNULL,
|
||||
GX_DF_NONE,
|
||||
GX_AF_NONE
|
||||
);
|
||||
|
||||
// One set of UVs
|
||||
@@ -168,7 +167,12 @@ errorret_t shaderSetColorDolphin(
|
||||
assertNotNull(name, "Uniform name must not be null");
|
||||
assertStrLenMin(name, 1, "Uniform name cannot be empty");
|
||||
|
||||
GX_SetChanMatColor(GX_COLOR0A0, (GXColor){ color.r, color.g, color.b, color.a });
|
||||
GX_SetChanMatColor(GX_COLOR0A0, (GXColor){
|
||||
color.r,
|
||||
color.g,
|
||||
color.b,
|
||||
color.a
|
||||
});
|
||||
|
||||
errorOk();
|
||||
}
|
||||
|
||||
@@ -8,7 +8,19 @@
|
||||
#pragma once
|
||||
#include "display/texture/texture.h"
|
||||
|
||||
typedef union shadermaterial_u shadermaterial_t;
|
||||
typedef struct shaderdolphin_s shaderdolphin_t;
|
||||
|
||||
typedef struct {
|
||||
errorret_t (*setMaterial)(
|
||||
shaderdolphin_t *shader,
|
||||
const shadermaterial_t *material
|
||||
);
|
||||
} shaderdefinitiondolphin_t;
|
||||
|
||||
typedef struct shaderdolphin_s {
|
||||
shaderdefinitiondolphin_t *definition;
|
||||
|
||||
mat4 view;
|
||||
mat4 proj;
|
||||
mat4 model;
|
||||
@@ -22,10 +34,6 @@ typedef struct {
|
||||
uint_fast8_t dirtyMatrix;
|
||||
} shaderdolphin_t;
|
||||
|
||||
typedef struct {
|
||||
void *empty;
|
||||
} shaderdefinitiondolphin_t;
|
||||
|
||||
#define SHADER_DOLPHIN_DIRTY_MODEL (1 << 0)
|
||||
#define SHADER_DOLPHIN_DIRTY_PROJ (1 << 1)
|
||||
#define SHADER_DOLPHIN_DIRTY_VIEW (1 << 2)
|
||||
|
||||
@@ -8,6 +8,5 @@
|
||||
#include "display/shader/shaderunlit.h"
|
||||
|
||||
shaderdefinition_t SHADER_UNLIT_DEFINITION = {
|
||||
.platform = { 0 },
|
||||
.upload = shaderUnlitUpload
|
||||
.setMaterial = shaderUnlitSetMaterial
|
||||
};
|
||||
Reference in New Issue
Block a user