I have downloaded a sample project that uses OpenGL ES with ios using Objective-C. The app creates a simple cube. I want to make the cube a rectangular prism by decreasing the distance between the front face and back face of the cube (make it slimmer). In order to do that I need to decrease the size of the top, bottom, left, and right faces. I am new to openGL and dont know which code to change in order to decrease the four faces of the cube. Here is the code
typedef struct {
float Position[3];
float Color[4];
float TexCoord[2];
} Vertex;
const Vertex Vertices[] = {
// Front
{{1, -1, 1}, {1, 1, 1, 1}, {1, 0}},
{{1, 1, 1}, {1, 1, 1, 1}, {1, 1}},
{{-1, 1, 1}, {1, 1, 1, 1}, {0, 1}},
{{-1, -1, 1}, {1, 1, 1, 1}, {0, 0}},
// Back
{{1, 1, -1}, {1, 1, 1, 1}, {0, 1}},
{{-1, -1, -1}, {1, 1, 1, 1}, {1, 0}},
{{1, -1, -1}, {1, 1, 1, 1}, {0, 0}},
{{-1, 1, -1}, {1, 1, 1, 1}, {1, 1}},
// Left
{{-1, -1, 1}, {1, 1, 1, 1}, {1, 0}},
{{-1, 1, 1}, {1, 1, 1, 1}, {1, 1}},
{{-1, 1, -1}, {1, 1, 1, 1}, {0, 1}},
{{-1, -1, -1}, {1, 1, 1, 1}, {0, 0}},
// Right
{{1, -1, -1}, {1, 1, 1, 1}, {1, 0}},
{{1, 1, -1}, {1, 1, 1, 1}, {1, 1}},
{{1, 1, 1}, {1, 1, 1, 1}, {0, 1}},
{{1, -1, 1}, {1, 1, 1, 1}, {0, 0}},
// Top
{{1, 1, 1}, {1, 1, 1, 1}, {1, 0}},
{{1, 1, -1}, {1, 1, 1, 1}, {1, 1}},
{{-1, 1, -1}, {1, 1, 1, 1}, {0, 1}},
{{-1, 1, 1}, {1, 1, 1, 1}, {0, 0}},
// Bottom
{{1, -1, -1}, {1, 1, 1, 1}, {1, 0}},
{{1, -1, 1}, {1, 1, 1, 1}, {1, 1}},
{{-1, -1, 1}, {1, 1, 1, 1}, {0, 1}},
{{-1, -1, -1}, {1, 1, 1, 1}, {0, 0}}
};
const GLubyte Indices[] = {
// Front
0, 1, 2,
2, 3, 0,
// Back
4, 6, 5,
4, 5, 7,
// Left
8, 9, 10,
10, 11, 8,
// Right
12, 13, 14,
14, 15, 12,
// Top
16, 17, 18,
18, 19, 16,
// Bottom
20, 21, 22,
22, 23, 20
};
If you guys think that this isnt the code to determine the size of the faces, please tell me what method was probably used so I can find it in the project and post it here.
The problem was fixed thanks to Tommy. But now I have new issue. The size of the four faces has decreased but the front and back face now have a gap between the rest of the faces, here is a screenshot.
How can I move the front face inwards towards the other faces so its attached to them?
