0

I'm just working through the twee jump project which is written in cocos2d 1.0 found here

I'm having trouble converting this section of the code to OpenGL ES 2.0. I need at least 10 reputations to post a picture but a picture of the errors I get when I try to build and run can be found here:

enter image description here

- (void)draw {
    [super draw];

    if(currentScorePosition < 0) return;

    glColor4f(0.0f, 0.0f, 0.0f, 0.2f);

    float w = 320.0f;
    float h = 27.0f;
    float x = (320.0f - w) / 2.0f;
    float y = 359.0f - currentScorePosition * h;

    GLfloat vertices[4][2]; 
    GLubyte indices[4] = { 0, 1, 3, 2 };

    vertices[0][0] = x;     vertices[0][1] = y;
    vertices[1][0] = x+w;   vertices[1][1] = y;
    vertices[2][0] = x+w;   vertices[2][1] = y+h;
    vertices[3][0] = x;     vertices[3][1] = y+h;

    glDisable(GL_TEXTURE_2D);
    glDisableClientState(GL_TEXTURE_COORD_ARRAY);
    glDisableClientState(GL_COLOR_ARRAY);

    glVertexPointer(2, GL_FLOAT, 0, vertices);
    glDrawElements(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_BYTE, indices);

    glEnableClientState(GL_COLOR_ARRAY);
    glEnableClientState(GL_TEXTURE_COORD_ARRAY);
    glEnable(GL_TEXTURE_2D);

    glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
}
Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
Booms
  • 49
  • 1
  • 7
  • 1
    Every valid GL 1.x code is valid 2.x code, as 2.x is fully backward compatible. What are you trying to do, avoiding all later deprecated functionality like fixed-function pipeline, client side VAs, the matrix stack,...? – derhass Jul 14 '13 at 11:59
  • I forgot to mention that I am beginner at cocos2d so I'm not sure what you mean. When I try to build and run the program I get errors, i'll post a picture of the errors – Booms Jul 14 '13 at 12:40
  • I need at least 10 reputations to post a picture but a picture of the errors I get when I try to build and run can be found here: http://i39.tinypic.com/5ofs6x.png – Booms Jul 14 '13 at 12:52
  • For me, this does not look like you are targeting GL 2.0, but something like 3.x core profile. I don't know anything about cocos2d, though. – derhass Jul 14 '13 at 12:58
  • http://stackoverflow.com/questions/11662770/cocos2d-2-0-zillions-of-opengl-errors/11663486#11663486 – Guru Jul 14 '13 at 13:00
  • To clear some confusion here, I'm pretty sure this question is about OpenGL **ES** 1.0/2.0, where 2.0 is NOT backwards compatible. – Robert Rouhani Jul 24 '13 at 23:10

0 Answers0