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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T00:31:20+00:00 2026-06-17T00:31:20+00:00

I am trying to understand how to specify texture coordinates for a GL_QUAD_STRIP. I

  • 0

I am trying to understand how to specify texture coordinates for a GL_QUAD_STRIP.

I have managed to get things working for one quad:

float vertices[] = { 0.0f, 0.0f, 1.0f,   +1.0f, 0.0f, 0.0f,  // bottom line
                     0.0f, 1.0f, 1.0f,   +1.0f, 1.0f, 0.0f}; // top line

unsigned int indices[] = {2, 0,  // x =  0
                          3, 1}; // x = +1

float textureCoordinates[] = { 1.0f, 0.0f, 
                               0.0f, 0.0f,
                               1.0f, 1.0f,
                               0.0f, 1.0f};
...

glBindBuffer(GL_ARRAY_BUFFER, 0); // unbinds any buffer object previously bound
glTexCoordPointer(2, GL_FLOAT, 0, textureCoordinates);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibufferid);
glDrawElements(GL_QUAD_STRIP, 4, GL_UNSIGNED_INT, BUFFER_OFFSET(0));

And here is how the result looks (white rectangle with image, rest is drawn on to help explain):
enter image description here

However I do not understand the logic behind the choice of textureCoordinates[] :-(.

The first texture coordinate is (1,0); I would assume that this corresponds to lower right corner?

Also I would assume that when OpenGL reads the first index: 2, it uses this to look up the vertex: (0,1,1): upper left corner. Next it reads the first texture coordinate: (1,0).
But as mentioned above I would assume this to be the lower right corner of the texture !?

However the texture is shown unrotated so this can not be the case!?

  • 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-17T00:31:21+00:00Added an answer on June 17, 2026 at 12:31 am

    Just like the vertices, the texture coordinates are also selected based on the indices used by glDrawElements(). So the first texture coordinate is not (1,0), but (1,1) because the first index is 2. Vertices and coordinates would be according to the following table, where i = index, v = vertex and t = texture coordinate. (I’ll only take the x and y coordinates into consideration for the vertices, as the z coordinate doesn’t really matter in this case.)

    i   v     t
    2 (0,1) (1,1)
    0 (0,0) (1,0)
    3 (1,1) (0,1)
    1 (1,0) (0,0)
    

    If we draw this on a piece of paper, we can see that this means the coordinates make more sense, since the indices matter. (I recommend that you do this! I had to do that to understand what was going on.) Notice in the table how the y coordinates match perfectly between the vertex and texture coordinate for a given index. But the x coordinates don’t match: when the vertex has x = 0, the texture coordinate has x = 1 and vice versa. I assume this would make the image appear mirrored around the y axis instead of rotated in any way. What does the original image look like? Is it mirrored compared to what we see in the image you posted so that the building is on the left? If so, the texture coordinates would be the explanation. In that case, texture coordinate 2 and 3 should switch places.

    In case you are curious, you could take a look at the OpenGL 2.1 specification on page 18, Figure 2.5(a), to see why the vertex indices were selected as they were. It would create a quad with vertices specified in a counterclockwise direction when projected on the screen. This is good because the initial value for glFrontFace() is GL_CCW, which means we see the front face of the polygons in the rendered image and the polygons would not have been culled if culling was enabled (see glCullFace()). (Culling is not enabled by default though, so it may or may not have mattered in your case.)

    I hope this helped. Do comment if something is unclear!

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

Sidebar

Related Questions

I have been trying to understand and get something working with dependency properties. I
I'm trying to get to grips with HLSL... I understand how you can specify
I am trying understand ViewModels deeper and I have read many articles and blogs
I'm trying to understand why I can't specify choices to a form field's widget
I am trying to understand the differences between the following 2 connectionstrings. one uses
I am new to Haskell and I am trying to understand why one needs
I'm trying to better understand why one of our database update scripts failed to
I am trying to understand the concept of texture mapping. I tried to map
I'm trying to understand how URL rewriting works. I have the following link. mysite.com/profile.php?id=23
I'm currently trying to understand some of the fundamentals with LINQ. I have been

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.