Allolib  1.0
C++ Components For Interactive Multimedia
al::Texture Class Reference

#include <C:/Users/Andres/source/repos/casm_viewer/external/tinc/external/allolib/include/al/graphics/al_Texture.hpp>

Inheritance diagram for al::Texture:
al::GPUObject

Public Types

enum  DataType : unsigned int {
  BYTE = GL_BYTE , UBYTE = GL_UNSIGNED_BYTE , SHORT = GL_SHORT , USHORT = GL_UNSIGNED_SHORT ,
  INT = GL_INT , UINT = GL_UNSIGNED_INT , FLOAT = GL_FLOAT , DOUBLE = GL_DOUBLE
}
 
enum  Target : unsigned int {
  TEX_1D = GL_TEXTURE_1D , TEX_2D = GL_TEXTURE_2D , TEX_3D = GL_TEXTURE_3D , TEX_1D_ARRAY = GL_TEXTURE_1D_ARRAY ,
  TEX_2D_ARRAY = GL_TEXTURE_2D_ARRAY , TEX_RECTANGLE = GL_TEXTURE_RECTANGLE , TEX_CUBE_MAP = GL_TEXTURE_CUBE_MAP , TEX_BUFFER = GL_TEXTURE_BUFFER ,
  TEX_2D_MULTISAMPLE = GL_TEXTURE_2D_MULTISAMPLE , TEX_2D_MULTISAMPLE_ARRAY = GL_TEXTURE_2D_MULTISAMPLE_ARRAY , NO_TARGET = 0
}
 
enum  Wrap : int { CLAMP_TO_EDGE = GL_CLAMP_TO_EDGE , CLAMP_TO_BORDER = GL_CLAMP_TO_BORDER , MIRRORED_REPEAT = GL_MIRRORED_REPEAT , REPEAT = GL_REPEAT }
 
enum  Filter : int {
  NEAREST = GL_NEAREST , LINEAR = GL_LINEAR , NEAREST_MIPMAP_NEAREST = GL_NEAREST_MIPMAP_NEAREST , LINEAR_MIPMAP_NEAREST = GL_LINEAR_MIPMAP_NEAREST ,
  NEAREST_MIPMAP_LINEAR = GL_NEAREST_MIPMAP_LINEAR , LINEAR_MIPMAP_LINEAR = GL_LINEAR_MIPMAP_LINEAR
}
 
enum  Format : unsigned int {
  RED = GL_RED , RG = GL_RG , RGB = GL_RGB , BGR = GL_BGR ,
  RGBA = GL_RGBA , BGRA = GL_BGRA , DEPTH_COMPONENT = GL_DEPTH_COMPONENT , DEPTH_STENCIL = GL_DEPTH_STENCIL
}
 
enum  Internal : int {
  RGBA32F = GL_RGBA32F , RGBA16 = GL_RGBA16 , RGBA16F = GL_RGBA16F , RGBA8 = GL_RGBA8 ,
  SRGB8_ALPHA8 = GL_SRGB8_ALPHA8 , RG32F = GL_RG32F , RG16 = GL_RG16 , RG16F = GL_RG16F ,
  RG8 = GL_RG8 , R32F = GL_R32F , R16F = GL_R16F , R8 = GL_R8 ,
  RGB32F = GL_RGB32F , RGB16F = GL_RGB16F , RGB16 = GL_RGB16 , RGB8 = GL_RGB8 ,
  SRGB8 = GL_SRGB8 , DEPTH_COMPONENT32F = GL_DEPTH_COMPONENT32F , DEPTH_COMPONENT24 = GL_DEPTH_COMPONENT24 , DEPTH_COMPONENT16 = GL_DEPTH_COMPONENT16 ,
  DEPTH32F_STENCIL8 = GL_DEPTH32F_STENCIL8 , DEPTH24_STENCIL8 = GL_DEPTH24_STENCIL8
}
 

Public Member Functions

void create1D (GLsizei width, GLint internal=GL_RGBA8, GLenum format=GL_RGBA, GLenum type=GL_UNSIGNED_BYTE)
 
void create2D (unsigned int width, unsigned int height, int internal=GL_RGBA8, unsigned int format=GL_RGBA, unsigned int type=GL_UNSIGNED_BYTE)
 
void create2DArray (unsigned int width, unsigned int height, unsigned int depth, int internal=GL_RGBA8, unsigned int format=GL_RGBA, unsigned int type=GL_UNSIGNED_BYTE)
 
void createCubemap (unsigned int size, int internal=GL_RGBA8, unsigned int format=GL_RGBA, unsigned int type=GL_UNSIGNED_BYTE)
 
void bind (int binding_point=0)
 
void bind_temp ()
 
void unbind (int binding_point=0)
 Unbind the texture (from a multitexture unit)
 
void unbind_temp ()
 
unsigned int target () const
 Get target type (e.g., TEXTURE_2D)
 
int internalFormat () const
 Get internal format.
 
unsigned int format () const
 Get pixel (color) format.
 
unsigned int type () const
 Get pixel component data type.
 
unsigned int width () const
 Get width, in pixels.
 
unsigned int height () const
 Get height, in pixels.
 
unsigned int depth () const
 Get depth, in pixels.
 
