SenOGL  0.2
Library aiming to ease the use of OpenGL
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
Texture Class Referenceabstract

Describes a texture living on the GPU's memory. More...

#include <Texture.hpp>

Inheritance diagram for Texture:
OpenGLObject CubeMap Texture2D Texture3D

Classes

class  Binder
 Scoped texture Binder. More...
 

Public Types

enum  Parameter : GLenum {
  Parameter::DepthStencilMode = GL_DEPTH_STENCIL_TEXTURE_MODE, Parameter::BaseLevel = GL_TEXTURE_BASE_LEVEL, Parameter::SwizzleR = GL_TEXTURE_SWIZZLE_R, Parameter::SwizzleG = GL_TEXTURE_SWIZZLE_G,
  Parameter::SwizzleB = GL_TEXTURE_SWIZZLE_B, Parameter::SwizzleA = GL_TEXTURE_SWIZZLE_A, Parameter::MinFilter = GL_TEXTURE_MIN_FILTER, Parameter::MagFilter = GL_TEXTURE_MAG_FILTER,
  Parameter::MinLoD = GL_TEXTURE_MIN_LOD, Parameter::MaxLoD = GL_TEXTURE_MAX_LOD, Parameter::LoDBias = GL_TEXTURE_LOD_BIAS, Parameter::WrapS = GL_TEXTURE_WRAP_S,
  Parameter::WrapT = GL_TEXTURE_WRAP_T, Parameter::WrapR = GL_TEXTURE_WRAP_R, Parameter::BorderColor = GL_TEXTURE_BORDER_COLOR, Parameter::CompareMode = GL_TEXTURE_COMPARE_MODE,
  Parameter::CompareFunc = GL_TEXTURE_COMPARE_FUNC
}
 
enum  PixelType : GLenum { PixelType::UnsignedByte = GL_UNSIGNED_BYTE, PixelType::UnsignedShort565 = GL_UNSIGNED_SHORT_5_6_5, PixelType::UnsignedShort4444 = GL_UNSIGNED_SHORT_4_4_4_4, PixelType::UnsignedShort5551 = GL_UNSIGNED_SHORT_5_5_5_1 }
 

Public Member Functions

 Texture (PixelType pixelType=PixelType::UnsignedByte)
 
 Texture (PixelType pixelType, GLuint handle)
 
 Texture (const Texture &)=default
 
 Texture (Texture &&)=default
 
Textureoperator= (const Texture &)=default
 
Textureoperator= (Texture &&)=default
 
virtual ~Texture ()
 
virtual void init () override
 Generates a OpenGL object name to manage. More...
 
virtual void cleanup () override
 Deletes the managed OpenGL object. More...
 
virtual void bind (unsigned int unit=0) const
 
virtual void unbind (unsigned int unit=0) const
 
virtual bool isValid () const override
 Returns true if the object seems valid. More...
 
template<typename T >
void set (Parameter opt, T value) const
 
template<typename T >
void setI (Parameter opt, T value) const
 
void generateMipmaps () const
 
virtual void bindImage (GLuint unit, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format) const
 TODO. More...
 
virtual GLuint getBound (unsigned int unit=0) const =0
 
virtual void dump (const std::string &path) const
 Saves the texture as a png at path. More...
 
- Public Member Functions inherited from OpenGLObject
 OpenGLObject ()
 
 OpenGLObject (GLuint handle)
 Constructs a instance managing an existing OpenGL Object. More...
 
 OpenGLObject (const OpenGLObject &)=default
 
 OpenGLObject (OpenGLObject &&)=default
 
OpenGLObjectoperator= (const OpenGLObject &)=default
 
OpenGLObjectoperator= (OpenGLObject &&)=default
 
virtual ~OpenGLObject ()
 
GLuint getName () const
 Returns OpenGL name of the object. More...
 
