|
KGLLib
|
Abstract base class for all textures. More...
#include <texture.h>
Public Member Functions | |
| TextureBase () | |
| TextureBase (const QString &name) | |
| virtual | ~TextureBase () |
| bool | isValid () const |
| virtual void | bind () const |
| virtual void | unbind () const |
| virtual void | enable (bool bind=true) const |
| virtual void | disable (bool unbind=true) const |
| virtual void | setFilter (GLenum filter) |
| virtual void | setWrapMode (GLenum coordinate, GLenum mode) |
| virtual void | setWrapMode (GLenum mode)=0 |
| QString | name () const |
| void | setName (const QString &name) |
| virtual QString | debugString () const |
| virtual GLenum | glTarget () const =0 |
| virtual GLuint | glId () const |
Protected Member Functions | |
| void | setValid (bool valid) |
Protected Attributes | |
| bool | mValid |
| GLuint | mGLId |
| QString | mName |
| GLenum | mFormat |
| GLenum | mInternalFormat |
Abstract base class for all textures.
This class includes basic functionality such as bind/unbind and enable/disable methods which all textures have.
See Texture class documentation for more detailed introduction and examples.
| KGLLib::TextureBase::TextureBase | ( | ) |
Creates new invalid texture. It is up to subclasses to actually initialize the texture. TODO: should we do glGenTextures() here or in subclasses? Probably latter.
| KGLLib::TextureBase::TextureBase | ( | const QString & | name | ) |
Same as above but also sets texture name to name.
References setName().
| KGLLib::TextureBase::~TextureBase | ( | ) | [virtual] |
Deletes the OpenGL texture associated with this object.
| void KGLLib::TextureBase::bind | ( | ) | const [virtual] |
Binds the texture onto currently active texture unit.
References KGLLib::renderer.
Referenced by enable().
| void KGLLib::TextureBase::disable | ( | bool | unbind = true | ) | const [virtual] |
Disables texturing with this texture type for currently active texture unit.
| unbind | if true then unbind() is called before disabling texturing |
References KGLLib::renderer, and unbind().
Referenced by KGLLib::HdrGLWidget::render().
| void KGLLib::TextureBase::enable | ( | bool | bind = true | ) | const [virtual] |
Enables texturing with this texture type for currently active texture unit.
| bind | if true then bind() is called after enabling texturing |
References bind(), and KGLLib::renderer.
Referenced by KGLLib::HdrGLWidget::render().
| virtual GLuint KGLLib::TextureBase::glId | ( | ) | const [inline, virtual] |
| virtual GLenum KGLLib::TextureBase::glTarget | ( | ) | const [pure virtual] |
TODO: maybe rename to glType()
Implemented in KGLLib::Texture, and KGLLib::Texture3D.
Referenced by setFilter(), and setWrapMode().
| bool KGLLib::TextureBase::isValid | ( | ) | const [inline] |
| QString KGLLib::TextureBase::name | ( | ) | const [inline] |
Referenced by setName().
| void KGLLib::TextureBase::setFilter | ( | GLenum | filter | ) | [virtual] |
Sets texture's filter to filter. filter is minification filter, magnification filter is set to GL_NEAREST if filter is GL_NEAREST and to GL_LINEAR otherwise.
Common values are:
TODO: maybe set filter to GL_CLAMP by default because it seems to suit smaller apps better. OTOH I really don't like having defaults differ from OpenGL ones. Maybe add Renderer::setDefaultTextureFilter() method???
References glTarget().
Referenced by KGLLib::HdrGLWidget::render().
| void KGLLib::TextureBase::setName | ( | const QString & | name | ) |
Sets texture's name to name. The name doesn't have any connection with OpenGL but it can be used to identify textures when debugging.
References name().
Referenced by TextureBase().
| virtual void KGLLib::TextureBase::setWrapMode | ( | GLenum | mode | ) | [pure virtual] |
Sets wrap mode for all coordinates of this texture. Subclasses need to reimplement this, calling setWrapMode() for every possible coordinate.
Implemented in KGLLib::Texture, and KGLLib::Texture3D.
| void KGLLib::TextureBase::setWrapMode | ( | GLenum | coordinate, |
| GLenum | mode | ||
| ) | [virtual] |
Sets texture wrap mode for given coordinate. Wrap mode controls how exactly the texture coordinates are interpreted:
Usually you should use GL_REPEAT when you want texture to repeat across surfaces (e.g. for terrain with repeating texture) and GL_CLAMP when you want just one instance of the texture (e.g. for a logo).
References glTarget().
| void KGLLib::TextureBase::unbind | ( | ) | const [virtual] |
Unbinds the texture. After calling this, no texture is bound but texturing may still be enabled (in which case texturing results are undefined). TODO: is this meanful or should it be removed (as users usually want to either disable() texturing or just bind() another texture)?
References KGLLib::renderer.
Referenced by disable().
1.7.4