Computer Science Canada

Help binding PCX textures in openGL with SDL

Author:  CodeMonkey2000 [ Tue Apr 08, 2008 4:21 pm ]
Post subject:  Help binding PCX textures in openGL with SDL

I'm trying to load pcx images into openGL, but I keep getting an error. I'm using SDL_Image to load my pcx file, and it has no problems loading it. But when I try to generate the 2D image in openGL I get a runtime error. It can load bmp and png with no problems.
Here is where the program crashes (used a bunch of SDL_Delay(10000) to find it):
cplusplus:

glTexImage2D( GL_TEXTURE_2D, 0, 3,
                    TextureImage->w,
                    TextureImage->h,
                    0, GL_BGR,
                    GL_UNSIGNED_BYTE,
                    TextureImage->pixels );


Here is the function in general. texture is a member of MD2Model.
cplusplus:
void MD2Model::loadTexture( char* name)
{
    SDL_Surface *TextureImage;
    TextureImage=IMG_Load(name);
    if (TextureImage!=NULL)
    {
            glGenTextures( 1, &texture);
            glBindTexture( GL_TEXTURE_2D, texture);

            glTexImage2D( GL_TEXTURE_2D, 0, 3,
                    TextureImage->w,
                    TextureImage->h,
                    0, GL_BGR,
                    GL_UNSIGNED_BYTE,
                    TextureImage->pixels );

            glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
            glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
    }
    SDL_FreeSurface( TextureImage);
}

Author:  asd [ Wed Apr 09, 2008 10:14 am ]
Post subject:  RE:Help binding PCX textures in openGL with SDL

how about that runtime error then? is your SDL_image library compiled with PCX support?

Author:  CodeMonkey2000 [ Wed Apr 09, 2008 10:17 am ]
Post subject:  RE:Help binding PCX textures in openGL with SDL

The runtime error returns 3. SDL_Image supports pcx files, I displayed them before on SDL_SURFACE to makesure.

Author:  md [ Wed Apr 09, 2008 10:37 am ]
Post subject:  RE:Help binding PCX textures in openGL with SDL

Run time error 3 doesn't really help much - you need to turn the number into an error message.


: