I’ve got a problem. I am using PhotoShop to add an Alpha channel to a bitmap and saving as RAW ( 0 size header, including alpha, interleaved.). This all works OK but when I load and texture stuff with it in Delphi, I just get a garbled image. I’ve checked the image dimensions, and they are OK.
Below is the relevant code I’m using.
PTexture = ^TgloveTexture ;
TTexture = record
width, height, bytes : integer ;
data : Pointer ;
end ;
function LoadTextureRaw ( filename : string ; w,h : integer ) : Cardinal ;
var
ptr : PTexture ;
tex : GLUint ;
fp : FILE of BYTE ;
resultInt : Integer ;
begin
tex := -1 ;
NEW ( ptr ) ;
if ( ptr <> nil ) then
begin
ptr ^. width := w ;
ptr ^. height := h ;
ptr ^. bytes := 4 ; // R,G,B & A componants
ptr ^. data := nil ;
GetMem ( ptr ^. data, ( w*h*4) ) ;
if ( ptr^.data <> nil ) then
begin
AssignFile ( fp, filename ) ;
Reset ( fp ) ;
BlockRead ( fp, ptr ^. data, ( w*h*4 ) , resultInt ) ;
CloseFile ( fp ) ;
glGenTextures(1, tex);
glBindTexture(GL_TEXTURE_2D, tex);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, ptr^.bytes, ptr ^. width, ptr^.height, 0, GL_RGBA, GL_UNSIGNED_BYTE, ptr^.data );
end ;
end ;
LoadTextureRaw := tex ;
end ;
I then use the return texture variable (tex) to texture my polygons. BTW, the code for texturing the polys has not changed from when it works using a normal load of a bitmap (using the GLAUX routine).
Any ideas?
Thanks.