I'm writing for iPhone, OpenGL ES
Do you know how can I draw quad with part of particular texture?
Now I'm rendering like that:
static const GLfloat texCoo开发者_开发百科rds[] = {
0.0, 0.0,
10.0, 0.0,
10.0, 10.0,
0.0, 10.0
};
glBindTexture(GL_TEXTURE_2D, atlas_tex[0]);
GLfloat squareVertices[] = {
0.0f, 0.0f,
2000.5f, 0.0f,
2000.5f, 2000.33f,
0.0f, 2000.33f
};
glVertexPointer(2, GL_FLOAT, 0, squareVertices);
glEnableClientState(GL_VERTEX_ARRAY);
glTexCoordPointer(2, GL_FLOAT, 0, texCoords);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
But of course, it display all texture. I don't know how to cut it.
If I understood you correctly, you need to change the texCoords array appropriately.
E.g. try something like that:
static const GLfloat texCoords[] = {
0.0, 0.0,
0.5, 0.0,
0.5, 0.5,
0.0, 0.5
};
精彩评论