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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T16:26:14+00:00 2026-06-13T16:26:14+00:00

I’m using/targetting OpenGL 4.20, GSLSL 4.20, core. Using C. I’m exploring graphics with OpenGL

  • 0

I’m using/targetting OpenGL 4.20, GSLSL 4.20, core. Using C.

I’m exploring graphics with OpenGL and have decided to make a tile based game. I’m at the point where i’d like to actually draw a bunch of tiles, and am trying to use glDrawElements to draw individual triangles.

Relevant code:

const float vertexPositions[] = {
  -1.0f, -0.8f, //0
  -0.8f, -0.8f, //1
  -0.6f, -0.8f, //2
  -0.4f, -0.8f, //3
  -0.2f, -0.8f, //4
   0.0f, -0.8f, //5

  -1.0f, -1.0f, //6
  -0.8f, -1.0f, //7
  -0.6f, -1.0f, //8
  -0.4f, -1.0f, //9
  -0.2f, -1.0f, //10
   0.0f, -1.0f, //11

//The following are the texture coordinates.
  0.00f, 1.00f,
  1.00f, 1.00f,
  0.00f, 1.00f,
  1.00f, 1.00f,
  0.00f, 1.00f,
  1.00f, 1.00f,

  0.00f, 0.00f,
  1.00f, 0.00f,
  0.00f, 0.00f,
  1.00f, 0.00f,
  0.00f, 0.00f,
  1.00f, 0.00f,
};

const GLubyte indices[] = {
  0, 1, 6, 
  1, 7, 6, 
  1, 2, 7, 
  2, 8, 7, 
  2, 3, 8, 
  3, 9, 8,
  3, 4, 9,
  4, 10, 9,
  4, 5, 10,
  5, 11, 10,
};

with

glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, 0);
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 0, (void *)96);

glDrawElements(GL_TRIANGLES, 30, GL_UNSIGNED_BYTE, indices);

(There are other pieces, but it’s mostly formatting/attribute enabling etc. I’ll provide more if needed).

Basically what i get is:

0  1  2  3  4  5
+--+--+--+--+--+
|b | d|b |d |b |
+--+--+--+--+--+
6  7  8  9 10 11

and what i want is:

0  1  2  3  4  5
+--+--+--+--+--+
|b |b |b |b |b |
+--+--+--+--+--+
6  7  8  9 10 11

Where “b” is the correct orientation of the texture/square and “d” is the reverse/reflected.

I realize that since the vertex coordinates are shared this is going to happen, but from my own thoughts/some posts below it seems like it is unavoidable. Either I conserve vertices and have reflected textures, or I end up sending 3*2*number_of_tiles vertices, which i feel defeats the purpose of glDrawElements.

Resources that haven’t helped:

These are things I’ve found that are related, but seem (to me) to be either deprecated usage/not answered/not quite what I’m asking. Feel free to point me back to one of these posts if it in fact does answer my question.

This seems to say that glDrawElements is useless for a cube, and that you must have individual vertices making up faces. Does this apply to a 2d grid as well?

The answer to this question says (among other things) “Two squares with the same vertex positions, but different texture coordinates must be represented with different quads.” but I don’t understand what he’s getting at.

This one I thought was close. In the answer: The first link is broken/access denied. The second link has an answer that basically says the vertices must be distinct. Is this required? In the third link (second code snippet) they seem to just generate all 36 vertices. For one cube this is probably ok, but for n cubes..? Am i missing the point of his example, maybe?

Is what I’m requesting even possible? Am I using completely incorrect functions for what I’m trying to achieve? “UR DOIN IT RONG”?

I’ve thought of re-arranging the coordinates so it looks like:

0  2  4  6  8 10
+--+--+--+--+--+
|  |  |  |  |  |
+--+--+--+--+--+
1  3  5  7  9 11

But I didn’t see how that would fix the issue, since vertices are still shared.

Thanks, and feel free to correct me/my question. First one, so I expect it to need revising.

  • 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-13T16:26:17+00:00Added an answer on June 13, 2026 at 4:26 pm

    The second link has an answer that basically says the vertices must be distinct. Is this required?

    Yes. You want each individual quad to have texture coordinates that go from 0 to 1. Which means that the positions that make up the right side of the first quad can’t use the same texture coordinates as the positions that make up the left side of the second quad.

    And since you cannot have the same position with two different texture coordinates, you must duplicate your positions.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a small JavaScript validation script that validates inputs based on Regex. I
I have thousands of HTML files to process using Groovy/Java and I need to
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is
I have a jquery bug and I've been looking for hours now, I can't

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.