OpenGL renderer : conflict with glBindBuffer() & glBufferDat

For help with anything that CEGUI doesn't offer straight out-of-the-box, e.g.:
- Implementation of new features, such as new Core classes, widgets, WindowRenderers, etc. ...
- Modification of any existing features for specific purposes
- Integration of CEGUI in new engines or frameworks and writing of new plugins (Renderer, Parser, ...) or modules

Moderators: CEGUI MVP, CEGUI Team

User avatar
shat
Just popping in
Just popping in
Posts: 1
Joined: Fri Apr 01, 2005 22:37

OpenGL renderer : conflict with glBindBuffer() & glBufferDat

Postby shat » Fri Apr 01, 2005 23:02

Hello!

I have some (maybe serious, maybe not) problem. My program uses vertex and index buffers to draw a terrain. When I add the following lines to a program using CEGUI with OpenGL Renderer, the program flies away with a nice Access Violation exception.

Code: Select all

   int vertex_buffer_size = 128*128; // Size is irrelevant
   int index_buffer_size = 128*128;

   glGenBuffers(2, vertex_buffer);
   glGenBuffers(2, index_buffer);

   glBindBuffer(GL_ARRAY_BUFFER_ARB, vertex_buffer[0]);
   glBufferData(GL_ARRAY_BUFFER_ARB, vertex_buffer_size, 0, GL_STREAM_DRAW_ARB);
   glBindBuffer(GL_ARRAY_BUFFER_ARB, vertex_buffer[1]);
   glBufferData(GL_ARRAY_BUFFER_ARB, vertex_buffer_size, 0, GL_STREAM_DRAW_ARB);

   glBindBuffer(GL_ELEMENT_ARRAY_BUFFER_ARB, index_buffer[0]);
   glBufferData(GL_ELEMENT_ARRAY_BUFFER_ARB, index_buffer_size, 0, GL_STREAM_DRAW_ARB);
   glBindBuffer(GL_ELEMENT_ARRAY_BUFFER_ARB, index_buffer[1]);
   glBufferData(GL_ELEMENT_ARRAY_BUFFER_ARB, index_buffer_size, 0, GL_STREAM_DRAW_ARB);


The error occurs at the first execution of the OpenGLRenderer::renderVBuffer(), in the line

Code: Select all

      glDrawArrays(GL_TRIANGLES, 0, d_bufferPos);


I don't know what to do, because I don't understand the problem. What does the element array buffer do with the drawing of a totally different triangle array?

I'm using a GeForce 4 Ti4200, with the 61.77 ForceWare nVidia driver.

Thanks for the help!
shat

User avatar
rincewind
Just popping in
Just popping in
Posts: 14
Joined: Wed Jan 12, 2005 12:06

Re: OpenGL renderer : conflict with glBindBuffer() & glBuffe

Postby rincewind » Sat Apr 02, 2005 11:17

Hi,

you never "unbind" the buffers you use, so CEGUI's draw call tries to use the pointer supplied as an offset into your buffers (VBOs).

After you are done drawing with your buffers, reset GL to "normal" vertex/index array mode by doing:

Code: Select all

glBindBuffer(GL_ARRAY_BUFFER_ARB, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER_ARB, 0);


Hope this helps,

Rincewind


Return to “Modifications / Integrations / Customisations”

Who is online

Users browsing this forum: No registered users and 14 guests