📄 imaterialsystem.h
字号:
//=========== (C) Copyright 1999 Valve, L.L.C. All rights reserved. ===========
//
// The copyright to the contents herein is the property of Valve, L.L.C.
// The contents may be used and/or copied only with the written permission of
// Valve, L.L.C., or in accordance with the terms and conditions stipulated in
// the agreement/contract under which the contents have been supplied.
//
// $Header: $
// $NoKeywords: $
//
// main material system interface
//=============================================================================
#ifndef IMATERIALSYSTEM_H
#define IMATERIALSYSTEM_H
#ifdef _WIN32
#pragma once
#endif
#include "interface.h"
#include "vector.h"
#include "vector4d.h"
#include "appframework/IAppSystem.h"
#include "imageloader.h"
//-----------------------------------------------------------------------------
// forward declarations
//-----------------------------------------------------------------------------
class IMaterial;
class IMesh;
struct MaterialSystem_Config_t;
class VMatrix;
//-----------------------------------------------------------------------------
// important enumeration
//-----------------------------------------------------------------------------
// NOTE NOTE NOTE!!!! If you up this, grep for "NEW_INTERFACE" to see if there is anything
// waiting to be enabled during an interface revision.
#define MATERIAL_SYSTEM_INTERFACE_VERSION "VMaterialSystem060"
enum ShaderParamType_t
{
SHADER_PARAM_TYPE_TEXTURE,
SHADER_PARAM_TYPE_INTEGER,
SHADER_PARAM_TYPE_COLOR,
SHADER_PARAM_TYPE_VEC2,
SHADER_PARAM_TYPE_VEC3,
SHADER_PARAM_TYPE_VEC4,
SHADER_PARAM_TYPE_ENVMAP, // obsolete
SHADER_PARAM_TYPE_FLOAT,
SHADER_PARAM_TYPE_BOOL,
SHADER_PARAM_TYPE_FOURCC,
SHADER_PARAM_TYPE_MATRIX,
SHADER_PARAM_TYPE_MATERIAL,
};
enum MaterialMatrixMode_t
{
MATERIAL_VIEW = 0,
MATERIAL_PROJECTION,
// Texture matrices
MATERIAL_TEXTURE0,
MATERIAL_TEXTURE1,
MATERIAL_TEXTURE2,
MATERIAL_TEXTURE3,
MATERIAL_TEXTURE4,
MATERIAL_TEXTURE5,
MATERIAL_TEXTURE6,
MATERIAL_TEXTURE7,
MATERIAL_MODEL,
// FIXME: How do I specify the actual number of matrix modes?
NUM_MODEL_TRANSFORMS = 16,
MATERIAL_MODEL_MAX = MATERIAL_MODEL + NUM_MODEL_TRANSFORMS,
// Total number of matrices
NUM_MATRIX_MODES = MATERIAL_MODEL_MAX,
// Number of texture transforms
NUM_TEXTURE_TRANSFORMS = MATERIAL_TEXTURE7 - MATERIAL_TEXTURE0 + 1
};
#define MATERIAL_MODEL_MATRIX( _n ) (MaterialMatrixMode_t)(MATERIAL_MODEL + (_n))
enum MaterialPrimitiveType_t
{
MATERIAL_POINTS = 0x0,
MATERIAL_LINES,
MATERIAL_TRIANGLES,
MATERIAL_TRIANGLE_STRIP,
MATERIAL_LINE_STRIP,
MATERIAL_LINE_LOOP, // a single line loop
MATERIAL_POLYGON, // this is a *single* polygon
MATERIAL_QUADS,
// This is used for static meshes that contain multiple types of
// primitive types. When calling draw, you'll need to specify
// a primitive type.
MATERIAL_HETEROGENOUS
};
enum MaterialPropertyTypes_t
{
MATERIAL_PROPERTY_NEEDS_LIGHTMAP = 0, // bool
MATERIAL_PROPERTY_OPACITY, // int (enum MaterialPropertyOpacityTypes_t)
MATERIAL_PROPERTY_REFLECTIVITY, // vec3_t
MATERIAL_PROPERTY_NEEDS_BUMPED_LIGHTMAPS // bool
};
// acceptable property values for MATERIAL_PROPERTY_OPACITY
enum MaterialPropertyOpacityTypes_t
{
MATERIAL_ALPHATEST = 0,
MATERIAL_OPAQUE,
MATERIAL_TRANSLUCENT
};
enum MaterialBufferTypes_t
{
MATERIAL_FRONT = 0,
MATERIAL_BACK
};
enum MaterialCullMode_t
{
MATERIAL_CULLMODE_CCW, // this culls polygons with counterclockwise winding
MATERIAL_CULLMODE_CW // this culls polygons with clockwise winding
};
enum MaterialVertexFormat_t
{
MATERIAL_VERTEX_FORMAT_MODEL,
MATERIAL_VERTEX_FORMAT_COLOR,
};
enum MaterialFogMode_t
{
MATERIAL_FOG_NONE,
MATERIAL_FOG_LINEAR,
MATERIAL_FOG_LINEAR_BELOW_FOG_Z,
};
enum MaterialHeightClipMode_t
{
MATERIAL_HEIGHTCLIPMODE_DISABLE,
MATERIAL_HEIGHTCLIPMODE_RENDER_ABOVE_HEIGHT,
MATERIAL_HEIGHTCLIPMODE_RENDER_BELOW_HEIGHT
};
//-----------------------------------------------------------------------------
// Light structure
//-----------------------------------------------------------------------------
enum LightType_t
{
MATERIAL_LIGHT_DISABLE = 0,
MATERIAL_LIGHT_POINT,
MATERIAL_LIGHT_DIRECTIONAL,
MATERIAL_LIGHT_SPOT,
};
enum LightType_OptimizationFlags_t
{
LIGHTTYPE_OPTIMIZATIONFLAGS_HAS_ATTENUATION0 = 1,
LIGHTTYPE_OPTIMIZATIONFLAGS_HAS_ATTENUATION1 = 2,
LIGHTTYPE_OPTIMIZATIONFLAGS_HAS_ATTENUATION2 = 4,
};
struct LightDesc_t
{
LightType_t m_Type;
Vector m_Color;
Vector m_Position;
Vector m_Direction;
float m_Range;
float m_Falloff;
float m_Attenuation0;
float m_Attenuation1;
float m_Attenuation2;
float m_Theta;
float m_Phi;
// These aren't used by DX8. . used for software lighting.
float m_ThetaDot;
float m_PhiDot;
unsigned int m_Flags;
};
//-----------------------------------------------------------------------------
// Standard lightmaps
//-----------------------------------------------------------------------------
enum StandardLightmap_t
{
MATERIAL_SYSTEM_LIGHTMAP_PAGE_WHITE = -1,
MATERIAL_SYSTEM_LIGHTMAP_PAGE_BLACK = -2,
MATERIAL_SYSTEM_LIGHTMAP_PAGE_FLAT_NORMAL = -3,
MATERIAL_SYSTEM_LIGHTMAP_PAGE_WHITE_BUMP = -4
};
struct MaterialSystem_SortInfo_t
{
IMaterial *material;
int lightmapPageID;
};
//-----------------------------------------------------------------------------
// Information about each adapter
//-----------------------------------------------------------------------------
enum
{
MATERIAL_ADAPTER_NAME_LENGTH = 512
};
struct MaterialAdapterInfo_t
{
char m_pDriverName[MATERIAL_ADAPTER_NAME_LENGTH];
char m_pDriverDescription[MATERIAL_ADAPTER_NAME_LENGTH];
};
struct Material3DDriverInfo_t
{
char m_pDriverName[MATERIAL_ADAPTER_NAME_LENGTH];
char m_pDriverDescription[MATERIAL_ADAPTER_NAME_LENGTH];
char m_pDriverVersion[MATERIAL_ADAPTER_NAME_LENGTH];
unsigned int m_VendorID;
unsigned int m_DeviceID;
unsigned int m_SubSysID;
unsigned int m_Revision;
unsigned int m_WHQLLevel;
};
//-----------------------------------------------------------------------------
// Video mode info..
//-----------------------------------------------------------------------------
struct MaterialVideoMode_t
{
int m_Width; // if width and height are 0 and you select
int m_Height; // windowed mode, it'll use the window size
ImageFormat m_Format; // use ImageFormats (ignored for windowed mode)
int m_RefreshRate; // 0 == default (ignored for windowed mode)
};
//-----------------------------------------------------------------------------
// Flags to be used with the Init call
//-----------------------------------------------------------------------------
enum MaterialInitFlags_t
{
MATERIAL_INIT_REFERENCE_RASTERIZER = 0x4,
};
//-----------------------------------------------------------------------------
// Flags to be used when setting video mode..
//-----------------------------------------------------------------------------
enum MaterialVideoModeFlags_t
{
MATERIAL_VIDEO_MODE_WINDOWED = 0x1,
MATERIAL_VIDEO_MODE_RESIZING = 0x2,
MATERIAL_VIDEO_MODE_SOFTWARE_TL = 0x8,
MATERIAL_VIDEO_MODE_NO_WAIT_FOR_VSYNC = 0x10,
// Use this for multiple views. When setting the mode,
// the parent window won't actually get drawn. You
// need to add views which will get drawn.
MATERIAL_VIDEO_MODE_PARENT_WINDOW = 0x20,
MATERIAL_VIDEO_MODE_ANTIALIAS = 0x40,
MATERIAL_VIDEO_MODE_PRELOAD_SHADERS = 0x80,
MATERIAL_VIDEO_MODE_QUIT_AFTER_PRELOAD = 0x100,
};
//-----------------------------------------------------------------------------
// MaterialRect_t struct - used for DrawDebugText
//-----------------------------------------------------------------------------
struct MaterialRect_t
{
long left;
long top;
long right;
long bottom;
};
//-----------------------------------------------------------------------------
// A function to be called when we need to release all vertex buffers
//-----------------------------------------------------------------------------
typedef void (*MaterialBufferReleaseFunc_t)( );
typedef void (*MaterialBufferRestoreFunc_t)( );
typedef int VertexBufferHandle_t;
typedef unsigned short MaterialHandle_t;
class IMaterialProxyFactory;
class ITexture;
class IMaterialSystemHardwareConfig;
class IMaterialSystem : public IAppSystem
{
public:
// Call this to set an explicit shader version to use
// Must be called before Init().
virtual void SetShaderAPI( char const *pShaderAPIDLL ) = 0;
// Must be called before Init(), if you're going to call it at all...
virtual void SetAdapter( int nAdapter, int nFlags ) = 0;
// Call this to initialize the material system
// returns a method to create interfaces in the shader dll
virtual CreateInterfaceFn Init( char const* pShaderAPIDLL,
IMaterialProxyFactory *pMaterialProxyFactory,
CreateInterfaceFn fileSystemFactory,
CreateInterfaceFn cvarFactory=NULL ) = 0;
// virtual void Shutdown( ) = 0;
virtual IMaterialSystemHardwareConfig *GetHardwareConfig( const char *pVersion, int *returnCode ) = 0;
// Gets the number of adapters...
virtual int GetDisplayAdapterCount() const = 0;
// Returns info about each adapter
virtual void GetDisplayAdapterInfo( int adapter, MaterialAdapterInfo_t& info ) const = 0;
// Returns the number of modes
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -