I'm trying to move away from using glVertex() in my game code because it doesn't seem to work well with a large quantity of vertices. At the moment I'm trying to make code that uses Shaders, but when compiling with shaders.compileProgram, it gives me the error shown in the title, with no explanation as to what is wrong.
Code so far:
import OpenGL
from OpenGL.GL import *
from OpenGL.GL import shaders
from OpenGL.arrays import vbo
import math
import pygame
from pygame.locals import *
VERTEX_SHADER = shaders.compileShader("""
#version 120
void main() {
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
}
""", GL_VERTEX_SHADER)
FRAGMENT_SHADER = shaders.compileShader("""
#version 120
void main() {
gl_FragColor = vec4( 0, 1, 0, 1 );
}
""", GL_FRAGMENT_SHADER)
self.shader = shaders.compileProgram(VERTEX_SHADER,FRAGMENT_SHADER)
The full error message:
Traceback (most recent call last):
File "PyOpenGl shader test from scratch.py", line 24, in <module>
self.shader = shaders.compileProgram(VERTEX_SHADER,FRAGMENT_SHADER)
File "/home/[my name]/.local/lib/python2.7/site-packages/OpenGL /GL/shaders.py", line 196, in compileProgram
program.check_validate()
File "/home/[my name]/.local/lib/python2.7/site-packages/OpenGL/GL/shaders.py", line 108, in check_validate
glGetProgramInfoLog( self ),
RuntimeError: Validation failure (0):
Is there a line I need to add for it to tell me what is wrong?
glGetProgramInfoLog()
? Does anything change if you change the values in the fragment shader to(0.0, 1.0, 0.0, 1.0)
? I've sometimes had issues with implicit casts in glsl. \$\endgroup\$