Skip to content

Commit

Permalink
Added the flat shader generation
Browse files Browse the repository at this point in the history
  • Loading branch information
tanis2000 committed Oct 11, 2024
1 parent e7d392d commit 9cef91f
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
36 changes: 36 additions & 0 deletions assets/shaders/src/flat.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#pragma sokol @vs vs

in vec3 vertexPosition;
in vec4 vertexColor;
in vec2 vertexTexture;

uniform vs_params {
mat4 projectionMatrix;
mat4 viewMatrix;
mat4 modelMatrix;
};

out vec4 color;

void main(void) {
gl_Position = projectionMatrix * viewMatrix * modelMatrix * vec4(vertexPosition, 1.0);
//gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
gl_PointSize = 1.0;
color = vertexColor;
}

#pragma sokol @end

#pragma sokol @fs fs

in vec4 color;
out vec4 fragColor;
void main(void)
{
fragColor = color;
//fragColor = vec4(1.0, 1.0, 1.0, 1.0);
}

#pragma sokol @end

#pragma sokol @program flat vs fs
6 changes: 6 additions & 0 deletions example/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,24 @@
#define DEFAULT_FS_FILENAME "default.glsl_default_metal_macos_fs.metal"
#define SCREEN_VS_FILENAME "screen.glsl_default_metal_macos_vs.metal"
#define SCREEN_FS_FILENAME "screen.glsl_default_metal_macos_fs.metal"
#define FLAT_VS_FILENAME "flat_flat_metal_macos_vs.metal"
#define FLAT_FS_FILENAME "flat_flat_metal_macos_fs.metal"
#elif defined(__IPHONEOS__) || defined(__ANDROID__) || defined(__EMSCRIPTEN__)
#define SHADER_PATH "dst/gles"
#define DEFAULT_VS_FILENAME "default.glsl_default_glsl300es_vs.glsl"
#define DEFAULT_FS_FILENAME "default.glsl_default_glsl300es_fs.glsl"
#define SCREEN_VS_FILENAME "screen.glsl_default_glsl300es_vs.glsl"
#define SCREEN_FS_FILENAME "screen.glsl_default_glsl300es_fs.glsl"
#define FLAT_VS_FILENAME "flat_flat_glsl300es_vs.glsl"
#define FLAT_FS_FILENAME "flat_flat_glsl300es_fs.glsl"
#else
#define SHADER_PATH "dst/gl33"
#define DEFAULT_VS_FILENAME "default.glsl_default_glsl410_vs.glsl"
#define DEFAULT_FS_FILENAME "default.glsl_default_glsl410_fs.glsl"
#define SCREEN_VS_FILENAME "screen.glsl_default_glsl410_vs.glsl"
#define SCREEN_FS_FILENAME "screen.glsl_default_glsl410_fs.glsl"
#define FLAT_VS_FILENAME "flat_flat_glsl410_vs.glsl"
#define FLAT_FS_FILENAME "flat_flat_glsl410_fs.glsl"
#endif

typedef struct default_shader_params_t {
Expand Down

0 comments on commit 9cef91f

Please sign in to comment.