void setName (GLuint n)
 Sets the OpenGL name of the object managed by this instance /!\ Use with caution ! (assignment operator is probably what you're looking for) More...
 
 operator bool () const
 Syntactic sugar for isValid(). More...
 

Static Public Member Functions

static void activeUnit (unsigned int unit)
 

Protected Member Functions

virtual GLenum getType () const =0
 

Static Protected Member Functions

static bool isTexture (GLuint name)
 
static GLenum getFormat (GLuint compCount)
 
static GLuint getCompCount (GLenum format)
 

Protected Attributes

PixelType _pixelType = PixelType::UnsignedByte
 
- Protected Attributes inherited from OpenGLObject
GLuint _handle
 OpenGL name of the managed object. More...
 

Detailed Description

Describes a texture living on the GPU's memory.

Todo:

Store more information about the managed texture (type, format...) in order to provide easier use (image binding for example).

Use Sampler class ?

Parameter value enums

Member Enumeration Documentation

enum Texture::Parameter : GLenum
strong
Enumerator
DepthStencilMode 
BaseLevel 
SwizzleR 
SwizzleG 
SwizzleB 
SwizzleA 
MinFilter 
MagFilter 
MinLoD 
MaxLoD 
LoDBias 
WrapS 
WrapT 
WrapR 
BorderColor 
CompareMode 
CompareFunc 
enum Texture::PixelType : GLenum
strong
Enumerator
UnsignedByte 
UnsignedShort565 
UnsignedShort4444 
UnsignedShort5551 

Constructor & Destructor Documentation

Texture::Texture ( PixelType  pixelType = PixelType::UnsignedByte)
Texture::Texture ( PixelType  pixelType,
GLuint  handle 
)
Texture::Texture ( const Texture )
default
Texture::Texture ( Texture &&  )
default
Texture::~Texture ( )
virtual

Member Function Documentation

static void Texture::activeUnit ( unsigned int  unit)
inlinestatic
virtual void Texture::bind ( unsigned int  unit = 0) const
inlinevirtual

Reimplemented in CubeMap, Texture2D, and Texture3D.

void Texture::bindImage ( GLuint  unit,
GLint  level,
GLboolean  layered,
GLint  layer,
GLenum  access,
GLenum  format 
) const
virtual

TODO.

void Texture::cleanup ( )
overridevirtual

Deletes the managed OpenGL object.

Implements OpenGLObject.

void Texture::dump ( const std::string &  path) const
virtual

Saves the texture as a png at path.

Parameters
pathPath of the created file.

Reimplemented in CubeMap.

void Texture::generateMipmaps ( ) const
virtual GLuint Texture::getBound ( unsigned int  unit = 0) const
pure virtual
Parameters
unitTexture unit
Returns
Currently bound texture at unit.

Implemented in CubeMap, Texture2D, and Texture3D.

GLuint Texture::getCompCount ( GLenum  format)
staticprotected
GLenum Texture::getFormat ( GLuint  compCount)
staticprotected
virtual GLenum Texture::getType ( ) const
protectedpure virtual
void Texture::init ( )
overridevirtual

Generates a OpenGL object name to manage.

Implements OpenGLObject.

static bool Texture::isTexture ( GLuint  name)
inlinestaticprotected
virtual bool Texture::isValid ( ) const
inlineoverridevirtual

Returns true if the object seems valid.

Can be overloaded for concrete types if there is other attributes to test.

Reimplemented from OpenGLObject.

Texture& Texture::operator= ( const Texture )
default
Texture& Texture::operator= ( Texture &&  )
default
template<typename T >
void Texture::set ( Parameter  opt,
value 
) const
inline
template<typename T >
void Texture::setI ( Parameter  opt,
value 
) const
inline
virtual void Texture::unbind ( unsigned int  unit = 0) const
inlinevirtual

Reimplemented in CubeMap, Texture2D, and Texture3D.

Member Data Documentation

PixelType Texture::_pixelType = PixelType::UnsignedByte
protected

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