Use older GLSL ver for compatibility with OpenGL 2.1

This commit is contained in:
Epicalert 2021-01-13 17:48:21 +08:00
parent e28e7bf111
commit b05a6bff8f
No known key found for this signature in database
GPG key ID: CAA46F858D0979BD

View file

@ -112,10 +112,10 @@ void initTexture (GLuint* texNum, const char* path) {
void initShader() {
const char* vsSrc =
"#version 150\n"
"in vec2 position;"
"in vec2 texcoord;"
"out vec2 uv;"
"#version 120\n"
"attribute vec2 position;"
"attribute vec2 texcoord;"
"varying vec2 uv;"
"uniform mat4 transMatrix;"
"void main () {"
"gl_Position = transMatrix * vec4(position, 0.0, 1.0);"
@ -123,12 +123,11 @@ void initShader() {
"}";
const char* fsSrc =
"#version 150\n"
"in vec2 uv;"
"out vec4 color;"
"#version 120\n"
"varying vec2 uv;"
"uniform sampler2D tex;"
"void main () {"
"color = texture(tex, uv);"
"gl_FragColor = texture2D(tex, uv);"
"}";
//compile vert shader
@ -152,7 +151,7 @@ void initShader() {
shader = glCreateProgram();
glAttachShader(shader, vs);
glAttachShader(shader, fs);
glBindFragDataLocation(shader, 0, "color");
//glBindFragDataLocation(shader, 0, "color");
glLinkProgram(shader);
glUseProgram(shader);