Mountain  1.0.0
Simple C++ 2D Game Framework
Mountain::Graphics::GpuTexture Struct Reference

Low-level interface for OpenGL textures. More...

#include <gpu_texture.hpp>

Public Member Functions

void Create ()
 Create the texture on the GPU. More...
 
void Delete ()
 Delete the texture on the GPU. More...
 
void Recreate ()
 Shorthand for. More...
 
void CreateFrom (uint32_t originalTextureId, InternalFormat newInternalFormat, uint32_t minMipmapLevel, uint32_t mipmapLevels)
 Create the texture on the GPU from the given immutable texture. More...
 
void CreateFrom (GpuTexture originalGpuTexture, InternalFormat newInternalFormat, uint32_t minMipmapLevel, uint32_t mipmapLevels)
 Create the texture on the GPU from the given immutable texture. More...
 
void SetStorage (InternalFormat internalFormat, Vector2i size, int32_t mipmapLevels=1) const
 Initialize the immutable data storage on the GPU. More...
 
void SetSubData (Vector2i offset, Vector2i size, Format dataFormat, DataType dataType, const void *data, int32_t mipmapLevel=0) const
 Set a portion of the texture data. More...
 
void SetData (InternalFormat internalFormat, Vector2i size, Format dataFormat, DataType dataType, const void *data, int32_t mipmapLevel=0) const
 Initialize and set the initial texture data. More...
 
void GenerateMipmap () const
 
void SetDebugName (std::string_view name) const
 Adds a friendly debug name for this GpuTexture. This is used when debugging graphics in external applications such as Nsight or RenderDoc. This function does nothing if the application isn't compiled in Debug. More...
 
bool_t GetImmutable () const
 Get whether the GpuTexture data is immutable. More...
 
MagnificationFilter GetMinFilter () const
 
void SetMinFilter (MagnificationFilter newMinFilter) const
 
MagnificationFilter GetMagFilter () const
 
void SetMagFilter (MagnificationFilter newMagFilter) const
 
Wrapping GetWrappingHorizontal () const
 
void SetWrappingHorizontal (Wrapping newWrappingHorizontal) const
 
Wrapping GetWrappingVertical () const
 
void SetWrappingVertical (Wrapping newWrappingVertical) const
 
Color GetBorderColor () const
 
void SetBorderColor (Color newBorderColor) const
 
uint32_t GetId () const
 
 operator uint32_t () const
 

Detailed Description

Low-level interface for OpenGL textures.

Definition at line 12 of file gpu_texture.hpp.

Member Function Documentation

◆ Create()

void Mountain::Graphics::GpuTexture::Create ( )

Create the texture on the GPU.

See also
glCreateTextures()

◆ CreateFrom() [1/2]

void Mountain::Graphics::GpuTexture::CreateFrom ( uint32_t  originalTextureId,
InternalFormat  newInternalFormat,
uint32_t  minMipmapLevel,
uint32_t  mipmapLevels 
)

Create the texture on the GPU from the given immutable texture.

Parameters
originalTextureIdThe texture ID whose data is to be what this texture will view
newInternalFormatThe internal format for the newly created texture. This format must be compatible with the original texture format as per this table.
minMipmapLevelThe starting mipmap level in the original texture to view
mipmapLevelsThe number of mipmap levels of the original texture to view

This creates a new texture that is a view of the given original texture.

See also
glGenTextures() glTextureView()
Note
The original texture must be immutable

◆ CreateFrom() [2/2]

void Mountain::Graphics::GpuTexture::CreateFrom ( GpuTexture  originalGpuTexture,
InternalFormat  newInternalFormat,
uint32_t  minMipmapLevel,
uint32_t  mipmapLevels 
)

Create the texture on the GPU from the given immutable texture.

Parameters
originalGpuTextureThe texture whose data is to be what this texture will view
newInternalFormatThe internal format for the newly created texture. This format must be compatible with the original texture format as per this table.
minMipmapLevelThe starting mipmap level in the original texture to view
mipmapLevelsThe number of mipmap levels of the original texture to view

This creates a new texture that is a view of the given original texture.

See also
glGenTextures() glTextureView()
Note
The original texture must be immutable

