0

I have a problem with OpenGL: the faces of my cube aren't properly drawn. I tried to disable face culling but it didn't change a thing. By the way, I use sfml 2.1. I also tried to change the indices order of my cube, but it only got worse. Let me show you pictures:

Here's the picture using my first set of indices:

Here's the picture using my second set of indices:

Here are my sets of indices:

GLfloat vertexData[NUM_VERTS * ELEM_PER_POS + NUM_VERTS * ELEM_PER_COLOR] = {
-1.0f, -1.0f, -1.0f, // Positions
1.0f, -1.0f, -1.0f,
-1.0f, 1.0f, -1.0f,
1.0f, 1.0f, -1.0f,

-1.0f, -1.0f, 1.0f,
1.0f, -1.0f, 1.0f,
-1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f,

1.0f, 0.0f, 0.0f, 1.0f, // Colors
0.0f, 1.0f, 0.0f, 1.0f,
0.0f, 0.0f, 1.0f, 1.0f,
1.0f, 1.0f, 0.0f, 1.0f,

0.0f, 1.0f, 1.0f, 1.0f,
1.0f, 0.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 0.0f, 1.0f, 1.0f};

GLuint vertexIndices[NUM_INDICES] = { // first indices
0, 1, 2,
1, 2, 3,

0, 1, 4,
1, 4, 5,

2, 3, 6,
3, 6, 7,

0, 2, 4,
2, 4, 6,

1, 3, 5,
3, 5, 7,

4, 5, 6,
5, 6, 7};

/*  GLuint vertexIndices[NUM_INDICES] = { //second indices
2, 1, 0,
2, 3, 1,

0, 1, 4,
1, 5, 4,

2, 3, 6,
3, 7, 6,

0, 2, 4,
2, 6, 4,

1, 3, 5,
3, 7, 5,

6, 5, 4,
6, 7, 4};*/
Community
  • 1
  • 1
Benoît Dubreuil
  • 650
  • 1
  • 11
  • 27

0 Answers0