Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
W3DShaderManager Class Reference

forward reference More...

#include <W3DShaderManager.h>

Public Types

enum  ShaderTypes {
  ST_INVALID , ST_TERRAIN_BASE , ST_TERRAIN_BASE_NOISE1 , ST_TERRAIN_BASE_NOISE2 ,
  ST_TERRAIN_BASE_NOISE12 , ST_SHROUD_TEXTURE , ST_MASK_TEXTURE , ST_ROAD_BASE ,
  ST_ROAD_BASE_NOISE1 , ST_ROAD_BASE_NOISE2 , ST_ROAD_BASE_NOISE12 , ST_CLOUD_TEXTURE ,
  ST_FLAT_TERRAIN_BASE , ST_FLAT_TERRAIN_BASE_NOISE1 , ST_FLAT_TERRAIN_BASE_NOISE2 , ST_FLAT_TERRAIN_BASE_NOISE12 ,
  ST_FLAT_SHROUD_TEXTURE , ST_MAX
}
 

Public Member Functions

 W3DShaderManager (void)
 constructor
 

Static Public Member Functions

static void init (void)
 determine optimal shaders for current device.
 
static void shutdown (void)
 release resources used by shaders
 
static ChipsetType getChipset (void)
 return current device chipset.
 
static GraphicsVenderID getCurrentVendor (void)
 return current card vendor.
 
static getCurrentDriverVersion (void)
 return current driver version.
 
static Int getShaderPasses (ShaderTypes shader)
 rendering passes required for shader
 
static Int setShader (ShaderTypes shader, Int pass)
 enable specific shader pass.
 
static Int setShroudTex (Int stage)
 Set shroud in a texture stage.
 
static void resetShader (ShaderTypes shader)
 
static void setTexture (Int stage, TextureClass *texture)
 Specify all textures (up to 8) which can be accessed by the shaders.
 
static TextureClassgetShaderTexture (Int stage)
 Return current texture available to shaders.
 
static ShaderTypes getCurrentShader (void)
 Return last activated shader.
 
static HRESULT LoadAndCreateD3DShader (char *strFilePath, const DWORD *pDeclaration, DWORD Usage, Bool ShaderType, DWORD *pHandle)
 Loads a .vso file and creates a vertex shader for it.
 
static Bool testMinimumRequirements (ChipsetType *videoChipType, CpuType *cpuType, Int *cpuFreq, Int *numRAM, Real *intBenchIndex, Real *floatBenchIndex, Real *memBenchIndex)
 
static StaticGameLODLevel getGPUPerformanceIndex (void)
 
static Real GetCPUBenchTime (void)
 
static Bool filterPreRender (FilterTypes filter, Bool &skipRender, CustomScenePassModes &scenePassMode)
 Set up at start of render. Only applies to screen filter shaders.
 
static Bool filterPostRender (FilterTypes filter, enum FilterModes mode, Coord2D &scrollDelta, Bool &doExtraRender)
 Called after render. Only applies to screen filter shaders.
 
static Bool filterSetup (FilterTypes filter, enum FilterModes mode)
 
static Bool canRenderToTexture (void)
 
static void startRenderToTexture (void)
 Sets render target to texture.
 
static IDirect3DTexture8 * endRenderToTexture (void)
 Ends render to texture, & returns texture.
 
static IDirect3DTexture8 * getRenderTexture (void)
 returns last used render target texture
 
static Bool isRenderingToTexture (void)
 
static void drawViewport (Int color)
 draws 2 triangles covering the current tactical viewport
 

Static Protected Attributes

static TextureClassm_Textures [8]
 
static ChipsetType m_currentChipset
 textures assigned to each of the possible stages
 
static GraphicsVenderID m_currentVendor
 last video card vendor
 
static __int64 m_driverVersion
 driver version of last chipset.
 
static ShaderTypes m_currentShader
 last shader that was set.
 
static Int m_currentShaderPass
 pass of last shader that was set.
 
static FilterTypes m_currentFilter =FT_NULL_FILTER
 Last filter that was set.
 
static Bool m_renderingToTexture = false
 
static IDirect3DSurface8 * m_oldRenderSurface =NULL
 previous render target
 
static IDirect3DTexture8 * m_renderTexture =NULL
 texture into which rendering will be redirected.
 
static IDirect3DSurface8 * m_newRenderSurface =NULL
 new render target inside m_renderTexture
 
static IDirect3DSurface8 * m_oldDepthSurface =NULL
 previous depth buffer surface
 

Detailed Description

forward reference

System for managing complex rendering settings which are either not handled by WW3D2 or need custom paths depending on the video card. This system will determine the proper shader given video card limitations and also allow the app to query the hardware for specific features.

Definition at line 53 of file W3DShaderManager.h.

Member Enumeration Documentation

◆ ShaderTypes

Enumerator
ST_INVALID 
ST_TERRAIN_BASE 
ST_TERRAIN_BASE_NOISE1 
ST_TERRAIN_BASE_NOISE2 
ST_TERRAIN_BASE_NOISE12 
ST_SHROUD_TEXTURE 
ST_MASK_TEXTURE 
ST_ROAD_BASE 
ST_ROAD_BASE_NOISE1 
ST_ROAD_BASE_NOISE2 
ST_ROAD_BASE_NOISE12 
ST_CLOUD_TEXTURE 
ST_FLAT_TERRAIN_BASE 
ST_FLAT_TERRAIN_BASE_NOISE1 
ST_FLAT_TERRAIN_BASE_NOISE2 
ST_FLAT_TERRAIN_BASE_NOISE12 
ST_FLAT_SHROUD_TEXTURE 
ST_MAX 

Definition at line 58 of file W3DShaderManager.h.

Constructor & Destructor Documentation

◆ W3DShaderManager()

W3DShaderManager::W3DShaderManager ( void )

constructor

Constructor - just clears some variables

Definition at line 2582 of file W3DShaderManager.cpp.

Member Function Documentation

◆ canRenderToTexture()

static Bool W3DShaderManager::canRenderToTexture ( void )
inlinestatic

Definition at line 109 of file W3DShaderManager.h.

◆ drawViewport()

void W3DShaderManager::drawViewport ( Int color)
static

draws 2 triangles covering the current tactical viewport

Definition at line 2794 of file W3DShaderManager.cpp.

◆ endRenderToTexture()

IDirect3DTexture8 * W3DShaderManager::endRenderToTexture ( void )
static

Ends render to texture, & returns texture.

Ends rendering to a texture.

Definition at line 2876 of file W3DShaderManager.cpp.

◆ filterPostRender()

Bool W3DShaderManager::filterPostRender ( FilterTypes filter,
enum FilterModes mode,
Coord2D & scrollDelta,
Bool & doExtraRender )
static

Called after render. Only applies to screen filter shaders.

Call to view filter shaders after rendering is complete.

Definition at line 2772 of file W3DShaderManager.cpp.

◆ filterPreRender()

Bool W3DShaderManager::filterPreRender ( FilterTypes filter,
Bool & skipRender,
CustomScenePassModes & scenePassMode )
static

Set up at start of render. Only applies to screen filter shaders.

Call to view filter shaders before rendering starts.

Definition at line 2757 of file W3DShaderManager.cpp.

◆ filterSetup()

Bool W3DShaderManager::filterSetup ( FilterTypes filter,
enum FilterModes mode )
static

Definition at line 2786 of file W3DShaderManager.cpp.

◆ getChipset()

ChipsetType W3DShaderManager::getChipset ( void )
static

return current device chipset.

Returns the chipset used by the currently active rendering device. Can be useful for coding around specific driver bugs.

Todo
: Just guessing on this one - find actual Voodoo4 deviceID.

Definition at line 2918 of file W3DShaderManager.cpp.

◆ GetCPUBenchTime()

Real W3DShaderManager::GetCPUBenchTime ( void )
static

Returns seconds needed to run the test

Definition at line 3152 of file W3DShaderManager.cpp.

◆ getCurrentDriverVersion()

static W3DShaderManager::getCurrentDriverVersion ( void )
inlinestatic

return current driver version.

Definition at line 85 of file W3DShaderManager.h.

◆ getCurrentShader()

static ShaderTypes W3DShaderManager::getCurrentShader ( void )
inlinestatic

Return last activated shader.

Definition at line 95 of file W3DShaderManager.h.

◆ getCurrentVendor()

static GraphicsVenderID W3DShaderManager::getCurrentVendor ( void )
inlinestatic

return current card vendor.

Definition at line 84 of file W3DShaderManager.h.

◆ getGPUPerformanceIndex()

StaticGameLODLevel W3DShaderManager::getGPUPerformanceIndex ( void )
static

Try to guess how well the video card will handle the game assuming very fast CPU

Definition at line 3126 of file W3DShaderManager.cpp.

◆ getRenderTexture()

IDirect3DTexture8 * W3DShaderManager::getRenderTexture ( void )
static

returns last used render target texture

Returns texture containing the image that was last rendered using any of the effects requiring render target textures. Used mostly for cross-fading effects that need an unmodified version of the view before the effect was applied. NOTE: This texture does not survive device reset.. so quit effect on reset!

Definition at line 2901 of file W3DShaderManager.cpp.

◆ getShaderPasses()

Int W3DShaderManager::getShaderPasses ( ShaderTypes shader)
static

rendering passes required for shader

Return number of renderig passes required in perform the desired shader on current hardware. App will need to re-render the polygons this many times to complete the effect.

Definition at line 2718 of file W3DShaderManager.cpp.

◆ getShaderTexture()

static TextureClass * W3DShaderManager::getShaderTexture ( Int stage)
inlinestatic

Return current texture available to shaders.

returns currently selected texture for given stage

Definition at line 93 of file W3DShaderManager.h.

◆ init()

void W3DShaderManager::init ( void )
static

determine optimal shaders for current device.

