Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4580838
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T20:50:22+00:00 2026-05-21T20:50:22+00:00

I thought that this was impossible but I’m seeing it with my software. I

  • 0

I thought that this was impossible but I’m seeing it with my software. I have built a wrapper object to manage my buffer objects (I am working with shared contexts so I can’t use VAOs), and the VBO side of things was working fine until I starting testing it with IBOs (glDrawElements(), I’m using a pure OpenGL 3+ environment).

Here is the code for adding a buffer to my object (Sy_GLObject):

QList< uint > Sy_GLObject::addBuffers( uint numBuffers, GLenum target,
                                       GLenum numericType, GLenum usage )
{
    uint* adds = new uint[numBuffers];
    glGenBuffers( numBuffers, adds );

    QList< uint > l;
    for ( uint i = 0; i < numBuffers; ++i ) {
            Buffer buffer( target, adds[i], 0, numericType, usage );
            buffers_ << buffer;

            l << i;
    }
    delete[] adds;

    Sy_GL::checkError();
    return l;
}

And the buffer names returned by this function are fine, until it is called by this code:

void Sy_BVH::initialiseGLObject()
{
    Sy_application::getMainWindow()->getActiveProject(
                                        )->getModelContext()->makeCurrent();

    GLuint vLoc = Sy_settings::get( "shader/flat/vertexLoc" ).toUInt();
    drawBBs_ = Sy_GLObject::createObject();

    //  Add vertex array.
    drawBBs_->addBuffers( 1 );
    drawBBs_->buffers()[0].setVertexPointer( vLoc );

    //  Add indices array.
    drawBBs_->addBuffers( 1, GL_ELEMENT_ARRAY_BUFFER, GL_UNSIGNED_INT );
}

For some reason the indices array and vertex array names are both the same! setVertexPointer() does not actually call glVertexAttribPointer(), it just stores the parameters for it in a POD class – so no OpenGL calls are made between the two addBuffers() commands. The vertex call is ‘correct’ as it is one higher than the previous glGenBuffers() result, but from addBuffers() point of view there should be no difference between the calls.

Are there circumstances where glGenBuffers can possibly return the name of a buffer already in use!?

Thanks!

Update
To make sure threading was not a factor, I wrapped a static mutex around the glGenBuffers() block.

QMutexLocker locker( &mutex_ ); // mutex_ is a QMutex static class member.
uint* adds = new uint[numBuffers];
glGenBuffers( numBuffers, adds );
locker.unlock();

But it had absolutely no effect…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T20:50:23+00:00Added an answer on May 21, 2026 at 8:50 pm

    Thanks to Ilian Dinev over at the OpenGL.org forums for pointing out this stupid error. I created my Buffer object on the stack and conveniently had it’s destructor call glDeleteBuffers(). Fantastic bit of design.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would have thought that this would be an easy thing to do, but
I thought I heard that py2exe was able to do this, but I never
This may be impossible, but I thought I'd ask before I rework the whole
The comment to this answer got me wondering. I've always thought that C was
This is something that made me doubt for a while so I thought it
This is a question that's been nagging me for some time. I always thought
Here's what I got so far (that doesn't work). At this point I thought
I have always thought that the .equals() method in java should be overridden to
I read this question and thought that would easily be solved (not that it
Let say that I have many Javascript inside pages. At this moment is pretty

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.