technomage
22-01-2005, 06:44 PM
Hi
Ive; written some code to load a tga file using SDL_Image and then produce a opengl texture from that. The problem I'm getting this that the alpha channel doens't seem to be coming through. the I render with the Blend functions off the texture renders OK , but with blending all I get is a black screen. :?
Here is the code
Surface:= nil;
TempSurface := IMG_Load(PChar(Filename));
if TempSurface <> nil then
begin
SDL_FlipRectV(TempSurface, nil); // so the texture isn't upside down
Surface := SDL_CreateRGBSurface(SDL_SWSURFACE, Width, Height, TempSurface.format.BitsPerPixel,
TempSurface.format.RMask,TempSurface.format.GMask, TempSurface.format.BMask,TempSurface.format.AMask) ;
SDL_BlitSurface(TempSurface, nil, Surface, nil);
SDL_FreeSurface(TempSurface);
glEnable(GL_TEXTURE_2D);
glGenTextures(1, @FTextureID);
glBindTexture(GL_TEXTURE_2D, FTextureID);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, Width, Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, Surface.pixels);
end;
I keep the surface around becuase I will probably update is everynow and then and refresh the texture.
Can any one see any obvious problems?
Dean
Ive; written some code to load a tga file using SDL_Image and then produce a opengl texture from that. The problem I'm getting this that the alpha channel doens't seem to be coming through. the I render with the Blend functions off the texture renders OK , but with blending all I get is a black screen. :?
Here is the code
Surface:= nil;
TempSurface := IMG_Load(PChar(Filename));
if TempSurface <> nil then
begin
SDL_FlipRectV(TempSurface, nil); // so the texture isn't upside down
Surface := SDL_CreateRGBSurface(SDL_SWSURFACE, Width, Height, TempSurface.format.BitsPerPixel,
TempSurface.format.RMask,TempSurface.format.GMask, TempSurface.format.BMask,TempSurface.format.AMask) ;
SDL_BlitSurface(TempSurface, nil, Surface, nil);
SDL_FreeSurface(TempSurface);
glEnable(GL_TEXTURE_2D);
glGenTextures(1, @FTextureID);
glBindTexture(GL_TEXTURE_2D, FTextureID);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, Width, Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, Surface.pixels);
end;
I keep the surface around becuase I will probably update is everynow and then and refresh the texture.
Can any one see any obvious problems?
Dean