I have a question (well a few actually)
1) How do you render a cube in Python with Vertex Buffer Objects?
2) How could I relocate that cube several times
3) How would I go about not rendering certain faces on it? (I have an Octree to store the positions and I want to not render faces that touch eachother)
Thanks

- 55
- 4
- 13
1 Answers
1: I use this module to render cubes in OpenGL 3+
If you don't have a model view / projection matrix, just pass in 'numpy.identity(4)' which will leave the vertices centred around the origin. This also means that the camera will appear inside the cube so it may not be visible.
2: You don't 'relocate' objects, you change the model view / projection matrices and render the VBO's again.
The cube's vertices have no knowledge of where the reside in 3D space, they are relative to the origin. When you render it, you apply a matrix (projection * model view) which moves the cube's vertices.
3: There are a number of ways to do this:
A. Create a VAO / VBO per face and only render the faces you want.
B. Assign a vertex attribute to each vertex which corresponds to each face. Then, using a uniform value, pass in enough information for the vertex / fragment shader to know if they should render or not. You could implement this easily with a single integer, and use a single bit to represent each face.
I would use B, as you aren't changing VAO / VBO state often, just changing 6 values (1 for each face).

- 4,169
- 2
- 30
- 34
-
Your link provides a 404 page. – jakebird451 Mar 26 '13 at 02:03