Simple texture class

BlitzMax Forums/BlitzMax OpenGL Programming/Simple texture class

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

I have to ask what's up with that as well...

That really doesn't make any sense to me, as Load would prove far more useful as a static function. And making it like so would work better because then it doesn't always have to be an unloaded file, it could be a existing TStream, string, or any other type.

Method Load(url:Object)
	
	' Attempt To load image
	TextureImage:TPixmap=LoadPixmap(url)
	
	' Save dimensions for later
	Width=TextureImage.Width
	Height=TextureImage.Height
	
	' Create GL texture
	glGenTextures 1, Varptr TexID
	
	' Bind it first
	Bind()

	' Enable bilinear filtering
	glTexParameteri GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR
	glTexParameteri GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR
	
	' Create actual texture
	glTexImage2D GL_TEXTURE_2D, 0, 3, Width, Height, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage.pixels
	
	' Flag texture as unused so the garbage collector can do it's thing
	TextureImage = Null
	
	' Save filename for later
	Self.FileName = FileName

EndMethod