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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T11:41:44+00:00 2026-05-18T11:41:44+00:00

I have a question about glDrawElements and vertex, normal and texcoordinate indices. If I

  • 0

I have a question about glDrawElements and vertex, normal and texcoordinate indices.

If I have geometric vertex, vertex normals and texture vertices, each with its own indices.

Which of those indices may I use?

If I have this code:

glVertexAttribPointer(vertexHandle, 3, GL_FLOAT, GL_FALSE, 0,
        (const GLvoid*) &teapotVertices[0]);
glVertexAttribPointer(normalHandle, 3, GL_FLOAT, GL_FALSE, 0,
        (const GLvoid*) &teapotNormals[0]);
glVertexAttribPointer(textureCoordHandle, 2, GL_FLOAT, GL_FALSE, 0,
        (const GLvoid*) &teapotTexCoords[0]);

glEnableVertexAttribArray(vertexHandle);
glEnableVertexAttribArray(normalHandle);
glEnableVertexAttribArray(textureCoordHandle);

glBindTexture(GL_TEXTURE_2D, thisTexture->mTextureID);
glUniformMatrix4fv(mvpMatrixHandle, 1, GL_FALSE,
        (GLfloat*)&modelViewProjection.data[0] );
glDrawElements(GL_TRIANGLES, NUM_TEAPOT_OBJECT_INDEX, GL_UNSIGNED_SHORT,
        (const GLvoid*) &teapotIndices[0]);

What should hold teapotIndices?

Thanks.

  • 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-18T11:41:45+00:00Added an answer on May 18, 2026 at 11:41 am

    I’m not sure I understand your question.

    TeapotIndices should be a collection of indices indicating the order in which you want your vertices to be rendered.

    For instance, let’s say you have an object made out of three vertices (a triangle):

    0.0, 0.0, 0.0 //index 0, lower left corner
    0.5, 0.5, 0.0 //index 1, top corner
    1.0, 0.0, 0.0 //index 2, lower right corner
    

    You specify in the indices collection/array the order in which you want them rendered. Say you want your triangle to be rendered counterclockwise, you’ll specify your indices as

    0,2,1
    

    glDrawElements will then draw the lower left corner first, then the lower right corner, and finally the top corner

    Of course this doesn’t make much sense when just one triangle is involved, but suppose you wanted to add another triangle that mirrors the first one downwards. This means they touch at the first triangle’s bottom. Instead of specifying three vertices for that one again, you only need to add the one that is different to your vertices:

    0.0, 0.0, 0.0 //index 0, lower left corner for first triangle
    0.5, 0.5, 0.0 //index 1, top corner for first triangle
    1.0, 0.0, 0.0 //index 2, lower right corner for first triangle
    0.5, -0.5, 0.0 //new: index 3, bottom corner of a "mirrored" triangle
    

    And you would have your indices like this:

    0,2,1, 2,0,3
    //     ^^^^^ second triangle vertex indices
    

    See, we’ve added a whole second triangle with only one new vertex, and re-used two of the old vertices for the new triangle.

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

Sidebar

Related Questions

I have question about pointers in C. Each pointer has 4 bytes in memory
I have question about parsing in Html helper : I have sth like: @foreach
I have question about clean thory in Python. When: @decorator_func def func(bla, alba): pass
I have question about XSLT1.0. The task is to write out in HTML all
I have question about normalization. Suppose I have an applications dealing with songs. First
I have question about interpreting strings as packed binary data in C++. In python,
i have question about YAJLiOS parser... I have next json data : {{ body
I have a question about this formula from a book: EFW (cm,kg)= 10^(-1,7492+(0,166*BPD)+(0,046*AC)-(2,646*AC*BPD/1000)) The
I have a question about how GC works in Java. Consider the following code:
I have a question about SqlDataReader: Is there some way to modificated the values

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.