AireEngine
A 3D Open-World Game Engine
Loading...
Searching...
No Matches
Public Member Functions | List of all members
Aire::Texture2D Class Reference

A 2D texture class. More...

#include <texture.h>

Inheritance diagram for Aire::Texture2D:
Inheritance graph
[legend]
Collaboration diagram for Aire::Texture2D:
Collaboration graph
[legend]

Public Member Functions

 Texture2D (int width, int height, GLsizei levels, GLenum internalformat)
 
void setData (int xOffset, int yOffset, int width, int height, const unsigned char *data, GLenum format=GL_RGBA, GLenum type=GL_UNSIGNED_BYTE, int level=0)
 
void generateMipmaps ()
 Generate mipmaps. It is assumed that there is allocated memory for all levels.
 
virtual ~Texture2D () override
 Destroy the texture.
 
 Texture2D (const Texture2D &)=delete
 
Texture2Doperator= (const Texture2D &)=delete
 
- Public Member Functions inherited from Aire::Texture
 Texture ()
 Create the texture.
 
uint32_t getSize ()
 
GLuint getHandle () const
 
virtual ~Texture ()=0
 Destroy the texture.
 
void bindTexUnit (GLint textureUnit)
 
void setFiltering (GLint minFilter, GLint maxFilter)
 
void setWrapping (GLint wrapS, GLint wrapT, GLint wrapR)
 
unsigned chargetImageData ()
 
void setImageData (unsigned char *)
 
- Public Member Functions inherited from Aire::Resource
 Resource ()
 Default constructor.
 
virtual ~Resource ()
 Default destructor.
 
bool isLoadToGpu ()
 
ResourceState getState ()
 
void setState (ResourceState state)
 

Additional Inherited Members

- Public Attributes inherited from Aire::Texture
int texWidth
 
int texHeight
 
int texChannels
 
std::string dir
 
- Protected Attributes inherited from Aire::Texture
GLuint handle
 
unsigned charimageData
 
- Protected Attributes inherited from Aire::Resource
ResourceState resourceState
 

Detailed Description

A 2D texture class.

Constructor & Destructor Documentation

◆ Texture2D()

Texture2D::Texture2D ( int width,
int height,
GLsizei levels,
GLenum internalformat )

Create a new 2D texture. See: https://registry.khronos.org/OpenGL-Refpages/gl4/html/glTexStorage2D.xhtml

Parameters
widthWidth of the texture in number of pixels (texels).
heightHeight of the texture in number of pixels (texels).
levelsNumber of levels in the mipmap hierarchy to allocate. If 0, allocate the full hierarchy. Note that this is a custom treatment of the 0 value. A native OpenGL call with levels=0 will produce an error.
internalformatThe format of the texture data. See link for details.

Member Function Documentation

◆ setData()

void Texture2D::setData ( int xOffset,
int yOffset,
int width,
int height,
const unsigned char * data,
GLenum format = GL_RGBA,
GLenum type = GL_UNSIGNED_BYTE,
int level = 0 )

Set the image data for a region of the texture. See: https://registry.khronos.org/OpenGL-Refpages/gl4/html/glTexSubImage2D.xhtml

Parameters
xOffsetThe x-coordinate of the lower-left corner of the pixel region to be updated. Must be non-negative but smaller than texture width.
yOffsetThe y-coordinate of the lower-left corner of the pixel region to be updated. Must be non-negative but smaller than texture height.
widthThe width of the pixel region to be updated.
heightThe height of the pixel region to be updated.
dataA pointer to the image data (a row-major 2D array assumed, with the appropriate width and height).
formatThe format of the image data. Defaults to 4-channel GL_RGBA.
typeThe type of the image data. Defaults to GL_UNSIGNED_BYTE.
levelThe level in the mipmap hierarchy.

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