Fixed knulli rendering
This commit is contained in:
@@ -68,7 +68,6 @@ errorret_t displayInit(void) {
|
||||
errorChain(shaderSetMatrix(&SHADER_UNLIT, SHADER_UNLIT_MODEL, mat));
|
||||
errorChain(shaderSetTexture(&SHADER_UNLIT, SHADER_UNLIT_TEXTURE, NULL));
|
||||
|
||||
|
||||
errorChain(meshInit(&mesh, MESH_PRIMITIVE_TYPE_TRIANGLES, 3, vertices));
|
||||
|
||||
errorOk();
|
||||
@@ -90,26 +89,7 @@ errorret_t displayUpdate(void) {
|
||||
SCREEN.background
|
||||
);
|
||||
|
||||
camera_t cam;
|
||||
cameraInitOrthographic(&cam);
|
||||
cam.orthographic.right = SCREEN.width;
|
||||
cam.orthographic.top = SCREEN.height;
|
||||
cam.orthographic.left = 0;
|
||||
cam.orthographic.bottom = 0;
|
||||
|
||||
mat4 mat;
|
||||
cameraGetProjectionMatrix(&cam, mat);
|
||||
errorChain(shaderBind(&SHADER_UNLIT));
|
||||
errorChain(shaderSetMatrix(&SHADER_UNLIT, SHADER_UNLIT_PROJECTION, mat));
|
||||
cameraGetViewMatrix(&cam, mat);
|
||||
errorChain(shaderSetMatrix(&SHADER_UNLIT, SHADER_UNLIT_VIEW, mat));
|
||||
glm_mat4_identity(mat);
|
||||
errorChain(shaderSetMatrix(&SHADER_UNLIT, SHADER_UNLIT_MODEL, mat));
|
||||
|
||||
textDraw(32, 32, "Hello World", COLOR_WHITE, &DEFAULT_FONT_TILESET, &DEFAULT_FONT_TEXTURE);
|
||||
spriteBatchFlush();
|
||||
|
||||
// errorChain(sceneRender());
|
||||
errorChain(sceneRender());
|
||||
|
||||
// Render UI
|
||||
// uiRender();
|
||||
|
||||
@@ -122,7 +122,7 @@
|
||||
// Uniforms
|
||||
"uniform sampler2D u_Texture;\n"
|
||||
"uniform int u_TextureType;\n"
|
||||
"uniform vec4 u_Colors[256];\n"// For paletted textures.
|
||||
"uniform uint u_Colors[256];\n"// For paletted textures.
|
||||
"uniform int u_ColorCount;\n"
|
||||
// Fragment shader inputs
|
||||
"in vec4 v_Color;\n"
|
||||
@@ -140,8 +140,13 @@
|
||||
" }\n"
|
||||
" if(u_TextureType == 2) {\n"// Paletted texture
|
||||
" vec4 texColor = texture(u_Texture, v_TexCoord);\n"
|
||||
" int index = int(floor(texColor.r * 255.0));\n"
|
||||
" vec4 paletteColor = u_Colors[index];\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"
|
||||
" return;\n"
|
||||
" }\n"
|
||||
|
||||
Reference in New Issue
Block a user