• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

KGLLib

KGLLib::TextureBase

KGLLib::TextureBase Class Reference

#include <texture.h>

Inheritance diagram for KGLLib::TextureBase:

Inheritance graph
[legend]

List of all members.


Detailed Description

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.

See also:
Texture

Definition at line 44 of file texture.h.


Public Member Functions

virtual void bind () const
virtual QString debugString () const
virtual void disable (bool unbind=true) const
virtual void enable (bool bind=true) const
virtual GLuint glId () const
virtual GLenum glTarget () const =0
bool isValid () const
QString name () const
virtual void setFilter (GLenum filter)
void setName (const QString &name)
virtual void setWrapMode (GLenum mode)=0
virtual void setWrapMode (GLenum coordinate, GLenum mode)
 TextureBase (const QString &name)
 TextureBase ()
virtual void unbind () const
virtual ~TextureBase ()

Protected Member Functions

void setValid (bool valid)

Protected Attributes

GLenum mFormat
GLuint mGLId
GLenum mInternalFormat
QString mName
bool mValid

Constructor & Destructor Documentation

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.

Definition at line 155 of file texture.cpp.

KGLLib::TextureBase::TextureBase ( const QString &  name  ) 

Same as above but also sets texture name to name.

Definition at line 161 of file texture.cpp.

KGLLib::TextureBase::~TextureBase (  )  [virtual]

Deletes the OpenGL texture associated with this object.

Definition at line 168 of file texture.cpp.


Member Function Documentation

void KGLLib::TextureBase::bind (  )  const [virtual]

Binds the texture onto currently active texture unit.

Definition at line 175 of file texture.cpp.

QString KGLLib::TextureBase::debugString (  )  const [virtual]

Definition at line 218 of file texture.cpp.

void KGLLib::TextureBase::disable ( bool  unbind = true  )  const [virtual]

Disables texturing with this texture type for currently active texture unit.

Parameters:
unbind if true then unbind() is called before disabling texturing

Definition at line 193 of file texture.cpp.

void KGLLib::TextureBase::enable ( bool  bind = true  )  const [virtual]

Enables texturing with this texture type for currently active texture unit.

Parameters:
bind if true then bind() is called after enabling texturing

Definition at line 185 of file texture.cpp.

virtual GLuint KGLLib::TextureBase::glId (  )  const [inline, virtual]

Returns:
internal OpenGL texture id of this texture.

Definition at line 156 of file texture.h.

virtual GLenum KGLLib::TextureBase::glTarget (  )  const [pure virtual]

TODO: maybe rename to glType().

Returns:
type of this texture (e.g. GL_TEXTURE_2D)

Implemented in KGLLib::Texture, and KGLLib::Texture3D.

bool KGLLib::TextureBase::isValid (  )  const [inline]

Returns:
whether the texture is valid

Definition at line 65 of file texture.h.

QString KGLLib::TextureBase::name (  )  const [inline]

Returns:
name of this texture.

It can be used to identify textures e.g. to ease debugging.

Definition at line 137 of file texture.h.

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:

  • GL_NEAREST - return nearest pixel. Usually you don't want this.
  • GL_LINEAR - return weighed average of neighboring pixels.
  • GL_NEAREST_MIPMAP_LINEAR - same as GL_LINEAR but uses nearest MIPMAP (aka bilinear).
  • GL_LINEAR_MIPMAP_LINEAR - uses GL_LINEAR on two neighboring mipmaps and then takes weighed average of them (aka trilinear) TODO: some better wording here GL_LINEAR_MIPMAP_LINEAR usually gives best quality but uses a third more memory and has a bit lower performance.
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???

Definition at line 201 of file texture.cpp.

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.

Definition at line 213 of file texture.cpp.

void KGLLib::TextureBase::setValid ( bool  valid  )  [inline, protected]

Definition at line 159 of file texture.h.

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:

  • GL_REPEAT is default and ignores integer part of the texture coordinate, causing the texture to be repeated.
  • GL_CLAMP clamps coordinates to range [0; 1]. TODO: explain other modes as well
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).

Definition at line 208 of file texture.cpp.

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)?

Definition at line 180 of file texture.cpp.


Member Data Documentation

GLenum KGLLib::TextureBase::mFormat [protected]

Definition at line 165 of file texture.h.

GLuint KGLLib::TextureBase::mGLId [protected]

Definition at line 163 of file texture.h.

GLenum KGLLib::TextureBase::mInternalFormat [protected]

Definition at line 166 of file texture.h.

QString KGLLib::TextureBase::mName [protected]

Definition at line 164 of file texture.h.

bool KGLLib::TextureBase::mValid [protected]

Definition at line 162 of file texture.h.


The documentation for this class was generated from the following files:
  • texture.h
  • texture.cpp

KGLLib

Skip menu "KGLLib"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

API Reference

Skip menu "API Reference"
  • KGLLib
Generated for API Reference by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal