Dgame.Graphic.Texture

« Go back

Bottom


struct Texture;
A Texture is a 2 dimensional pixel reprasentation. It is a wrapper of an OpenGL Texture.

Author:
Randy Schuett (rswhite4@googlemail.com)

enum Format: int;
Supported Texture Format

None
Take this if you want to declare that you give no Format.

RGB
Alias for GL_RGB

RGBA
Alias for GL_RGBA

BGR
Alias for GL_BGR

BGRA
Alias for GL_BGRA

RGB8
8 Bit RGB Format

RGB16
16 Bit RGB Format

RGBA8
8 Bit RGBA Format

RGBA16
16 Bit RGBA Format

Alpha
Alias for GL_ALPHA

Luminance
Alias for GL_LUMINANCE

LuminanceAlpha
Alias for GL_LUMINANCE_ALPHA

nothrow @nogc this(void* memory, uint width, uint height, Format fmt);
CTor

nothrow @nogc this()(auto ref const Surface srfc, Format fmt = Format.None);
CTor

static nothrow @nogc int currentlyBound();
Returns the currently bound texture id.

const pure nothrow @nogc @property uint ID();
Returns the Texture Id.

const pure nothrow @nogc bool isValid();
Returns if the texture is used.

const pure nothrow @nogc @property uint width();
Returns the width of this Texture

const pure nothrow @nogc @property uint height();
Returns the height of this Texture.

const pure nothrow @nogc @property ubyte depth();
Returns the depth. May often 24 or 32.

const pure nothrow @nogc @property Format format();
Returns the Format.

See:
Format enum.

const nothrow @nogc void bind();
Binds this Texture. Means this Texture is now activated.

const nothrow @nogc void unbind();
Binds this Texture. Means this Texture is now deactivated.

const nothrow @nogc bool isCurrentlyBound();
Returns true, if this Texture is currently activated.

nothrow @nogc void setSmooth(bool smooth);
Set smooth filter.

const pure nothrow @nogc bool isSmooth();
Returns if smooth filter are activated.

nothrow @nogc void setRepeat(bool repeat);
Set repeating.

const pure nothrow @nogc bool isRepeated();
Returns if repeating is enabled.

nothrow @nogc void loadFrom()(auto ref const Surface srfc, Format fmt = Format.None);
Load from Surface

nothrow @nogc void loadFromMemory(const void* memory, uint width, uint height, Format fmt);
Load from memory.

nothrow @nogc void setColorkey()(auto ref const Color4b colorkey);
Set a colorkey.

const pure nothrow @nogc size_t getByteSize();
Returns the byte size of the Texture

const nothrow @nogc void[] getPixels(void[] pixels);
Returns the pixel data of this Texture or null if this Texture isn't valid. pixels is used to store the pixel data.

const nothrow void[] getPixels();
Returns the pixel of this Texture or null if this Texture isn't valid.

Note:
this method allocates GC memory.

const nothrow @nogc void update(const void* memory, const Rect* rect = null, Format fmt = Format.None);
Update the pixel data of this Texture. The second parameter is a pointer to the area which is updated. If it is null (default) the whole Texture will be updated. The third parameter is the format of the pixels.

pure nothrow @nogc ubyte formatToBits(Texture.Format fmt);
Format a Texture.Format into the related bit count. If the format is not supported, it returns 0.

Examples:
assert(formatToBits(Texture.Format.RGBA) == 32);
assert(formatToBits(Texture.Format.RGB) == 24);
assert(formatToBits(Texture.Format.BGRA) == 32);
assert(formatToBits(Texture.Format.BGR) == 24);


pure nothrow @nogc Texture.Format bitsToFormat(ubyte bits, bool reverse = false);
Format a bit count into the related Texture.Format. If no bit count is supported, it returns Texture.Format.None.

Examples:
assert(bitsToFormat(32) == Texture.Format.RGBA);
assert(bitsToFormat(24) == Texture.Format.RGB);
assert(bitsToFormat(32, true) == Texture.Format.BGRA);
assert(bitsToFormat(24, true) == Texture.Format.BGR);


pure nothrow @nogc Texture.Format switchFormat(Texture.Format fmt, bool alpha = false);
Switch/Reverse Texture.Format.

Examples:
assert(switchFormat(Texture.Format.RGB) == Texture.Format.BGR);
assert(switchFormat(Texture.Format.RGB, true) == Texture.Format.BGRA);
assert(switchFormat(Texture.Format.RGBA) == Texture.Format.BGRA);
assert(switchFormat(Texture.Format.RGBA, true) == Texture.Format.BGRA);



Page generated by Ddoc.

» Dgame.Graphic.Texture on Github

Top

« Go back