and I''m stumped as to why.
Here''s an abbreviated version of my main() func:
int main( int argc, char* argv[] )
{
// SDL setup stuff here...
// Set up OpenGL
float ratio = (float) width / (float) height;
glShadeModel( GL_SMOOTH );
glCullFace( GL_BACK );
glFrontFace( GL_CCW );
glEnable( GL_CULL_FACE );
glEnable( GL_TEXTURE_2D );
glClearColor( 0, 0, 0, 0 );
glViewport( 0, 0, width, height );
glMatrixMode( GL_PROJECTION );
glLoadIdentity( );
gluPerspective( 60.0, ratio, 1.0, 1024.0 );
// initialize the game board
GameBoard.init( 1 );
// message loop here..
}
And here''s GameBoard::init()
void ShuffleBoard::init( int diff )
{
// set difficully
if( diff < 0 ) diff = 0;
if( diff > 4 ) diff = 4;
difficulty = diff;
// Generate all texture objects
glGenTextures(10, textureNames);
int width, height;
glBindTexture(GL_TEXTURE_2D, textureNames[0]);
blockTex[0] = LoadBitmapFile("box1.bmp", &width, &height);
if( blockTex[0] == NULL )
printf("Something happened in LoadBitmapFile!\n");
else
{
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); // linear magnification
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); // linear minification
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, blockTex[0]);
}
return;
}
I''ve left out and abbreviated some of the stuff that I think is unimportant. I can post full versions if this turns out to be not enough though.
The code is crashing on glTexImage2D(). I''ve confirmed that LoadBitmapFile() is doing its job correctly, width and height are both set to 128 (the correct numbers for the bitmap) by loadBitmapFile() and blockTex[0] is a pointer to an unsigned char array of size 128*128 that contains all the bitmap data. So everything -looks- good to me.
Any ideas of what I a) forgot to do, or b) am doing wrong?