From 8c060fa1c728aab95147b6eb483ceccf580ff120 Mon Sep 17 00:00:00 2001 From: Priit Laes Date: Wed, 31 Aug 2022 06:01:20 +0300 Subject: [PATCH] gl: Relax GLSL requirement from 3.3 to 3.1 (#137) * opengl: Bump to OpenGL 3.1 / GLSL 1.40 --- src/harness/io_platforms/sdl_gl.c | 2 +- src/harness/renderers/gl/gl_renderer.c | 2 +- src/harness/renderers/gl/shaders.c | 12 ++++++++---- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/harness/io_platforms/sdl_gl.c b/src/harness/io_platforms/sdl_gl.c index f531ae7a..192ec931 100644 --- a/src/harness/io_platforms/sdl_gl.c +++ b/src/harness/io_platforms/sdl_gl.c @@ -153,7 +153,7 @@ tRenderer* Window_Create(char* title, int width, int height, int pRender_width, LOG_PANIC("Failed to set SDL_GL_CONTEXT_PROFILE_MASK attribute. %s", SDL_GetError()); }; SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); - SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1); SDL_GL_SetSwapInterval(1); diff --git a/src/harness/renderers/gl/gl_renderer.c b/src/harness/renderers/gl/gl_renderer.c index 641482ac..773a820d 100644 --- a/src/harness/renderers/gl/gl_renderer.c +++ b/src/harness/renderers/gl/gl_renderer.c @@ -225,7 +225,7 @@ void GLRenderer_Init(int width, int height, int pRender_width, int pRender_heigh glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT16, render_width, render_height, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, 0); - glFramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, depth_texture, 0); + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, depth_texture, 0); if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { LOG_PANIC("Framebuffer is not complete!"); diff --git a/src/harness/renderers/gl/shaders.c b/src/harness/renderers/gl/shaders.c index 148fe2ee..c0555c03 100644 --- a/src/harness/renderers/gl/shaders.c +++ b/src/harness/renderers/gl/shaders.c @@ -1,5 +1,6 @@ -const char* vs_2d = "#version 330 core\n" +const char* vs_2d = "#version 140\n" + "#extension GL_ARB_explicit_attrib_location : require\n" "layout (location = 0) in vec3 aPos;\n" "layout (location = 1) in vec3 aColor;\n" "layout (location = 2) in vec2 aTexCoord;\n" @@ -10,7 +11,8 @@ const char* vs_2d = "#version 330 core\n" " TexCoord = aTexCoord;\n" "}\0"; -const char* fs_2d = "#version 330 core\n" +const char* fs_2d = "#version 140\n" + "#extension GL_ARB_explicit_attrib_location : require\n" "in vec2 TexCoord;\n" "uniform usampler2D pixels;\n" "uniform sampler2D palette;\n" @@ -23,7 +25,8 @@ const char* fs_2d = "#version 330 core\n" " FragColor = texel;\n" "}\n\0"; -const char* vs_3d = "#version 330 core\n" +const char* vs_3d = "#version 140\n" + "#extension GL_ARB_explicit_attrib_location : require\n" "layout (location = 0) in vec3 aPos;\n" "layout (location = 1) in vec3 aNormal;\n" "layout (location = 2) in vec2 aUV;\n" @@ -43,7 +46,8 @@ const char* vs_3d = "#version 330 core\n" " gl_Position = projection * view * vec4(FragPos, 1.0);\n" "}\0"; -const char* fs_3d = "#version 330 core\n" +const char* fs_3d = "#version 140\n" + "#extension GL_ARB_explicit_attrib_location : require\n" "in vec3 Normal;\n" "in vec3 FragPos;\n" "in vec2 TexCoord;\n"