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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:02:33+00:00 2026-05-25T23:02:33+00:00

This might be a noob question. As I understand it, glBindAttribLocation(…, AAA, …) will

  • 0

This might be a noob question. As I understand it, glBindAttribLocation(…, AAA, …) will bind an attribute within the program to the location ID of AAA, as long as AAA is unique. If I have the following code:

glBindAttribLocation(..., 0, "XXX");
glBindAttribLocation(..., 1, "YYY");

This will bind my two variables to location ID 0 and 1. I would then call:

glBindBuffer(GL_ARRAY_BUFFER, VBId);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, IBId);

glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(float) * 6, 0);
glEnableVertexAttribArray(0);
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, sizeof(float) * 6, (void *) 0 + sizeof(float) * 3);
glEnableVertexAttribArray(1);

glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0);

Up to this point, I understand that the IDs of 0 and 1 are passed into glVertexAttribPointer() as the first parameter.

Would it be safe to assume that if I obtained the location IDs of the attributes (as above) through glGetAttribLocation() calls, such that the IDs returned were 5 and 6 instead of 0 and 1, could I pass 5 and 6 into glVertexAttribPointer() and glEnableVertexAttribArray() instead of 0 and 1??

  • 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-25T23:02:33+00:00Added an answer on May 25, 2026 at 11:02 pm

    glGetAttribLocation() returns the correct index. So yes, it is safe to use those values in glVertexAttribPointer() and glEnableVertexAttribArray().

    But calling glGetAttribLocation for each shader might be expensive if you don’t cache it. Using glBindAttribLocation() allows to use a convention, position always in 0, normal in 1 and so on.

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

Sidebar

Related Questions

Sorry, this might be a basic/stupid/noob question - I am just trying to tweak
This might be a naive question. However, I am just trying to understand why
I might be mixing apples and oranges in this question since I'm noob in
This might be a noob question. but I'm really torned between adding documents to
This might be a noob question, but can't find an answer anywhere. I have
This might sound like a noob question but this is the first time I'm
This might be a noob question but i've been fiddling with it for hours
Hi there this might me a very noob question but I'm stuck, and I'm
This might be a noob question, but I'm wondering if there's a way to
I'm pretty new to php so this might be a noob question. I'm using

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.