newspeoplefor developersdocumentationdownloads

nShader2 Class Reference

#include <nshader2.h>

Inheritance diagram for nShader2:

nResource nRoot nObject nNode nReferenced nSignalEmitter nCgFXShader nD3D9Shader nGLShader nGLSLShader List of all members.

Detailed Description

A shader object loads itself from a shader resource file, and contains everything to render a mesh and texture. It may be completely render state based, use vertex and pixel shader programs, or both. Shaders usually use a 3rd party subsystem, like D3DX effects, or CgFX. This is done by subclasses of the nShader2 class.

How the shader is rendered is totally up to the gfx server.

For the sake of efficiency, shader parameters are now enums with associated string names. The use of enums allows to do parameter lookup as simple indexed array lookup. The disadvantage is of course, that new shader states require this file to be extended or replaced.

(C) 2002 RadonLabs GmbH

Definition at line 34 of file nshader2.h.


Public Member Functions

 nShader2 ()
 constructor
virtual ~nShader2 ()
 destructor
virtual bool HasTechnique (const char *t) const
 return true if technique exists in shader
virtual bool SetTechnique (const char *t)
 set a technique
virtual const char * GetTechnique () const
 get current technique
virtual int UpdateInstanceStreamDecl (nInstanceStream::Declaration &decl)
 create or append an instance stream declaration for this shader
virtual bool IsParameterUsed (nShaderState::Param p)
 is parameter used by effect?
virtual void SetBool (nShaderState::Param p, bool val)
 set bool parameter
virtual void SetInt (nShaderState::Param p, int val)
 set int parameter
virtual void SetFloat (nShaderState::Param p, float val)
 set float parameter
virtual void SetVector4 (nShaderState::Param p, const vector4 &val)
 set vector parameter as vector4 (fastest)
virtual void SetVector3 (nShaderState::Param p, const vector3 &val)
 set vector parameter as vector3
virtual void SetFloat4 (nShaderState::Param p, const nFloat4 &val)
 set vector parameter as nFloat4
virtual void SetMatrix (nShaderState::Param p, const matrix44 &val)
 set matrix parameter
virtual void SetTexture (nShaderState::Param p, nTexture2 *tex)
 set texture parameter
virtual void SetBoolArray (nShaderState::Param p, const bool *array, int count)
 set bool[] parameter
virtual void SetIntArray (nShaderState::Param p, const int *array, int count)
 set int[] parameter
virtual void SetFloatArray (nShaderState::Param p, const float *array, int count)
 set float[] parameter
virtual void SetFloat4Array (nShaderState::Param p, const nFloat4 *array, int count)
 set float4[] parameter
virtual void SetVector4Array (nShaderState::Param p, const vector4 *array, int count)
 set vector4[] parameter
virtual void SetMatrixArray (nShaderState::Param p, const matrix44 *array, int count)
 set matrix array parameter
virtual void SetMatrixPointerArray (nShaderState::Param p, const matrix44 **array, int count)
 set matrix pointer array parameter
virtual void SetParams (const nShaderParams &params)
 set a whole shader parameter block at once
virtual int Begin (bool saveState)
 begin applying the shader, returns number of passes
virtual void BeginPass (int pass)
 begin a pass
virtual void CommitChanges ()
 commit changes during pass before rendering
virtual void EndPass ()
 end a pass
virtual void End ()
 finish applying the shader

Constructor & Destructor Documentation

nShader2::nShader2  ) 
 

constructor

Definition at line 13 of file nshader2_main.cc.

nShader2::~nShader2  )  [virtual]
 

destructor

Definition at line 21 of file nshader2_main.cc.


Member Function Documentation

bool nShader2::HasTechnique const char *  t  )  const [virtual]
 

return true if technique exists in shader

Reimplemented in nD3D9Shader, and nGLSLShader.

Definition at line 245 of file nshader2_main.cc.

bool nShader2::SetTechnique const char *  t  )  [virtual]
 

set a technique

Reimplemented in nD3D9Shader, and nGLSLShader.

Definition at line 254 of file nshader2_main.cc.

const char * nShader2::GetTechnique  )  const [virtual]
 

get current technique

Reimplemented in nD3D9Shader, and nGLSLShader.

Definition at line 263 of file nshader2_main.cc.

int nShader2::UpdateInstanceStreamDecl nInstanceStream::Declaration decl  )  [virtual]
 

create or append an instance stream declaration for this shader

Create or update the instance stream declaration for this shader. Stream components will be appended, unless they already exist in the declaration. Returns the number of components appended. Override this method in a subclass.

Reimplemented in nD3D9Shader.

Definition at line 37 of file nshader2_main.cc.

bool nShader2::IsParameterUsed nShaderState::Param  p  )  [virtual]
 

is parameter used by effect?

Reimplemented in nD3D9Shader, nCgFXShader, and nGLSLShader.

Definition at line 46 of file nshader2_main.cc.

void nShader2::SetBool nShaderState::Param  p,
bool  val
[virtual]
 

set bool parameter

Reimplemented in nD3D9Shader, nCgFXShader, and nGLSLShader.

Definition at line 55 of file nshader2_main.cc.

