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

  • SEARCH
  • Home
  • 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 9105403
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T02:05:57+00:00 2026-06-17T02:05:57+00:00

I am writing a little graphics engine using OpenGL ( via OpenTK with C#

  • 0

I am writing a little graphics engine using OpenGL ( via OpenTK with C# ).

To define vertex attributes, I have a VertexDeclaration class with an array of VertexElement structures that are mapped to glEnableVertexAttribArray/glVertexAttribPointer calls.

Also, to support multiple vertex streams, I have a special structure holding a vertex buffer, vertex declaration, vertex offset and instance frequency (like the XNA’s VertexBufferBinding structure).

Currently, whenever a drawing call is invoked, I iterate over all the set vertex streams and
bind their vertex buffers, apply vertex declarations, disable unused vertex attributes and draw the primitives.

I would like to use VAOs to cache the glEnableVertexAttribArray calls into them,
and whenever a vertex stream is applied, bind the VAO and change its array buffer binding.

Is that a correct usage of VAOs?

  • 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-06-17T02:05:58+00:00Added an answer on June 17, 2026 at 2:05 am

    Is that a correct usage of VAOs?

    No1.

    glVertexAttribPointer uses the buffer object that was bound to GL_ARRAY_BUFFER at the moment the function was called. So you can’t do this:

    glVertexAttribPointer(...);
    glBindBuffer(GL_ARRAY_BUFFER, bufferObject);
    glDrawArrays(...);
    

    This will not use bufferObject; it will use whatever was bound to GL_ARRAY_BUFFER when glVertexAttribPointer was originally called.

    VAOs capture this state. So the VAO will, for each vertex attribute, store whatever buffer object was bound to GL_ARRAY_BUFFER when it was called. This allows you to do things like this:

    glBindVertexArray(VAO);
    glBindBuffer(GL_ARRAY_BUFFER, buffer1);
    glVertexAttribPointer(0, ...);
    glVertexAttribPointer(1, ...);
    glBindBuffer(GL_ARRAY_BUFFER, buffer2);
    glVertexAttribPointer(2, ...);
    

    Attributes 0 and 1 will come from buffer1, and attribute 2 will come from buffer2. VAO now captures all of that state. To render, you just do this:

    glBindVertexArray(VAO);
    glDraw*();
    

    In short, if you want to change where an attribute’s storage comes from in OpenGL, you must also change it’s format. Even if it’s the same format, you must call glVertexAttribPointer again.

    1: This discussion assumes you’re not using the new ARB_vertex_attrib_binding. Or, as it is otherwise known, “Exactly how Direct3D does vertex attribute binding.” If you happen to be using an implementation that offers this extension, you can effectively do what you’re talking about, because the attribute format is not tied with the buffer object’s storage. Also, the tortured logic of glVertexAttribPointer is gone.

    In general, the way we solve this in the OpenGL world is to put as many things as possible in the same buffer object. Failing that, just use one VAO for each object.

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

Sidebar

Related Questions

I am writing a little picture frame app for android that is using opengl
I'm writing a little app that displays some graphics and just now I'm trying
I am writing a little utill for me on ruby using qt. How to
I'm writing a tool in Java which does a little drawing on a Graphics
I'm writing a little chat app, and I have this event handler: void o_Typing(object
I'm writing opengl code in python using the library pyglet. When I draw to
I'm writing a little text mode application using curses on Linux. For keyboard input
I am writing a little gui application with Tkinter, which requires me to have
So I have been writing a lot of image processing code lately using only
BACKGROUND I'm writing a little game using Java, slick2d and other frameworks. Slick2d does

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.