Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

ADevice.h File Reference


Detailed Description

Provides the functionalities that encapsulate a d3dDevice. When attempt to change a device state, these functions will first check whether the request state is already present, if it is, no changes is necessary.

Definition in file ADevice.h.

#include "AState.h"

Include dependency graph for ADevice.h:

Include dependency graph

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Go to the source code of this file.

Functions

void device_flushSettings ()
void device_setTextureStageState (DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD Value)
void device_setRenderState (D3DRENDERSTATETYPE state, DWORD value)
void device_setVertexShader (DWORD vsh)
void device_setPixelShader (DWORD psh)
void device_setRenderStateBlendMode (int blendMode)
void device_setStreamSource (int streamNum, IDirect3DVertexBuffer8 *pStreamData, UINT Stride)
void device_setIndexSource (LPDIRECT3DINDEXBUFFER8 pIB)
void device_setTexture (int stageNo, IDirect3DBaseTexture8 *pTexture)


Function Documentation

void device_flushSettings   [inline]
 

Definition at line 31 of file ADevice.h.

References MAX_STATE_TYPE, MAX_STREAM, and MAX_TEXTURE.

Referenced by beginRendering(), and overlay_render().

00032 {       
00033         AS.device_vsh = static_cast<DWORD>(-1); //So we can get an all 1's bit pattern
00034         AS.device_psh = static_cast<DWORD>(-1); //So we can get an all 1'1 bit pattern
00035         AS.device_ib = NULL;
00036         for( int i=0; i<MAX_STREAM; i++ )               AS.device_vb[i] = NULL;
00037         for( int i=0; i<MAX_STATE_TYPE; i++ )   AS.device_renderStates[i] = static_cast<UINT>(-1);
00038         for( int i=0; i<MAX_TEXTURE; i++ )              AS.device_texture[i] = NULL;
00039 }

void device_setIndexSource LPDIRECT3DINDEXBUFFER8    pIB [inline]
 

Definition at line 124 of file ADevice.h.

Referenced by mesh_processRenderRequests(), and terrain_processRenderRequest().

00125 {
00126         if( AS.device_ib != pIB )
00127         {
00128                 AS.device_ib = pIB;
00129                 AS.pDevice->SetIndices( pIB, 0 );
00130         }
00131 }

void device_setPixelShader DWORD    psh [inline]
 

Definition at line 66 of file ADevice.h.

Referenced by flare_process(), mesh_processRenderRequests(), overlay_render(), sprite_process(), and terrain_processRenderRequest().

00067 {
00068         if( AS.device_psh != psh )
00069         {
00070                 AS.device_psh = psh;
00071                 AS.pDevice->SetPixelShader(psh);
00072         }
00073 }

void device_setRenderState D3DRENDERSTATETYPE    state,
DWORD    value
[inline]
 

Definition at line 47 of file ADevice.h.

Referenced by device_setRenderStateBlendMode(), flare_process(), mesh_processRenderRequests(), sprite_process(), terrain_processRenderRequest(), and useOverlayShaders().

00048 {
00049         assert( state>=0 && state<MAX_STATE_TYPE );
00050         if( AS.device_renderStates[state] != value )
00051         {
00052                 AS.device_renderStates[state] = value;
00053                 AS.pDevice->SetRenderState( state, value );
00054         }
00055 }

void device_setRenderStateBlendMode int    blendMode [inline]
 

Definition at line 75 of file ADevice.h.

References device_setRenderState().

Referenced by flare_process(), mesh_processRenderRequests(), overlay_render(), sprite_process(), and terrain_processRenderRequest().

