A GPU texture. More...
#include <Luminous/Texture.hpp>
Public Types | |
| enum | Filter { FILTER_NEAREST = GL_NEAREST, FILTER_LINEAR = GL_LINEAR, FILTER_NEAREST_MIPMAP_NEAREST = GL_NEAREST_MIPMAP_NEAREST, FILTER_NEAREST_MIPMAP_LINEAR = GL_NEAREST_MIPMAP_LINEAR, FILTER_LINEAR_MIPMAP_NEAREST = GL_LINEAR_MIPMAP_NEAREST, FILTER_LINEAR_MIPMAP_LINEAR = GL_LINEAR_MIPMAP_LINEAR } |
| Texture filter mode. More... | |
| enum | Wrap { WRAP_REPEAT, WRAP_MIRROR, WRAP_CLAMP, WRAP_BORDER } |
| Texture wrap mode. More... | |
Public Types inherited from Luminous::RenderResource | |
| typedef uint64_t | Id |
| Id of a resource. | |
| enum | Type { VertexArray, Buffer, Program, Texture, RenderBuffer, FrameBuffer } |
| Different types of render resources. More... | |
Public Member Functions | |
| LUMINOUS_API void | addDirtyRect (const QRect &rect) |
| Mark a region of the texture as dirty. More... | |
| LUMINOUS_API const Radiant::Color & | borderColor () const |
| Get the texture border color. More... | |
| LUMINOUS_API const void * | data () const |
| Get the raw pointer to texture data. More... | |
| LUMINOUS_API const PixelFormat & | dataFormat () const |
| Get the pixel format of the texture data. More... | |
| LUMINOUS_API std::size_t | dataSize () const |
| Get the size of the texture data in bytes. More... | |
| LUMINOUS_API unsigned int | depth () const |
| Get the depth of the texture. More... | |
| LUMINOUS_API uint8_t | dimensions () const |
| Get texture dimension. More... | |
| LUMINOUS_API QRegion | dirtyRegion (unsigned int threadIndex) const |
| Get the texture dirty region for the given thread. More... | |
| LUMINOUS_API Filter | getMagFilter () const |
| Get texture magnification filter mode. More... | |
| LUMINOUS_API Filter | getMinFilter () const |
| Get the texture minification filter mode. More... | |
| LUMINOUS_API void | getWrap (Wrap &s, Wrap &t, Wrap &r) const |
| Get the texture wrap mode. More... | |
| LUMINOUS_API unsigned int | height () const |
| Get the height of the texture. More... | |
| LUMINOUS_API int | internalFormat () const |
| Get the number of color components in the texture. More... | |
| LUMINOUS_API bool | isValid () const |
| Check if the texture is valid. More... | |
| LUMINOUS_API unsigned int | lineSizePixels () const |
| Get the texture line size in pixels. More... | |
| LUMINOUS_API bool | mipmapsEnabled () const |
| True if automatic GPU mipmap generation is enabled. | |
| LUMINOUS_API Texture & | operator= (const Texture &tex) |
| Copy a texture. More... | |
| LUMINOUS_API Texture & | operator= (Texture &&tex) |
| Move a texture. More... | |
| LUMINOUS_API int | paramsGeneration () const |
| Get the generation number for texture parameters. More... | |
| LUMINOUS_API void | reset () |
| Reset the texture to invalid state. | |
| LUMINOUS_API unsigned int | samples () const |
| Get the sample count of the texture. More... | |
| LUMINOUS_API void | setBorderColor (const Radiant::Color &color) |
| Set the texture border color. More... | |
| LUMINOUS_API void | setData (unsigned int width, const PixelFormat &dataFormat, const void *data) |
| Set 1D texture data from memory. More... | |
| LUMINOUS_API void | setData (unsigned int width, unsigned int height, const PixelFormat &dataFormat, const void *data) |
| Set 2D texture data from memory. More... | |
| LUMINOUS_API void | setData (unsigned int width, unsigned int height, unsigned int depth, const PixelFormat &dataFormat, const void *data) |
| Set 3D texture data from memory. More... | |
| LUMINOUS_API void | setInternalFormat (int format) |
| Specify the number of color components in the texture. More... | |
| LUMINOUS_API void | setLineSizePixels (std::size_t size) |
| Set the texture line size in pixels. More... | |
| LUMINOUS_API void | setMagFilter (Filter filter) |
| Set texture magnification filtering. More... | |
| LUMINOUS_API void | setMinFilter (Filter filter) |
| Set texture minification filtering. More... | |
| LUMINOUS_API void | setMipmapsEnabled (bool enabled) |
| Enables or disables automatic GPU mipmap generation. | |
| LUMINOUS_API void | setSamples (unsigned int samples) |
| Set the number of samples for the texture. More... | |
| LUMINOUS_API void | setTranslucency (bool translucency) |
| Set translucency flag to the texture. More... | |
| LUMINOUS_API void | setWrap (Wrap s, Wrap t, Wrap r) |
| Set the texture wrap mode. More... | |
| LUMINOUS_API QRegion | takeDirtyRegion (unsigned int threadIndex) const |
| Get the dirty region for the given thread and clear the dirty region. More... | |
| LUMINOUS_API | Texture () |
| Construct a new texture. | |
| LUMINOUS_API | Texture (const Texture &tex) |
| Construct a copy. More... | |
| LUMINOUS_API | Texture (Texture &&tex) |
| Construct texture by moving. More... | |
| LUMINOUS_API bool | translucent () const |
| Check if the texture is translucent. More... | |
| LUMINOUS_API unsigned int | width () const |
| Get the width of the texture. More... | |
| LUMINOUS_API | ~Texture () |
| Destructor. | |
Public Member Functions inherited from Luminous::RenderResource | |
| unsigned int | expiration () const |
| Returns resource expiration time. More... | |
| int | generation () const |
| Returns generation of this resource. More... | |
| void | invalidate () |
| Invalidates correspondent GPU objects and forces uploading of data to GPU. | |
| RenderResource & | operator= (RenderResource &&rr) |
| Move assignment operator. More... | |
| RenderResource (Type type) | |
| Constructor of RenderResource. More... | |
| RenderResource (RenderResource &&rr) | |
| Move constructor. More... | |
| Id | resourceId () const |
| Returns identifier of resource. More... | |
| Type | resourceType () const |
| Returns type of the resource. More... | |
| void | setExpiration (unsigned int seconds) |
| Set resource expiration time. More... | |
| void | setGeneration (int generation) |
| Sets generation for this resource. More... | |
| virtual | ~RenderResource () |
| Destructor of RenderResource. | |
Additional Inherited Members | |
Protected Member Functions inherited from Luminous::RenderResource | |
| RenderResource & | operator= (const RenderResource &rr) |
| Assignment operator. More... | |
| RenderResource (const RenderResource &rr) | |
| Copy constructor. More... | |
A GPU texture.
This class contains the necessary CPU-side information about a texture. This class does not own the memory it handles. All pointers given to this class must remain valid during the lifetime of this object. GPU correspondent of this class is TextureGL
Texture filter mode.
Texture wrap mode.
| Enumerator | |
|---|---|
| WRAP_REPEAT |
Repeat texture. |
| WRAP_MIRROR |
Mirror texture. |
| WRAP_CLAMP |
Clamp texture. |
| WRAP_BORDER |
Clamp-to-border. |
| LUMINOUS_API Luminous::Texture::Texture | ( | const Texture & | tex | ) |
Construct a copy.
| tex | texture to copy |
| LUMINOUS_API Luminous::Texture::Texture | ( | Texture && | tex | ) |
Construct texture by moving.
| tex | texture to move |
| LUMINOUS_API void Luminous::Texture::addDirtyRect | ( | const QRect & | rect | ) |
Mark a region of the texture as dirty.
Dirty regions are used to determine which parts of the texture data must be uploaded to GPU memory. Use this function if you want to optimize texture uploads to GPU. For example, if you only update a small region of a large texture, you can just mark the changed region as dirty and Cornerstone will only upload that part of the texture to the GPU.
| rect | dirty region define in pixel coordinates |
| LUMINOUS_API const Radiant::Color& Luminous::Texture::borderColor | ( | ) | const |
Get the texture border color.
| LUMINOUS_API const void* Luminous::Texture::data | ( | ) | const |
Get the raw pointer to texture data.
| LUMINOUS_API const PixelFormat& Luminous::Texture::dataFormat | ( | ) | const |
Get the pixel format of the texture data.
| LUMINOUS_API std::size_t Luminous::Texture::dataSize | ( | ) | const |
Get the size of the texture data in bytes.
| LUMINOUS_API unsigned int Luminous::Texture::depth | ( | ) | const |
Get the depth of the texture.
| LUMINOUS_API uint8_t Luminous::Texture::dimensions | ( | ) | const |
Get texture dimension.
2D textures will have dimension 2 and 3D textures 3.
| LUMINOUS_API QRegion Luminous::Texture::dirtyRegion | ( | unsigned int | threadIndex | ) | const |
Get the texture dirty region for the given thread.
This functions returns the dirty region of the texture for the given thread. This function is used by Cornerstone internally. There should be no reason to call this function manually.
| threadIndex | index of the thread to query the region for |
| LUMINOUS_API Filter Luminous::Texture::getMagFilter | ( | ) | const |
Get texture magnification filter mode.
| LUMINOUS_API Filter Luminous::Texture::getMinFilter | ( | ) | const |
Get the texture minification filter mode.
Get the texture wrap mode.
| [out] | s | wrap mode for s coordinate |
| [out] | t | wrap mode for t coordinate |
| [out] | r | wrap mode for r coordinate |
| LUMINOUS_API unsigned int Luminous::Texture::height | ( | ) | const |
Get the height of the texture.
| LUMINOUS_API int Luminous::Texture::internalFormat | ( | ) | const |
Get the number of color components in the texture.
| LUMINOUS_API bool Luminous::Texture::isValid | ( | ) | const |
Check if the texture is valid.
Texture is considered valid, if its dimension has been defined.
| LUMINOUS_API unsigned int Luminous::Texture::lineSizePixels | ( | ) | const |
Get the texture line size in pixels.
Copy a texture.
| tex | texture to copy |
Move a texture.
| tex | texture to move |
| LUMINOUS_API int Luminous::Texture::paramsGeneration | ( | ) | const |
Get the generation number for texture parameters.
This is increased every time border color, wrap mode or min/mag filters are changed
| LUMINOUS_API unsigned int Luminous::Texture::samples | ( | ) | const |
Get the sample count of the texture.
By default, the sample count is zero for textures that are not multi-sampled.
| LUMINOUS_API void Luminous::Texture::setBorderColor | ( | const Radiant::Color & | color | ) |
Set the texture border color.
| color | border color |
| LUMINOUS_API void Luminous::Texture::setData | ( | unsigned int | width, |
| const PixelFormat & | dataFormat, | ||
| const void * | data | ||
| ) |
Set 1D texture data from memory.
| width | width of the texture |
| dataFormat | data format |
| data | data pointer |
| LUMINOUS_API void Luminous::Texture::setData | ( | unsigned int | width, |
| unsigned int | height, | ||
| const PixelFormat & | dataFormat, | ||
| const void * | data | ||
| ) |
Set 2D texture data from memory.
| width | width of the texture |
| height | height of the texture |
| dataFormat | data format |
| data | data pointer |
| LUMINOUS_API void Luminous::Texture::setData | ( | unsigned int | width, |
| unsigned int | height, | ||
| unsigned int | depth, | ||
| const PixelFormat & | dataFormat, | ||
| const void * | data | ||
| ) |
Set 3D texture data from memory.
| width | width of the texture |
| height | height of the texture |
| depth | depth of the texture |
| dataFormat | data format |
| data | data pointer |
| LUMINOUS_API void Luminous::Texture::setInternalFormat | ( | int | format | ) |
Specify the number of color components in the texture.
Use 0 to let Cornerstone select the default format. See "internalFormat" parameter description in http://www.opengl.org/sdk/docs/man3/xhtml/glTexImage2D.xml
| format | number of color components |
| LUMINOUS_API void Luminous::Texture::setLineSizePixels | ( | std::size_t | size | ) |
Set the texture line size in pixels.
Use 0 to use width of the texture.
| size | size of one line in pixels |
| LUMINOUS_API void Luminous::Texture::setMagFilter | ( | Filter | filter | ) |
Set texture magnification filtering.
| filter | filtering used |
| LUMINOUS_API void Luminous::Texture::setMinFilter | ( | Filter | filter | ) |
Set texture minification filtering.
| filter | filtering used |
| LUMINOUS_API void Luminous::Texture::setSamples | ( | unsigned int | samples | ) |
Set the number of samples for the texture.
This function can be used to define multi-sampled textures.
| samples | sample count |
| LUMINOUS_API void Luminous::Texture::setTranslucency | ( | bool | translucency | ) |
Set translucency flag to the texture.
This flag is used by Cornerstone to optimize rendering. Rendering opaque textures can be sorted for optimal performance. Rendering translucent textures can not be sorted. A texture must be marked as translucent if it has an alpha channel and any pixel in the texture has an alpha component other than one. Failure to do so may cause rendering artifacts as incorrect blending.
| translucency | texture translucency |
Set the texture wrap mode.
| s | wrap mode for s texture coordinate |
| t | wrap mode for t texture coordinate |
| r | wrap mode for r texture coordinate |
| LUMINOUS_API QRegion Luminous::Texture::takeDirtyRegion | ( | unsigned int | threadIndex | ) | const |
Get the dirty region for the given thread and clear the dirty region.
This functions returns the dirty region of the texture and simultaneously clears it to empty. This function is used by Cornerstone internally and there should be no reason to call this function manually.
| threadIndex | index of the thread to query |
| LUMINOUS_API bool Luminous::Texture::translucent | ( | ) | const |
Check if the texture is translucent.
| LUMINOUS_API unsigned int Luminous::Texture::width | ( | ) | const |
Get the width of the texture.