Class Texture

D class that wraps SDL_Texture storing textures in the VRAM

class Texture ;

dsdl2.Texture stores a 2D image out of pixels with a width and height, where each pixel stored in the GPU RAM (VRAM) according to its defined dsdl2.PixelFormat. A dsdl2.Texture is associated with its dsdl2.Renderer, and can only be operated with/by it.

Constructors

NameDescription
this (sdlTexture, isOwner, userRef) Constructs a dsdl2.Texture from a vanilla SDL_Texture* from bindbc-sdl
this (renderer, pixelFormat, access, size) Creates a blank dsdl2.Texture in the VRAM, which wraps SDL_CreateTexture
this (renderer, surface) Creates a dsdl2.Texture in the VRAM from a dsdl2.Surface, which wraps SDL_CreateTextureFromSurface

Fields

NameTypeDescription
sdlTexture sdl.render.SDL_Texture*Internal SDL_Texture pointer

Properties

NameTypeDescription
access[get] TextureAccessWraps SDL_QueryTexture which gets the dsdl2.TextureAccess of the dsdl2.Texture
alphaMod[get] ubyteWraps SDL_GetTextureAlphaMod which gets the alpha multiplier of the dsdl2.Texture
alphaMod[set] ubyteWraps SDL_SetTextureAlphaMod which sets the alpha multiplier of the dsdl2.Texture
blendMode[get] BlendModeWraps SDL_GetTextureBlendMode which gets the dsdl2.Texture's dsdl2.BlendMode defining drawing
blendMode[set] BlendModeWraps SDL_SetTextureBlendMode which sets the dsdl2.Texture's dsdl2.BlendMode defining drawing
colorMod[get] ubyte[3]Wraps SDL_GetTextureColorMod which gets the color multipliers of the dsdl2.Texture
colorMod[set] ubyte[3]Wraps SDL_SetTextureColorMod which sets the color multipliers of the dsdl2.Texture
height[get] uintWraps SDL_QueryTexture which gets the height of the dsdl2.Texture in pixels
mod[get] ColorGets the color and alpha multipliers of the dsdl2.Texture that wraps SDL_GetTextureColorMod and SDL_GetTextureAlphaMod
mod[set] ColorSets the color and alpha multipliers of the dsdl2.Texture that wraps SDL_SetTextureColorMod and SDL_SetTextureAlphaMod
pixelFormat[get] const(PixelFormat)Wraps SDL_QueryTexture which gets the dsdl2.PixelFormat of the dsdl2.Texture
scaleMode[get] ScaleModeWraps SDL_GetTextureScaleMode (from SDL 2.0.12) which gets the texture's scaling mode
scaleMode[set] ScaleModeWraps SDL_SetTextureScaleMode (from SDL 2.0.12) which sets the texture's scaling mode
size[get] uint[2]Wraps SDL_QueryTexture which gets the size of the dsdl2.Texture in pixels
width[get] uintWraps SDL_QueryTexture which gets the width of the dsdl2.Texture in pixels

Methods

NameDescription
bindGL () Wraps SDL_GL_BindTexture which binds the texture in OpenGL
opEquals (rhs) Equality operator overload
toHash () Gets the hash of the dsdl2.Texture
toString () Formats the dsdl2.Texture into its construction representation: "dsdl2.Texture(<sdlTexture>)"
unbindGL () Wraps SDL_GL_UnbindTexture which unbinds the texture in OpenGL
update (pixels, pitch) Wraps SDL_UpdateTexture which updates the entire dsdl2.Texture's pixel data
update (rect, pixels, pitch) Wraps SDL_UpdateTexture which updates the dsdl2.Texture's pixel data at a certain dsdl2.Rect boundary

Example

auto renderer = new dsdl2.Renderer(...);
auto surface = new dsdl2.Surface(...);

auto texture = new dsdl2.Texture(renderer, surface);