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 8122485
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T05:51:03+00:00 2026-06-06T05:51:03+00:00

This is some simple code that draws to the screen. GLuint vbo; glGenBuffers(1, &vbo);

  • 0

This is some simple code that draws to the screen.

GLuint vbo;

glGenBuffers(1, &vbo);

glUseProgram(myProgram);

glBindBuffer(GL_ARRAY_BUFFER, vbo);

glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, 0);

//Fill up my VBO with vertex data
glBufferData(GL_ARRAY_BUFFER, sizeof(vertexes), &vertexes, GL_STATIC_DRAW);

/*Draw to the screen*/

This works fine. However, I tried changing the order of some GL calls like so:

GLuint vbo;

glGenBuffers(1, &vbo);

glUseProgram(myProgram);

glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, 0);

//Now comes after the setting of the vertex attributes.
glBindBuffer(GL_ARRAY_BUFFER, vbo);

//Fill up my VBO with vertex data
glBufferData(GL_ARRAY_BUFFER, sizeof(vertexes), &vertexes, GL_STATIC_DRAW);

/*Draw to the screen*/

This crashes my program. Why does there need to be a VBO bound to GL_ARRAY_BUFFER while I’m just setting up vertex attributes? To me, what glVertexAttribPointer does is just set up the format of vertexes that OpenGL will eventually use to draw things. It is not specific to any VBO. Thus, if multiple VBOs wanted to use the same vertex format, you would not need to format the vertexes in the VBO again.

  • 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-06T05:51:04+00:00Added an answer on June 6, 2026 at 5:51 am

    Why does there need to be a VBO bound to GL_ARRAY_BUFFER while I’m just setting up vertex attributes?

    No, you’re not “just” setting up vertex attributes. You’re actually creating a reference with the currently bound buffer object.

    If there’s no buffer object bound, then gl…Pointer will create a reference to your process address space pointed at the given address. Since this is a null pointer in your case, any attempt to dereference a vertex will cause a segmentation fault/access violation.

    To me, what glVertexAttribPointer does is just set up the format of vertexes that OpenGL will eventually use to draw things.

    No. It also creates a reference to where to get the data from.

    It is not specific to any VBO.

    Yes it actually is specific to the bound VBO, or the process address space if no VBO is bound. And changing the buffer binding will not update along the gl…Pointer references.

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

Sidebar

Related Questions

Thanks to this site and a few others, I've created some simple code to
I'm having problems with some AS3 code that simply draws on a Sprite 's
I have some simple OpenGL ES code in C++ that I've run on a
I have to code a simple control in .Net that draws geometry that looks
I am working on a simple GUI app that just draws some graphics on
so I have some code that draws a path and a circle. the circle
Can someone write some sample code to explain this concept? I know what a
I am trying to use some sample code and my compiler won't compile this
I'm teaching myself Python and I was translating some sample code into this class
So in some of the apple sample code I see things like this for

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.