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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T06:51:42+00:00 2026-06-15T06:51:42+00:00

I am using GL Kit to draw a cube which rotates on the screen.

  • 0

I am using GL Kit to draw a cube which rotates on the screen. I have this working very well with the same texture drawn on each face. I would like to draw a different texture on each face.

This is currently how my code draws the cube (note that I actually have 6 different textures loaded in the theTextures array, but so far I only draw all the sides of the cube the same when I change textures).

self.effect.texture2d0.name = theTextures[i].name;
self.effect.texture2d0.enabled = true;
self.effect.texture2d0.target = GLKTextureTarget2D;

glBindBuffer(GL_ARRAY_BUFFER, _vertexBuffer);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _indexBuffer);

glBindVertexArrayOES(_vertexArray); 

glDrawElements(GL_TRIANGLES, sizeof(Indices)/sizeof(Indices[0]), GL_UNSIGNED_BYTE, 0);

I have done a lot of searches here on stackOverflow and looked at many tutorials, but can’t find a simple way to do this. I assume that I can create a vertex array for each of the sides and use glDrawElements for each vertex array, but that seems very inefficient. Is there a way for me to do this without having to create 6 different vertex arrays? 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-06-15T06:51:44+00:00Added an answer on June 15, 2026 at 6:51 am

    I found away to do this in a somewhat efficient way, although I still draw each side separately. I create a different vertex array & texture for each side, but use only one Indice array with the vertices described in two triangles. If you have any suggestions, please send them my way,

    // draw one texture per side
    
    for (int i = 0; i <= 5; i++)
    {
        glBindBuffer(GL_ARRAY_BUFFER, _vertexBuffer[i]);
        glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _indexBuffer);
    
        glEnableVertexAttribArray(GLKVertexAttribPosition);
        glVertexAttribPointer(GLKVertexAttribPosition, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (const GLvoid *) offsetof(Vertex, Position));
        glEnableVertexAttribArray(GLKVertexAttribColor);
        glVertexAttribPointer(GLKVertexAttribColor, 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), (const GLvoid *) offsetof(Vertex, Color));
        glEnableVertexAttribArray(GLKVertexAttribTexCoord0);
        glVertexAttribPointer(GLKVertexAttribTexCoord0, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), (const GLvoid *) offsetof(Vertex, TexCoord));
    
        glActiveTexture(GL_TEXTURE0);
        glBindTexture(GL_TEXTURE_2D, myTexture[i].name);
    
        glDrawElements(GL_TRIANGLES, sizeof(Indices1)/sizeof(Indices1[0]), GL_UNSIGNED_BYTE, 0);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Game Center matchmaker working and implemented, and by using Game Kit's
I am using Parse Kit and I have question with grammar. This my grammar
I have installed some Emacs packages such as the starter-kit using M-x package-install .
Using the Microsoft Driver Development Kit (DDK), this error plagued me as I attempted
I installed clojure-mode and slime using the emacs starter kit and I get this
I have been using Google Chrome's dev tool kit (element inspection, stack trace, javascript
This is my first time using Store Kit and everything has gone great up
I have my site up and running just fine using the kit. My question
I am working with some controls that are written using microsoft ajax tool kit.
I am using Tab control of ajax tool kit and it is working fine

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.