OpenGLPrakt --> cObject --> cMaterial --> cTextureMaterial

class cTextureMaterial
    extends cMaterial as public

a class for representation of an OpenGL material

This is thought to be the base material class.

It might be derived from it later. (e.g. for Texturing)

Source:
../src/cTextureMaterial.hh:36

Constructors Index

cTextureMaterial
[public] default constructor
cTextureMaterial
[public] constructor with initialization
cTextureMaterial
[public] constructor with initialization
cTextureMaterial
[public] constructor with initialization
cTextureMaterial
[public] copy constructor - important!
~cTextureMaterial
[public] destructor


Variables Index

mComponentNo
[protected] number of color components within texture
mEnvMode
[protected]
mInitialized
[protected] have we spoken to OpenGL yet?
mMagFilter
[protected]
mMinFilter
[protected]
mMinMmFilter
[protected]
mMipmapped
[protected] current state of mipmapping
mOldEnvMode
[protected]
mOldMagFilter
[protected]
mOldMinFilter
[protected] minification filter for mipmaping
mOldTex2DState
[protected] old state of GL_TEXTURE_2D
mOldTexBinding
[protected] used by Start/EndMaterialUse to remember old bound texture
mOldWrapS
[protected]
mOldWrapT
[protected]
mSizeX
[protected] width of texture
mSizeY
[protected] height of texture
mTextureData
[protected] texture data
mTextureFile
[protected] file name of texture
mTextureName
[protected] handle for texture (OpenGL slang: name) 0 == no name allocated
mWrapS
[protected]
mWrapT
[protected]


Methods Index

Activate
[protected] activate material
AllocateTextureName
[protected] aquire a texture name from OpenGL
Deactivate
[protected] deactivate material
EndMaterialUse
[public] end using the material's properties
GetDefaultName
[protected]
Init
[public] initialization: loads texture
IsMipmapped
[public] get state of mipmapping
LoadTexture
[public] load a (new) texture for the material
SetMipmapping
[public] enable/disable mipmapping
SetTextureParameters
[public] set parameters for texturing
StartMaterialUse
[public] start using the material's properties
UpdateTexture
[protected] update texture - upload it to OpenGL
UseTexture
[public] supply a (new) texture for the material (it is copied)


Constructors

cTextureMaterial

public cTextureMaterial ( const char * name = NULL ) ;

default constructor

Parameters:
name optional name of object

cTextureMaterial

public cTextureMaterial ( const cADSEColor & color = cADSEColor ( ) ,
                          const int shininess = 0 ,
                          const char * name = NULL ) ;

constructor with initialization

Parameters:
color material's color (cADSEColor object)
shininess how shiny is the surface (0..128)
name optional name of object

cTextureMaterial

public cTextureMaterial ( const char * texture ,
                          const cADSEColor & color ,
                          const int shininess ,
                          const char * name = NULL ) ;

constructor with initialization

Parameters:
texture file name of texture to load The texture is loaded by Init(). Only JPEG files are supported.
color material's color (cADSEColor object)
shininess how shiny is the surface (0..128)
name optional name of object

cTextureMaterial

public cTextureMaterial ( const char * texture ,
                          bool usemipmaps ,
                          const cADSEColor & color ,
                          const int shininess ,
                          const char * name = NULL ) ;

constructor with initialization

Parameters:
texture file name of texture to load The texture is loaded by Init(). Only JPEG files are supported.
usemipmaps enable mipmapping?
color material's color (cADSEColor object)
shininess how shiny is the surface (0..128)
name optional name of object

cTextureMaterial

public cTextureMaterial ( const cTextureMaterial & ctm ) ;

copy constructor - important!

cTextureMaterial

public virtual ~ cTextureMaterial ( ) ;

destructor


Variables

mInitialized

protected bool mInitialized

have we spoken to OpenGL yet?

mTextureFile

protected string mTextureFile

file name of texture

mMipmapped

protected bool mMipmapped

current state of mipmapping

mSizeX

protected int mSizeX

width of texture

mSizeY

protected int mSizeY

height of texture

mComponentNo

protected int mComponentNo

number of color components within texture

mTextureData

protected void * mTextureData

texture data

mTextureName

protected GLuint mTextureName

handle for texture (OpenGL slang: name) 0 == no name allocated

mOldTexBinding

