📄 ishaderapi.h
字号:
// Methods that can be called from the SHADER_INIT blocks of shaders
//-----------------------------------------------------------------------------
class IShaderInit
{
public:
// Loads up a texture
virtual void LoadTexture( IMaterialVar *pTextureVar ) = 0;
virtual void LoadBumpMap( IMaterialVar *pTextureVar ) = 0;
virtual void LoadCubeMap( IMaterialVar **ppParams, IMaterialVar *pTextureVar ) = 0;
};
//-----------------------------------------------------------------------------
// the shader API interface (methods called from shaders)
//-----------------------------------------------------------------------------
class IShaderShadow
{
public:
// Sets the default *shadow* state
virtual void SetDefaultState() = 0;
// Methods related to depth buffering
virtual void DepthFunc( ShaderDepthFunc_t depthFunc ) = 0;
virtual void EnableDepthWrites( bool bEnable ) = 0;
virtual void EnableDepthTest( bool bEnable ) = 0;
virtual void EnablePolyOffset( bool bEnable ) = 0;
// Suppresses/activates color writing
virtual void EnableColorWrites( bool bEnable ) = 0;
virtual void EnableAlphaWrites( bool bEnable ) = 0;
// Methods related to alpha blending
virtual void EnableBlending( bool bEnable ) = 0;
virtual void BlendFunc( ShaderBlendFactor_t srcFactor, ShaderBlendFactor_t dstFactor ) = 0;
// Alpha testing
virtual void EnableAlphaTest( bool bEnable ) = 0;
virtual void AlphaFunc( ShaderAlphaFunc_t alphaFunc, float alphaRef /* [0-1] */ ) = 0;
// Wireframe/filled polygons
virtual void PolyMode( ShaderPolyModeFace_t face, ShaderPolyMode_t polyMode ) = 0;
// Back face culling
virtual void EnableCulling( bool bEnable ) = 0;
// constant color + transparency
virtual void EnableConstantColor( bool bEnable ) = 0;
// Indicates we're preprocessing vertex data
virtual void EnableVertexDataPreprocess( bool bEnable ) = 0;
// Indicates the vertex format for use with a vertex shader
// The flags to pass in here come from the VertexFormatFlags_t enum
// If pTexCoordDimensions is *not* specified, we assume all coordinates
// are 2-dimensional
virtual void VertexShaderVertexFormat( unsigned int flags,
int numTexCoords, int* pTexCoordDimensions, int numBoneWeights,
int userDataSize ) = 0;
// Pixel and vertex shader methods
virtual void SetVertexShader( char const* pFileName, int nStaticVshIndex = 0 ) = 0;
virtual void SetPixelShader( char const* pFileName, int nStaticPshIndex = 0 ) = 0;
// Indicates we're going to light the model
virtual void EnableLighting( bool bEnable ) = 0;
// Enables specular lighting (lighting has also got to be enabled)
virtual void EnableSpecular( bool bEnable ) = 0;
// Convert from linear to gamma color space on writes to frame buffer.
virtual void EnableSRGBWrite( bool bEnable ) = 0;
// Indicates we're going to be using the ambient cube on stage0
virtual void EnableAmbientLightCubeOnStage0( bool bEnable ) = 0;
// Activate/deactivate skinning. Indexed blending is automatically
// enabled if it's available for this hardware. When blending is enabled,
// we allocate enough room for 3 weights (max allowed)
virtual void EnableVertexBlend( bool bEnable ) = 0;
// per texture unit stuff
virtual void OverbrightValue( TextureStage_t stage, float value ) = 0;
virtual void EnableTexture( TextureStage_t stage, bool bEnable ) = 0;
virtual void EnableTexGen( TextureStage_t stage, bool bEnable ) = 0;
virtual void TexGen( TextureStage_t stage, ShaderTexGenParam_t param ) = 0;
// alternate method of specifying per-texture unit stuff, more flexible and more complicated
// Can be used to specify different operation per channel (alpha/color)...
virtual void EnableCustomPixelPipe( bool bEnable ) = 0;
virtual void CustomTextureStages( int stageCount ) = 0;
virtual void CustomTextureOperation( TextureStage_t stage, ShaderTexChannel_t channel,
ShaderTexOp_t op, ShaderTexArg_t arg1, ShaderTexArg_t arg2 ) = 0;
// indicates what per-vertex data we're providing
virtual void DrawFlags( unsigned int drawFlags ) = 0;
// per texture unit stuff
virtual void VertexShaderOverbrightValue( float val ) = 0;
// A simpler method of dealing with alpha modulation
virtual void EnableAlphaPipe( bool bEnable ) = 0;
virtual void EnableConstantAlpha( bool bEnable ) = 0;
virtual void EnableVertexAlpha( bool bEnable ) = 0;
virtual void EnableTextureAlpha( TextureStage_t stage, bool bEnable ) = 0;
// GR - Separate alpha blending
virtual void EnableBlendingSeparateAlpha( bool bEnable ) = 0;
virtual void BlendFuncSeparateAlpha( ShaderBlendFactor_t srcFactor, ShaderBlendFactor_t dstFactor ) = 0;
};
//-----------------------------------------------------------------------------
// the 3D shader API interface
// This interface is all that shaders see.
//-----------------------------------------------------------------------------
class IShaderDynamicAPI
{
public:
// returns the current time in seconds....
virtual double CurrentTime() const = 0;
// Lightmap texture binding
virtual void BindLightmap( TextureStage_t stage ) = 0;
// GR - bind separate lightmap alpha
virtual void BindLightmapAlpha( TextureStage_t stage ) = 0;
virtual void BindBumpLightmap( TextureStage_t stage ) = 0;
virtual void BindWhite( TextureStage_t stage ) = 0;
virtual void BindBlack( TextureStage_t stage ) = 0;
virtual void BindGrey( TextureStage_t stage ) = 0;
virtual void BindSyncTexture( TextureStage_t stage, int texture ) = 0;
virtual void BindFBTexture( TextureStage_t stage ) = 0;
virtual void EnableSRGBRead( TextureStage_t stage, bool bEnable ) = 0;
// Gets the lightmap dimensions
virtual void GetLightmapDimensions( int *w, int *h ) = 0;
// Special system flat normal map binding.
virtual void BindFlatNormalMap( TextureStage_t stage ) = 0;
virtual void BindNormalizationCubeMap( TextureStage_t stage ) = 0;
// Fog methods...
virtual void FogMode( MaterialFogMode_t fogMode ) = 0;
virtual void FogColor3f( float r, float g, float b ) = 0;
virtual void FogColor3fv( float const* rgb ) = 0;
virtual void FogColor3ub( unsigned char r, unsigned char g, unsigned char b ) = 0;
virtual void FogColor3ubv( unsigned char const* rgb ) = 0;
// Scene fog state.
virtual void GetSceneFogColor( unsigned char *rgb ) = 0;
virtual MaterialFogMode_t GetSceneFogMode( ) = 0;
virtual float GetFogStart( void ) const = 0;
virtual float GetFogEnd( void ) const = 0;
// stuff related to matrix stacks
virtual void MatrixMode( MaterialMatrixMode_t matrixMode ) = 0;
virtual void PushMatrix() = 0;
virtual void PopMatrix() = 0;
virtual void LoadMatrix( float *m ) = 0;
virtual void MultMatrix( float *m ) = 0;
virtual void MultMatrixLocal( float *m ) = 0;
virtual void GetMatrix( MaterialMatrixMode_t matrixMode, float *dst ) = 0;
virtual void LoadIdentity( void ) = 0;
virtual void LoadCameraToWorld( void ) = 0;
virtual void Ortho( double left, double right, double bottom, double top, double zNear, double zFar ) = 0;
virtual void PerspectiveX( double fovx, double aspect, double zNear, double zFar ) = 0;
virtual void PickMatrix( int x, int y, int width, int height ) = 0;
virtual void Rotate( float angle, float x, float y, float z ) = 0;
virtual void Translate( float x, float y, float z ) = 0;
virtual void Scale( float x, float y, float z ) = 0;
virtual void ScaleXY( float x, float y ) = 0;
// Sets the color to modulate by
virtual void Color3f( float r, float g, float b ) = 0;
virtual void Color3fv( float const* pColor ) = 0;
virtual void Color4f( float r, float g, float b, float a ) = 0;
virtual void Color4fv( float const* pColor ) = 0;
virtual void Color3ub( unsigned char r, unsigned char g, unsigned char b ) = 0;
virtual void Color3ubv( unsigned char const* pColor ) = 0;
virtual void Color4ub( unsigned char r, unsigned char g, unsigned char b, unsigned char a ) = 0;
virtual void Color4ubv( unsigned char const* pColor ) = 0;
// Sets the constant register for vertex and pixel shaders
virtual void SetVertexShaderConstant( int var, float const* pVec, int numConst = 1, bool bForce = false ) = 0;
virtual void SetPixelShaderConstant( int var, float const* pVec, int numConst = 1, bool bForce = false ) = 0;
// Sets the default *dynamic* state
virtual void SetDefaultState() = 0;
// Get the current camera position in world space.
virtual void GetWorldSpaceCameraPosition( float* pPos ) const = 0;
virtual int GetCurrentNumBones( void ) const = 0;
virtual int GetCurrentLightCombo( void ) const = 0;
virtual int GetCurrentFogType( void ) const = 0;
// fixme: move this to shadow state
virtual void SetTextureTransformDimension( int textureStage, int dimension, bool projected ) = 0;
virtual void DisableTextureTransform( int textureStage ) = 0;
virtual void SetBumpEnvMatrix( int textureStage, float m00, float m01, float m10, float m11 ) = 0;
// Sets the vertex and pixel shaders
virtual void SetVertexShaderIndex( int vshIndex = -1 ) = 0;
virtual void SetPixelShaderIndex( int pshIndex = 0 ) = 0;
// Get the dimensions of the back buffer.
virtual void GetBackBufferDimensions( int& width, int& height ) const = 0;
// FIXME: The following 6 methods used to live in IShaderAPI
// and were moved for stdshader_dx8. Let's try to move them back!
// Render state for the ambient light cube
virtual void BindAmbientLightCubeToStage0( ) = 0;
// Get the lights
virtual int GetMaxLights( void ) const = 0;
virtual const LightDesc_t& GetLight( int lightNum ) const = 0;
// Render state for the ambient light cube (vertex shaders)
virtual void SetVertexShaderStateAmbientLightCube() = 0;
// Use this to get the mesh builder that allows us to modify vertex data
virtual CMeshBuilder* GetVertexModifyBuilder() = 0;
};
//-----------------------------------------------------------------------------
// Software vertex shaders
//-----------------------------------------------------------------------------
typedef void (*SoftwareVertexShader_t)( CMeshBuilder& meshBuilder, IMaterialVar **params, IShaderDynamicAPI *pShaderAPI );
#endif // ISHADERAPI_H
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -