Jopnal Engine  alpha 0.4
Simple Component Based 2D/3D Game Engine
Public Member Functions | Static Public Member Functions | List of all members
jop::Texture2D Class Reference

#include <Texture2D.hpp>

Inheritance diagram for jop::Texture2D:
jop::Texture jop::Resource jop::SafeReferenceable< Resource > jop::SerializeInfo

Public Member Functions

 Texture2D (const std::string &name)
 Constructor. More...
 
bool load (const std::string &path, const uint32 flags=0)
 Load from file. More...
 
bool load (const void *ptr, const uint32 size, const uint32 flags=0)
 Load from memory. More...
 
bool load (const glm::uvec2 &size, const Format format, const uint32 flags=0)
 Creates flat/empty texture. More...
 
bool load (const glm::uvec2 &size, const Format format, const void *pixels, const uint32 flags=0)
 Create a texture from an array of pixels. More...
 
bool load (const Image &image, const uint32 flags=0)
 Load from a compressed image. More...
 
void setPixels (const glm::uvec2 &start, const glm::uvec2 &size, const void *pixels)
 Set a subset of pixels. More...
 
void setPixels (const glm::uvec2 &start, const Image &image)
 Set a subset of pixels from an image. More...
 
glm::uvec2 getSize () const override
 Get the texture size. More...
 
unsigned int getPixelDepth () const override
 Get the texture pixel depth. More...
 
Image getImage () const
 Copy the texture into an image. More...
 
- Public Member Functions inherited from jop::Texture
 Texture (const std::string &name, const unsigned int glTarget)
 Constructor. More...
 
virtual ~Texture () override=0
 Virtual destructor. More...
 
void destroy ()
 Destroy this texture, erasing it from video memory. More...
 
bool bind (const unsigned int texUnit=0) const
 Bind this texture. More...
 
void unbind (const unsigned int texUnit=0) const
 Unbind a current texture. More...
 
bool isValid () const
 Check if this texture is valid. More...
 
void setSampler (const TextureSampler &sampler)
 Set a texture sampler. More...
 
void removeSampler ()
 Remove the bound texture sampler. More...
 
const TextureSamplergetSampler () const
 Get the currently bound sampler. More...
 
TexturesetFilterMode (const TextureSampler::Filter mode, const float param=1.f)
 Set the filtering mode. More...
 
TexturesetRepeatMode (const TextureSampler::Repeat repeat)
 Set the repeating mode. More...
 
TexturesetBorderColor (const Color &color)
 Set the border color. More...
 
TextureSampler::Filter getFilterMode () const
 Get the filtering mode. More...
 
TextureSampler::Repeat getRepeatMode () const
 Get the repeating mode. More...
 
float getAnisotropyLevel () const
 Get the anisotropy level. More...
 
const ColorgetBorderColor () const
 Get the border color. More...
 
unsigned int getHandle () const
 Get the OpenGL handle for this texture. More...
 
- Public Member Functions inherited from jop::Resource
 Resource (const std::string &name)
 Constructor. More...
 
virtual ~Resource ()=0
 Virtual destructor. More...
 
const std::string & getName () const
 Get the name of this resource. More...
 
void setPersistence (const unsigned short level)
 Set the persistence level. More...
 
unsigned short getPersistence () const
 Get the persistence level. More...
 
- Public Member Functions inherited from jop::SafeReferenceable< Resource >
WeakReference< ResourcegetReference () const
 Get a weak reference to the bound object. More...
 
- Public Member Functions inherited from jop::SerializeInfo
 SerializeInfo ()
 
void setSerializePackage (const uint16 package)
 
uint16 getSerializePackage () const
 
void setShouldSerialize (const bool set)
 
bool shouldSerialize () const
 
void setLightSerializeable (const bool set)
 
bool isLightSerializeable () const
 

Static Public Member Functions

static unsigned int getMaximumSize ()
 Get the maximum supported 2D texture size on this system. More...
 
static Texture2DgetError ()
 Get the error texture. More...
 
static Texture2DgetDefault ()
 Get the default texture. More...
 
- Static Public Member Functions inherited from jop::Texture
static unsigned int getMaxTextureUnits ()
 Get the maximum texture units. More...
 
static void setUnpackAlignment (const Format format)
 Set the pixel store alignment. More...
 
static bool allowSRGB ()
 Check is the sRGB color space is allowed. More...
 
static bool allowGenMipmaps (const glm::uvec2 &size, const bool srgb)
 Check is automatic mipmap generation is allowed. More...
 

Additional Inherited Members

- Public Types inherited from jop::Texture
enum  Format {
  Format::None, Format::Alpha_UB_8, Format::RGB_UB_8, Format::RGBA_UB_8,
  Format::RGB_F_16, Format::RGBA_F_16, Format::Depth_US_16, Format::Depth_UI_24,
  Format::Stencil_UB_8, Format::DepthStencil_UI_24_B_8
}
 
- Protected Member Functions inherited from jop::Texture
void setAlphaSwizzle (const Format format)
 Set the swizzle mask for 8 bit textures. More...
 
- Protected Member Functions inherited from jop::Resource
 Resource (const Resource &other, const std::string &newName)
 Copy constructor. More...
 
- Protected Member Functions inherited from jop::SafeReferenceable< Resource >
 SafeReferenceable (Resource *ref)
 Constructor. More...
 
 SafeReferenceable (SafeReferenceable< Resource > &&other)
 Move constructor. More...
 
SafeReferenceableoperator= (SafeReferenceable< Resource > &&other)
 Move assignment operator. More...
 
 ~SafeReferenceable ()
 Protected destructor. More...
 
- Static Protected Member Functions inherited from jop::Texture
static Format getFormatFromDepth (const uint32 depth)
 Get the texture format from pixel depth. More...
 
static unsigned int getDepthFromFormat (const Format format)
 Get the texture pixel depth from format. More...
 
- Protected Attributes inherited from jop::Texture
Format m_format
 Must be filled by derived classes during load() More...
 

Detailed Description

Definition at line 35 of file Texture2D.hpp.

Constructor & Destructor Documentation

jop::Texture2D::Texture2D ( const std::string &  name)

Constructor.

Parameters
nameName of the resource

Member Function Documentation

static Texture2D& jop::Texture2D::getDefault ( )
static

Get the default texture.

Returns
Reference to the texture
static Texture2D& jop::Texture2D::getError ( )
static

Get the error texture.

Returns
Reference to the texture
Image jop::Texture2D::getImage ( ) const

Copy the texture into an image.

Returns
A new image with the texture pixels
static unsigned int jop::Texture2D::getMaximumSize ( )
static

Get the maximum supported 2D texture size on this system.

Returns
The maximum texture size
unsigned int jop::Texture2D::getPixelDepth ( ) const
overridevirtual

Get the texture pixel depth.

Returns
The texture pixel depth in bytes

Implements jop::Texture.

glm::uvec2 jop::Texture2D::getSize ( ) const
overridevirtual

Get the texture size.

Returns
The texture size

Implements jop::Texture.

bool jop::Texture2D::load ( const std::string &  path,
const uint32  flags = 0 
)

Load from file.

Parameters
pathThe file path
flagsTexture flags
Returns
True if successful
bool jop::Texture2D::load ( const void *  ptr,
const uint32  size,
const uint32  flags = 0 
)

Load from memory.

Parameters
ptrPointer to data (pixels)
sizeSize of the data to be loaded in bytes
flagsTexture flags
Returns
True if successful
bool jop::Texture2D::load ( const glm::uvec2 &  size,
const Format  format,
const uint32  flags = 0 
)

Creates flat/empty texture.

Parameters
sizeThe texture dimensions
formatThe texture format
flagsTexture flags
Returns
True if successful
bool jop::Texture2D::load ( const glm::uvec2 &  size,
const Format  format,
const void *  pixels,
const uint32  flags = 0 
)

Create a texture from an array of pixels.

Parameters
sizeThe texture dimensions
formatThe texture format
pixelsPointer to the beginning of the pixel array. Data must match the format
flagsTexture flags
Returns
True if successful
bool jop::Texture2D::load ( const Image image,
const uint32  flags = 0 
)

Load from a compressed image.

Parameters
imageImage to load from
flagsTexture flags
void jop::Texture2D::setPixels ( const glm::uvec2 &  start,
const glm::uvec2 &  size,
const void *  pixels 
)

Set a subset of pixels.

Parameters
startThe starting coordinates in pixels
sizeThe size of the area in pixels
pixelsPointer to the pixels. The data must match the texture format
void jop::Texture2D::setPixels ( const glm::uvec2 &  start,
const Image image 
)

Set a subset of pixels from an image.

The image must not be compressed.

Parameters
startThe starting coordinates in pixels
imageThe image to set the pixels from

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