I am rendering some scenery with Pyopengl. Everything works, but for every frame I need to pass all vertices to opengl, in a way:
for object in objects:
for face in object:
for vertex in face:
glBegin(GL_QUADS)
glVertex3f(vertex)
glEnd()
Is there a way how to avoid three loops for the static objects? I would like to pass the vertices only once and in next frame just call the references of objects that should render again (in the similar way like the textures).
Is that possible somehow?
Yes, this is absolutely possible. In fact, the whole API part you are using (glBegin/glEnd
) has been removed from OpenGL 3.2 Core Profile in 2009.
When using OpenGL 3.2+ core, you are forced to store all vertex information in a Vertex Buffer Object (VBO) on the GPU. This pre-loaded data is then used when a draw command is issued.