0
I already studied Opengl, and now I was reading Modern Opengl, I was watching some videos on Youtube and some tutorials on the internet and I wrote this code:
import pyglet, numpy, ctypes
from OpenGL.GL import *
import OpenGL.GL.shaders as shader
a = pyglet.window.Window()
t = [-.5,-.5,0,.5,-.5,0,.5,.5,0]
t = numpy.array(t, dtype=numpy.float32)
v = """
void main(){
gl_Position = ftransform();
}
"""
f = """
void main(){
gl_FragColor = vec4(1,1,1,1);
}
"""
s = shader.compileProgram(shader.compileShader(v,GL_VERTEX_SHADER),shader.compileShader(f,GL_FRAGMENT_SHADER))
VBO = glGenBuffers(1)
glBindBuffer(GL_ARRAY_BUFFER, VBO)
glBufferData(GL_ARRAY_BUFFER, len(t), t, GL_STATIC_DRAW)
glUseProgram(s)
@a.event
def on_draw():
glClear(GL_COLOR_BUFFER_BIT)
glBindVertexArray(0)
glDrawArrays(GL_TRIANGLES, 0, 3)
def SRO(dt):
on_draw()
pyglet.clock.schedule_interval(SRO, 1/30)
pyglet.app.run()
A White triangle was supposed to appear, but the window just opens and there’s a black screen, I searched some codes, added a glVertexAttribPointer
did not work(or at least bugged the code enough) and a glBindVertexArray
which also didn’t make much difference. Someone there knows where I’m going wrong?