You.i Engine
CYIGLTextureObject Class Reference

Detailed Description

IYIGPUObject implementation for OpenGL textures.

This class is able to encapsulate any OpenGL texture types that can be generated via glGenTextures(), such as GL_TEXTURE_2D

#include <renderer/YiGLTextureObject.h>

Inheritance diagram for CYIGLTextureObject:

Public Member Functions

 CYIGLTextureObject ()
virtual ~CYIGLTextureObject ()
virtual void Load (const std::shared_ptr< CYIAssetHardware > &pAsset) override
virtual void Unload () override
virtual void Use () const override
virtual void Generate () override
virtual void Free () override
virtual void InvalidateHandle () override
bool Configure (GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type)
- Public Member Functions inherited from CYIGLAbstractBufferObject
 CYIGLAbstractBufferObject (GLuint handle)
virtual ~CYIGLAbstractBufferObject ()
virtual void SetTarget (GLenum target)
virtual GLenum GetTarget ()
virtual GLuint GetHandle ()
- Public Member Functions inherited from CYIBufferObject
 CYIBufferObject ()
virtual ~CYIBufferObject ()
virtual void * Map ()
virtual void Unmap (size_t size)
- Public Member Functions inherited from IYIGPUObject
 IYIGPUObject ()
virtual ~IYIGPUObject ()
Status GetStatus () const

Protected Attributes

GLint m_level
GLint m_internalFormat
GLsizei m_width
GLsizei m_height
GLint m_border
GLenum m_format
GLenum m_type
bool m_needsFullReload
- Protected Attributes inherited from CYIGLAbstractBufferObject
GLuint m_handle
GLenum m_target
- Protected Attributes inherited from IYIGPUObject
Status m_status


class CYIGLFramebufferObject

Additional Inherited Members

- Public Types inherited from IYIGPUObject
enum  Status {

Constructor & Destructor Documentation

◆ CYIGLTextureObject()

CYIGLTextureObject::CYIGLTextureObject ( )

Upon creation, a texture object will generate a valid handle in graphics memory

◆ ~CYIGLTextureObject()

virtual CYIGLTextureObject::~CYIGLTextureObject ( )

Upon deletion, a texture object will free all of its memory and invalidate its handle

Member Function Documentation

◆ Configure()

bool CYIGLTextureObject::Configure ( GLint  level,
GLint  internalFormat,
GLsizei  width,
GLsizei  height,
GLint  border,
GLenum  format,
GLenum  type 

Parameters are identical to those used for glTexImage2D(). See OpenGL documentation for your platform for details.

The data in pixels as interpreted to be in the format colorspace will be written to the appropriate mipmap level in order to create a width by height texture in the internalFormat colorspace. If the GL version on the target platform supports borders, a border pixels width border will be applied to the image.

Returns true if the texture object has been modified as a result of the call to Configure.

◆ Free()

virtual void CYIGLTextureObject::Free ( )

Deallocates the GPU memory associated with this object.

Implements IYIGPUObject.

◆ Generate()

virtual void CYIGLTextureObject::Generate ( )

Generates a valid handle. No GPU memory is allocated until Load() is called.

Implements IYIGPUObject.

◆ InvalidateHandle()

virtual void CYIGLTextureObject::InvalidateHandle ( )

This function can be called to invalidate the buffer handle without freeing the associated memory.

This can be used if the GL context is lost and GPU memory is freed implicitly. Calling Free() on this object will result in a crash if the handle is no longer pointing to valid memory, and a new handle may not be created with Generate() if the current handle is valid. This function allows you to inform the buffer object that the GL data has been freed externally and that the handle should be disconnected.

Calling this function without being sure that the handle has been freed in GPU memory will result in a memory leak. Use at your own risk.

Implements IYIGPUObject.

◆ Load()

virtual void CYIGLTextureObject::Load ( const std::shared_ptr< CYIAssetHardware > &  pHWAsset)

Loads the software data from the associated CYIAsset into graphics memory. If the Status is LOADED_FRESH upon a call to load, meaning that data was previously successfully loaded, the status may become LOADED_STALE in the case where this load failed. See the Status documentation for more details.

Implements IYIGPUObject.

◆ Unload()

virtual void CYIGLTextureObject::Unload ( )

Frees any previously loaded data from video memory, but retains the handle.

Implements IYIGPUObject.

◆ Use()

virtual void CYIGLTextureObject::Use ( ) const

Makes the GPU Object active, called by the renderer

Implements IYIGPUObject.

Friends And Related Function Documentation

◆ CYIGLFramebufferObject

friend class CYIGLFramebufferObject

Member Data Documentation

◆ m_border

GLint CYIGLTextureObject::m_border

◆ m_format

GLenum CYIGLTextureObject::m_format

◆ m_height

GLsizei CYIGLTextureObject::m_height

◆ m_internalFormat

GLint CYIGLTextureObject::m_internalFormat

◆ m_level

GLint CYIGLTextureObject::m_level

◆ m_needsFullReload

bool CYIGLTextureObject::m_needsFullReload

◆ m_type

GLenum CYIGLTextureObject::m_type

◆ m_width

GLsizei CYIGLTextureObject::m_width

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