void nShader2::SetInt nShaderState::Param  p,
int  val
[virtual]
 

set int parameter

Reimplemented in nD3D9Shader, nCgFXShader, and nGLSLShader.

Definition at line 73 of file nshader2_main.cc.

void nShader2::SetFloat nShaderState::Param  p,
float  val
[virtual]
 

set float parameter

Reimplemented in nD3D9Shader, nCgFXShader, and nGLSLShader.

Definition at line 91 of file nshader2_main.cc.

void nShader2::SetVector4 nShaderState::Param  p,
const vector4 val
[virtual]
 

set vector parameter as vector4 (fastest)

Reimplemented in nD3D9Shader, nCgFXShader, and nGLSLShader.

Definition at line 109 of file nshader2_main.cc.

void nShader2::SetVector3 nShaderState::Param  p,
const vector3 val
[virtual]
 

set vector parameter as vector3

Reimplemented in nD3D9Shader, nCgFXShader, and nGLSLShader.

Definition at line 118 of file nshader2_main.cc.

void nShader2::SetFloat4 nShaderState::Param  p,
const nFloat4 val
[virtual]
 

set vector parameter as nFloat4

Reimplemented in nD3D9Shader, nCgFXShader, and nGLSLShader.

Definition at line 127 of file nshader2_main.cc.

void nShader2::SetMatrix nShaderState::Param  p,
const matrix44 val
[virtual]
 

set matrix parameter

Reimplemented in nD3D9Shader, nCgFXShader, and nGLSLShader.

Definition at line 154 of file nshader2_main.cc.

void nShader2::SetTexture nShaderState::Param  p,
nTexture2 tex
[virtual]
 

set texture parameter

Reimplemented in nD3D9Shader, nCgFXShader, and nGLSLShader.

Definition at line 181 of file nshader2_main.cc.

void nShader2::SetBoolArray nShaderState::Param  p,
const bool *  array,
int  count
[virtual]
 

set bool[] parameter

Reimplemented in nD3D9Shader, nCgFXShader, and nGLSLShader.

Definition at line 64 of file nshader2_main.cc.

void nShader2::SetIntArray nShaderState::Param  p,
const int *  array,
int  count
[virtual]
 

set int[] parameter

Reimplemented in nD3D9Shader, nCgFXShader, and nGLSLShader.

Definition at line 82 of file nshader2_main.cc.

void nShader2::SetFloatArray nShaderState::Param  p,
const float *  array,
int  count
[virtual]
 

set float[] parameter

Reimplemented in nD3D9Shader, nCgFXShader, and nGLSLShader.

Definition at line 100 of file nshader2_main.cc.

void nShader2::SetFloat4Array nShaderState::Param  p,
const nFloat4 array,
int  count
[virtual]
 

set float4[] parameter

Reimplemented in nD3D9Shader, nCgFXShader, and nGLSLShader.

Definition at line 136 of file nshader2_main.cc.

void nShader2::SetVector4Array nShaderState::Param  p,
const vector4 array,
int  count
[virtual]
 

set vector4[] parameter

Reimplemented in nD3D9Shader, nCgFXShader, and nGLSLShader.

Definition at line 145 of file nshader2_main.cc.

void nShader2::SetMatrixArray nShaderState::Param  p,
const matrix44 array,
int  count
[virtual]
 

set matrix array parameter

Reimplemented in nD3D9Shader, nCgFXShader, and nGLSLShader.

Definition at line 163 of file nshader2_main.cc.

void nShader2::SetMatrixPointerArray nShaderState::Param  p,
const matrix44 **  array,
int  count
[virtual]
 

set matrix pointer array parameter

Reimplemented in nD3D9Shader, nCgFXShader, and nGLSLShader.

Definition at line 172 of file nshader2_main.cc.

void nShader2::SetParams const nShaderParams params  )  [virtual]
 

set a whole shader parameter block at once

Reimplemented in nD3D9Shader, nCgFXShader, and nGLSLShader.

Definition at line 190 of file nshader2_main.cc.

int nShader2::Begin bool  saveState  )  [virtual]
 

begin applying the shader, returns number of passes

Reimplemented in nD3D9Shader, nCgFXShader, and nGLSLShader.

Definition at line 199 of file nshader2_main.cc.

void nShader2::BeginPass int  pass  )  [virtual]
 

begin a pass

Reimplemented in nD3D9Shader, nCgFXShader, and nGLSLShader.

Definition at line 209 of file nshader2_main.cc.

void nShader2::CommitChanges  )  [virtual]
 

commit changes during pass before rendering

Reimplemented in nD3D9Shader, nCgFXShader, and nGLSLShader.

Definition at line 218 of file nshader2_main.cc.

void nShader2::EndPass  )  [virtual]
 

end a pass

Reimplemented in nD3D9Shader, nCgFXShader, and nGLSLShader.

Definition at line 227 of file nshader2_main.cc.

void nShader2::End  )  [virtual]
 

finish applying the shader

Reimplemented in nD3D9Shader, nCgFXShader, and nGLSLShader.

Definition at line 236 of file nshader2_main.cc.


The documentation for this class was generated from the following files:

Copyright © 1999-2005 by the contributing authors. Ideas, requests, problems: Send feedback.