yeah, you'd be better to load a pixmap. Also, GLTexFromPixmap can be funny on some intel systems and give an 'Unable to calculate tex size' style error. I use these replacement functions in my games to get around this:
Function TexFromPixmap:Int(pixmap:TPixmap, mipmap:Int = True)
If pixmap.format<>PF_RGBA8888 pixmap=pixmap.Convert( PF_RGBA8888 )
Local width:Int=pixmap.width,height:Int=pixmap.height
AdjustTexSize width,height
If width<>pixmap.width Or height<>pixmap.height pixmap=ResizePixmap( pixmap,width,height )
Local old_name:Int,old_row_len:Int
glGetIntegerv GL_TEXTURE_BINDING_2D,Varptr old_name
glGetIntegerv GL_UNPACK_ROW_LENGTH,Varptr old_row_len
Local Name:Int
glGenTextures 1,Varptr name
glBindtexture GL_TEXTURE_2D,name
Local mip_level:Int
Repeat
glPixelStorei GL_UNPACK_ROW_LENGTH,pixmap.pitch/BytesPerPixel[pixmap.format]
glTexImage2D GL_TEXTURE_2D,mip_level,GL_RGBA8,width,height,0,GL_RGBA,GL_UNSIGNED_BYTE,pixmap.pixels
If Not mipmap Exit
If width=1 And height=1 Exit
If width>1 width:/2
If height>1 height:/2
pixmap=ResizePixmap( pixmap,width,height )
mip_level:+1
Forever
glBindTexture GL_TEXTURE_2D,old_name
glPixelStorei GL_UNPACK_ROW_LENGTH,old_row_len
Return name
End Function
Function AdjustTexSize(Width:Int Var, Height:Int Var)
Function Pow2Size:Int(N:Int)
Local Size:Int
Size = 1
While Size < N
Size = Size Shl 1
Wend
Return Size
End Function
Width = Pow2Size(Width)
Height = Pow2Size(Height)
End Function
Cheers Charlie
|