I try to draw colorized triangle. I want to use modern OpenGL and translate data via vertex attrib array.
Vertex shader and Fragment shader just pass color from input to output and don't contain any interesting code
pg.init()
triangle = np.array( triangle, dtype=np.float32 )
triangle_buffer = glGenBuffers( 1 )
glBindBuffer( GL_ARRAY_BUFFER, triangle_buffer )
glBufferData( GL_ARRAY_BUFFER, triangle.nbytes, triangle, GL_STATIC_DRAW )
vertex_shader = compileShader( vertex_src, GL_VERTEX_SHADER )
fragment_shader = compileShader( fragment_src, GL_FRAGMENT_SHADER )
shader_program = compileProgram( vertex_shader, fragment_shader )
glUseProgram( shader_program )
glEnableVertexAttribArray( 0 )
glVertexAttribPointer( 0, 3, GL_FLOAT, GL_FALSE, triangle.itemsize * 6, ctypes.c_void_p( 0 ) )
when I try to run this program an exception throws.
OpenGL.error.Error: Attempt to retrieve context when no valid context
Process finished with exit code 1
what I'm doing wrong?
It's need to swich Wayland
to Xorg
at login time! On Wayland you can add env variable PYOPENGL_PLATFORM=x11
.