1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
int drawcube(float x,float y,float z,int tex)
{
glBindTexture(GL_TEXTURE_2D, texture[tex]); // Select Our Texture
glBegin(GL_QUADS);
// Front Face
glTexCoord2f(0.0f, 0.0f); glVertex3f(x, y, z); // Bottom Left Of The Texture and Quad
glTexCoord2f(1.0f, 0.0f); glVertex3f(x+scale, y, z); // Bottom Right Of The Texture and Quad
glTexCoord2f(1.0f, 1.0f); glVertex3f(x+scale, y+scale, z); // Top Right Of The Texture and Quad
glTexCoord2f(0.0f, 1.0f); glVertex3f(x, y+scale, z); // Top Left Of The Texture and Quad
// Back Face
glTexCoord2f(1.0f, 0.0f); glVertex3f(x, y, z-scale); // Bottom Right Of The Texture and Quad
glTexCoord2f(1.0f, 1.0f); glVertex3f(x, y+scale, z-scale); // Top Right Of The Texture and Quad
glTexCoord2f(0.0f, 1.0f); glVertex3f(x+scale, y+scale, z-scale); // Top Left Of The Texture and Quad
glTexCoord2f(0.0f, 0.0f); glVertex3f(x+scale, y, z-scale); // Bottom Left Of The Texture and Quad
// Top Face
glTexCoord2f(0.0f, 1.0f); glVertex3f(x, y+scale, z-scale); // Top Left Of The Texture and Quad
glTexCoord2f(0.0f, 0.0f); glVertex3f(x, y+scale, z); // Bottom Left Of The Texture and Quad
glTexCoord2f(1.0f, 0.0f); glVertex3f(x+scale, y+scale, z); // Bottom Right Of The Texture and Quad
glTexCoord2f(1.0f, 1.0f); glVertex3f(x+scale, y+scale, z-scale); // Top Right Of The Texture and Quad
// Bottom Face
glTexCoord2f(1.0f, 1.0f); glVertex3f(x, y, z-scale); // Top Right Of The Texture and Quad
glTexCoord2f(0.0f, 1.0f); glVertex3f(x+scale, y, z-scale); // Top Left Of The Texture and Quad
glTexCoord2f(0.0f, 0.0f); glVertex3f(x+scale, y, z); // Bottom Left Of The Texture and Quad
glTexCoord2f(1.0f, 0.0f); glVertex3f(x, y, z); // Bottom Right Of The Texture and Quad
// Right face
glTexCoord2f(1.0f, 0.0f); glVertex3f(x+scale, y, z-scale); // Bottom Right Of The Texture and Quad
glTexCoord2f(1.0f, 1.0f); glVertex3f(x+scale, y+scale, z-scale); // Top Right Of The Texture and Quad
glTexCoord2f(0.0f, 1.0f); glVertex3f(x+scale, y+scale, z); // Top Left Of The Texture and Quad
glTexCoord2f(0.0f, 0.0f); glVertex3f(x+scale, y, z); // Bottom Left Of The Texture and Quad
// Left Face
glTexCoord2f(0.0f, 0.0f); glVertex3f(x, y, z-scale); // Bottom Left Of The Texture and Quad
glTexCoord2f(1.0f, 0.0f); glVertex3f(x, y, z); // Bottom Right Of The Texture and Quad
glTexCoord2f(1.0f, 1.0f); glVertex3f(x, y+scale, z); // Top Right Of The Texture and Quad
glTexCoord2f(0.0f, 1.0f); glVertex3f(x, y+scale, z-scale); // Top Left Of The Texture and Quad
glEnd();
return true;
}
|