1

i have upload a model with the following model loader in my Opengles code in ios.

http://bill.dudney.net/roller/objc/entry/wave_front_obj_textures_working

now the problem is that when i want to draw a cube along with this model loader with following code

const GLfloat floorVertices[] = {
    -1.0, 1.0, 0.0,     // Top left
    -1.0, -1.0, 0.0,    // Bottom left
    1.0, -1.0, 0.0,     // Bottom right
    1.0, 1.0, 0.0       // Top right
};



glVertexPointer(3, GL_FLOAT, 0, floorVertices);
glEnableClientState(GL_VERTEX_ARRAY);
glRotatef(90.0, 0.0, 1.0, 0.0);
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);

it crashes on glDrawArrays(GL_TRIANGLE_FAN, 0, 4) with EXC_BAD_ACCESS error

i have searched this problem over internet but can't simple solution or explanation. here is another question about it but i cannot get his answer due to lack of knowledge about opengles.

glDrawArrays crash with EXC_BAD_ACCESS.

Can anyone have solution of this problem or simple explanation of already asked question. thanks in advance

Community
  • 1
  • 1
s.zainulabideen
  • 2,047
  • 1
  • 13
  • 13

1 Answers1

4

This is likely because other vertex arrays are still enabled, while OpenGL's pointers to them haven't been cleared, leading OpenGL to dereference dangling pointers.

Use the OpenGL Frame Debugger or glGetIntegerv() to see if any of the other array types are enabled (COLOR_ARRAY, NORMAL_ARRAY, GL_TEXTURE_COORD_ARRAY).

Frogblast
  • 1,671
  • 10
  • 9