00076 {
00077         switch(blendMode)
00078         {
00079 
00080         case BlendModes::NONE:
00081                 device_setRenderState( D3DRS_ALPHABLENDENABLE, false );
00082                 device_setRenderState( D3DRS_ALPHATESTENABLE, FALSE );
00083                 device_setRenderState( D3DRS_ALPHAFUNC, D3DCMP_ALWAYS );
00084                 break;
00085 
00086         case BlendModes::KEY:           
00087                 device_setRenderState( D3DRS_ALPHATESTENABLE, TRUE );
00088                 device_setRenderState( D3DRS_ALPHABLENDENABLE, false );
00089                 device_setRenderState( D3DRS_ALPHAFUNC, D3DCMP_GREATER );
00090                 device_setRenderState( D3DRS_ALPHAREF, 0x0 );
00091                 break;
00092 
00093         case BlendModes::ADD:
00094                 device_setRenderState( D3DRS_ALPHABLENDENABLE, true );
00095                 device_setRenderState( D3DRS_ALPHATESTENABLE, FALSE );
00096                 device_setRenderState( D3DRS_ALPHAFUNC, D3DCMP_ALWAYS );
00097                 device_setRenderState( D3DRS_SRCBLEND,  D3DBLEND_SRCALPHA );
00098                 device_setRenderState( D3DRS_DESTBLEND, D3DBLEND_ONE );
00099                 break;
00100 
00101         case BlendModes::MIX:
00102                 device_setRenderState( D3DRS_ALPHABLENDENABLE, true );
00103                 device_setRenderState( D3DRS_ALPHATESTENABLE, FALSE );
00104                 device_setRenderState( D3DRS_ALPHAFUNC, D3DCMP_ALWAYS );
00105                 device_setRenderState( D3DRS_SRCBLEND,  D3DBLEND_SRCALPHA    );
00106                 device_setRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA );
00107                 break;
00108 
00109         default:
00110                 assert( false && "Invalid blendMode" );
00111         };
00112 }

void device_setStreamSource int    streamNum,
IDirect3DVertexBuffer8 *    pStreamData,
UINT    Stride
[inline]
 

Definition at line 114 of file ADevice.h.

Referenced by flare_process(), mesh_processRenderRequests(), sprite_process(), terrain_processRenderRequest(), and useOverlayShaders().

00115 {
00116         assert( streamNum>=0 && streamNum<MAX_STREAM );
00117         if( AS.device_vb[streamNum] != pStreamData )
00118         {
00119                 AS.device_vb[streamNum] = pStreamData;
00120                 AS.pDevice->SetStreamSource( streamNum, pStreamData, Stride );
00121         }
00122 }

void device_setTexture int    stageNo,
IDirect3DBaseTexture8 *    pTexture
[inline]
 

Definition at line 133 of file ADevice.h.

Referenced by flare_process(), mesh_processRenderRequests(), overlay_render(), sprite_process(), and terrain_processRenderRequest().

00134 {
00135         assert( stageNo>=0 && stageNo<MAX_TEXTURE );
00136         if( AS.device_texture[stageNo] != pTexture )
00137         {
00138                 AS.device_texture[stageNo] = pTexture;
00139                 AS.pDevice->SetTexture( stageNo, pTexture );
00140         }
00141 }

void device_setTextureStageState DWORD    Stage,
D3DTEXTURESTAGESTATETYPE    Type,
DWORD    Value
[inline]
 

Definition at line 41 of file ADevice.h.

Referenced by flare_process(), mesh_processRenderRequests(), sprite_process(), terrain_processRenderRequest(), and useOverlayShaders().

00042 {
00043         // direct pass-through for now because I don't think there will be much repetitions/trashing
00044         AS.pDevice->SetTextureStageState(Stage,Type,Value);
00045 }

void device_setVertexShader DWORD    vsh [inline]
 

Definition at line 57 of file ADevice.h.

Referenced by flare_process(), mesh_processRenderRequests(), sprite_process(), terrain_processRenderRequest(), and useOverlayShaders().

00058 {
00059         if( AS.device_vsh != vsh )
00060         {
00061                 AS.device_vsh = vsh;
00062                 AS.pDevice->SetVertexShader(vsh);
00063         }
00064 }


Generated on Wed Apr 23 05:50:21 2003 for Modern Warfare by doxygen1.3-rc2