LightsprintSDK 2021.08.08
rr_gl::Texture Class Reference

#include <Texture.h>

Inheritance diagram for rr_gl::Texture:
rr::RRUniformlyAllocatedNonCopyable rr::RRUniformlyAllocated

Public Member Functions

 Texture (rr::RRBuffer *buffer, bool buildMipMaps, bool compress, int magn=GL_LINEAR, int mini=GL_LINEAR, int wrapS=GL_REPEAT, int wrapT=GL_REPEAT)
 
rr::RRBuffergetBuffer ()
 
const rr::RRBuffergetBuffer () const
 
void reset (bool buildMipMaps, bool compress, bool scaledAsSRGB)
 
void bindTexture () const
 
void copyTextureToBuffer ()
 
const GLuint getId () const
 
 ~Texture ()
 
- Public Member Functions inherited from rr::RRUniformlyAllocated
void * operator new (std::size_t n)
 
void * operator new[] (std::size_t n)
 
void operator delete (void *p, std::size_t n)
 
void operator delete[] (void *p, std::size_t n)
 

Static Public Member Functions

static TexturecreateShadowmap (unsigned width, unsigned height, bool color=false)
 

Public Attributes

unsigned version
 

Protected Attributes

rr::RRBufferbuffer
 
GLuint id
 
GLenum cubeOr2d
 
GLenum internalFormat
 

Friends

class FBO
 

Additional Inherited Members

- Protected Member Functions inherited from rr::RRUniformlyAllocatedNonCopyable
 RRUniformlyAllocatedNonCopyable ()
 
 ~RRUniformlyAllocatedNonCopyable ()
 

Detailed Description

Texture is simple OpenGL wrapper around rr::RRBuffer.

It supports BT_2D_TEXTURE and BT_CUBE_TEXTURE buffer types. It can be constructed and destructed manually (use one of constructor) or automatically by getTexture() function.

Constructor & Destructor Documentation

◆ Texture()

rr_gl::Texture::Texture ( rr::RRBuffer buffer,
bool  buildMipMaps,
bool  compress,
int  magn = GL_LINEAR,
int  mini = GL_LINEAR,
int  wrapS = GL_REPEAT,
int  wrapT = GL_REPEAT 
)

Creates texture. Buffer is not adopted, not deleted in destructor.

◆ ~Texture()

rr_gl::Texture::~Texture ( )

Member Function Documentation

◆ createShadowmap()

static Texture * rr_gl::Texture::createShadowmap ( unsigned  width,
unsigned  height,
bool  color = false 
)
static

Creates shadowmap, depth or color texture.

◆ getBuffer() [1/2]

rr::RRBuffer * rr_gl::Texture::getBuffer ( )

Returns texture buffer (with type, width, height, format, data).

◆ getBuffer() [2/2]

const rr::RRBuffer * rr_gl::Texture::getBuffer ( ) const

Returns texture buffer (with type, width, height, format, data).

◆ reset()

void rr_gl::Texture::reset ( bool  buildMipMaps,
bool  compress,
bool  scaledAsSRGB 
)

Rebuilds texture from buffer and additional parameters.

Note that depth textures are automatically configured for the most common use case - shadowmapping. If you plan to read depth values from depth texture (instead of shadowmapping), call glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_NONE); after reset().

Parameters
buildMipMapsBuilds texture with mipmaps.
compressBuilds compressed texture.
scaledAsSRGBBuilds sRGB (rather than RGB) texture for scaled buffers.

◆ bindTexture()

void rr_gl::Texture::bindTexture ( ) const

Binds texture.

◆ copyTextureToBuffer()

void rr_gl::Texture::copyTextureToBuffer ( )

Reads texture back from GPU memory to buffer, increases version.

◆ getId()

const GLuint rr_gl::Texture::getId ( ) const
inline

Returns OpenGL specific id of texture. Only necessary for passing our textures to third party OpenGL code.

Friends And Related Symbol Documentation

◆ FBO

friend class FBO
friend

Member Data Documentation

◆ version

unsigned rr_gl::Texture::version

◆ buffer

rr::RRBuffer* rr_gl::Texture::buffer
protected

◆ id

GLuint rr_gl::Texture::id
protected

◆ cubeOr2d

GLenum rr_gl::Texture::cubeOr2d
protected

◆ internalFormat

GLenum rr_gl::Texture::internalFormat
protected