C# Class TexLib.TexUtil

The TexUtil class is released under the MIT-license. /Olof Bjarnason
Mostra file Open project: LukaHorvat/Kento

Public Methods

Method Description
CreateRGBATexture ( int width, int height, byte rgba ) : int

Create a translucent OpenGL texture object from given byte-array of r,g,b,a-triplets. See CreateRGBTexture for more info.

CreateRGBTexture ( int width, int height, byte rgb ) : int

Create an opaque OpenGL texture object from a given byte-array of r,g,b-triplets. Make sure width and height is 1, 2, .., 32, 64, 128, 256 and so on in size since all 3d graphics cards support those dimensions. Not necessarily square. Don't forget to call GL.DeleteTexture(int) when you don't need the texture anymore (eg. when switching levels in your game).

CreateTextureFromBitmap ( Bitmap bitmap ) : int

Create an OpenGL texture (translucent or opaque) from a given Bitmap. 24- and 32-bit bitmaps supported.

CreateTextureFromFile ( string path ) : int

Create an OpenGL texture (translucent or opaque) by loading a bitmap from file. 24- and 32-bit bitmaps supported.

InitTexturing ( ) : void

Initialize OpenGL state to enable alpha-blended texturing. Disable again with GL.Disable(EnableCap.Texture2D). Call this before drawing any texture, when you boot your application, eg. in OnLoad() of GameWindow or Form_Load() if you're building a WinForm app.

Private Methods

Method Description
CreateTexture ( int width, int height, bool alpha, byte bytes ) : int
GiveMeATexture ( ) : int
SetParameters ( ) : void
Upload ( int width, int height, bool alpha, byte bytes ) : void

Method Details

CreateRGBATexture() public static method

Create a translucent OpenGL texture object from given byte-array of r,g,b,a-triplets. See CreateRGBTexture for more info.
public static CreateRGBATexture ( int width, int height, byte rgba ) : int
width int
height int
rgba byte
return int

CreateRGBTexture() public static method

Create an opaque OpenGL texture object from a given byte-array of r,g,b-triplets. Make sure width and height is 1, 2, .., 32, 64, 128, 256 and so on in size since all 3d graphics cards support those dimensions. Not necessarily square. Don't forget to call GL.DeleteTexture(int) when you don't need the texture anymore (eg. when switching levels in your game).
public static CreateRGBTexture ( int width, int height, byte rgb ) : int
width int
height int
rgb byte
return int

CreateTextureFromBitmap() public static method

Create an OpenGL texture (translucent or opaque) from a given Bitmap. 24- and 32-bit bitmaps supported.
public static CreateTextureFromBitmap ( Bitmap bitmap ) : int
bitmap System.Drawing.Bitmap
return int

CreateTextureFromFile() public static method

Create an OpenGL texture (translucent or opaque) by loading a bitmap from file. 24- and 32-bit bitmaps supported.
public static CreateTextureFromFile ( string path ) : int
path string
return int

InitTexturing() public static method

Initialize OpenGL state to enable alpha-blended texturing. Disable again with GL.Disable(EnableCap.Texture2D). Call this before drawing any texture, when you boot your application, eg. in OnLoad() of GameWindow or Form_Load() if you're building a WinForm app.
public static InitTexturing ( ) : void
return void