Game of Ur 0.3.3
This is a computer adaptation of Game of Ur, written in C++ mainly using SDL and OpenGL.
Loading...
Searching...
No Matches
ToyMaker::Texture Class Reference

The class representation of textures on this engine, which are a type of Resource used both within and outside of the engine. More...

#include <texture.hpp>

Inheritance diagram for ToyMaker::Texture:
ToyMaker::Resource< Texture > ToyMaker::IResource

Public Member Functions

 Texture (GLuint textureID, const ColorBufferDefinition &colorBufferDefinition, const std::string &filepath="")
 Constructs a new texture object which takes ownership of an OpenGL texture handle and engine colorbuffer definition created outside of it.
 
 Texture (const Texture &other)
 
Textureoperator= (const Texture &other)
 
 Texture (Texture &&other) noexcept
 
Textureoperator= (Texture &&other) noexcept
 
virtual void free ()
 
void bind (GLuint textureUnit) const
 Binds this texture to a texture unit, making it available for use by a shader.
 
void attachToFramebuffer (GLuint attachmentUnit) const
 Attaches this texture to a (presumably existing and bound) framebuffer, allowing the user of the framebuffer to read from and render to it.
 
GLuint getTextureID () const
 Gets the OpenGL texture ID for this texture.
 
GLint getWidth () const
 Gets the width of this texture (per its color buffer definition).
 
GLint getHeight () const
 Gets the height of this texture (per its color buffer definition).
 
ColorBufferDefinition getColorBufferDefinition ()
 Gets the description of this texture.
 
- Public Member Functions inherited from ToyMaker::Resource< Texture >
std::string getResourceTypeName_ () const override
 Get the resource type string for this resource.
 
- Public Member Functions inherited from ToyMaker::IResource
virtual ~IResource ()=default
 Destroy the IResource object.
 

Static Public Member Functions

static std::string getResourceTypeName ()
 Gets the resource type string associated with this resource.
 

Protected Member Functions

void copyImage (const Texture &other)
 
void generateTexture ()
 Generates a new texture based on the stored color buffer definition.
 
GLenum internalFormat ()
 The enum value passed as the "internalFormat" argument of glTexImage2D.
 
GLenum externalFormat ()
 The enum value passed as the "format" argument of glTexImage2D.
 
void destroyResource ()
 Destroys (OpenGL managed) texture tied to this object.
 
void releaseResource ()
 Removes references to (OpenGL managed) texture tied to this object, so that another object or part of the program can take ownership of it.
 
- Protected Member Functions inherited from ToyMaker::Resource< Texture >
 Resource (int explicitlyInitializeMe)
 Construct a new resource object.
 
- Protected Member Functions inherited from ToyMaker::IResource
 IResource ()=default
 Construct a new IResource object.
 

Protected Attributes

GLuint mID {0}
 The OpenGL ID of this texture.
 
std::string mFilepath {""}
 The file this texture was loaded from, if any.
 
ColorBufferDefinition mColorBufferDefinition
 The color buffer definition of this texture.
 

Additional Inherited Members

- Static Protected Member Functions inherited from ToyMaker::IResource
template<typename TResource>
static void RegisterResource ()
 Registers this resource as a Resource type with the ResourceDatabase.
 

Detailed Description

The class representation of textures on this engine, which are a type of Resource used both within and outside of the engine.

Constructor & Destructor Documentation

◆ Texture()

Texture::Texture ( GLuint textureID,
const ColorBufferDefinition & colorBufferDefinition,
const std::string & filepath = "" )

Constructs a new texture object which takes ownership of an OpenGL texture handle and engine colorbuffer definition created outside of it.

Parameters
textureIDThe ID of the texture now to be owned by this object.
colorBufferDefinitionThe color buffer definition for this object.
filepathThe path to the file the texture was loaded from, if any.

Member Function Documentation

◆ attachToFramebuffer()

void Texture::attachToFramebuffer ( GLuint attachmentUnit) const

Attaches this texture to a (presumably existing and bound) framebuffer, allowing the user of the framebuffer to read from and render to it.

Parameters
attachmentUnitThe attachment unit to which this texture will be bound.

◆ bind()

void Texture::bind ( GLuint textureUnit) const

Binds this texture to a texture unit, making it available for use by a shader.

Parameters
textureUnitThe unit this texture is to be bound to.

◆ externalFormat()

GLenum Texture::externalFormat ( )
protected

The enum value passed as the "format" argument of glTexImage2D.

Returns
GLenum The enum value corresponding to glTexImage2D's "format" argument.

◆ getColorBufferDefinition()

ColorBufferDefinition ToyMaker::Texture::getColorBufferDefinition ( )
inline

Gets the description of this texture.

Returns
ColorBufferDefinition This texture's color buffer definition.

◆ getHeight()

GLint Texture::getHeight ( ) const

Gets the height of this texture (per its color buffer definition).

Returns
GLint This texture's height.

◆ getResourceTypeName()

static std::string ToyMaker::Texture::getResourceTypeName ( )
inlinestatic

Gets the resource type string associated with this resource.

Returns
std::string The resource type string of this object.

◆ getTextureID()

GLuint Texture::getTextureID ( ) const

Gets the OpenGL texture ID for this texture.

Returns
GLuint This texture's OpenGL texture id.

◆ getWidth()

GLint Texture::getWidth ( ) const

Gets the width of this texture (per its color buffer definition).

Returns
GLint This texture's width.

◆ internalFormat()

GLenum Texture::internalFormat ( )
protected

The enum value passed as the "internalFormat" argument of glTexImage2D.

Returns
GLenum The enum value corresponding to glTexImage2D's "internalFormat" argument.

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