protected GLuint mOldTexBinding

used by Start/EndMaterialUse to remember old bound texture

mOldTex2DState

protected GLboolean mOldTex2DState

old state of GL_TEXTURE_2D

mMinFilter

protected mMinFilter

mMinMmFilter

protected mMinMmFilter

mMagFilter

protected /** magnification filter  */ mMagFilter

mWrapS

protected /** magnification filter  */ /** wrap-mode for S coordinate */ mWrapS

mWrapT

protected /** magnification filter  */ /** wrap-mode for T coordinate */ mWrapT

mEnvMode

protected /** magnification filter  */ /** glTexEnv mode (how to apply texel color) */ mEnvMode

mOldMinFilter

protected mOldMinFilter

minification filter for mipmaping

mOldMagFilter

protected mOldMagFilter

mOldWrapS

protected /** saved wrap-mode for S coordinate */ mOldWrapS

mOldWrapT

protected /** saved wrap-mode for S coordinate */ /** saved wrap-mode for T coordinate */ mOldWrapT

mOldEnvMode

protected /** saved wrap-mode for S coordinate */ /** saved glTexEnv mode (how to apply texel color) */ mOldEnvMode


Methods

Init

public virtual int Init ( ) ;

initialization: loads texture

SetMipmapping

public virtual void SetMipmapping ( bool state ) ;

enable/disable mipmapping

Parameters:
state enable or disable mipmaps

IsMipmapped

public virtual bool IsMipmapped ( ) const ;

get state of mipmapping

StartMaterialUse

public virtual void StartMaterialUse ( ) ;

start using the material's properties

This is only neccessary to embed a cMaterial into a cVisibleObject. We cannot use Activate() there since it will call cObject::Activate() which in turn calls Deactivate() so the material settings are undone before the object gets drawn.

EndMaterialUse

public virtual void EndMaterialUse ( ) ;

end using the material's properties

LoadTexture

public virtual int LoadTexture ( const char * texture ,
                                 bool usemipmaps = false ) ;

load a (new) texture for the material

Parameters:
texture file name of texture to use (JPEG) (NULL - delete texture, do not load a new one)
usemipmaps enable mipmapping?

Return:
-1 on error, 0 on success

UseTexture

public virtual int UseTexture ( int width ,
                                int height ,
                                int components ,
                                const unsigned char * data ,
                                bool usemipmaps = false ) ;

supply a (new) texture for the material (it is copied)

Parameters:
width width of texture
height heigh of texture
components number of color components in texture (3 = RGB, 4 = RGBA, no other values allowed)
data unsigned char ptr to texture data
usemipmaps enable mipmapping? (default: no)

Return:
-1 on error, 0 on success

SetTextureParameters

public virtual void SetTextureParameters ( GLenum min_filter = GL_NEAREST ,
                                           GLenum min_mm_filter = GL_NEAREST_MIPMAP_LINEAR ,
                                           GLenum mag_filter = GL_NEAREST ,
                                           GLenum wrap_s = GL_REPEAT ,
                                           GLenum wrap_t = GL_REPEAT ,
                                           GLenum env_mode = GL_DECAL ) ;

set parameters for texturing

See OpenGL reference for GL_[NEAREST|LINEAR] etc. constants.

Parameters:
min_filter filter to use for minification (default: GL_NEAREST)
min_mm_filter filter to use for minification when using mipmapping (default: GL_NEAREST_MIPMAP_LINEAR)
mag_filter filter to use for magnification (default: GL_NEAREST)
wrap_s method to use for wrapping textures s-coordinate (default: GL_REPEAT)
wrap_t method to use for wrapping textures t-coordinate (default: GL_REPEAT)
env_mode how to interpret the texel's color (default: GL_DECAL)

GetDefaultName

protected virtual const char * GetDefaultName ( ) const ;

UpdateTexture

protected virtual void UpdateTexture ( ) ;

update texture - upload it to OpenGL

Activate

protected virtual void Activate ( ) ;

activate material

Deactivate

protected virtual void Deactivate ( ) ;

deactivate material

AllocateTextureName

protected void AllocateTextureName ( ) ;

aquire a texture name from OpenGL


This documentation was generated automatically by the ccdoc tool (version 0.7a).
Click here to submit a bug report or feature request.

Click here to return to the top of the page.