Walk through all shaders and find versions suitable for current hardware

Definition at line 2609 of file W3DShaderManager.cpp.

◆ isRenderingToTexture()

static Bool W3DShaderManager::isRenderingToTexture ( void )
inlinestatic

Definition at line 113 of file W3DShaderManager.h.

◆ LoadAndCreateD3DShader()

HRESULT W3DShaderManager::LoadAndCreateD3DShader ( char * strFilePath,
const DWORD * pDeclaration,
DWORD Usage,
Bool ShaderType,
DWORD * pHandle )
static

Loads a .vso file and creates a vertex shader for it.

Loads and creates a D3D pixel or vertex shader.

Definition at line 3011 of file W3DShaderManager.cpp.

◆ resetShader()

void W3DShaderManager::resetShader ( ShaderTypes shader)
static

make sure W3D2 gets restored to normal

Must call this method after all polygons and rendering passes have been submitted. This method allows D3D to reset itself to a default state that doesn't conflict with the WW3D2 Shader system.

Definition at line 2745 of file W3DShaderManager.cpp.

◆ setShader()

Int W3DShaderManager::setShader ( ShaderTypes shader,
Int pass )
static

enable specific shader pass.

Must call this method before each rendering pass in order to perform proper D3D setup for each shader.

Definition at line 2728 of file W3DShaderManager.cpp.

◆ setShroudTex()

Int W3DShaderManager::setShroudTex ( Int stage)
static

Set shroud in a texture stage.

Puts the shroud texture into a texture stage.

Definition at line 3195 of file W3DShaderManager.cpp.

◆ setTexture()

static void W3DShaderManager::setTexture ( Int stage,
TextureClass * texture )
inlinestatic

Specify all textures (up to 8) which can be accessed by the shaders.

Definition at line 91 of file W3DShaderManager.h.

◆ shutdown()

void W3DShaderManager::shutdown ( void )
static

release resources used by shaders

Any shaders which allocate resources will be allowed to free them

Definition at line 2683 of file W3DShaderManager.cpp.

◆ startRenderToTexture()

void W3DShaderManager::startRenderToTexture ( void )
static

Sets render target to texture.

Starts rendering to a texture.

Definition at line 2839 of file W3DShaderManager.cpp.

◆ testMinimumRequirements()

Bool W3DShaderManager::testMinimumRequirements ( ChipsetType * videoChipType,
CpuType * cpuType,
Int * cpuFreq,
Int * numRAM,
Real * intBenchIndex,
Real * floatBenchIndex,
Real * memBenchIndex )
static

Definition at line 3083 of file W3DShaderManager.cpp.

Member Data Documentation

◆ m_currentChipset

ChipsetType W3DShaderManager::m_currentChipset
staticprotected

textures assigned to each of the possible stages

last video card chipset that was detected.

Definition at line 119 of file W3DShaderManager.h.

◆ m_currentFilter

FilterTypes W3DShaderManager::m_currentFilter =FT_NULL_FILTER
staticprotected

Last filter that was set.

Definition at line 125 of file W3DShaderManager.h.

◆ m_currentShader

W3DShaderManager::ShaderTypes W3DShaderManager::m_currentShader
staticprotected

last shader that was set.

Definition at line 122 of file W3DShaderManager.h.

◆ m_currentShaderPass

Int W3DShaderManager::m_currentShaderPass
staticprotected

pass of last shader that was set.

Definition at line 123 of file W3DShaderManager.h.

◆ m_currentVendor

GraphicsVenderID W3DShaderManager::m_currentVendor
staticprotected

last video card vendor

Definition at line 120 of file W3DShaderManager.h.

◆ m_driverVersion

__int64 W3DShaderManager::m_driverVersion
staticprotected

driver version of last chipset.

Definition at line 121 of file W3DShaderManager.h.

◆ m_newRenderSurface

IDirect3DSurface8 * W3DShaderManager::m_newRenderSurface =NULL
staticprotected

new render target inside m_renderTexture

Definition at line 130 of file W3DShaderManager.h.

◆ m_oldDepthSurface

IDirect3DSurface8 * W3DShaderManager::m_oldDepthSurface =NULL
staticprotected

previous depth buffer surface

Definition at line 131 of file W3DShaderManager.h.

◆ m_oldRenderSurface

IDirect3DSurface8 * W3DShaderManager::m_oldRenderSurface =NULL
staticprotected

previous render target

Definition at line 128 of file W3DShaderManager.h.

◆ m_renderingToTexture

Bool W3DShaderManager::m_renderingToTexture = false
staticprotected

Definition at line 127 of file W3DShaderManager.h.

◆ m_renderTexture

IDirect3DTexture8 * W3DShaderManager::m_renderTexture =NULL
staticprotected

texture into which rendering will be redirected.

Definition at line 129 of file W3DShaderManager.h.

◆ m_Textures

TextureClass * W3DShaderManager::m_Textures
staticprotected

Definition at line 118 of file W3DShaderManager.h.


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