开发者

glDrawArrays works in vm, crashes on phone

I am drawing a line in opengl es from the Android NDK. I have been developing on the VM's and just recently tried my application on a phone. The application runs fine on the vm's. A line is drawn. However, on a motorola droid, the application just crashes, and on a HTC incredible it just shows a black screen. I have verified that the number being passed to the function are correct. The application haults on the glDrawArray(GL_LINES, 0, 2) call. The whole function looks like this:

void drawLine(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2, GLfloat * color)
{
    GLfloat vVertices[] =
    {x1, y1,
    x2, y2};

    glEnableClientState(GL_VERTEX_ARRAY);
    glEnableClientState(GL_COLOR_ARRAY);
    glColor4f(color[0],color[1],color[2],color[3]);
    glVertexPointer(2, GL开发者_运维知识库_FLOAT, 0, vVertices);

    glDrawArrays(GL_LINES, 0, 2);
    __android_log_write(ANDROID_LOG_ERROR,"to mama","You drew arrays");

    glDisableClientState(GL_COLOR_ARRAY);
    glDisableClientState(GL_VERTEX_ARRAY);
}

and the call to it looks like this:

drawLine(0.0f,0.0f,1.0f,0.0f,colorx);/*x is green*/

I can try drawelements next, but there is not reason draw arrays should not work (as far as i know).


You're enabling the color array (glEnableClientState(GL_COLOR_ARRAY)) without actually setting setting the glColorPointer().

Either set the color pointer or don't enable the color array.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