Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Help binding PCX textures in openGL with SDL
Index -> Programming, C++ -> C++ Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
CodeMonkey2000




PostPosted: 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);
}
Sponsor
Sponsor
Sponsor
sponsor
asd




PostPosted: 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?
CodeMonkey2000




PostPosted: 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.
md




PostPosted: 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.
Display posts from previous:   
   Index -> Programming, C++ -> C++ Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: