Application crash on glColor4f OpenGl function in IOS

1k views Asked by At

I am working on OpenCV client app, my application works fine on IOS 5.1 but when i run my application on IOS 4.3 then it crashed at glColor4f function which defined in gl.h class, but it not show any error message on crash. I am doing like following:

QCAR::Matrix44F modelViewProjection;


                glColor4f(0.5f,0.0f,0.0f,0.0f);
                ShaderUtils::multiplyMatrix(&qUtils.projectionMatrix.data[0], &modelViewMatrix.data[0], &modelViewProjection.data[0]);
                glUseProgram(shaderProgramID);
                glVertexAttribPointer(vertexHandle, 3, GL_FLOAT, GL_FALSE, 0, (const GLvoid*) &vbVertices[0]);
                glEnableVertexAttribArray(vertexHandle);
                glUniformMatrix4fv(mvpMatrixHandle, 1, GL_FALSE, (GLfloat*)&modelViewProjection.data[0] );
                glColor4f(0.5f,0.0f,0.0f,0.0f);

                glEnableClientState (GL_VERTEX_ARRAY);
                glEnableClientState (GL_COLOR_ARRAY); 
                glEnableClientState(GL_COLOR_ARRAY);    
              //  glColorPointer(4, GL_FLOAT, 0, triangleColors);  
                glVertexPointer(3, GL_FLOAT, 0, (const GLvoid*) &vbVertices[0]); 
                glDisableClientState(GL_TEXTURE_COORD_ARRAY);
                glDisable(GL_TEXTURE_2D);
                glDrawArrays(GL_LINES, 0, 8);
                //glDisableClientState(GL_TEXTURE_COORD_ARRAY);
                //glDisable(GL_TEXTURE_2D);
                glDisableVertexAttribArray(vertexHandle);
2

There are 2 answers

0
karlphillip On BEST ANSWER

I've done some research and here's a couple of things for you to try:

Also, someone replied your question in this thread. He might be right.

0
Brad Larson On

glColor4f() is only used with the OpenGL ES 1.1 fixed function pipeline. From the use of glUseProgram() in your above code, you're working in OpenGL ES 2.0, therefore glColor4f() is not supported.

If you wish to set the color of your materials, you will need to do that via a uniform in your shader program. If you instead want to just set the background color of your scene, you'd use something like the following:

    glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
    glClear(GL_COLOR_BUFFER_BIT);