Header Files into iPhone and OpenGL
Trying to learn OpenGL at the same time I'm learning the iPhone SDK
I made a simple cube in Cheetah 3D and was trying to display it on the iPhone using the header file export, what I get is just a unrecognizable blob on the screen. Any suggestions on what I'm doing wrong? thanks.
The Cheetah header file had everything I thought I would need, but it appears the iPhone doesn't support glInterleavedArrays, so I had to try to change the code to work without it.
glTexCoordPointer(2, GL_FLOAT, 8 * sizeof(GL_FLOAT), Box_vertex);
glNormalPointer(GL_FLOAT, 8 * sizeof(GL_FLOAT), Box_vertex + 2);
glVertexPointer(3, GL_FLOAT, 8 * sizeof(GL_FLOAT), Box_vertex + 5);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
glEnableClientState(GL_VERTEX_ARRAY);
glDrawElements(GL_TRIANGLES,Box_polygoncount*3,GL_UNSIGNED_SHORT,Box_index);
GLfloat Box_vertexBox_vertexcount[8]={
{0.00000, 1.00000, 0.00000, 0.00000, 1.00000, -0.50000, -0.50000, 0.50000},
{0.00000, 0.00000, 0.00000, 0.00000, 1.00000, -0.50000, 0.50000, 0.50000},
{1.00000, 0.00000, 0.00000, 0.00000, 1.00000, 0.50000, 0.50000, 0.50000},
{1.00000, 1.00000, 0.00000, 0.00000, 1.00000, 0.50000, -0.50000, 0.50000},
{0.00000, 1.00000, 0.00000, 0.00000, -1.00000, 0.50000, -0.50000, -0.50000},
{0.00000, 0.00000, 0.00000, 0.00000, -1.00000, 0.50000, 0.50000, -0.50000},
{1.00000, 0.00000, 0.00000, 0.00000, -1.00000, -0.50000, 0.50000, -0.50000},
{1.00000, 1.00000, 0.00000, 0.00000, -1.00000, -0.50000, -0.50000, -0.50000},
{0.00000, 1.00000, -1.00000, 0.00000, 0.00000, -0.50000, -0.50000, -0.50000},
{0.00000, 0.00000, -1.00000, 0.00000, 0.00000, -0.50000, 0.50000, -0.50000},
{1.00000, 0.00000, -1.00000, 0.00000, 0.00000, -0.50000, 0.50000, 0.50000},
{1.00000, 1.00000, -1.00000, 0.00000, 0.00000, -0.50000, -0.50000, 0.50000},
{0.00000, 1.00000, 1.00000, 0.00000, 0.00000, 0.50000, -0.50000, 0.50000},
{0.00000, 0.00000, 1.00000, 0.00000, 0.00000, 0.50000, 0.50000, 0.50000},
{1.00000, 0.00000, 1.00000, 0.00000, 0.00000, 0.50000, 0.50000, -0.50000},
{1.00000, 1.00000, 1.00000, 0.00000, 0.00000, 0.50000, -0.50000, -0.50000},
{0.00000, 1.00000, 0.00000, 1.00000, 0.00000, -0.50000, 0.50000, 0.50000},
{0.00000, 0.00000, 0.00000, 1.00000, 0.00000, -0.50000, 0.50000, -0.50000},
{1.00000, 0.00000, 0.00000, 1.00000, 0.00000, 0.50000, 0.50000, -0.50000},
{1.00000, 1.00000, 0.00000, 1.00000, 0.00000, 0.50000, 0.50000, 0.50000},
{0.00000, 1.00000, 0.00000, -1.00000, 0.00000, -0.50000, -0.50000, -0.50000},
{0.00000, 0.00000, 0.00000, -1.00000, 0.00000, -0.50000, -0.50000, 0.50000},
{1.00000, 0.00000, 0.00000, -1.00000, 0.00000, 0.50000, -0.50000, 0.50000},
{1.00000, 1.00000, 0.00000, -1.00000, 0.00000, 0.50000, -0.50000, -0.50000},
};
GLushort Box_indexBox_polygoncount[3]={
{0, 1, 2},
{2, 3, 0},
{4, 5, 6},
{6, 7, 4},
{8, 9, 10},
{10, 11, 8},
{12, 13, 14},
{14, 15, 12},
{16, 17, 18},
{18, 19, 16},
{20, 21, 22},
{22, 23, 20},
};
Trying to learn OpenGL at the same time I'm learning the iPhone SDK
I made a simple cube in Cheetah 3D and was trying to display it on the iPhone using the header file export, what I get is just a unrecognizable blob on the screen. Any suggestions on what I'm doing wrong? thanks.
The Cheetah header file had everything I thought I would need, but it appears the iPhone doesn't support glInterleavedArrays, so I had to try to change the code to work without it.
glTexCoordPointer(2, GL_FLOAT, 8 * sizeof(GL_FLOAT), Box_vertex);
glNormalPointer(GL_FLOAT, 8 * sizeof(GL_FLOAT), Box_vertex + 2);
glVertexPointer(3, GL_FLOAT, 8 * sizeof(GL_FLOAT), Box_vertex + 5);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
glEnableClientState(GL_VERTEX_ARRAY);
glDrawElements(GL_TRIANGLES,Box_polygoncount*3,GL_UNSIGNED_SHORT,Box_index);
GLfloat Box_vertexBox_vertexcount[8]={
{0.00000, 1.00000, 0.00000, 0.00000, 1.00000, -0.50000, -0.50000, 0.50000},
{0.00000, 0.00000, 0.00000, 0.00000, 1.00000, -0.50000, 0.50000, 0.50000},
{1.00000, 0.00000, 0.00000, 0.00000, 1.00000, 0.50000, 0.50000, 0.50000},
{1.00000, 1.00000, 0.00000, 0.00000, 1.00000, 0.50000, -0.50000, 0.50000},
{0.00000, 1.00000, 0.00000, 0.00000, -1.00000, 0.50000, -0.50000, -0.50000},
{0.00000, 0.00000, 0.00000, 0.00000, -1.00000, 0.50000, 0.50000, -0.50000},
{1.00000, 0.00000, 0.00000, 0.00000, -1.00000, -0.50000, 0.50000, -0.50000},
{1.00000, 1.00000, 0.00000, 0.00000, -1.00000, -0.50000, -0.50000, -0.50000},
{0.00000, 1.00000, -1.00000, 0.00000, 0.00000, -0.50000, -0.50000, -0.50000},
{0.00000, 0.00000, -1.00000, 0.00000, 0.00000, -0.50000, 0.50000, -0.50000},
{1.00000, 0.00000, -1.00000, 0.00000, 0.00000, -0.50000, 0.50000, 0.50000},
{1.00000, 1.00000, -1.00000, 0.00000, 0.00000, -0.50000, -0.50000, 0.50000},
{0.00000, 1.00000, 1.00000, 0.00000, 0.00000, 0.50000, -0.50000, 0.50000},
{0.00000, 0.00000, 1.00000, 0.00000, 0.00000, 0.50000, 0.50000, 0.50000},
{1.00000, 0.00000, 1.00000, 0.00000, 0.00000, 0.50000, 0.50000, -0.50000},
{1.00000, 1.00000, 1.00000, 0.00000, 0.00000, 0.50000, -0.50000, -0.50000},
{0.00000, 1.00000, 0.00000, 1.00000, 0.00000, -0.50000, 0.50000, 0.50000},
{0.00000, 0.00000, 0.00000, 1.00000, 0.00000, -0.50000, 0.50000, -0.50000},
{1.00000, 0.00000, 0.00000, 1.00000, 0.00000, 0.50000, 0.50000, -0.50000},
{1.00000, 1.00000, 0.00000, 1.00000, 0.00000, 0.50000, 0.50000, 0.50000},
{0.00000, 1.00000, 0.00000, -1.00000, 0.00000, -0.50000, -0.50000, -0.50000},
{0.00000, 0.00000, 0.00000, -1.00000, 0.00000, -0.50000, -0.50000, 0.50000},
{1.00000, 0.00000, 0.00000, -1.00000, 0.00000, 0.50000, -0.50000, 0.50000},
{1.00000, 1.00000, 0.00000, -1.00000, 0.00000, 0.50000, -0.50000, -0.50000},
};
GLushort Box_indexBox_polygoncount[3]={
{0, 1, 2},
{2, 3, 0},
{4, 5, 6},
{6, 7, 4},
{8, 9, 10},
{10, 11, 8},
{12, 13, 14},
{14, 15, 12},
{16, 17, 18},
{18, 19, 16},
{20, 21, 22},
{22, 23, 20},
};