Hi guys
I am developing an iPad application which just drawing a 3d cube. User can rotate it with finger motion and can zoom in/out with pinching it.
Right now I am coloring whole cube (every surface) at same time. Now if I want user to color each surface of cube separately, means user will tap one surface and it will color that surface only but I dont know how to identify that surface what user have tapped..
I am drawing whole cube with simple openGL basics as below..
static const GLfloat cubeVertices[] = {
-1.0, -1.0, 1.0,
1.0, -1.0, 1.0,
1.0, 1.0, 1.0,
-1.0, 1.0, 1.0,
-1.0, -1.0, -1.0,
1.0, -1.0, -1.0,
1.0, 1.0, -1.0,
-1.0, 1.0, -1.0,
};
static const GLushort cubeIndicesFaceFront[] = {
0, 1, 2, 3, 0
};
static const GLushort cubeIndicesFaceBack[] = {
4, 5, 6, 7, 4
};
static const GLushort cubeIndicesFaceLeft[] = {
0, 4, 7, 3, 0
};
static const GLushort cubeIndicesFaceRight[] = {
1, 5, 6, 2, 1
};
static const GLushort cubeIndicesFaceTop[] = {
3, 2, 6, 7, 3
};
static const GLushort cubeIndicesFaceBottom[] = {
0, 1, 5, 4, 0
};
static const GLubyte cubeColors[] = {
0, 255, 255, 255,
0, 255, 255, 255,
0, 255, 255, 255,
0, 255, 255, 255,
0, 255, 255, 255,
};
glVertexPointer(3, GL_FLOAT, 0, cubeVertices);
glEnableClientState(GL_VERTEX_ARRAY);
glColorPointer(4, GL_UNSIGNED_BYTE, 0, cubeColors);
glEnableClientState(GL_COLOR_ARRAY);
glDrawElements(GL_TRIANGLE_FAN, 5, GL_UNSIGNED_SHORT, cubeIndicesFaceFront);
glDrawElements(GL_TRIANGLE_FAN, 5, GL_UNSIGNED_SHORT, cubeIndicesFaceBack);
glDrawElements(GL_TRIANGLE_FAN, 5, GL_UNSIGNED_SHORT, cubeIndicesFaceLeft);
glDrawElements(GL_TRIANGLE_FAN, 5, GL_UNSIGNED_SHORT, cubeIndicesFaceRight);
glDrawElements(GL_TRIANGLE_FAN, 5, GL_UNSIGNED_SHORT, cubeIndicesFaceTop);
glDrawElements(GL_TRIANGLE_FAN, 5, GL_UNSIGNED_SHORT, cubeIndicesFaceBottom);
glBindRenderbufferOES(GL_RENDERBUFFER_OES, colorRenderbuffer);
[context presentRenderbuffer:GL_RENDERBUFFER_OES];
Thanks in advance....appreciated your support.