Gorgon Game Engine
Texture Class Reference

This class represents an image depends on a GL texture. More...

Inheritance diagram for Texture:
[legend]

Public Member Functions

 Texture ()
 Default constructor, creates an empty texture. More...
 
 Texture (const Containers::Image &image)
 This constructor creates a new texture from the given Image. More...
 
 Texture (GL::Texture id, ColorMode mode, const Geometry::Size &size)
 Regular, full texture constructor. More...
 
 Texture (GL::Texture id, ColorMode mode, const Geometry::Size &size, const Geometry::Bounds &location)
 Atlas constructor, specifies a region of the texture. More...
 
 Texture (Texture &&other)
 Moves a texture. More...
 
 Texture (Texture &other)
 Copies a texture. This newly created texture will not assume ownership. More...
 
virtual ~Texture ()
 
void Assume (GL::Texture id, ColorMode mode, const Geometry::Size &size)
 Sets the texture to the given id with the given size. More...
 
void Assume (GL::Texture id, ColorMode mode, const Geometry::Size &size, const Geometry::Bounds &location)
 Sets the texture to the given id with the given size. More...
 
void CreateEmpty (const Geometry::Size &size, ColorMode mode)
 Create an empty texture. More...
 
void Destroy ()
 Remove the texture from this object. If this object is the owner of the texture, then it is destroyed. More...
 
virtual const Geometry::PointfGetCoordinates () const override final
 Returns the coordinates of the texture to be used. Declared final to allow inlining. More...
 
virtual GL::Texture GetID () const override final
 Returns GL::Texture to be drawn. Declared final to allow inlining. More...
 
virtual Geometry::Size GetImageSize () const override final
 Returns the size of the texture in pixels. Declared final to allow inlining. More...
 
ColorMode GetMode () const override
 
GL::Texture Release ()
 Releases the texture id that might be owned by this object without destroying it. More...
 
void Set (const Containers::Image &image)
 Sets the texture to the given id with the given size. More...
 
void Set (GL::Texture id)
 Sets the texture to the given id without any modification to size or color mode. More...
 
void Set (GL::Texture id, ColorMode mode, const Geometry::Size &size)
 Sets the texture to the given id with the given size. More...
 
void Set (GL::Texture id, ColorMode mode, const Geometry::Size &size, const Geometry::Bounds &location)
 Sets the texture to the given id with the given size. More...
 
void Swap (Texture &other)
 Swaps two textures. More...
 
- Public Member Functions inherited from TextureSource
bool IsPartial () const
 Returns whether this texture uses only a part of the GL::Texture. More...
 

Protected Attributes

Geometry::Pointf coordinates [4]
 Readily calculated texture coordinates of the image. More...
 
GL::Texture id
 GL texture id. More...
 
ColorMode mode
 Color mode of the texture, necessary to choose correct texture. More...
 
bool owner
 Whether this object owns this texture. More...
 
Geometry::Size size
 Size of the texture. More...
 

Additional Inherited Members

- Static Protected Attributes inherited from TextureSource
static const Geometry::Pointf fullcoordinates [4]
 Coordinates that selects the entire texture to be used. More...
 

Detailed Description

This class represents an image depends on a GL texture.

Fulfills the requirements of Graphics::TextureSource. Unless GL::Texture created by this object, it is not destroyed by constructor. This is because a GL::Texture could be shared between multiple Graphics::Textures.

Constructor & Destructor Documentation

◆ Texture() [1/6]

Texture ( )

Default constructor, creates an empty texture.

References Gorgon::Graphics::Invalid, and Texture::Set().

◆ Texture() [2/6]

Texture ( GL::Texture  id,
ColorMode  mode,
const Geometry::Size size 
)

Regular, full texture constructor.

References Texture::mode, Texture::Set(), and Texture::size.

◆ Texture() [3/6]

Texture ( GL::Texture  id,
ColorMode  mode,
const Geometry::Size size,
const Geometry::Bounds location 
)

Atlas constructor, specifies a region of the texture.

References Texture::mode, Texture::Set(), and Texture::size.

◆ Texture() [4/6]

Texture ( const Containers::Image image)

This constructor creates a new texture from the given Image.

References Texture::owner.

◆ Texture() [5/6]

Texture ( Texture other)

Copies a texture. This newly created texture will not assume ownership.

References Texture::coordinates.

◆ Texture() [6/6]

Texture ( Texture &&  other)

Moves a texture.

This newly created texture object will own the texture if the other object owns it

References Texture::coordinates.

◆ ~Texture()

virtual ~Texture ( )
virtual

