OpenGL for OpenGL-ES - glRectf ()

I'm trying to learn OpenGL on iPhone using the "Super Bible" , but I have problems migrating from OpenGLto to OpenGL ES. I understand that the function is glRectf()not available in the latter. What is an alternative approach? Any relevant conceptual information will also be appreciated.

+3
source share
2 answers

An alternative approach is to draw a triangular strip:

GLfloat texture[] =
{
    0, 0,
    0, 1,
    1, 0,
    1, 1
};

GLfloat model[] =
{
    0, 0, // lower left
    0, h, // upper left
    w, 0, // lower right
    w, h  // upper right
};

glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);

glVertexPointer(2, GL_FLOAT, 0, model);
glTexCoordPointer(2, GL_FLOAT, 0, texture);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);

It draws a textured rectangle with width wand height h.

+9
source

Instead of making a rectangle, you just make two triangles.

, , GL-ES iPhone . , , .

+2

Source: https://habr.com/ru/post/1707694/


All Articles