📄 imaterialsystem.h
字号:
virtual int GetModeCount( int adapter ) const = 0;
// Returns mode information..
virtual void GetModeInfo( int adapter, int mode, MaterialVideoMode_t& info ) const = 0;
// Returns the mode info for the current display device
virtual void GetDisplayMode( MaterialVideoMode_t& mode ) const = 0;
// Sets the mode...
virtual bool SetMode( void* hwnd, const MaterialVideoMode_t &mode, int flags, int nSuperSamples = 0 ) = 0;
// Creates/ destroys a child window
virtual bool AddView( void* hwnd ) = 0;
virtual void RemoveView( void* hwnd ) = 0;
// Sets the view
virtual void SetView( void* hwnd ) = 0;
virtual void Get3DDriverInfo( Material3DDriverInfo_t& info ) const = 0;
// return true if lightmaps need to be redownloaded
// Call this before rendering each frame with the current config
// for the material system.
// Will do whatever is necessary to get the material system into the correct state
// upon configuration change. .doesn't much else otherwise.
virtual bool UpdateConfig( MaterialSystem_Config_t *config, bool forceUpdate ) = 0;
// This is the interface for knowing what materials are available
// is to use the following functions to get a list of materials. The
// material names will have the full path to the material, and that is the
// only way that the directory structure of the materials will be seen through this
// interface.
// NOTE: This is mostly for worldcraft to get a list of materials to put
// in the "texture" browser.in Worldcraft
virtual MaterialHandle_t FirstMaterial() const = 0;
// returns InvalidMaterial if there isn't another material.
// WARNING: you must call GetNextMaterial until it returns NULL,
// otherwise there will be a memory leak.
virtual MaterialHandle_t NextMaterial( MaterialHandle_t h ) const = 0;
// This is the invalid material
virtual MaterialHandle_t InvalidMaterial() const = 0;
// Returns a particular material
virtual IMaterial* GetMaterial( MaterialHandle_t h ) const = 0;
// Find a material by name.
// The name of a material is a full path to
// the vmt file starting from "hl2/materials" (or equivalent) without
// a file extension.
// eg. "dev/dev_bumptest" refers to somethign similar to:
// "d:/hl2/hl2/materials/dev/dev_bumptest.vmt"
virtual IMaterial * FindMaterial( char const* pMaterialName, bool *pFound, bool complain = true ) = 0;
virtual ITexture * FindTexture( char const* pTextureName, bool *pFound, bool complain = true ) = 0;
virtual void BindLocalCubemap( ITexture *pTexture ) = 0;
// pass in an ITexture (that is build with "rendertarget" "1") or
// pass in NULL for the regular backbuffer.
virtual void SetRenderTarget( ITexture *pTexture ) = 0;
virtual ITexture * GetRenderTarget( void ) = 0;
virtual void GetRenderTargetDimensions( int &width, int &height) const = 0;
virtual void GetBackBufferDimensions( int &width, int &height) const = 0;
// Get the total number of materials in the system. These aren't just the used
// materials, but the complete collection.
virtual int GetNumMaterials( ) const = 0;
// Remove any materials from memory that aren't in use as determined
// by the IMaterial's reference count.
virtual void UncacheUnusedMaterials( ) = 0;
// uncache all materials. . good for forcing reload of materials.
virtual void UncacheAllMaterials( ) = 0;
// Load any materials into memory that are to be used as determined
// by the IMaterial's reference count.
virtual void CacheUsedMaterials( ) = 0;
// Force all textures to be reloaded from disk.
virtual void ReloadTextures( ) = 0;
//
// lightmap allocation stuff
//
// To allocate lightmaps, sort the whole world by material twice.
// The first time through, call AllocateLightmap for every surface.
// that has a lightmap.
// The second time through, call AllocateWhiteLightmap for every
// surface that expects to use shaders that expect lightmaps.
virtual void BeginLightmapAllocation( ) = 0;
// returns the sorting id for this surface
virtual int AllocateLightmap( int width, int height,
int offsetIntoLightmapPage[2],
IMaterial *pMaterial ) = 0;
// returns the sorting id for this surface
virtual int AllocateWhiteLightmap( IMaterial *pMaterial ) = 0;
virtual void EndLightmapAllocation( ) = 0;
// lightmaps are in linear color space
// lightmapPageID is returned by GetLightmapPageIDForSortID
// lightmapSize and offsetIntoLightmapPage are returned by AllocateLightmap.
// You should never call UpdateLightmap for a lightmap allocated through
// AllocateWhiteLightmap.
virtual void UpdateLightmap( int lightmapPageID, int lightmapSize[2],
int offsetIntoLightmapPage[2],
float *pFloatImage, float *pFloatImageBump1,
float *pFloatImageBump2, float *pFloatImageBump3 ) = 0;
// Force the lightmaps updated with UpdateLightmap to be sent to the hardware.
virtual void FlushLightmaps( ) = 0;
// fixme: could just be an array of ints for lightmapPageIDs since the material
// for a surface is already known.
virtual int GetNumSortIDs( ) = 0;
// virtual int GetLightmapPageIDForSortID( int sortID ) = 0;
virtual void GetSortInfo( MaterialSystem_SortInfo_t *sortInfoArray ) = 0;
virtual void BeginFrame( ) = 0;
virtual void EndFrame( ) = 0;
// Bind a material is current for rendering.
virtual void Bind( IMaterial *material, void *proxyData = 0 ) = 0;
// Bind a lightmap page current for rendering. You only have to
// do this for materials that require lightmaps.
virtual void BindLightmapPage( int lightmapPageID ) = 0;
// Used for WorldCraft lighting preview mode.
virtual void SetForceBindWhiteLightmaps( bool bForce ) = 0;
// inputs are between 0 and 1
virtual void DepthRange( float zNear, float zFar ) = 0;
virtual void ClearBuffers( bool bClearColor, bool bClearDepth ) = 0;
// read to a unsigned char rgb image.
virtual void ReadPixels( int x, int y, int width, int height, unsigned char *data, ImageFormat dstFormat ) = 0;
// Sets lighting
virtual void SetAmbientLight( float r, float g, float b ) = 0;
virtual void SetLight( int lightNum, LightDesc_t& desc ) = 0;
// The faces of the cube are specified in the same order as cubemap textures
virtual void SetAmbientLightCube( Vector4D cube[6] ) = 0;
// Blit the backbuffer to the framebuffer texture
virtual void CopyRenderTargetToTexture( ITexture *pTexture ) = 0;
// Set the current texture that is a copy of the framebuffer.
virtual void SetFrameBufferCopyTexture( ITexture *pTexture ) = 0;
virtual ITexture *GetFrameBufferCopyTexture( void ) = 0;
// Get the image format of the back buffer. . useful when creating render targets, etc.
virtual ImageFormat GetBackBufferFormat() const = 0;
// do we need this?
virtual void Flush( bool flushHardware = false ) = 0;
//
// end vertex array api
//
//
// Debugging tools
//
virtual void DebugPrintUsedMaterials( const char *pSearchSubString, bool bVerbose ) = 0;
virtual void DebugPrintUsedTextures( void ) = 0;
virtual void ToggleSuppressMaterial( char const* pMaterialName ) = 0;
virtual void ToggleDebugMaterial( char const* pMaterialName ) = 0;
//
// Debugging text output
//
virtual void DrawDebugText( int desiredLeft, int desiredTop,
MaterialRect_t *pActualRect,
const char *fmt, ... ) = 0;
// matrix api
virtual void MatrixMode( MaterialMatrixMode_t matrixMode ) = 0;
virtual void PushMatrix( void ) = 0;
virtual void PopMatrix( void ) = 0;
virtual void LoadMatrix( float * ) = 0;
virtual void MultMatrix( float * ) = 0;
virtual void MultMatrixLocal( float * ) = 0;
virtual void GetMatrix( MaterialMatrixMode_t matrixMode, float *dst ) = 0;
virtual void LoadIdentity( void ) = 0;
virtual void Ortho( double left, double top, double right, double bottom, 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;
// end matrix api
// Sets/gets the viewport
virtual void Viewport( int x, int y, int width, int height ) = 0;
virtual void GetViewport( int& x, int& y, int& width, int& height ) const = 0;
// Point size
virtual void PointSize( float size ) = 0;
// The cull mode
virtual void CullMode( MaterialCullMode_t cullMode ) = 0;
// end matrix api
// This could easily be extended to a general user clip plane
virtual void SetHeightClipMode( enum MaterialHeightClipMode_t ) = 0;
// garymcthack : fog z is always used for heightclipz for now.
virtual void SetHeightClipZ( float z ) = 0;
// Fog methods...
virtual void FogMode( MaterialFogMode_t fogMode ) = 0;
virtual void FogStart( float fStart ) = 0;
virtual void FogEnd( float fEnd ) = 0;
virtual void SetFogZ( float fogZ ) = 0;
virtual MaterialFogMode_t GetFogMode( void ) = 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;
// Sets the number of bones for skinning
virtual void SetNumBoneWeights( int numBones ) = 0;
virtual IMaterialProxyFactory *GetMaterialProxyFactory() = 0;
// Read the page size of an existing lightmap by sort id (returned from AllocateLightmap())
virtual void GetLightmapPageSize( int lightmap, int *width, int *height ) const = 0;
/// FIXME: This stuff needs to be cleaned up and abstracted.
// Stuff that gets exported to the launcher through the engine
virtual void SwapBuffers( ) = 0;
// Use this to spew information about the 3D layer
virtual void SpewDriverInfo() const = 0;
// Creates/destroys Mesh
virtual IMesh* CreateStaticMesh( IMaterial* pMaterial, bool bForceTempMesh = false ) = 0;
virtual IMesh* CreateStaticMesh( MaterialVertexFormat_t fmt, bool bSoftwareVertexShader ) = 0;
virtual void DestroyStaticMesh( IMesh* mesh ) = 0;
// Gets the dynamic mesh associated with the currently bound material
// note that you've got to render the mesh before calling this function
// a second time. Clients should *not* call DestroyStaticMesh on the mesh
// returned by this call.
// Use buffered = false if you want to not have the mesh be buffered,
// but use it instead in the following pattern:
// meshBuilder.Begin
// meshBuilder.End
// Draw partial
// Draw partial
// Draw partial
// meshBuilder.Begin
// meshBuilder.End
// etc
// Use Vertex or Index Override to supply a static vertex or index buffer
// to use in place of the dynamic buffers.
//
// If you pass in a material in pAutoBind, it will automatically bind the
// material. This can be helpful since you must bind the material you're
// going to use BEFORE calling GetDynamicMesh.
virtual IMesh* GetDynamicMesh(
bool buffered = true,
IMesh* pVertexOverride = 0,
IMesh* pIndexOverride = 0,
IMaterial *pAutoBind = 0 ) = 0;
// Selection mode methods
virtual int SelectionMode( bool selectionMode ) = 0;
virtual void SelectionBuffer( unsigned int* pBuffer, int size ) = 0;
virtual void ClearSelectionNames( ) = 0;
virtual void LoadSelectionName( int name ) = 0;
virtual void PushSelectionName( int name ) = 0;
virtual void PopSelectionName() = 0;
// Installs a function to be called when we need to release vertex buffers + textures
virtual void AddReleaseFunc( MaterialBufferReleaseFunc_t func ) = 0;
virtual void RemoveReleaseFunc( MaterialBufferReleaseFunc_t func ) = 0;
// Installs a function to be called when we need to restore vertex buffers
virtual void AddRestoreFunc( MaterialBufferRestoreFunc_t func ) = 0;
virtual void RemoveRestoreFunc( MaterialBufferRestoreFunc_t func ) = 0;
// Reloads materials
virtual void ReloadMaterials( const char *pSubString = NULL ) = 0;
virtual void ResetMaterialLightmapPageInfo() = 0;
// Methods that use VMatrix
virtual void LoadMatrix( VMatrix const& matrix ) = 0;
// Sets the Clear Color for ClearBuffer....
virtual void ClearColor3ub( unsigned char r, unsigned char g, unsigned char b ) = 0;
virtual void ClearColor4ub( unsigned char r, unsigned char g, unsigned char b, unsigned char a ) = 0;
// Force it to ignore Draw calls.
virtual void SetInStubMode( bool bInStubMode ) = 0;
virtual void GetMatrix( MaterialMatrixMode_t matrixMode, VMatrix *pMatrix ) = 0;
// Create new materials
virtual IMaterial *CreateMaterial() = 0;
// Creates a render target
// If depth == true, a depth buffer is also allocated. If not, then
// the screen's depth buffer is used.
virtual ITexture* CreateRenderTargetTexture( int w, int h, ImageFormat format, bool depth = false ) = 0;
// Creates a procedural texture
virtual ITexture *CreateProceduralTexture( const char *pTextureName, int w, int h, ImageFormat fmt, int nFlags ) = 0;
// Allows us to override the depth buffer setting of a material
virtual void OverrideDepthEnable( bool bEnable, bool bDepthEnable ) = 0;
// FIXME: This is a hack required for NVidia, can they fix in drivers?
virtual void DrawScreenSpaceQuad( IMaterial* pMaterial ) = 0;
// Release temporary HW memory...
virtual void ReleaseTempTextureMemory() = 0;
// GR - named RT
virtual ITexture* CreateNamedRenderTargetTexture( const char *pRTName, int w, int h, ImageFormat format, bool depth = false, bool bClampTexCoords = true, bool bAutoMipMap = false ) = 0;
// For debugging and building recording files. This will stuff a token into the recording file,
// then someone doing a playback can watch for the token.
virtual void SyncToken( const char *pToken ) = 0;
};
extern IMaterialSystem *materials;
#endif // IMATERIALSYSTEM_H
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -