Note that there are some explanatory texts on larger screens.

plurals
  1. POOpenGL 3.0: Access Violation exception caused by VBOs
    primarykey
    data
    text
    <p>I am updating a quite outdated OpenGL project. So I am trying to move from vertex arrays to VBOs, but I have an access violation exception that I cannot trace.</p> <p>So I am using a VBO and an IBO that I generate in my class constructor:</p> <pre><code>if (glewIsSupported("GL_VERSION_3_0")) { glGenBuffers(2, bufferIds); } </code></pre> <p>(glewInit() was already called)</p> <p>The various rendering objects are defined as:</p> <pre><code>struct RenderBufferVertexElement { NxVec3 position; NxVec3 normal; float texCoord[2]; }; // The rendering buffers RenderBufferVertexElement* mVertexRenderBuffer; NxU32* mIndexRenderBuffer; // Buffer Objects enum { VBO, IBO }; GLuint bufferIds[2]; </code></pre> <p>Then in my drawing function I do:</p> <pre><code>glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_NORMAL_ARRAY); // VBO glBindBuffer(GL_ARRAY_BUFFER, bufferIds[VBO]); glBufferData(GL_ARRAY_BUFFER, sizeof(mVertexRenderBuffer), mVertexRenderBuffer, GL_STREAM_DRAW); glVertexPointer(3, GL_FLOAT, sizeof(RenderBufferVertexElement), BUFFER_OFFSET(offsetof(RenderBufferVertexElement,position))); glNormalPointer(GL_FLOAT, sizeof(RenderBufferVertexElement), BUFFER_OFFSET( offsetof(RenderBufferVertexElement,normal) )); // IBO glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferIds[IBO]); glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(mIndexRenderBuffer), mIndexRenderBuffer, GL_STREAM_DRAW); textures.front()-&gt;setClientActive(); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glTexCoordPointer(2, GL_FLOAT, sizeof(RenderBufferVertexElement), BUFFER_OFFSET(offsetof(RenderBufferVertexElement,texCoord))); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, textures.front()-&gt;textureId); [...] glDrawElements(GL_TRIANGLES, numElements, GL_UNSIGNED_INT, BUFFER_OFFSET(0)); glDisableClientState(...); glDisable(GL_TEXTURE_2D); </code></pre> <p>Everything worked fine with old style calls to glVertexPointer... but now my program crashes with an access violation exception. Any idea where that might come from?</p> <p>Thanks</p>
    singulars
    1. This table or related slice is empty.
    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