Note that there are some explanatory texts on larger screens.

plurals
  1. POOpenGL first person camera rotation and translation
    primarykey
    data
    text
    <p>I'm trying to write a simple maze game, without using any deprecated OpenGL API (i.e. no immediate mode). I'm using one Vertex Buffer Object for each tile I have in my maze, which is essentially a combination of four <code>Vertex</code>s:</p> <pre><code>class Vertex { public: GLfloat x, y, z; // coords GLfloat tx, ty; // texture coords Vertex(); }; </code></pre> <p>and are stored in VBOs like this:</p> <pre><code>void initVBO() { Vertex vertices[4]; vertices[0].x = -0.5; vertices[0].y = -0.5; vertices[0].z = 0.0; vertices[0].tx = 0.0; vertices[0].ty = 1.0; vertices[1].x = -0.5; vertices[1].y = 0.5; vertices[1].z = 0.0; vertices[1].tx = 0.0; vertices[1].ty = 0.0; vertices[2].x = 0.5; vertices[2].y = 0.5; vertices[2].z = 0.0; vertices[2].tx = 1.0; vertices[2].ty = 0.0; vertices[3].x = 0.5; vertices[3].y = -0.5; vertices[3].z = 0.0; vertices[3].tx = 1.0; vertices[3].ty = 1.0; glGenBuffers(1, &amp;vbo); glBindBuffer(GL_ARRAY_BUFFER, vbo); glBufferData(GL_ARRAY_BUFFER, sizeof(Vertex)*4, &amp;vertices[0].x, GL_STATIC_DRAW); ushort indices[4]; indices[0] = 0; indices[1] = 1; indices[2] = 2; indices[3] = 3; glGenBuffers(1, &amp;ibo); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo); glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(ushort) * 4, indices, GL_STATIC_DRAW); } </code></pre> <p>Now, I'm stuck on the camera movement. In a previous version of my project, I used <code>glRotatef</code> and <code>glTranslatef</code> to translate and rotate the scene and then I rendered every tile using <code>glBegin()</code>/<code>glEnd()</code> mode. But these two functions are now deprecated, and I didn't find any tutorial about creating a camera in a context using only VBOs. Which is the correct way to proceed? Should I loop between every tile modifying the position of the vertices according to the new camera position?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload