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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:34:13+00:00 2026-05-29T10:34:13+00:00

What I need to do is draw a vertex array that has more than

  • 0

What I need to do is draw a vertex array that has more than 256 elements. When I have less than that many, and I use GL_UNSIGNED_BYTE in my call to glDrawElements, everything works fine. When I have more than 256 elements, it starts drawing back at the first vertex again (i.e., last element [256 – 255, whatever] connects with first [1, or 0], and further elements don’t get drawn). If I use GL_UNSIGNED_SHORT instead, I get EXC_BAD_ACCESS. What gives?

int indexLim = self.animIndex;

GLushort glIndLim = (GLushort)indexLim;

Vertex localVertices[glIndLim];
GLubyte localIndices[glIndLim];

for(GLushort i=0; i < glIndLim; i++)
{
    x = (float)i;
    y = [[data objectAtIndex:i ] floatValue];

    x = x*xScale + xOffset;
    y = y*yScale + yOffset;

    localVertices[i].Position[0] = x;
    localVertices[i].Position[1] = y;
    localVertices[i].Position[2] = z;
    localVertices[i].Color[0]    = r;
    localVertices[i].Color[1]    = g;
    localVertices[i].Color[2]    = b;
    localVertices[i].Color[3]    = a;
    localIndices[i] = i;
}    

// setupVBOs
GLuint vertexBuffer;
glGenBuffers(1, &vertexBuffer);
glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer);
glBufferData(GL_ARRAY_BUFFER, sizeof(localVertices), localVertices, GL_STATIC_DRAW);

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

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


//glDrawElements(GL_LINE_STRIP, glIndLim, GL_UNSIGNED_BYTE, 0); // Works, but only draws 256 elements
glDrawElements(GL_LINE_STRIP, glIndLim, GL_UNSIGNED_SHORT, 0); // EXC_BAD_ACCESS!!!!
  • 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-29T10:34:14+00:00Added an answer on May 29, 2026 at 10:34 am

    Have you tried defining:

    GLubyte localIndices[glIndLim];
    

    as

    GLushort localIndices[glIndLim];
    

    ?

    The reasoning is that if that should represent the index for your vertex, it should admit all possible values for GLushort, otherwise the local index will always be a GLubyte.

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

Sidebar

Related Questions

Is there a way to draw many filled circles using one vertex array. Is
I am trying to draw some contours that I have stored as vertex arrays:
I need to draw on a TPanel, ideally directly so I don't have another
I need to draw a .png image on an UIView. I have no clue
I need to draw a Polygon from several points (I have their latitude, longitude).
I need to draw a circle to display the distance around a point that
I need to draw a circle around a vertex in JUNG . The circle
I need to draw a gridded image using opengl. I've read that images created
I have a running program that uses glVertexPointer, glNormalPointer etc to draw a large
I need to draw some simple network topology charts, suggestions of some good tools

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.