It works fine at the moment, but it is using OpenGL1's glBegin(GL_QUADS) function. I need it to use OpenGL2's glDrawArrays or glDrawElements.
The code that needs updating is this:
void drawSkybox() { for (int i = 0; i < 6; i++) { glBindTexture(GL_TEXTURE_2D, skybox); glBegin(GL_QUADS); for (int j = 0; j < 4; j++) { glTexCoord2dv(texture[j]); glVertex3fv(vertices[faces[j]]); } glEnd(); }}
The textures are loading fine in another function and their GLuint id's are stored in the skybox array. The arrays for vertices, faces and textures are defined as:
GLfloat vertices[8][3] = {{-0.5, -0.5, -0.5}, // 0: left, bottom, back {-0.5, -0.5, +0.5}, // 1: left, bottom, front {-0.5, +0.5, -0.5}, // 2: left, top, back {-0.5, +0.5, +0.5}, // 3: left, top, front {+0.5, -0.5, -0.5}, // 4: right, bottom, back {+0.5, -0.5, +0.5}, // 5: right, bottom, front {+0.5, +0.5, -0.5}, // 6: right, top, back {+0.5, +0.5, +0.5}};// 7: right, top, frontGLubyte faces[6][4] = {{1, 0, 2, 3}, // 0: west {4, 5, 7, 6}, // 1: east {4, 0, 1, 5}, // 2: below {7, 3, 2, 6}, // 3: above {5, 1, 3, 7}, // 4: south {0, 4, 6, 2}};// 5: northGLdouble texture[4][2] = {{0.0, 0.0}, // 0: left, bottom {1.0, 0.0}, // 1: right, bottom {1.0, 1.0}, // 2: right, top {0.0, 1.0}};// 3: left, top
I've been struggling with this for hours. I keep getting strange tearing accross the surfaces of the cube. Can anyone help me?
Many thanks,
Chris