rename font shader to generic sprite shader

Thu, 21 Mar 2024 20:48:18 +0100

author
Mike Becker <universe@uap-core.de>
date
Thu, 21 Mar 2024 20:48:18 +0100
changeset 40
6c438be1a1fd
parent 39
7cf310cc47cb
child 41
df81d493716e

rename font shader to generic sprite shader

shader/font_frag.glsl file | annotate | diff | comparison | revisions
shader/font_vtx.glsl file | annotate | diff | comparison | revisions
shader/sprite_frag.glsl file | annotate | diff | comparison | revisions
shader/sprite_vtx.glsl file | annotate | diff | comparison | revisions
src/ascension/shader.h file | annotate | diff | comparison | revisions
src/scene.c file | annotate | diff | comparison | revisions
src/shader.c file | annotate | diff | comparison | revisions
src/text.c file | annotate | diff | comparison | revisions
--- a/shader/font_frag.glsl	Thu Mar 21 20:34:33 2024 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,10 +0,0 @@
-#version 400 core
-
-layout(location = 0) out vec4 diffuse;
-in vec2 texcoord;
-
-uniform sampler2DRect surface;
-
-void main(void) {
-    diffuse = texture(surface, texcoord);
-}
--- a/shader/font_vtx.glsl	Thu Mar 21 20:34:33 2024 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,12 +0,0 @@
-#version 400 core
-
-layout(location = 0) in vec2 position;
-out vec2 texcoord;
-
-uniform mat4 projection;
-uniform mat4 model;
-
-void main(void) {
-    gl_Position = projection*model*vec4(position, 0.0, 1.0);
-    texcoord = vec2(model[0].x, model[1].y)*position;
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/shader/sprite_frag.glsl	Thu Mar 21 20:48:18 2024 +0100
@@ -0,0 +1,10 @@
+#version 400 core
+
+layout(location = 0) out vec4 diffuse;
+in vec2 texcoord;
+
+uniform sampler2DRect surface;
+
+void main(void) {
+    diffuse = texture(surface, texcoord);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/shader/sprite_vtx.glsl	Thu Mar 21 20:48:18 2024 +0100
@@ -0,0 +1,12 @@
+#version 400 core
+
+layout(location = 0) in vec2 position;
+out vec2 texcoord;
+
+uniform mat4 projection;
+uniform mat4 model;
+
+void main(void) {
+    gl_Position = projection*model*vec4(position, 0.0, 1.0);
+    texcoord = vec2(model[0].x, model[1].y)*position;
+}
--- a/src/ascension/shader.h	Thu Mar 21 20:34:33 2024 +0100
+++ b/src/ascension/shader.h	Thu Mar 21 20:48:18 2024 +0100
@@ -39,13 +39,13 @@
     int projection;
 } AscShaderProgram;
 
-typedef struct AscShaderFont {
+typedef struct AscShaderSprite {
     AscShaderProgram base;
     int surface;
-} AscShaderFont;
+} AscShaderSprite;
 
 
-extern AscShaderFont ASC_SHADER_FONT;
+extern AscShaderSprite ASC_SHADER_SPRITE;
 
 
 /**
--- a/src/scene.c	Thu Mar 21 20:34:33 2024 +0100
+++ b/src/scene.c	Thu Mar 21 20:48:18 2024 +0100
@@ -160,8 +160,8 @@
         glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
         // TODO: see if we can really always ignore the view matrix
         // TODO: compute render order for alpha blending to work correctly
-        glUseProgram(ASC_SHADER_FONT.base.id);
-        glUniformMatrix4fv(ASC_SHADER_FONT.base.projection, 1,
+        glUseProgram(ASC_SHADER_SPRITE.base.id);
+        glUniformMatrix4fv(ASC_SHADER_SPRITE.base.projection, 1,
                            GL_FALSE, camera->projection);
         asc_scene_draw_render_group(scene->rg_fonts);
     }
--- a/src/shader.c	Thu Mar 21 20:34:33 2024 +0100
+++ b/src/shader.c	Thu Mar 21 20:48:18 2024 +0100
@@ -32,7 +32,7 @@
 #include <GL/glew.h>
 #include <string.h>
 
-AscShaderFont ASC_SHADER_FONT;
+AscShaderSprite ASC_SHADER_SPRITE;
 
 
 AscShader asc_shader_compile(unsigned int type,
@@ -137,10 +137,10 @@
 }
 
 void asc_shader_initialize_predefined(void) {
-    ASC_SHADER_FONT.base = asc_shader_compile_link_discard("shader/font_vtx.glsl", "shader/font_frag.glsl");
-    ASC_SHADER_FONT.surface = glGetUniformLocation(ASC_SHADER_FONT.base.id, "surface");
+    ASC_SHADER_SPRITE.base = asc_shader_compile_link_discard("shader/sprite_vtx.glsl", "shader/sprite_frag.glsl");
+    ASC_SHADER_SPRITE.surface = glGetUniformLocation(ASC_SHADER_SPRITE.base.id, "surface");
 }
 
 void asc_shader_destroy_predefined(void) {
-    asc_shader_program_destroy(ASC_SHADER_FONT.base);
+    asc_shader_program_destroy(ASC_SHADER_SPRITE.base);
 }
\ No newline at end of file
--- a/src/text.c	Thu Mar 21 20:34:33 2024 +0100
+++ b/src/text.c	Thu Mar 21 20:48:18 2024 +0100
@@ -38,13 +38,13 @@
     }
 
     // Upload model matrix
-    glUniformMatrix4fv(ASC_SHADER_FONT.base.model, 1,
+    glUniformMatrix4fv(ASC_SHADER_SPRITE.base.model, 1,
                        GL_FALSE, node->base.final_transform);
 
     // Upload surface
     glActiveTexture(GL_TEXTURE0);
     glBindTexture(GL_TEXTURE_RECTANGLE, node->tex_id);
-    glUniform1i(ASC_SHADER_FONT.surface, 0);
+    glUniform1i(ASC_SHADER_SPRITE.surface, 0);
 
     // Draw mesh
     asc_primitives_draw_plane();

mercurial