References Texture::Destroy().

Member Function Documentation

◆ Assume() [1/2]

void Assume ( GL::Texture  id,
ColorMode  mode,
const Geometry::Size size 
)

Sets the texture to the given id with the given size.

Resets the coordinates to cover entire GL texture. Transfers the ownership of the texture.

References Texture::mode, Texture::owner, Texture::Set(), and Texture::size.

◆ Assume() [2/2]

void Assume ( GL::Texture  id,
ColorMode  mode,
const Geometry::Size size,
const Geometry::Bounds location 
)

Sets the texture to the given id with the given size.

Calculates the texture coordinates for the specified location in pixels. Transfers the ownership of the texture

Parameters
idid of the texture, reported by the underlying GL framework
sizeof the GL texture in pixels
locationis the location of this texture over GL texture in pixels.

References Texture::mode, Texture::owner, Texture::Set(), and Texture::size.

◆ CreateEmpty()

void CreateEmpty ( const Geometry::Size size,
ColorMode  mode 
)

◆ Destroy()

void Destroy ( )

Remove the texture from this object. If this object is the owner of the texture, then it is destroyed.

References Gorgon::GL::DestroyTexture(), Texture::owner, and Texture::size.

◆ GetCoordinates()

virtual const Geometry::Pointf* GetCoordinates ( ) const
finaloverridevirtual

Returns the coordinates of the texture to be used. Declared final to allow inlining.

Implements TextureSource.

References Texture::coordinates.

◆ GetID()

virtual GL::Texture GetID ( ) const
finaloverridevirtual

Returns GL::Texture to be drawn. Declared final to allow inlining.

Implements TextureSource.

References Texture::id.

◆ GetImageSize()

virtual Geometry::Size GetImageSize ( ) const
finaloverridevirtual

Returns the size of the texture in pixels. Declared final to allow inlining.

Implements TextureSource.

References Texture::size.

◆ GetMode()

ColorMode GetMode ( ) const
overridevirtual

Implements TextureSource.

References Texture::mode.

◆ Release()

GL::Texture Release ( )

Releases the texture id that might be owned by this object without destroying it.

References Texture::id, Texture::owner, and Texture::size.

◆ Set() [1/4]

void Set ( const Containers::Image image)

Sets the texture to the given id with the given size.

Resets the coordinates to cover entire GL texture

References Texture::coordinates, Texture::Destroy(), TextureSource::fullcoordinates, Gorgon::GL::GenerateTexture(), basic_Image< T_ >::GetMode(), basic_Image< T_ >::GetSize(), Texture::mode, Texture::owner, and Texture::size.

◆ Set() [2/4]

void Set ( GL::Texture  id)

Sets the texture to the given id without any modification to size or color mode.

Use this function to change atlas base.

References Gorgon::GL::DestroyTexture(), Texture::id, and Texture::owner.

◆ Set() [3/4]

void Set ( GL::Texture  id,
ColorMode  mode,
const Geometry::Size size 
)

Sets the texture to the given id with the given size.

Resets the coordinates to cover entire GL texture

References Texture::coordinates, Texture::Destroy(), TextureSource::fullcoordinates, Texture::id, Texture::mode, and Texture::size.

◆ Set() [4/4]

void Set ( GL::Texture  id,
ColorMode  mode,
const Geometry::Size size,
const Geometry::Bounds location 
)

Sets the texture to the given id with the given size.

Calculates the texture coordinates for the specified location in pixels

Parameters
idid of the texture, reported by the underlying GL framework
sizeof the GL texture in pixels
locationis the location of this texture over GL texture in pixels.

References basic_Bounds< T_ >::Bottom, Texture::coordinates, Texture::Destroy(), basic_Bounds< T_ >::GetSize(), basic_Size< T_ >::Height, Texture::id, basic_Bounds< T_ >::Left, Texture::mode, basic_Bounds< T_ >::Right, Texture::size, basic_Bounds< T_ >::Top, and basic_Size< T_ >::Width.

◆ Swap()

void Swap ( Texture other)

Member Data Documentation

◆ coordinates

Geometry::Pointf coordinates[4]
protected

Readily calculated texture coordinates of the image.

Normally spans entire GL texture, however, could be changed to create texture atlas. These coordinates are kept in floating point u,v representation for quick consumption by the GL

◆ id

GL::Texture id
protected

GL texture id.

◆ mode

ColorMode mode
protected

Color mode of the texture, necessary to choose correct texture.

◆ owner

bool owner
protected

Whether this object owns this texture.

◆ size

Geometry::Size size
protected

Size of the texture.


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