◆ Delete()

void Mountain::Graphics::GpuTexture::Delete ( )

Delete the texture on the GPU.

See also
glDeleteTextures()

◆ GenerateMipmap()

void Mountain::Graphics::GpuTexture::GenerateMipmap ( ) const

◆ GetBorderColor()

Color Mountain::Graphics::GpuTexture::GetBorderColor ( ) const

◆ GetImmutable()

bool_t Mountain::Graphics::GpuTexture::GetImmutable ( ) const

Get whether the GpuTexture data is immutable.

See also
glGetTexParameteriv()

◆ GetMagFilter()

MagnificationFilter Mountain::Graphics::GpuTexture::GetMagFilter ( ) const

◆ GetMinFilter()

MagnificationFilter Mountain::Graphics::GpuTexture::GetMinFilter ( ) const

◆ GetWrappingHorizontal()

Wrapping Mountain::Graphics::GpuTexture::GetWrappingHorizontal ( ) const

◆ GetWrappingVertical()

Wrapping Mountain::Graphics::GpuTexture::GetWrappingVertical ( ) const

◆ Recreate()

void Mountain::Graphics::GpuTexture::Recreate ( )

Shorthand for.

◆ SetBorderColor()

void Mountain::Graphics::GpuTexture::SetBorderColor ( Color  newBorderColor) const

◆ SetData()

void Mountain::Graphics::GpuTexture::SetData ( InternalFormat  internalFormat,
Vector2i  size,
Format  dataFormat,
DataType  dataType,
const void *  data,
int32_t  mipmapLevel = 0 
) const

Initialize and set the initial texture data.

Parameters
internalFormatThe format to use to store the data on the GPU
sizeThe size of the texture
dataFormatThe format of the given data
dataTypeThe type of the given data
dataThe data to set
mipmapLevelThe mipmap level to set
Note
This will fail if the texture data is immutable, e.g. a call to SetStorage() was already made. If you want to use this function and the texture data is immutable, you first need to Recreate() the texture.
See also
glTexImage2D()

◆ SetDebugName()

void Mountain::Graphics::GpuTexture::SetDebugName ( std::string_view  name) const

Adds a friendly debug name for this GpuTexture. This is used when debugging graphics in external applications such as Nsight or RenderDoc. This function does nothing if the application isn't compiled in Debug.

Parameters
nameThe name of this GpuTexture
See also
glObjectLabel()

◆ SetMagFilter()

void Mountain::Graphics::GpuTexture::SetMagFilter ( MagnificationFilter  newMagFilter) const

◆ SetMinFilter()

void Mountain::Graphics::GpuTexture::SetMinFilter ( MagnificationFilter  newMinFilter) const

◆ SetStorage()

void Mountain::Graphics::GpuTexture::SetStorage ( InternalFormat  internalFormat,
Vector2i  size,
int32_t  mipmapLevels = 1 
) const

Initialize the immutable data storage on the GPU.

Parameters
mipmapLevelsThe number of mipmap levels to initialize
internalFormatThe format to use to store the data on the GPU
sizeThe size of the texture
Note
This will fail if the texture data is already immutable, e.g. a call to SetStorage() was already made. If you want to use this function again, you first need to Recreate() the texture.
See also
glTexStorage2D()

◆ SetSubData()

void Mountain::Graphics::GpuTexture::SetSubData ( Vector2i  offset,
Vector2i  size,
Format  dataFormat,
DataType  dataType,
const void *  data,
int32_t  mipmapLevel = 0 
) const

Set a portion of the texture data.

Parameters
offsetThe offset from in the texture to set the data from
sizeThe size of the data the set
dataFormatThe format of the given data
dataTypeThe type of the given format
dataThe data to set
mipmapLevelThe mipmap level to set
See also
glTexSubImage2D()

◆ SetWrappingHorizontal()

void Mountain::Graphics::GpuTexture::SetWrappingHorizontal ( Wrapping  newWrappingHorizontal) const

◆ SetWrappingVertical()

void Mountain::Graphics::GpuTexture::SetWrappingVertical ( Wrapping  newWrappingVertical) const

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