In OpenGL ES 1.1, use the functions glVertexPointer() , glColorPointer() , glTexCoordPointer() and glDrawArrays() to draw a quadrant. Unlike your OpenGL implementation, you will need to describe the structures (vectors, colors, texture coordinates) that your quad is in, instead of using the built-in glTexCoord2f , glVertex2f and glColor3f .
Here is an example of code that should do what you want. (I used the argument names that you used in the function definition, so it should just be transferring your code from the example.)
First you need to define a structure for one vertex of your quadrant. This will contain the positions of the vertices of the quadrangles, color and texture.
Then you must define a structure that describes the entire square, consisting of four vertices:
Now create your quad and assign information about the four vertices (position, color, texture coordinates):
Quad quad; quad.bl.vect = (Vec2){x,y}; quad.br.vect = (Vec2){w+x,y}; quad.tr.vect = (Vec2){w+x,h+y}; quad.tl.vect = (Vec2){x,h+y}; quad.tl.color = quad.tr.color = quad.bl.color = quad.br.color = (Color4B){r,g,b,255}; quad.tl.texCoords = (Vec2){0,0}; quad.tr.texCoords = (Vec2){1,0}; quad.br.texCoords = (Vec2){1,1}; quad.bl.texCoords = (Vec2){0,1};
Now tell OpenGL how to draw a quad. The gl...Pointer calls provide OpenGL with the correct offsets and sizes up to the vertex structure values, so they can subsequently use this information to draw a quadrant.
// "Explain" the quad structure to OpenGL ES #define kQuadSize sizeof(quad.bl) long offset = (long)&quad; // vertex int diff = offsetof(QuadVertex, vect); glVertexPointer(2, GL_FLOAT, kQuadSize, (void*)(offset + diff)); // color diff = offsetof(QuadVertex, color); glColorPointer(4, GL_UNSIGNED_BYTE, kQuadSize, (void*)(offset + diff)); // texCoods diff = offsetof(QuadVertex, texCoords); glTexCoordPointer(2, GL_FLOAT, kQuadSize, (void*)(offset + diff));
Finally, assign a texture and draw a quad. glDrawArrays tells OpenGL to use the previously defined offsets along with the values contained in your Quad object to draw the shape defined by vertices 4 .
glBindTexture(GL_TEXTURE_2D, tex);
Also note that using OpenGL ES 1 is great if you don't need shaders. The main difference between ES1 and ES2 is that there is no fixed pipeline in ES2, so you will need to implement a matrix stack plus shaders for main rendering. If you are fine with the functionality offered by the fixed pipeline, just use OpenGL ES 1.