int filterMin () const
 Get minification filter type.
 
int filterMag () const
 Get magnification filter type.
 
int wrapS () const
 Get S wrapping type.
 
int wrapT () const
 Get T wrapping type.
 
int wrapR () const
 Get R wrapping type.
 
bool mipmap () const
 
void resize (unsigned w)
 Get number of components per pixel. More...
 
bool resize (unsigned int w, unsigned int h, int internal, unsigned int format, unsigned int type)
 Resize 2D texture.
 
bool resize (unsigned int w, unsigned int h)
 
void resize (unsigned w, unsigned h, unsigned d)
 Resize 3D texture.
 
void filter (int v)
 Set minification and magnification filter types all at once.
 
void filterMin (int v)
 Set minification filter type.
 
void filterMag (int v)
 Set magnification filter type.
 
void wrap (int S, int T, int R)
 Set 3D wrapping modes.
 
void wrap (int S, int T)
 Set 2D wrapping modes.
 
void wrap (int v)
 Set wrapping mode for all dimensions.
 
void wrapS (int v)
 
void wrapT (int v)
 
void wrapR (int v)
 
void mipmap (bool b)
 Set whether to generate mipmaps.
 
void submit (const void *pixels, unsigned int format, unsigned int type)
 
void submit (const void *pixels)
 
void generateMipmap ()
 
void disableMipmap ()
 
void copyFrameBuffer (int w=-1, int h=-1, int fbx=0, int fby=0, int texx=0, int texy=0, int texz=0)
 Copy pixels from current frame buffer to texture texels. More...
 
unsigned numComponents () const
 Get number of components per pixel.
 
bool created () const
 Returns whether object has been created.
 
void create ()
 Creates object on GPU.
 
void destroy ()
 Destroys object on GPU.
 
unsigned long id () const
 Returns the assigned object id.
 
void id (unsigned long v)
 
void validate ()
 Ensure that the GPUObject is ready to use. More...
 
void invalidate ()
 Triggers re-creation of object safely.
 

Static Public Member Functions

static void unbind (int binding_point, unsigned int target)
 
static int numComponents (Texture::Format v)
 Returns number of components for given color type.
 

Protected Member Functions

void onCreate () override
 Called when currently assigned context is created.
 
void onDestroy () override
 Called when currently assigned context is destroyed.
 
void update_filter ()
 
void update_wrap ()
 
void update_mipmap ()
 
template<class T >
void update_param (const T &v, T &var, bool &flag)
 

Protected Attributes

unsigned int mTarget = GL_TEXTURE_2D
 
int mInternalFormat = GL_RGBA8
 
unsigned int mWidth = 0
 
unsigned int mHeight = 0
 
unsigned int mDepth = 0
 
unsigned int mFormat = GL_RGBA
 
unsigned int mType = GL_UNSIGNED_BYTE
 
int mWrapS = GL_CLAMP_TO_EDGE
 
int mWrapT = GL_CLAMP_TO_EDGE
 
int mWrapR = GL_CLAMP_TO_EDGE
 
int mFilterMin = GL_NEAREST
 
int mFilterMag = GL_NEAREST
 
bool mUseMipmap = false
 
bool mFilterUpdated = true
 
bool mWrapUpdated = true
 
bool mUsingMipmapUpdated = true
 
unsigned int mID
 
bool mResubmit
 

Detailed Description

A simple wrapper around an OpenGL Texture

Definition at line 90 of file al_Texture.hpp.

Member Function Documentation

◆ bind()

void al::Texture::bind ( int  binding_point = 0)

Bind the texture (to a multitexture unit) also update params and mipmap if changed

◆ bind_temp()

void al::Texture::bind_temp ( )

use last binding point so it doesn't collide with user's binding also bind without updating params

◆ copyFrameBuffer()

void al::Texture::copyFrameBuffer ( int  w = -1,
int  h = -1,
int  fbx = 0,
int  fby = 0,
int  texx = 0,
int  texy = 0,
int  texz = 0 
)

Copy pixels from current frame buffer to texture texels.

Parameters
[in]wwidth of region to copy; w<0 uses w + 1 + texture.width
[in]hheight of region to copy; h<0 uses h + 1 + texture.height
[in]fbxpixel offset from left edge of frame buffer
[in]fbypixel offset from bottom edge of frame buffer
[in]texxtexel offset in x direction
[in]texytexel offset in y direction (2D/3D only)
[in]texztexel offset in z direction (3D only)

◆ resize()

void al::Texture::resize ( unsigned  w)
inline

Get number of components per pixel.

Get total number of elements (components x width x height x depth) Get total number of pixels Resize 1D texture

Definition at line 263 of file al_Texture.hpp.

◆ submit()

void al::Texture::submit ( const void *  pixels,
unsigned int  format,
unsigned int  type 
)

Copy client pixels to GPU texels NOTE: the graphics context (e.g. Window) must have been created If pixels is NULL, then the only effect is to resize the texture remotely.

◆ validate()

void al::GPUObject::validate ( )
inherited

Ensure that the GPUObject is ready to use.

This is typically placed before any rendering implementation. If the object has been invalidated, the object will be destroyed and then created again. Otherwise, the object will simply be created if not already created.


The documentation for this class was generated from the following file: