I am learning how to use OpenGL ES 2.0 on iOS. Now I just want to make a basic 2D animation (for example, move the rectangle around the screen and resize it). I started with a project template for OpenGL ES provided by Apple in Xcode. My drawing code is as follows:
static GLfloat squareVertices[] = {
-0.5f, -0.33f,
0.5f, -0.33f,
-0.5f, 0.33f,
0.5f, 0.33f
};
glVertexAttribPointer(VERTEX_ATTR, 2, GL_FLOAT, 0, 0, squareVertices);
glEnableVertexAttribArray(VERTEX_ATTR);
glVertexAttribPointer(COLOR_ATTR, 4, GL_UNSIGNED_BYTE, 1, 0, squareColors);
glEnableVertexAttribArray(COLOR_ATTR);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 5);
Now it will draw a beautiful rectangle in the middle of the screen. But if I start changing the rectangle by adding the following code, it will start to look funky :
squareVertices[5] -= .001;
squareVertices[7] -= .001;
. OpenGL ES, , . , , OpenGL ES 3D- , 2D-. : 2D- OpenGL ES 2.0? OpenGL ES 1.1, . 2D- OpenGL ES 2.0 - 2D-?
.