Hi. I just threw together a quick texture class as my first BMX project. Use as you please :)
Just throw it in a file named Texture.bmx and Import it at the top of your source file.
Now you can create and load a texture like so.
And then you simply bind it before drawing your 3D model.
Oh and I'm a new user BTW but have a long record as a professional game programmer on both PC, Playstation and Mac using all from assembler, over C/C++ to Java.
I'm hoping to contribute some nice OOP based classes for my own prototyping amusement in BlitzMax and possibly do a few simple games for fun :)
Oh yeah. Just ask me any question about game programming, OpenGL etc. If I have the time, I'm always up for a chat :)
' Simple texture class by Odin Jensen (http://www.furi.dk) ' Free to use for all purposes :) Type Texture ' Texture dimensions Field Width:Int Field Height:Int ' Texture name Field FileName:String ' Texture OpenGL ID Field TexID:Int ' Load texture Method Load(FileName:String) ' Attempt To load image TextureImage:TPixmap=LoadPixmap(FileName) ' 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 ' Bind texture (Call before drawing) Method Bind() glBindTexture GL_TEXTURE_2D, TexID EndMethod EndType
Just throw it in a file named Texture.bmx and Import it at the top of your source file.
Now you can create and load a texture like so.
MyTex:Texture MyTex=new Texture MyTex.Load("MyTex.tga")
And then you simply bind it before drawing your 3D model.
MyTex.Bind()
Oh and I'm a new user BTW but have a long record as a professional game programmer on both PC, Playstation and Mac using all from assembler, over C/C++ to Java.
I'm hoping to contribute some nice OOP based classes for my own prototyping amusement in BlitzMax and possibly do a few simple games for fun :)
Oh yeah. Just ask me any question about game programming, OpenGL etc. If I have the time, I'm always up for a chat :)