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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:26:25+00:00 2026-05-22T18:26:25+00:00

I’m having an issue rendering in OpenGL ES 1.1 for an iPhone game that

  • 0

I’m having an issue rendering in OpenGL ES 1.1 for an iPhone game that I’m building.

In short, I am rendering 3 items:

  1. Background (works fine)
  2. A number of spherical objects (works fine)
  3. A simple line circle that changes size (I am getting a problem here).

Basically, I am getting an EXC_BAD_ACCESS error when I call drawArrays on the circle. I have tested the code in the basic iPhone OpenGL template and it works just fine, so I can’t really track why it’s not working here. Can someone point me in the right way?

Here is the drawCircle code used to render the circle.

- (void) drawCircles
{
if (!m_circleEffects.empty())
{
    int segments = 24;
    for (int i = 0; i < m_circleEffects.size(); i++)
    {
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();
        glTranslatef(m_circleEffects[i].position.x, m_circleEffects[i].position.y, 0);

        float radius;
        if(m_circleEffects[i].isPulseOutward)
            radius = cos(m_circleEffects[i].frameCounter * M_PI / 720);
        else
            radius = sin(m_circleEffects[i].frameCounter * M_PI / 720);

        GLfloat circlePoints[segments * 3];                    
        int count = 0;

        for (GLfloat i = 0; i < 360.0f; i += (360.0f / segments))
        {
            circlePoints[count++] = (cos(i * M_PI / 180) * radius);
            circlePoints[count++] = (sin(i * M_PI / 180) * radius);
            circlePoints[count++] = z + 1;
        }

        glEnableClientState(GL_VERTEX_ARRAY);  
        glVertexPointer(3, GL_FLOAT, 0, circlePoints);                       
        glDrawArrays(GL_LINE_LOOP, 0, segments);   
        glDisableClientState(GL_VERTEX_ARRAY);
    }      
    m_circleEffects.clear();
}
}

And the following is my other rendering code. It is called prior to the above code in the run loop. Everything in the following seems to work OK.

- (void)passInVisualsToUse:(vector<Visual>)visuals
{
frameCounter += 0.2;
if (frameCounter >= 360)
    frameCounter -= 360;

glClearColor(0.5f, 0.5f, 0.5f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glEnable(GL_DEPTH_TEST);
glEnable(GL_TEXTURE_2D);

glDepthMask(GL_FALSE);

glBindTexture(GL_TEXTURE_2D, m_backgroundTexture);

glDrawTexfOES(0, 0, 0, 480, 320);
glDepthMask(GL_TRUE);

vector<Visual>::const_iterator visual = visuals.begin();
for (int visualIndex = 0;
     visual != visuals.end();
     ++visual, ++visualIndex)
{        

    if (visual->ObjectType == 1)
        glBindTexture(GL_TEXTURE_2D, m_oneTexture);
    else if (visual->ObjectType == 2)
        glBindTexture(GL_TEXTURE_2D, m_twoTexture);
    else if (visual->ObjectType == 3)
        glBindTexture(GL_TEXTURE_2D, m_threeTexture);
    else
        glBindTexture(GL_TEXTURE_2D, m_fourTexture);

    // Set the viewport transform.
    vec3 position = visual->Position;

    // Set the light position.
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

    glTranslatef(position.x, position.y, position.z);
    float rotationAngle = visual->RotationAngle;
    glRotatef(rotationAngle, 0, 1, 0);

    float scale = visual->Scale;   

    if (visual->ShouldThrob)
    {
        float scaleFactor = scale + sin(frameCounter) / 25;
        glScalef(scaleFactor, scaleFactor, scale);

        BOOL isPulseOutward;
        if (visual->isPulseOutward)
            isPulseOutward = YES;
        else
            isPulseOutward = NO;

        CircleEffect toAdd;
        toAdd.position = position;
        toAdd.frameCounter = frameCounter;
        toAdd.isPulseOutward = isPulseOutward;
        m_circleEffects.push_back(toAdd);
    }
    else
        glScalef(scale, scale, scale);

    // Set the projection transform.
    float h = (float)screenSize.size.height / (float)screenSize.size.width;

    mat4 projection = mat4::Ortho(xleft, xright, h * xleft, h * xright, znear, zfar);

    glMatrixMode(GL_PROJECTION);
    glLoadMatrixf(projection.Pointer());

    // Draw the surface.
    int stride = sizeof(vec3) + sizeof(vec3) + sizeof(vec2);
    const GLvoid* texCoordOffset = (const GLvoid*) (2 * sizeof(vec3));
    const Drawable& drawable = m_drawables[visualIndex];
    glBindBuffer(GL_ARRAY_BUFFER, drawable.VertexBuffer);
    glVertexPointer(3, GL_FLOAT, stride, 0);
    const GLvoid* normalOffset = (const GLvoid*) sizeof(vec3);
    glNormalPointer(GL_FLOAT, stride, normalOffset);
    glTexCoordPointer(2, GL_FLOAT, stride, texCoordOffset);
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, drawable.IndexBuffer);
    glDrawElements(GL_TRIANGLES, drawable.IndexCount, GL_UNSIGNED_SHORT, 0);
}


glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisable(GL_DEPTH_TEST);
glDisable(GL_TEXTURE_2D);
}

The relevant buffers have been set-up elsewhere, and as mentioned, the second code all works fine.

Basically, I am getting an EXC_BAD_ACCESS on the drawArrays code in the top code snippet. Anyone have any ideas why?

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-05-22T18:26:25+00:00Added an answer on May 22, 2026 at 6:26 pm

    My guess is the GL state has an array still bound that shouldn’t be.

    If it works on its own, then that method might be fine. But a previous method may not have returned the state to what it should be or something.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a
I need a function that will clean a strings' special characters. I do NOT
I'm having trouble keeping the paragraph square between the quote marks. In firefox the

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.