assert(mode == GL_NORMAL_MAP_EXT);
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, mode);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, mode);
glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, mode);
glTexParameteri(GL_TEXTURE_CUBE_MAP_EXT, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_CUBE_MAP_EXT, GL_TEXTURE_WRAP_T, GL_CLAMP);
}
GLvoid ReSizeGLScene(GLsizei width, GLsizei height) // Resize And Initialize The GL Window
{
if (height==0) // Prevent A Divide By Zero By
{
height=1; // Making Height Equal One
}
glViewport(0,0,width,height); // Reset The Current Viewport
glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
glLoadIdentity(); // Reset The Projection Matrix
// Calculate The Aspect Ratio Of The Window
gluPerspective( 45.0f, (GLfloat)width/(GLfloat)height, 0.1f, 100.0f);
glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
}
int InitGL(GLvoid) // All Setup For OpenGL Goes Here
{
glShadeModel(GL_SMOOTH); // Enable Smooth Shading
glClearColor(0.0f, 0.0f, 0.0f, 0.5f); // Black Background
glClearDepth(1.0f); // Depth Buffer Setup
glEnable(GL_TEXTURE_CUBE_MAP_EXT);
glEnable(GL_DEPTH_TEST); // Enables Depth Testing
glDepthFunc(GL_LEQUAL); // The Type Of Depth Testing To Do
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Really Nice Perspective Calculations
makeCubeMap(); // Should be here initialised
assert(mode == GL_NORMAL_MAP_EXT); // Ensure
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, mode);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, mode);
glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, mode);
return TRUE; // Initialization Went OK
}
int DrawGLScene(GLvoid) // Here's Where We Do All The Drawing
{
GLfloat m[4][4];
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer
glLoadIdentity(); // Reset The Current Modelview Matrix
GLUquadricObj* quadric = gluNewQuadric();
glEnable(GL_BLEND);
glDisable(GL_TEXTURE_2D);
//glDisable(GL_TEXTURE_CUBE_MAP_EXT);
glEnable(GL_TEXTURE_CUBE_MAP_EXT);
//glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_CUBE_MAP_EXT, cubeMapTexNum);
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
glEnable(GL_TEXTURE_GEN_R);
glPushMatrix();
glTranslatef(0.0f,0.0f,-6.0f);
glRotatef(xrot, 1.0f, 0.0f, 0.0f); // Rotate on the X Axis by xrot
glRotatef(yrot, 0.0f, 1.0f, 0.0f); // Rotate on the Y Axis by yrot
gluSphere(quadric, 2.0f, 32,32);
glDisable(GL_BLEND);
glDisable(GL_TEXTURE_CUBE_MAP_EXT);
glDisable(GL_TEXTURE_GEN_S);
glDisable(GL_TEXTURE_GEN_T);
glDisable(GL_TEXTURE_GEN_R);
glEnable(GL_TEXTURE_2D);
glPopMatrix();
xrot+=xspeed;
yrot+=yspeed;
return TRUE; // Everything Went OK
}