I am using this sample of code to render a box:
Code: Select all
struct MyVertex
{
float u, v;
float x,y,z;
};
struct MyVertex __attribute__((aligned(16))) verti[12*3] =
{
{0, 0, -1,-1, 1}, // 0
{1, 0, -1, 1, 1}, // 4
{1, 1, 1, 1, 1}, // 5
{0, 0, -1,-1, 1}, // 0
{1, 1, 1, 1, 1}, // 5
{0, 1, 1,-1, 1}, // 1
{0, 0, -1,-1,-1}, // 3
{1, 0, 1,-1,-1}, // 2
{1, 1, 1, 1,-1}, // 6
{0, 0, -1,-1,-1}, // 3
{1, 1, 1, 1,-1}, // 6
{0, 1, -1, 1,-1}, // 7
{0, 0, 1,-1,-1}, // 0
{1, 0, 1,-1, 1}, // 3
{1, 1, 1, 1, 1}, // 7
{0, 0, 1,-1,-1}, // 0
{1, 1, 1, 1, 1}, // 7
{0, 1, 1, 1,-1}, // 4
{0, 0, -1,-1,-1}, // 0
{1, 0, -1, 1,-1}, // 3
{1, 1, -1, 1, 1}, // 7
{0, 0, -1,-1,-1}, // 0
{1, 1, -1, 1, 1}, // 7
{0, 1, -1,-1, 1}, // 4
{0, 0, -1, 1,-1}, // 0
{1, 0, 1, 1,-1}, // 1
{1, 1, 1, 1, 1}, // 2
{0, 0, -1, 1,-1}, // 0
{1, 1, 1, 1, 1}, // 2
{0, 1, -1, 1, 1}, // 3
{0, 0, -1,-1,-1}, // 4
{1, 0, -1,-1, 1}, // 7
{1, 1, 1,-1, 1}, // 6
{0, 0, -1,-1,-1}, // 4
{1, 1, 1,-1, 1}, // 6
{0, 1, 1,-1,-1}, // 5
};
...
//That sets it up, this renders it:
glInterleavedArrays(GL_T2F_V3F, 0, verti);
glDrawArrays(GL_TRIANGLES, 0, 12*3);
Code: Select all
//Setup simple index buffer
USHORT buff[12*3];
buff[0] = 0;
buff[1] = 1;
buff[2] = 2;
buff[3] = 3;
buff[4] = 4;
buff[5] = 5;
buff[6] = 6;
buff[7] = 7;
buff[8] = 8;
buff[9] = 9;
buff[10] =10;
buff[11] =11;
buff[12] =12;
buff[13] =13;
buff[14] =14;
buff[15] =15;
buff[16] =16;
buff[17] =17;
buff[18] =18;
buff[19] =19;
buff[20] =20;
buff[21] =21;
buff[22] =22;
buff[23] =23;
buff[24] =24;
buff[25] =25;
buff[26] =26;
buff[27] =27;
buff[28] =28;
buff[29] =29;
buff[30] =30;
buff[31] =31;
buff[32] =32;
buff[33] =33;
buff[34] =34;
buff[35] =35;
glInterleavedArrays(GL_T2F_V3F, 0, verti);
glDrawElements(GL_TRIANGLES, 12*3, GL_UNSIGNED_SHORT, &buff[0]);
NOTE:
I also know that I should be using 8 verts and 36 indicies but this is just a test to get drawelemets to work cause on my other models it doesn't seem to be rendering or incorrectly rendering.
Thanks a lot
Jeff King.