Loading TGAs with SDL+SDLImage+OpenGL
I'm with troubles loading TGAs with transparency(Alpha channel), using SDL + OpenGL and SDLImage to load the TGA(Since SDL only loads bmp).
The image loads, but it's been disfigurated? The colors become crazy or someting... Only using the SDL to display the image with the SDLsurface, the image looks great. But using a OpenGL surface, becomes crazy. What happens?
Look at:
http://geocities.yahoo.com.br/megaspeedlinux/snap.jpg
show yours glTexImage2D call. it looks like you are using GL_RGB for its format parameter, instead of GL_RGBA or GL_BGRA...
Dolphins - The sharks of the sea.
OK! That's it.
But the image do'nt show the alpha.
The rose color is a alpha channel, but is showing?
Look at:
http://geocities.yahoo.com.br/megaspeedlinux/snap1.jpg
But the image do'nt show the alpha.
The rose color is a alpha channel, but is showing?
Look at:
http://geocities.yahoo.com.br/megaspeedlinux/snap1.jpg
Are you using blending? Without it, the alpha won't be used.
Try glEnable(GL_BLEND); and glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); for example.
Try glEnable(GL_BLEND); and glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); for example.
Wow! That's great! Works very well. Thank you!!
Result:
http://geocities.yahoo.com.br/megaspeedlinux/snap2.jpg
Result:
http://geocities.yahoo.com.br/megaspeedlinux/snap2.jpg
Strange... I tried now with other image(a bit different), but the image don't load correctly
-> http://geocities.yahoo.com.br/megaspeedlinux/img.tga.zip
This is the image i'm trying to load, and i'm using like said:
glEnable( GL_BLEND );
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
and...
glTranslatef( -0.578f, 0.2f, -1.4f );
glBindTexture( GL_TEXTURE_2D, texture[72] );
glBegin(GL_QUADS);
glTexCoord2f( 0.0f, 1.0f ); glVertex3f( -0.11f, -0.11f, 0.0f );
glTexCoord2f( 1.0f, 1.0f ); glVertex3f( 0.11f, -0.11f, 0.0f );
glTexCoord2f( 1.0f, 0.0f ); glVertex3f( 0.11f, 0.1f, 0.0f );
glTexCoord2f( 0.0f, 0.0f ); glVertex3f( -0.11f, 0.1f, 0.0f );
glEnd( );
Works for the other textures, but not for that. What is wrong?
-> http://geocities.yahoo.com.br/megaspeedlinux/img.tga.zip
This is the image i'm trying to load, and i'm using like said:
glEnable( GL_BLEND );
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
and...
glTranslatef( -0.578f, 0.2f, -1.4f );
glBindTexture( GL_TEXTURE_2D, texture[72] );
glBegin(GL_QUADS);
glTexCoord2f( 0.0f, 1.0f ); glVertex3f( -0.11f, -0.11f, 0.0f );
glTexCoord2f( 1.0f, 1.0f ); glVertex3f( 0.11f, -0.11f, 0.0f );
glTexCoord2f( 1.0f, 0.0f ); glVertex3f( 0.11f, 0.1f, 0.0f );
glTexCoord2f( 0.0f, 0.0f ); glVertex3f( -0.11f, 0.1f, 0.0f );
glEnd( );
Works for the other textures, but not for that. What is wrong?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement