   Probably an easy fix....
  Hello all,I am working off of code from Gametutorials.com and i''m running into problems.  I can''t seem to get my textures to map at all.  If you could look at my code and give some insight that''d be awesome.  It''s probably a real simple fix, but i''ve been staring at it too long...This code is designed to create a skybox and that''s it.  When i render my scene all i get is a big white screne, which to me would say that the images weren''t the right size, but i''m using mipmaps, so that shouldn''t come into play. (they are only 256x256 btw)Thanks a ton~R   #ifndef _SKY_BOX_H#define _SKY_BOX_H#include <math.h>#include <gl\gl.h>// Header File For The OpenGL32 Library#include <gl\glu.h>// Header File For The GLu32 Library#include <gl\glaux.h>#include <stdio.h>//#define MAX_TEXTURES 6// The maximum amount of textures to load#define GL_CLAMP_TO_EDGE0x812F// This is for our skybox textures#define BACK_ID0// The texture ID for the back side of the cube#define FRONT_ID1// The texture ID for the front side of the cube#define BOTTOM_ID2// The texture ID for the bottom side of the cube#define TOP_ID3// The texture ID for the top side of the cube#define LEFT_ID4// The texture ID for the left side of the cube#define RIGHT_ID5// The texture ID for the right side of the cubeclass SKY_BOX{private:UINT g_Texture[6];// This holds the texture info, referenced by an IDfloat X;float Y;float Z; float WIDTH;float HEIGHT;float LENGTH ;void CreateTexture(UINT textureArray[], LPSTR strFileName, int textureID){AUX_RGBImageRec *pBitmap = NULL;FILE *pFile = NULL;// The File Handle we will use to read the bitmapif(!strFileName)// Return from the function if no file name was passed inreturn;pFile = fopen(strFileName,"r");// Check To See If The File Existsif(pFile)// If we have a valid file pointer we found the file{pBitmap = auxDIBImageLoad(strFileName);// Load the bitmap and store the data}else// If we can''t find the file, quit!{// Prompt the error messageMessageBox(NULL, "Couldn''t find a texture!", "Error!", MB_OK);exit(0);}// Generate a texture with the associative texture ID stored in the arrayglGenTextures(6, &textureArray[textureID]);// This sets the alignment requirements for the start of each pixel row in memory.glPixelStorei (GL_UNPACK_ALIGNMENT, 1);// Bind the texture to the texture arrays index and init the textureglBindTexture(GL_TEXTURE_2D, textureArray[textureID]);// Build Mipmaps (builds different versions of the picture for distances - looks better)gluBuild2DMipmaps(GL_TEXTURE_2D, 3, pBitmap->sizeX, pBitmap->sizeY, GL_RGB, GL_UNSIGNED_BYTE, pBitmap->data);// Lastly, we need to tell OpenGL the quality of our texture map.  GL_LINEAR_MIPMAP_LINEAR// is the smoothest.  GL_LINEAR_MIPMAP_NEAREST is faster than GL_LINEAR_MIPMAP_LINEAR, // but looks blochy and pixilated.  Good for slower computers though.  glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST);glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR_MIPMAP_LINEAR);// The default GL_TEXTURE_WRAP_S and ""_WRAP_T property is GL_REPEAT.// We need to turn this to GL_CLAMP_TO_EDGE, otherwise it creates ugly seems// in our sky box.  GL_CLAMP_TO_EDGE does not repeat when bound to an object.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);// Now we need to free the bitmap data that we loaded since openGL stored it as a textureif (pBitmap)// If we loaded the bitmap{if (pBitmap->data)// If there is texture data{free(pBitmap->data);// Free the texture data, we don''t need it anymore}free(pBitmap);// Free the bitmap structure}return;}void MAKE_BOX(float x, float y, float z, float width, float height, float length){// This is the most important function of this tutorial.  This function// used to just create a silly colored cube in the RotateCube tutorial,// but now it creates something beautiful.  You''ll notice we added// some more parameters to the function.  This way we can change the perspective// of the sky box.  It doesn''t really look good if it''s a perfect cube.  Some// textures look better at different ratios.  We assign the sky box textures// to each side of the box creating the illusion of a detailed 3D world.// You will notice I had to change the texture coordinates for every one// to be flipped correctly.  Also, depending on your culling, the vertex// order might need to be changed around.  I don''t use culling in this tutorial// so it will work fine here, but be sure to remember this if you do.// Bind the BACK texture of the sky map to the BACK side of the cubeglBindTexture(GL_TEXTURE_2D, g_Texture[BACK_ID]);// Since we want the sky box to be centered around X, Y, and Z for ease,// we do a little math to accomplish this.  We just change the X, Y and Z// to perform this task.  If we just minus half the width, height and length// from x, y and z it will give us the desired result.  Now when we create the// box it will center it around (x, y, z)// This centers the sky box around (x, y, z)x = x - width  / 2;y = y - height / 2;z = z - length / 2;// Start drawing the side as a QUADglBegin(GL_QUADS);// Assign the texture coordinates and vertices for the BACK SideglTexCoord2f(1.0f, 0.0f); glVertex3f(x + width, y,z);glTexCoord2f(1.0f, 1.0f); glVertex3f(x + width, y + height, z); glTexCoord2f(0.0f, 1.0f); glVertex3f(x,y + height, z);glTexCoord2f(0.0f, 0.0f); glVertex3f(x,y,z);glEnd();// Bind the FRONT texture of the sky map to the FRONT side of the boxglBindTexture(GL_TEXTURE_2D, g_Texture[FRONT_ID]);// Start drawing the side as a QUADglBegin(GL_QUADS);// Assign the texture coordinates and vertices for the FRONT SideglTexCoord2f(1.0f, 0.0f); glVertex3f(x,y,z + length);glTexCoord2f(1.0f, 1.0f); glVertex3f(x,y + height, z + length);glTexCoord2f(0.0f, 1.0f); glVertex3f(x + width, y + height, z + length); glTexCoord2f(0.0f, 0.0f); glVertex3f(x + width, y,z + length);glEnd();// Bind the BOTTOM texture of the sky map to the BOTTOM side of the boxglBindTexture(GL_TEXTURE_2D, g_Texture[BOTTOM_ID]);// Start drawing the side as a QUADglBegin(GL_QUADS);// Assign the texture coordinates and vertices for the BOTTOM SideglTexCoord2f(1.0f, 0.0f); glVertex3f(x,y,z);glTexCoord2f(1.0f, 1.0f); glVertex3f(x,y,z + length);glTexCoord2f(0.0f, 1.0f); glVertex3f(x + width, y,z + length); glTexCoord2f(0.0f, 0.0f); glVertex3f(x + width, y,z);glEnd();// Bind the TOP texture of the sky map to the TOP side of the boxglBindTexture(GL_TEXTURE_2D, g_Texture[TOP_ID]);// Start drawing the side as a QUADglBegin(GL_QUADS);// Assign the texture coordinates and vertices for the TOP SideglTexCoord2f(0.0f, 1.0f); glVertex3f(x + width, y + height, z);glTexCoord2f(0.0f, 0.0f); glVertex3f(x + width, y + height, z + length); glTexCoord2f(1.0f, 0.0f); glVertex3f(x,y + height,z + length);glTexCoord2f(1.0f, 1.0f); glVertex3f(x,y + height,z);glEnd();// Bind the LEFT texture of the sky map to the LEFT side of the boxglBindTexture(GL_TEXTURE_2D, g_Texture[LEFT_ID]);// Start drawing the side as a QUADglBegin(GL_QUADS);// Assign the texture coordinates and vertices for the LEFT SideglTexCoord2f(1.0f, 1.0f); glVertex3f(x,y + height,z);glTexCoord2f(0.0f, 1.0f); glVertex3f(x,y + height,z + length); glTexCoord2f(0.0f, 0.0f); glVertex3f(x,y,z + length);glTexCoord2f(1.0f, 0.0f); glVertex3f(x,y,z);glEnd();// Bind the RIGHT texture of the sky map to the RIGHT side of the boxglBindTexture(GL_TEXTURE_2D, g_Texture[RIGHT_ID]);// Start drawing the side as a QUADglBegin(GL_QUADS);// Assign the texture coordinates and vertices for the RIGHT SideglTexCoord2f(0.0f, 0.0f); glVertex3f(x + width, y,z);glTexCoord2f(1.0f, 0.0f); glVertex3f(x + width, y,z + length);glTexCoord2f(1.0f, 1.0f); glVertex3f(x + width, y + height,z + length); glTexCoord2f(0.0f, 1.0f); glVertex3f(x + width, y + height,z);glEnd();return;}public:SKY_BOX::SKY_BOX(float x, float y, float z, float width, float height, float length){glEnable(GL_TEXTURE_2D);// Below we read in the 6 texture maps used for the sky box.// The ID''s are important, so don''t mix them up.  There is a// texture for every side of the box.CreateTexture(g_Texture, "Data/Back.bmp",BACK_ID);CreateTexture(g_Texture, "Data/Front.bmp",FRONT_ID);CreateTexture(g_Texture, "Data/Bottom.bmp",BOTTOM_ID);CreateTexture(g_Texture, "Data/Top.bmp",TOP_ID);CreateTexture(g_Texture, "Data/Left.bmp",LEFT_ID);CreateTexture(g_Texture, "Data/Right.bmp",RIGHT_ID);MAKE_BOX(x, y, z, width, height, length);X= x;Y= y;Z= z;WIDTH= width;HEIGHT= height;LENGTH= length;}SKY_BOX::RENDER(){MAKE_BOX(X, Y, Z, WIDTH, HEIGHT, LENGTH);}};#endif   
  put a couple of MessageBox(........) calls in that CreateTexture function to make sure it isnt failing somewhere and not creating the texture.  If i remember correctly i had trouble loading bmp files with that function from gametutorials.com so i threw it out and wrote my own function to load bmps and create textures from them. "A soldier is a part of the 1% of the population that keeps the other 99% free"  - Lt. Colonel Todd, 1/38th Infantry, Ft. Benning, GA ;  I see SKY_BOX::SKY_BOX in there - is that a constructor?  Are you using that constructor?  If so, check to see if that object is instantiating itself before you''ve called wglCreateContext.  There must be an active rendering context when you create your textures or they''ll be "forgotten".  Are you declaring your skybox as a global variable maybe?The other thing to check is, are you changing the value of GL_CULL_FACE?  I think his code depends on it being GL_CCW, i.e.glEnable(GL_CULL_FACE);// do not calculate inside of poly''sglFrontFace(GL_CCW);// counter clock-wise polygons are outHope this helps Love means nothing to a tennis playerMy nothing-to-write-home-about OpenGL webpage. (please pardon the popups!);  dal, are you saying that I shouldn''t declare it as a global variable then?  At the moment it is.  It is declared right before LRESULTCALLBACK WndProc(HWND, UINT, WPARAM, LPARAM)  If it shouldn''t be where should i declare it?I grabbed lesson 1 from here to test out the my SkyBox.   I declare it as a global variable and call my render function in the DrawGLScene function....Thanks,~R ;  What to do is purely a matter of taste.What happens is, if you declare it as a global variable, all of the code in the skybox::skybox constructor is actually executed BEFORE you ever to get to WinMain.  If you haven''t even gotten to WinMain yet, you haven''t gotten to your call to wglCreateContext yet, and any texture creation you do before your call to wglCreateContext is "forgotten".What I would do (and this is just me) is go ahead and leave the skybox variable a global variable, but move all of the texture loading code to a member function called something like InitializeTextures(), and call mySkyBox.InitializeTextures() any time after wglCreateContext.Hope this helps!   Love means nothing to a tennis playerMy nothing-to-write-home-about OpenGL webpage. (please pardon the popups!)