diff options
author | pommicket <pommicket@gmail.com> | 2022-11-03 20:22:03 -0400 |
---|---|---|
committer | pommicket <pommicket@gmail.com> | 2022-11-03 20:22:03 -0400 |
commit | e894fe92cdc669ae05d15da2a66bc8db5af8bfdf (patch) | |
tree | f66e98e3189e3c18730a6d964d96088ed36db282 /gl.c | |
parent | e263805bf5e6f4a13f82287803ad3c44e1c1cc5e (diff) |
[1.3] allow newer glsl versions w IN,OUT macros, msi version
Diffstat (limited to 'gl.c')
-rw-r--r-- | gl.c | 18 |
1 files changed, 12 insertions, 6 deletions
@@ -133,16 +133,22 @@ static GLuint glsl_version(void) { switch (v) { case 200: return 110; case 210: return 120; + case 300: return 130; + case 310: return 140; + case 320: return 150; } - // don't go above 130. i don't want to write two different shaders one using varying and one using whatever new stuff GLSL has these days - return 130; + return v; } // compile a GLSL shader static GLuint gl_compile_shader(char error_buf[256], char const *code, GLenum shader_type) { GLuint shader = glCreateShader(shader_type); - char header[32]; - strbuf_printf(header, "#version %u\n#line 1\n", glsl_version()); + char header[128]; + int glsl = glsl_version(); + strbuf_printf(header, "#version %u\n\ +#define IN %s\n\ +#define OUT %s\n\ +#line 1\n", glsl, glsl >= 130 ? "in" : "varying", glsl >= 130 ? "out" : "varying"); const char *sources[2] = { header, code @@ -240,13 +246,13 @@ static GLuint gl_geometry_vbo, gl_geometry_vao; static void gl_geometry_init(void) { char const *vshader_code = "attribute vec2 v_pos;\n\ attribute vec4 v_color;\n\ - varying vec4 color;\n\ + OUT vec4 color;\n\ void main() {\n\ gl_Position = vec4(v_pos, 0.0, 1.0);\n\ color = v_color;\n\ }\n\ "; - char const *fshader_code = "varying vec4 color;\n\ + char const *fshader_code = "IN vec4 color;\n\ void main() {\n\ gl_FragColor = color;\n\ }\n\ |