Note that there are some explanatory texts on larger screens.

plurals
  1. POOpenGL VBO, VAO, Cubes, and Colors
    text
    copied!<p>I'm currently trying to get my head around VBOs and I'm running into some problems.</p> <p>I'm using an interleaved array with position, colors, and normals. However, when I go to draw, the display is just white.</p> <p>This is the structure of my array:</p> <pre><code>GLfloat position[3]; GLfloat normal[3]; GLfloat color[4]; </code></pre> <p>Here's the code:</p> <p><strong>Initialization:</strong></p> <pre><code>glGenBuffers(1, &amp;arrays[0]); glBindBuffer(GL_ARRAY_BUFFER, arrays[0]); glBufferData(GL_ARRAY_BUFFER, 125*10*36*sizeof(GLfloat), vertices, GL_STATIC_DRAW); glBindBuffer(GL_ARRAY_BUFFER, 0); glGenVertexArrays(1, &amp;vaoID[1]); glBindVertexArray(vaoID[1]); glBindBuffer(GL_ARRAY_BUFFER, vaoID[1]); glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 40, ((void*)0)); glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 40, ((void*)12)); glVertexAttribPointer(2, 4, GL_UNSIGNED_BYTE, GL_TRUE, 40, ((void*)24)); glEnableVertexAttribArray(0); glEnableVertexAttribArray(1); glEnableVertexAttribArray(2); glBindVertexArray(0); glDisableVertexAttribArray(0); glDisableVertexAttribArray(1); glDisableVertexAttribArray(2); glBindBuffer(GL_ARRAY_BUFFER, 0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); </code></pre> <p><strong>Draw:</strong></p> <pre><code>glPushMatrix(); glBindVertexArray(vaoID[1]); glDrawArrays(GL_TRIANGLE_STRIP, 0, 125*36); glPopMatrix(); </code></pre> <p>I'm making a 5x5 cube of cubes that spectrum in color from black to white. However, on draw, this is all I'm getting:</p> <p><img src="https://i.stack.imgur.com/eOoVX.png" alt="White Cube."></p>
 

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