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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:51:08+00:00 2026-05-29T11:51:08+00:00

I had a quick question on openGL ES 2.0 I am trying to create

  • 0

I had a quick question on openGL ES 2.0 I am trying to create some drawings on the screen which will require multiple geometries. This is how I am creating the geometries.

(void)setupBoxGeometry{

   GLuint vertexBuffer;
   glGenBuffers(1, &vertexBuffer);
   glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer);
   glBufferData(GL_ARRAY_BUFFER, sizeof(BoxVertices), BoxVertices, GL_STATIC_DRAW);

   GLuint indexBuffer;
   glGenBuffers(1, &indexBuffer);
   glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuffer);
   glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(BoxIndices), BoxIndices, GL_STATIC_DRAW);
}

- (void)setupLineGeometry{

   GLuint vertexBuffer;
   glGenBuffers(1, &vertexBuffer);
   glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer);
   glBufferData(GL_ARRAY_BUFFER, sizeof(LineVertices), LineVertices, GL_STATIC_DRAW);

   GLuint indexBuffer;
   glGenBuffers(1, &indexBuffer);
   glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuffer);
   glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(LineIndices), LineIndices, GL_STATIC_DRAW);
}

This is my render function

- (void)render:(CADisplayLink*)displayLink {
   glClearColor(0.0/255.0, 0.0/255.0, 0.0/255.0, 1.0);
   glClear(GL_COLOR_BUFFER_BIT);

   float h = 4.0f * self.frame.size.height / self.frame.size.width;
   glViewport(0, 0, self.frame.size.width, self.frame.size.height);

   glVertexAttribPointer(_positionSlot, 3, GL_FLOAT, GL_FALSE, 
                      sizeof(Vertex), 0);
   glVertexAttribPointer(_colorSlot, 4, GL_FLOAT, GL_FALSE, 
                      sizeof(Vertex), (GLvoid*) (sizeof(float) * 3));


   // Do some thing to the projection    
   CC3GLMatrix *projection = [CC3GLMatrix matrix];    
   [projection populateFromFrustumLeft:-2 andRight:2 andBottom:-h/2 andTop:h/2 andNear:4 andFar:10];
   glUniformMatrix4fv(_projectionUniform, 1, 0, projection.glMatrix);


   // Create the base for the square to be drawn on the screen    
   _baseMatrix = [CC3GLMatrix matrix];


   [_baseMatrix populateFromTranslation:CC3VectorMake(-3.0, -5.2 + _yIncrease, -10)];    
   [_baseMatrix scaleByX:0.5];
   [_baseMatrix scaleByY:_yIncrease];
   [_baseMatrix rotateBy:CC3VectorMake(0, _rotationAngle, 0)];
   glUniformMatrix4fv(_modelViewUniform, 1, 0, _baseMatrix.glMatrix);
   glDrawElements(GL_TRIANGLES, sizeof(BoxIndices)/sizeof(BoxIndices[0]), 
               GL_UNSIGNED_BYTE, 0);
}

I call the box geometry function before I call the line geometry function. The problem is now my render function only draws lines. It does not draw any boxes. What am I doing wrong. If the question is not clear I can give more clarifications/

  • 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-29T11:51:10+00:00Added an answer on May 29, 2026 at 11:51 am

    Where are you binding buffers before drawing?
    Call

    glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer);
    

    before

    glVertexAttribPointer(...);
    

    And call

    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuffer);
    

    before

    glDrawElements(...);
    

    Also you need to enable vertex pointers you are using:

    glEnableVertexAttribArray(_positionSlot);
    glEnableVertexAttribArray(_colorSlot);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to Ruby and had a quick question. I am trying to
I had a quick question. I am trying to get an user-authentication form to
Just a quick question. I have a system which contains some silverlight elements to
I had this question during an exam, and I couldn't find a quick answer.
I had a quick log4net question. How can I specify which appender to use
I had a quick question. Is it possible to save a file without actually
I had a quick question about Django URL configuration, and I guess REGEX as
I just had a quick question about git - how backwards compatible are git
I am not familiar with PHP at all and had a quick question. I
just a quick question: I am a CS undergrad and have only had experience

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.