OpenGLPrakt --> cObject --> cMaterial --> cTextureMaterial
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)
public cTextureMaterial ( const char * name = NULL ) ;
default constructor
name | optional name of object |
public cTextureMaterial ( const cADSEColor & color = cADSEColor ( ) , const int shininess = 0 , const char * name = NULL ) ;
constructor with initialization
color | material's color (cADSEColor object) |
shininess | how shiny is the surface (0..128) |
name | optional name of object |
public cTextureMaterial ( const char * texture , const cADSEColor & color , const int shininess , const char * name = NULL ) ;
constructor with initialization
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 |
public cTextureMaterial ( const char * texture , bool usemipmaps , const cADSEColor & color , const int shininess , const char * name = NULL ) ;
constructor with initialization
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 |
public cTextureMaterial ( const cTextureMaterial & ctm ) ;
copy constructor - important!
public virtual ~ cTextureMaterial ( ) ;
destructor
protected bool mInitialized
have we spoken to OpenGL yet?
protected string mTextureFile
file name of texture
protected bool mMipmapped
current state of mipmapping
protected int mSizeX
width of texture
protected int mSizeY
height of texture
protected int mComponentNo
number of color components within texture
protected void * mTextureData
texture data
protected GLuint mTextureName
handle for texture (OpenGL slang: name) 0 == no name allocated
protected GLuint mOldTexBinding
used by Start/EndMaterialUse to remember old bound texture
protected GLboolean mOldTex2DState
old state of GL_TEXTURE_2D
protected mMinFilter
protected mMinMmFilter
protected /** magnification filter */ mMagFilter
protected /** magnification filter */ /** wrap-mode for S coordinate */ mWrapS
protected /** magnification filter */ /** wrap-mode for T coordinate */ mWrapT
protected /** magnification filter */ /** glTexEnv mode (how to apply texel color) */ mEnvMode
protected mOldMinFilter
minification filter for mipmaping
protected mOldMagFilter
protected /** saved wrap-mode for S coordinate */ mOldWrapS
protected /** saved wrap-mode for S coordinate */ /** saved wrap-mode for T coordinate */ mOldWrapT
protected /** saved wrap-mode for S coordinate */ /** saved glTexEnv mode (how to apply texel color) */ mOldEnvMode
public virtual int Init ( ) ;
initialization: loads texture
public virtual void SetMipmapping ( bool state ) ;
enable/disable mipmapping
state | enable or disable mipmaps |
public virtual bool IsMipmapped ( ) const ;
get state of mipmapping
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.
public virtual void EndMaterialUse ( ) ;
end using the material's properties
public virtual int LoadTexture ( const char * texture , bool usemipmaps = false ) ;
load a (new) texture for the material
texture | file name of texture to use (JPEG) (NULL - delete texture, do not load a new one) |
usemipmaps | enable mipmapping? |
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)
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) |
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.
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) |
protected virtual const char * GetDefaultName ( ) const ;
protected virtual void UpdateTexture ( ) ;
update texture - upload it to OpenGL
protected virtual void Activate ( ) ;
activate material
protected virtual void Deactivate ( ) ;
deactivate material
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.