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

  • Home
  • SEARCH
  • 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 8471373
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T16:46:44+00:00 2026-06-10T16:46:44+00:00

See edit below which significantly changes the question. ORIGINAL: I’m having a problem rendering

  • 0

See edit below which significantly changes the question.

ORIGINAL:

I’m having a problem rendering elements using OpenGL ES 2.0 on iOS 4 using Xcode 4.1.

Things display just fine without any issues using glDrawElements:

glDrawElements(GL_TRIANGLES, indicesSizeAll/sizeof(IndicesAll[0]), GL_UNSIGNED_SHORT, 0);

but if I use an equivalent glDrawRangeElements I get various problems:

glDrawRangeElements(GL_TRIANGLES, 0, (indicesSizeAll/sizeof(IndicesAll[0]))-1, indicesSizeAll/sizeof(IndicesAll[0]), GL_UNSIGNED_SHORT, 0);

I get the following build warning:

Semantic Issue: Implicit declaration of function 'glDrawRangeElements' is invalid in C99

and the following error during execution:

Program received signal: "EXC_BAD_ACCESS"

I included this function prototype:

extern void glDrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid * indices);

which got rid of the build warning but I still have the execution error.

Not really sure what to do about solving this problem. I’m taking things one step at a time and got things to display, but moving forward I believe I’m going to need to use glDrawRangeElements so I’m trying to get that working. Anyone have some guidance for me?

EDIT:

Its been brought to my attention that:

DrawRangeElements doesn’t exist in OpenGL ES 1.1 or 2.0, which is why it isn’t in the system headers. You should call glDrawElements instead.

That puts me back in the situation I was before when I thought glDrawRangeElements would solve my problems.

That means I need to use multiple buffers to render everything since I want to apply a different rotation to each buffer.

[modelView rotateBy:CC3VectorMake(x, y, z)];
glUniformMatrix4fv(_modelViewUniform, 1, 0, modelView.glMatrix);

I set up two different buffers:

glGenBuffers(1, &vertexBufferA);
glBindBuffer(GL_ARRAY_BUFFER, vertexBufferA);
glBufferData(GL_ARRAY_BUFFER, verticesSizeA, VerticesA, GL_STATIC_DRAW);

glGenBuffers(1, &indexBufferA);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBufferA);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, indicesSizeA, IndicesA, GL_STATIC_DRAW);
--------------------
glGenBuffers(1, &vertexBufferZ);
glBindBuffer(GL_ARRAY_BUFFER, vertexBufferZ);
glBufferData(GL_ARRAY_BUFFER, verticesSizeZ, VerticesZ, GL_STATIC_DRAW);

glGenBuffers(1, &indexBufferZ);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBufferZ);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, indicesSizeZ, IndicesZ, GL_STATIC_DRAW);

Then when I want to render those elements:

glBindBuffer(GL_ARRAY_BUFFER, vertexBufferA);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBufferA);

glDrawElements(GL_TRIANGLES, indicesSizeA/sizeof(IndicesA[0]), GL_UNSIGNED_SHORT, 0);
--------------------
glBindBuffer(GL_ARRAY_BUFFER, vertexBufferZ);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBufferZ);

glDrawElements(GL_TRIANGLES, indicesSizeZ/sizeof(IndicesZ[0]), GL_UNSIGNED_SHORT, 0);

A single call to glDrawElements will render just fine, but if I call it for each buffer only the second call does any rendering.

Not exactly sure what I am missing here. I’m new to the whole OpenGL thing and learning as I go.

Appreciate any pointers or clarification.

  • 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-10T16:46:45+00:00Added an answer on June 10, 2026 at 4:46 pm

    I’ve figured out the answer to my own question. As it turns out, I can save all of my data in a single buffer and specify the desired range for each render.


    Set up vertex and index buffers: single set of buffers to contain data for two graphics (A and Z)

    glGenBuffers(1, &vertexBufferAll);
    glBindBuffer(GL_ARRAY_BUFFER, vertexBufferAll);
    glBufferData(GL_ARRAY_BUFFER, verticesSizeAll, VerticesAll, GL_STATIC_DRAW);
    
    glGenBuffers(1, &indexBufferAll);
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBufferAll);
    glBufferData(GL_ELEMENT_ARRAY_BUFFER, indicesSizeAll, IndicesAll, GL_STATIC_DRAW);
    

    Define offsets for data in the vertex array:

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

    Draw elements located at specified offset in the index array:

    glDrawElements(GL_TRIANGLES, indicesCountA, GL_UNSIGNED_SHORT, (GLvoid*) (sizeof(GLushort) * 0));
    glDrawElements(GL_TRIANGLES, indicesCountZ, GL_UNSIGNED_SHORT, (GLvoid*) (sizeof(GLushort) * indicesCountA));
    

    Apply the appropriate matrix before each glDrawElements to achieve the desired rotation:

    glUniformMatrix4fv(_modelViewUniform, 1, 0, modelView.glMatrix);
    

    Now that I have things working, it sure seems pretty simple and kind of obvious, but I had to go through a lot of variations until I stumbled upon the proper setup. Feels like with OpenGL, if things aren’t 100% correct they are incorrect.

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

Sidebar

Related Questions

See Edit below initial question for a revised version of the original problem Using
In my application I have an edit profile page which you can see below;
This question was initially misphrased, see the EDIT below. I'll leave it up for
[EDIT: Problem solved. Please see my answer below.] In my app I call the
EDIT: This problem has been solved. See below. Hey all. I'm building an iPhone
[Edit: see final code below] I'm using the code below to randomly select 5
PLEASE SEE THE EDIT BELOW, THE REPORT SEEMS TO USE CACHED DATA? I cant
EDIT: See my answer below--> I am wanting to have a view that when
I have a Controller with two Edit methods (see below). When I submit the
Intro: EDIT: See solution at the bottom of this question (c++) I have a

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.