gl: Relax GLSL requirement from 3.3 to 3.1 (#137)

* opengl: Bump to OpenGL 3.1 / GLSL 1.40
This commit is contained in:
Priit Laes 2022-08-31 06:01:20 +03:00 committed by GitHub
parent 20c2128b89
commit 8c060fa1c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 6 deletions

View File

@ -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);

View File

@ -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!");

View File

@ -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"