GFXDevice Class Reference

#include <gfxDevice.h>

Inheritance diagram for GFXDevice:

Inheritance graph
[legend]
List of all members.

Detailed Description

GFXDevice is the TSE graphics interface layer.

This allows the TSE to do many things, such as use multiple render devices for multi-head systems, and allow a game to render in DirectX 9, OpenGL or any other API which has a GFX implementation seamlessly. There are many concepts in GFX device which may not be familiar to you, especially if you have not used DirectX.
Buffers There are three types of buffers in GFX: vertex, index and primitive. Please note that index buffers are not accessable outside the GFX layer, they are wrapped by primitive buffers. Primitive buffers will be explained in detail later. Buffers are allocated and deallocated using their associated allocXBuffer and freeXBuffer methods on the device. When a buffer is allocated you pass in a pointer to, depending on the buffer, a vertex type pointer or a U16 pointer. During allocation, this pointer is set to the address of where you should copy in the information for this buffer. You must the tell the GFXDevice that the information is in, and it should prepare the buffer for use by calling the prepare method on it. Dynamic vertex buffer example:

 GFXVertexP *verts;        // Making a buffer containing verticies with only position

 // Allocate a dynamic vertex buffer to hold 3 vertices and use *verts as the location to copy information into
 GFXVertexBufferHandle vb = GFX->allocVertexBuffer( 3, &verts, true ); 

 // Now set the information, we're making a triangle
 verts[0].point = Point3F( 200.f, 200.f, 0.f );
 verts[1].point = Point3F( 200.f, 400.f, 0.f );
 verts[2].point = Point3F( 400.f, 200.f, 0.f );

 // Tell GFX that the information is in and it should be made ready for use
 // Note that nothing is done with verts, this should not and MUST NOT be deleted
 // stored, or otherwise used after prepare is called.
 GFX->prepare( vb );

 // Because this is a dynamic vertex buffer, it is only assured to be valid until someone 
 // else allocates a dynamic vertex buffer, so we will render it now
 GFX->setVertexBuffer( vb );
 GFX->drawPrimitive( GFXTriangleStrip, 0, 1 );

 // Now because this is a dynamic vertex buffer it MUST NOT BE FREED you are only
 // given a handle to a vertex buffer which belongs to the device

To use a static vertex buffer, it is very similar, this is an example using a static primitive buffer:
This takes place inside a constructor for a class which has a member variable called mPB which is the primitive buffer for the class instance.

 U16 *idx;                          // This is going to be where to write indices
 GFXPrimitiveInfo *primitiveInfo;   // This will be where to write primitive information

 // Allocate a primitive buffer with 4 indices, and 1 primitive described for use
 mPB = GFX->allocPrimitiveBuffer( 4, &idx, 1, &primitiveInfo );

 // Write the index information, this is going to be for the outline of a triangle using
 // a line strip
 idx[0] = 0;
 idx[1] = 1;
 idx[2] = 2;
 idx[3] = 0;

 // Write the information for the primitive
 primitiveInfo->indexStart = 0;            // Starting with index 0
 primitiveInfo->minVertex = 0;             // The minimum vertex index is 0
 primitiveInfo->maxVertex = 3;             // The maximum vertex index is 3
 primitiveInfo->primitiveCount = 3;        // There are 3 lines we are drawing
 primitiveInfo->type = GFXLineStrip;       // This primitive info describes a line strip
The following code takes place in the destructor for the same class
 // Because this is a static buffer it's our responsibility to free it when we are done
 GFX->freePrimitiveBuffer( mPB );
This last bit takes place in the rendering function for the class
 // You need to set a vertex buffer as well, primitive buffers contain indexing
 // information, not vertex information. This is so you could have, say, a static
 // vertex buffer, and a dynamic primitive buffer.

 // This sets the primitive buffer to the static buffer we allocated in the constructor
 GFX->setPrimitiveBuffer( mPB );
 
 // Draw the first primitive contained in the set primitive buffer, our primitive buffer
 // has only one primitive, so we could also technically call GFX->drawPrimitives(); and
 // get the same result. 
 GFX->drawPrimitive( 0 );
If you need any more examples on how to use these buffers please see the rest of the engine.
Primitive Buffers
Primitive buffers wrap and extend the concept of index buffers. The purpose of a primitive buffer is to let objects store all information they have to render their primitives in a central place. Say that a shape is made up of triangle strips and triangle fans, it would still have only one primitive buffer which contained primitive information for each strip and fan. It could then draw itself with one call.

TO BE FINISHED LATER


Matrix interface

enum  GenericShaderType {
  GSColor = 0,
  GSTexture,
  GSModColorTexture,
  GSAddColorTexture,
  GS_COUNT
}
void setWorldMatrix (const MatrixF &newWorld)
 Sets the top of the world matrix stack.
const MatrixFgetWorldMatrix () const
 Gets the matrix on the top of the world matrix stack.
void pushWorldMatrix ()
 Pushes the world matrix stack and copies the current top matrix to the new top of the stack.
void popWorldMatrix ()
 Pops the world matrix stack.
void setProjectionMatrix (const MatrixF &newProj)
 Sets the projection matrix.
const MatrixFgetProjectionMatrix () const
 Gets the projection matrix.
void setViewMatrix (const MatrixF &newView)
 Sets the view matrix.
const MatrixFgetViewMatrix () const
 Gets the view matrix.
void multWorld (const MatrixF &mat)
 Multiplies the matrix at the top of the world matrix stack by a matrix and replaces the top of the matrix stack with the result.
void setTextureMatrix (const U32 stage, const MatrixF &texMat)
 Set texture matrix for a sampler.
virtual void setViewport (const RectI &rect)=0
virtual const RectIgetViewport () const =0
virtual void setClipRect (const RectI &rect)=0
virtual const RectIgetClipRect () const =0
virtual void setFrustum (F32 left, F32 right, F32 bottom, F32 top, F32 nearPlane, F32 farPlane, bool bRotate=true)
void getFrustum (F32 *left, F32 *right, F32 *bottom, F32 *top, F32 *nearPlane, F32 *farPlane, bool *isOrtho)
virtual void setFrustum (F32 FOV, F32 aspectRatio, F32 nearPlane, F32 farPlane)
void setOrtho (F32 left, F32 right, F32 bottom, F32 top, F32 nearPlane, F32 farPlane, bool doRotate=false)
 This will construct and apply an orthographic projection matrix with the provided parameters.
F32 projectRadius (F32 dist, F32 radius)
F32 worldToScreenScale ()
virtual void setupGenericShaders (GenericShaderType type=GSColor)
 This is a helper function to set a default shader for rendering GUI elements on systems which do not support fixed-function operations as well as for things which need just generic position/texture/color shaders.
virtual F32 getFillConventionOffset () const =0
 Get the fill convention for this device.
virtual U32 getMaxDynamicVerts ()=0
virtual U32 getMaxDynamicIndices ()=0
virtual void doParanoidStateCheck ()
GFXDrawUtilgetDrawUtil ()
 Get access to this device's drawing utility class.
void clearSamplerOverrides ()
void setSamplerMipLODBiasOverride (S32 stage, bool on, F32 bias=0.0f)
void setSamplerAddressModeOverride (S32 stage, bool on, GFXTextureAddressMode mode=GFXAddressClamp)
void getSamplerAddressModeOverride (S32 stage, bool &on, GFXTextureAddressMode &mode)
void getSamplerMipLODBiasOverride (S32 stage, bool &on, F32 &bias)
void dumpStates (const char *fileName) const
 This is a method designed for debugging.
GFXDrawUtilmDrawer

Resource debug methods

virtual void listResources (bool unflaggedOnly)
 Lists how many of each GFX resource (e.g.
virtual void flagCurrentResources ()
 Flags all resources GFX is currently aware of.
virtual void clearResourceFlags ()
 Clears the flag on all resources GFX is currently aware of.
virtual void describeResources (const char *resName, const char *file, bool unflaggedOnly)
 Dumps a description of the specified resource types to the console.
GFXDeviceStatisticsgetDeviceStatistics ()
 Returns the current GFXDeviceStatistics, stats are cleared every beginScene call.
virtual void fillResourceVectors (const char *resNames, bool unflaggedOnly, Vector< GFXResource * > &textureObjects, Vector< GFXResource * > &textureTargets, Vector< GFXResource * > &windowTargets, Vector< GFXResource * > &vertexBuffers, Vector< GFXResource * > &primitiveBuffers, Vector< GFXResource * > &fences, Vector< GFXResource * > &cubemaps, Vector< GFXResource * > &shaders, Vector< GFXResource * > &stateblocks)
 This is a helper method for describeResourcesToFile.
GFXDeviceStatistics mDeviceStatistics

Texture functions

virtual GFXCubemapcreateCubemap ()=0
GFXTextureManagergetTextureManager ()
GFXTextureManagermTextureManager

State tracking variables

typedef Map< U32, GFXStateBlockRefStateBlockMap
enum  TexDirtyType {
  GFXTDT_Normal,
  GFXTDT_Cube
}
bool mStateDirty
 Set if ANY state is dirty, including matrices or primitive buffers.
GFXTexHandle mCurrentTexture [TEXTURE_STAGE_COUNT]
GFXTexHandle mNewTexture [TEXTURE_STAGE_COUNT]
GFXCubemapHandle mCurrentCubemap [TEXTURE_STAGE_COUNT]
GFXCubemapHandle mNewCubemap [TEXTURE_STAGE_COUNT]
TexDirtyType mTexType [TEXTURE_STAGE_COUNT]
bool mTextureDirty [TEXTURE_STAGE_COUNT]
bool mTexturesDirty
StateBlockMap mCurrentStateBlocks
bool mStateBlockDirty
GFXStateBlockRef mCurrentStateBlock
GFXStateBlockRef mNewStateBlock
GFXShaderConstBufferRef mCurrentShaderConstBuffer
bool mSamplerAddressModeOverride [TEXTURE_STAGE_COUNT]
GFXTextureAddressMode mSamplerAddressModeOverrides [TEXTURE_STAGE_COUNT]
bool mSamplerMipLODBiasOverride [TEXTURE_STAGE_COUNT]
F32 mSamplerMipLODBiasOverrides [TEXTURE_STAGE_COUNT]

Buffer Allocation

These methods are implemented per-device and are called by the GFX layer when a user calls an alloc

Note:
Primitive Buffers are NOT implemented per device, they wrap index buffers


virtual GFXVertexBufferallocVertexBuffer (U32 numVerts, U32 vertFlags, U32 vertSize, GFXBufferType bufferType)=0
 This allocates a vertex buffer and returns a pointer to the allocated buffer.
virtual GFXPrimitiveBufferallocPrimitiveBuffer (U32 numIndices, U32 numPrimitives, GFXBufferType bufferType)=0
 This allocates a primitive buffer and returns a pointer to the allocated buffer.
StrongRefPtr< GFXVertexBuffermCurrentVertexBuffer
bool mVertexBufferDirty
StrongRefPtr< GFXPrimitiveBuffermCurrentPrimitiveBuffer
bool mPrimitiveBufferDirty

Public Types

typedef Signal< bool(GFXDeviceEventType)> DeviceEventSignal
 deCreate
 The device has been created, but not initialized.
 deInit
 The device has been initialized.
 deDestroy
 The device is about to be destroyed.
 GSColor = 0
 GSTexture
 GSModColorTexture
 GSAddColorTexture
 GS_COUNT
enum  GFXDeviceEventType {
  deCreate,
  deInit,
  deDestroy
}

Public Member Functions

 GFXDevice ()
virtual ~GFXDevice ()
virtual void init (const GFXVideoMode &mode, PlatformWindow *window=NULL)=0
 Initialize this GFXDevice, optionally specifying a platform window to bind to.
bool canCurrentlyRender ()
void setAllowRender (bool render)
bool allowRender ()
GFXCardProfilergetCardProfiler () const
const U32 getDeviceIndex () const
virtual GFXAdapterType getAdapterType ()=0
 Returns active graphics adapter type.
virtual const GFXAdaptergetAdapter ()
 Returns the Adapter that was used to create this device.
const Swizzle< U8, 4 > * getDeviceSwizzle32 () const
 Swizzle to convert 32bpp bitmaps from RGBA to the native device format.
const Swizzle< U8, 3 > * getDeviceSwizzle24 () const
 Swizzle to convert 24bpp bitmaps from RGB to the native device format.
virtual GFXFencecreateFence ()=0
 Allocate a fence.
Debug Methods
virtual void enterDebugEvent (ColorI color, const char *name)=0
virtual void leaveDebugEvent ()=0
virtual void setDebugMarker (ColorI color, const char *name)=0
Video Mode Functions
Enumerates the supported video modes of the device

virtual void enumerateVideoModes ()=0
const Vector< GFXVideoMode
> *const 
getVideoModeList () const
 Well, this function gets the video mode list!
F32 formatByteSize (GFXFormat format)
virtual GFXFormat selectSupportedFormat (GFXTextureProfile *profile, const Vector< GFXFormat > &formats, bool texture, bool mustblend)=0
Special FX Back Buffer functions
virtual GFXTexHandlegetSfxBackBuffer ()
virtual void copyBBToSfxBuff ()=0
Render Target functions
virtual GFXTextureTargetallocRenderToTextureTarget ()=0
 Allocate a target for doing render to texture operations, with no depth/stencil buffer.
virtual GFXWindowTargetallocWindowTarget (PlatformWindow *window)=0
 Allocate a target for a given window.
virtual void pushActiveRenderTarget ()
 Save current render target states - note this works with MRT's.
virtual void popActiveRenderTarget ()
 Restore all render targets - supports MRT's.
virtual void setActiveRenderTarget (GFXTarget *target)=0
 Start rendering to to a specified render target.
virtual GFXTargetgetActiveRenderTarget ()
 Return a pointer to the current active render target.
Shader functions
virtual F32 getPixelShaderVersion () const =0
virtual void setPixelShaderVersion (F32 version)=0
virtual U32 getNumSamplers () const =0
 Returns the number of texture samplers that can be used in a shader rendering pass.
virtual void setShader (GFXShader *shader)
virtual void disableShaders ()
void setShaderConstBuffer (GFXShaderConstBuffer *buffer)
 Set the buffer! (Actual set happens on the next draw call, just like textures, state blocks, etc).
virtual GFXShadercreateShader (const char *vertFile, const char *pixFile, F32 pixVersion, const Vector< GFXShaderMacro > &macros=Vector< GFXShaderMacro >())=0
 Creates a shader.
virtual void destroyShader (GFXShader *shader)
 Destroys shader.
Rendering methods
virtual void clear (U32 flags, ColorI color, F32 z, U32 stencil)=0
virtual bool beginScene ()
virtual void endScene ()
virtual GFXTexHandlegetFrontBuffer ()
void setPrimitiveBuffer (GFXPrimitiveBuffer *buffer)
void setVertexBuffer (GFXVertexBuffer *buffer)
virtual void drawPrimitive (GFXPrimitiveType primType, U32 vertexStart, U32 primitiveCount)=0
virtual void drawIndexedPrimitive (GFXPrimitiveType primType, U32 minIndex, U32 numVerts, U32 startIndex, U32 primitiveCount)=0
void drawPrimitive (U32 primitiveIndex)
void drawPrimitives ()
void drawPrimitiveBuffer (GFXPrimitiveBuffer *buffer)
Light Settings
NONE of these should be overridden by API implementations because of the state caching stuff.

void setLight (U32 stage, GFXLightInfo *light)
void setLightMaterial (GFXLightMaterial mat)
void setGlobalAmbientColor (ColorF color)
Texture State Settings
NONE of these should be overridden by API implementations because of the state caching stuff.

void setTexture (U32 stage, GFXTextureObject *texture)
void setCubeTexture (U32 stage, GFXCubemap *cubemap)
GFXTextureObjectgetCurrentTexture (U32 stage)
State Block Interface
Creates a state block object based on the desc passed in. This object represents an immutable state.

virtual GFXStateBlockRef createStateBlock (const GFXStateBlockDesc &desc)
virtual void setStateBlock (GFXStateBlock *block)
 Sets the current stateblock (actually activated in updateStates).
General state interface
void updateStates (bool forceSetAll=false)
 Sets the dirty Render/Texture/Sampler states from the caching system.

Static Public Member Functions

static DeviceEventSignalgetDeviceEventSignal ()
static GFXDeviceget ()
static void initConsole ()
static bool destroy ()
static const Vector< GFXDevice * > * getDeviceVector ()
static void setActiveDevice (U32 deviceIndex)
static bool devicePresent ()

Protected Member Functions

virtual void preDestroy ()
 This is called before this, or any other device, is deleted in the global destroy() method.
virtual void setAdapter (const GFXAdapter &adapter)
 Set the adapter that this device is using. For use by GFXInit::createDevice only.
virtual void deviceInited ()
 Notify GFXDevice that we are initialized.
virtual void setShaderConstBufferInternal (GFXShaderConstBuffer *buffer)=0
 Called by base GFXDevice to actually set a const buffer.
virtual void setTextureInternal (U32 textureUnit, const GFXTextureObject *texture)=0
virtual void setLightInternal (U32 lightStage, const GFXLightInfo light, bool lightEnable)=0
virtual void setGlobalAmbientInternal (ColorF color)=0
virtual void setLightMaterialInternal (const GFXLightMaterial mat)=0
virtual bool beginSceneInternal ()=0
virtual void endSceneInternal ()=0
virtual void setMatrix (GFXMatrixType mtype, const MatrixF &mat)=0
 This function must be implemented differently per API and it should set ONLY the current matrix.
virtual void _updateRenderTargets ()
Stateblock functions
virtual GFXStateBlockRef createStateBlockInternal (const GFXStateBlockDesc &desc)=0
 Called by GFXDevice to create a device specific stateblock.
virtual void setStateBlockInternal (GFXStateBlock *block, bool force)=0
 Called by GFXDevice to actually set a stateblock.
State Initialization.
virtual void initStates ()=0
 State initialization.

Protected Attributes

Vector< GFXVideoModemVideoModes
 List of valid video modes for this device.
GFXCardProfilermCardProfiler
 The CardProfiler for this device.
GFXResourcemResourceListHead
 Head of the resource list.
bool mCanCurrentlyRender
 Set once the device is active.
bool mAllowRender
 Set if we're in a mode where we want rendering to occur.
bool mInitialized
 This will allow querying to see if a device is initialized and ready to have operations performed on it.
Swizzle< U8, 4 > * mDeviceSwizzle32
Swizzle< U8, 3 > * mDeviceSwizzle24
GFXTexHandle mSfxBackBuffer
bool mUseSfxBackBuffer
GFXTexHandle mFrontBuffer [2]
U32 mCurrentFrontBufferIdx
Vector< GFXTargetRefmRTStack
GFXTargetRef mCurrentRT
Light Tracking
GFXLightInfo mCurrentLight [LIGHT_STAGE_COUNT]
bool mCurrentLightEnable [LIGHT_STAGE_COUNT]
bool mLightDirty [LIGHT_STAGE_COUNT]
bool mLightsDirty
ColorF mGlobalAmbientColor
bool mGlobalAmbientColorDirty
Fixed function material tracking
GFXLightMaterial mCurrentLightMaterial
bool mLightMaterialDirty
Matrix managing variables
MatrixF mWorldMatrix [WORLD_STACK_MAX]
bool mWorldMatrixDirty
S32 mWorldStackSize
MatrixF mProjectionMatrix
bool mProjectionMatrixDirty
MatrixF mViewMatrix
bool mViewMatrixDirty
MatrixF mTextureMatrix [TEXTURE_STAGE_COUNT]
bool mTextureMatrixDirty [TEXTURE_STAGE_COUNT]
bool mTextureMatrixCheckDirty
Current frustum planes
F32 mFrustLeft
F32 mFrustRight
F32 mFrustBottom
F32 mFrustTop
F32 mFrustNear
F32 mFrustFar
bool mFrustOrtho

Static Protected Attributes

static S32 smSfxBackBufferSize

Private Attributes

U32 mDeviceIndex
 Device ID for this device.
GFXAdapter mAdapter
 Adapter for this device.

Static Private Attributes

Device management variables
static Vector< GFXDevice * > smGFXDevice
 Global GFXDevice vector.
static S32 smActiveDeviceIndex
 Active GFX Device index, signed so -1 can be uninitialized.
static DeviceEventSignalsmSignalGFXDeviceEvent

Friends

class GFXInit
class GFXPrimitiveBufferHandle
class GFXVertexBufferHandleBase
class GFXTextureObject
class GFXTexHandle
class GFXTestFullscreenToggle
class TestGFXTextureCube
class TestGFXRenderTargetCube
class TestGFXRenderTargetStack
class GFXResource


Member Typedef Documentation


Member Enumeration Documentation

Enumerator:
deCreate  The device has been created, but not initialized.
deInit  The device has been initialized.
deDestroy  The device is about to be destroyed.

enum GFXDevice::TexDirtyType [protected]

Enumerator:
GFXTDT_Normal 
GFXTDT_Cube 

Enumerator:
GSColor 
GSTexture 
GSModColorTexture 
GSAddColorTexture 
GS_COUNT 


Constructor & Destructor Documentation

GFXDevice::GFXDevice (  ) 

virtual GFXDevice::~GFXDevice (  )  [virtual]


Member Function Documentation

static DeviceEventSignal& GFXDevice::getDeviceEventSignal (  )  [static]

static GFXDevice* GFXDevice::get (  )  [static]

static void GFXDevice::initConsole (  )  [static]

static bool GFXDevice::destroy (  )  [static]

static const Vector<GFXDevice *>* GFXDevice::getDeviceVector (  )  [inline, static]

static void GFXDevice::setActiveDevice ( U32  deviceIndex  )  [static]

static bool GFXDevice::devicePresent (  )  [inline, static]

virtual void GFXDevice::preDestroy (  )  [protected, virtual]

This is called before this, or any other device, is deleted in the global destroy() method.

It allows the device to clean up anything while everything is still valid.

Reimplemented in GFXD3D8Device, GFXD3D9Device, GFXGLDevice, and GFXNullDevice.

virtual void GFXDevice::setAdapter ( const GFXAdapter adapter  )  [inline, protected, virtual]

Set the adapter that this device is using. For use by GFXInit::createDevice only.

virtual void GFXDevice::deviceInited (  )  [protected, virtual]

Notify GFXDevice that we are initialized.

virtual void GFXDevice::init ( const GFXVideoMode mode,
PlatformWindow window = NULL 
) [pure virtual]

Initialize this GFXDevice, optionally specifying a platform window to bind to.

Implemented in GFXD3D8Device, GFX360Device, GFXD3D9Device, GFXPCD3D9Device, GFXGLDevice, and GFXNullDevice.

bool GFXDevice::canCurrentlyRender (  )  [inline]

void GFXDevice::setAllowRender ( bool  render  )  [inline]

bool GFXDevice::allowRender (  )  [inline]

GFXCardProfiler* GFXDevice::getCardProfiler (  )  const [inline]

const U32 GFXDevice::getDeviceIndex (  )  const [inline]

virtual GFXAdapterType GFXDevice::getAdapterType (  )  [pure virtual]

Returns active graphics adapter type.

Implemented in GFXD3D8Device, GFX360Device, GFXD3D9Device, GFXGLDevice, and GFXNullDevice.

virtual const GFXAdapter& GFXDevice::getAdapter (  )  [inline, virtual]

Returns the Adapter that was used to create this device.

virtual void GFXDevice::enterDebugEvent ( ColorI  color,
const char *  name 
) [pure virtual]

virtual void GFXDevice::leaveDebugEvent (  )  [pure virtual]

virtual void GFXDevice::setDebugMarker ( ColorI  color,
const char *  name 
) [pure virtual]

virtual void GFXDevice::listResources ( bool  unflaggedOnly  )  [virtual]

Lists how many of each GFX resource (e.g.

textures, texture targets, shaders, etc.) GFX is aware of

Parameters:
unflaggedOnly If true, this method only counts unflagged resources

virtual void GFXDevice::flagCurrentResources (  )  [virtual]

Flags all resources GFX is currently aware of.

virtual void GFXDevice::clearResourceFlags (  )  [virtual]

Clears the flag on all resources GFX is currently aware of.

virtual void GFXDevice::describeResources ( const char *  resName,
const char *  file,
bool  unflaggedOnly 
) [virtual]

Dumps a description of the specified resource types to the console.

Parameters:
resNames A string of space separated class names (e.g. "GFXTextureObject GFXTextureTarget GFXShader") to describe to the console
file A path to the file to write the descriptions to. If it is NULL or "", descriptions are written to the console.
unflaggedOnly If true, this method only counts unflagged resources
Note:
resNames is case sensitive because there is no dStristr function.

GFXDeviceStatistics* GFXDevice::getDeviceStatistics (  )  [inline]

Returns the current GFXDeviceStatistics, stats are cleared every beginScene call.

virtual void GFXDevice::fillResourceVectors ( const char *  resNames,
bool  unflaggedOnly,
Vector< GFXResource * > &  textureObjects,
Vector< GFXResource * > &  textureTargets,
Vector< GFXResource * > &  windowTargets,
Vector< GFXResource * > &  vertexBuffers,
Vector< GFXResource * > &  primitiveBuffers,
Vector< GFXResource * > &  fences,
Vector< GFXResource * > &  cubemaps,
Vector< GFXResource * > &  shaders,
Vector< GFXResource * > &  stateblocks 
) [protected, virtual]

This is a helper method for describeResourcesToFile.

It walks through the GFXResource list and sorts it by item type, putting the resources into the proper vector.

See also:
describeResources

virtual void GFXDevice::enumerateVideoModes (  )  [pure virtual]

const Vector< GFXVideoMode > *const GFXDevice::getVideoModeList (  )  const [inline]

Well, this function gets the video mode list!

F32 GFXDevice::formatByteSize ( GFXFormat  format  ) 

virtual GFXFormat GFXDevice::selectSupportedFormat ( GFXTextureProfile profile,
const Vector< GFXFormat > &  formats,
bool  texture,
bool  mustblend 
) [pure virtual]

virtual GFXStateBlockRef GFXDevice::createStateBlockInternal ( const GFXStateBlockDesc desc  )  [protected, pure virtual]

Called by GFXDevice to create a device specific stateblock.

Implemented in GFXD3D8Device, GFXD3D9Device, GFXGLDevice, and GFXNullDevice.

virtual void GFXDevice::setStateBlockInternal ( GFXStateBlock block,
bool  force 
) [protected, pure virtual]

Called by GFXDevice to actually set a stateblock.

Parameters:
force If true, set all states

Implemented in GFXD3D8Device, GFXD3D9Device, GFXGLDevice, and GFXNullDevice.

virtual void GFXDevice::setShaderConstBufferInternal ( GFXShaderConstBuffer buffer  )  [protected, pure virtual]

Called by base GFXDevice to actually set a const buffer.

Implemented in GFXD3D8Device, GFXD3D9Device, GFXGLDevice, and GFXNullDevice.

virtual void GFXDevice::setTextureInternal ( U32  textureUnit,
const GFXTextureObject texture 
) [protected, pure virtual]

virtual void GFXDevice::setLightInternal ( U32  lightStage,
const GFXLightInfo  light,
bool  lightEnable 
) [protected, pure virtual]

virtual void GFXDevice::setGlobalAmbientInternal ( ColorF  color  )  [protected, pure virtual]

virtual void GFXDevice::setLightMaterialInternal ( const GFXLightMaterial  mat  )  [protected, pure virtual]

virtual bool GFXDevice::beginSceneInternal (  )  [protected, pure virtual]

virtual void GFXDevice::endSceneInternal (  )  [protected, pure virtual]

virtual void GFXDevice::initStates (  )  [protected, pure virtual]

State initialization.

This MUST BE CALLED in setVideoMode after the device is created.

Implemented in GFXD3D8Device, GFX360Device, GFXD3D9Device, GFXPCD3D9Device, GFXGLDevice, and GFXNullDevice.

virtual void GFXDevice::setMatrix ( GFXMatrixType  mtype,
const MatrixF mat 
) [protected, pure virtual]

This function must be implemented differently per API and it should set ONLY the current matrix.

For example, in OpenGL, there should be NO matrix stack activity, all the stack stuff is managed in the GFX layer.

OpenGL does not have separate world and view matrices. It has ModelView which is world * view. You must take this into consideration.

Parameters:
mtype Which matrix to set, world/view/projection
mat Matrix to assign

Implemented in GFXD3D8Device, GFX360Device, GFXPCD3D9Device, GFXGLDevice, and GFXNullDevice.

virtual GFXVertexBuffer* GFXDevice::allocVertexBuffer ( U32  numVerts,
U32  vertFlags,
U32  vertSize,
GFXBufferType  bufferType 
) [protected, pure virtual]

This allocates a vertex buffer and returns a pointer to the allocated buffer.

This function should not be called directly - rather it should be used by the GFXVertexBufferHandle class.

Implemented in GFXD3D8Device, GFXD3D9Device, GFXGLDevice, and GFXNullDevice.

virtual GFXPrimitiveBuffer* GFXDevice::allocPrimitiveBuffer ( U32  numIndices,
U32  numPrimitives,
GFXBufferType  bufferType 
) [protected, pure virtual]

This allocates a primitive buffer and returns a pointer to the allocated buffer.

A primitive buffer's type argument refers to the index data - the primitive data will always be preserved from call to call.

Note:
All index buffers use 16-bit indices.

Implemented in GFXD3D8Device, GFXD3D9Device, GFXGLDevice, and GFXNullDevice.

virtual void GFXDevice::_updateRenderTargets (  )  [protected, virtual]

virtual GFXTexHandle& GFXDevice::getSfxBackBuffer (  )  [inline, virtual]

virtual void GFXDevice::copyBBToSfxBuff (  )  [pure virtual]

virtual GFXCubemap* GFXDevice::createCubemap (  )  [pure virtual]

GFXTextureManager* GFXDevice::getTextureManager (  )  [inline]

const Swizzle<U8, 4>* GFXDevice::getDeviceSwizzle32 (  )  const [inline]

Swizzle to convert 32bpp bitmaps from RGBA to the native device format.

const Swizzle<U8, 3>* GFXDevice::getDeviceSwizzle24 (  )  const [inline]

Swizzle to convert 24bpp bitmaps from RGB to the native device format.

virtual GFXTextureTarget* GFXDevice::allocRenderToTextureTarget (  )  [pure virtual]

Allocate a target for doing render to texture operations, with no depth/stencil buffer.

Implemented in GFXD3D8Device, GFX360Device, GFXD3D9Device, GFXGLDevice, and GFXNullDevice.

virtual GFXWindowTarget* GFXDevice::allocWindowTarget ( PlatformWindow window  )  [pure virtual]

Allocate a target for a given window.

Implemented in GFXD3D8Device, GFXD3D9Device, GFXGLDevice, and GFXNullDevice.

virtual void GFXDevice::pushActiveRenderTarget (  )  [virtual]

Save current render target states - note this works with MRT's.

Reimplemented in GFXD3D8Device, and GFXNullDevice.

virtual void GFXDevice::popActiveRenderTarget (  )  [virtual]

Restore all render targets - supports MRT's.

Reimplemented in GFXD3D8Device, and GFXNullDevice.

virtual void GFXDevice::setActiveRenderTarget ( GFXTarget target  )  [pure virtual]

Start rendering to to a specified render target.

Implemented in GFXD3D8Device, GFX360Device, GFXD3D9Device, GFXGLDevice, and GFXNullDevice.

virtual GFXTarget* GFXDevice::getActiveRenderTarget (  )  [virtual]

Return a pointer to the current active render target.

Reimplemented in GFXD3D8Device, GFXGLDevice, and GFXNullDevice.

virtual F32 GFXDevice::getPixelShaderVersion (  )  const [pure virtual]

virtual void GFXDevice::setPixelShaderVersion ( F32  version  )  [pure virtual]

virtual U32 GFXDevice::getNumSamplers (  )  const [pure virtual]

Returns the number of texture samplers that can be used in a shader rendering pass.

Implemented in GFXD3D8Device, GFXD3D9Device, GFXGLDevice, and GFXNullDevice.

virtual void GFXDevice::setShader ( GFXShader shader  )  [inline, virtual]

Reimplemented in GFXD3D8Device, GFXD3D9Device, and GFXGLDevice.

virtual void GFXDevice::disableShaders (  )  [inline, virtual]

Reimplemented in GFXD3D8Device, GFXD3D9Device, and GFXGLDevice.

void GFXDevice::setShaderConstBuffer ( GFXShaderConstBuffer buffer  ) 

Set the buffer! (Actual set happens on the next draw call, just like textures, state blocks, etc).

virtual GFXShader* GFXDevice::createShader ( const char *  vertFile,
const char *  pixFile,
F32  pixVersion,
const Vector< GFXShaderMacro > &  macros = VectorGFXShaderMacro >() 
) [pure virtual]

Creates a shader.

Parameters:
vertFile Vertex shader filename
pixFile Pixel shader filename
pixVersion Pixel shader version
macros Macros passed to the shader compiler.

Implemented in GFXD3D8Device, GFXD3D9Device, GFXGLDevice, and GFXNullDevice.

virtual void GFXDevice::destroyShader ( GFXShader shader  )  [inline, virtual]

Destroys shader.

Reimplemented in GFXD3D9Device.

virtual void GFXDevice::clear ( U32  flags,
ColorI  color,
F32  z,
U32  stencil 
) [pure virtual]

virtual bool GFXDevice::beginScene (  )  [virtual]

Reimplemented in GFX360Device.

virtual void GFXDevice::endScene (  )  [virtual]

Reimplemented in GFX360Device.

virtual GFXTexHandle& GFXDevice::getFrontBuffer (  )  [inline, virtual]

void GFXDevice::setPrimitiveBuffer ( GFXPrimitiveBuffer buffer  ) 

Reimplemented in GFXD3D8Device.

void GFXDevice::setVertexBuffer ( GFXVertexBuffer buffer  )  [inline]

virtual void GFXDevice::drawPrimitive ( GFXPrimitiveType  primType,
U32  vertexStart,
U32  primitiveCount 
) [pure virtual]

virtual void GFXDevice::drawIndexedPrimitive ( GFXPrimitiveType  primType,
U32  minIndex,
U32  numVerts,
U32  startIndex,
U32  primitiveCount 
) [pure virtual]

void GFXDevice::drawPrimitive ( U32  primitiveIndex  ) 

void GFXDevice::drawPrimitives (  ) 

void GFXDevice::drawPrimitiveBuffer ( GFXPrimitiveBuffer buffer  ) 

virtual GFXFence* GFXDevice::createFence (  )  [pure virtual]

Allocate a fence.

The API specific implementation of GFXDevice is responsible to make sure that the proper type is used. GFXGeneralFence should work in all cases.

Implemented in GFXD3D8Device, GFXD3D9Device, GFXGLDevice, and GFXNullDevice.

void GFXDevice::setLight ( U32  stage,
GFXLightInfo light 
)

void GFXDevice::setLightMaterial ( GFXLightMaterial  mat  ) 

void GFXDevice::setGlobalAmbientColor ( ColorF  color  ) 

void GFXDevice::setTexture ( U32  stage,
GFXTextureObject texture 
)

void GFXDevice::setCubeTexture ( U32  stage,
GFXCubemap cubemap 
)

GFXTextureObject * GFXDevice::getCurrentTexture ( U32  stage  )  [inline]

virtual GFXStateBlockRef GFXDevice::createStateBlock ( const GFXStateBlockDesc desc  )  [virtual]

virtual void GFXDevice::setStateBlock ( GFXStateBlock block  )  [virtual]

Sets the current stateblock (actually activated in updateStates).

void GFXDevice::updateStates ( bool  forceSetAll = false  ) 

Sets the dirty Render/Texture/Sampler states from the caching system.

void GFXDevice::setWorldMatrix ( const MatrixF newWorld  )  [inline]

Sets the top of the world matrix stack.

Parameters:
newWorld New world matrix to set

const MatrixF & GFXDevice::getWorldMatrix (  )  const [inline]

Gets the matrix on the top of the world matrix stack.

void GFXDevice::pushWorldMatrix (  )  [inline]

Pushes the world matrix stack and copies the current top matrix to the new top of the stack.

void GFXDevice::popWorldMatrix (  )  [inline]

Pops the world matrix stack.

void GFXDevice::setProjectionMatrix ( const MatrixF newProj  )  [inline]

Sets the projection matrix.

Parameters:
newProj New projection matrix to set

const MatrixF & GFXDevice::getProjectionMatrix (  )  const [inline]

Gets the projection matrix.

void GFXDevice::setViewMatrix ( const MatrixF newView  )  [inline]

Sets the view matrix.

Parameters:
newView New view matrix to set

const MatrixF & GFXDevice::getViewMatrix (  )  const [inline]

Gets the view matrix.

void GFXDevice::multWorld ( const MatrixF mat  )  [inline]

Multiplies the matrix at the top of the world matrix stack by a matrix and replaces the top of the matrix stack with the result.

Parameters:
mat Matrix to multiply

void GFXDevice::setTextureMatrix ( const U32  stage,
const MatrixF texMat 
) [inline]

Set texture matrix for a sampler.

virtual void GFXDevice::setViewport ( const RectI rect  )  [pure virtual]

virtual const RectI& GFXDevice::getViewport (  )  const [pure virtual]

virtual void GFXDevice::setClipRect ( const RectI rect  )  [pure virtual]

virtual const RectI& GFXDevice::getClipRect (  )  const [pure virtual]

virtual void GFXDevice::setFrustum ( F32  left,
F32  right,
F32  bottom,
F32  top,
F32  nearPlane,
F32  farPlane,
bool  bRotate = true 
) [virtual]

void GFXDevice::getFrustum ( F32 left,
F32 right,
F32 bottom,
F32 top,
F32 nearPlane,
F32 farPlane,
bool isOrtho 
)

virtual void GFXDevice::setFrustum ( F32  FOV,
F32  aspectRatio,
F32  nearPlane,
F32  farPlane 
) [virtual]

void GFXDevice::setOrtho ( F32  left,
F32  right,
F32  bottom,
F32  top,
F32  nearPlane,
F32  farPlane,
bool  doRotate = false 
)

This will construct and apply an orthographic projection matrix with the provided parameters.

Parameters:
doRotate If set to true, the resulting matrix will be rotated PI/2 around the X axis

F32 GFXDevice::projectRadius ( F32  dist,
F32  radius 
)

F32 GFXDevice::worldToScreenScale (  ) 

virtual void GFXDevice::setupGenericShaders ( GenericShaderType  type = GSColor  )  [inline, virtual]

This is a helper function to set a default shader for rendering GUI elements on systems which do not support fixed-function operations as well as for things which need just generic position/texture/color shaders.

Parameters:
type Type of generic shader, add your own if you need

virtual F32 GFXDevice::getFillConventionOffset (  )  const [pure virtual]

Get the fill convention for this device.

Implemented in GFXD3D8Device, GFXD3D9Device, GFXGLDevice, and GFXNullDevice.

virtual U32 GFXDevice::getMaxDynamicVerts (  )  [pure virtual]

virtual U32 GFXDevice::getMaxDynamicIndices (  )  [pure virtual]

virtual void GFXDevice::doParanoidStateCheck (  )  [inline, virtual]

Reimplemented in GFXD3D9Device.

GFXDrawUtil* GFXDevice::getDrawUtil (  ) 

Get access to this device's drawing utility class.

void GFXDevice::clearSamplerOverrides (  ) 

void GFXDevice::setSamplerMipLODBiasOverride ( S32  stage,
bool  on,
F32  bias = 0.0f 
)

void GFXDevice::setSamplerAddressModeOverride ( S32  stage,
bool  on,
GFXTextureAddressMode  mode = GFXAddressClamp 
)

void GFXDevice::getSamplerAddressModeOverride ( S32  stage,
bool on,
GFXTextureAddressMode mode 
)

void GFXDevice::getSamplerMipLODBiasOverride ( S32  stage,
bool on,
F32 bias 
)

void GFXDevice::dumpStates ( const char *  fileName  )  const

This is a method designed for debugging.

It will allow you to dump the states in the render manager out to a file so that it can be diffed and examined.


Friends And Related Function Documentation

friend class GFXInit [friend]

friend class GFXPrimitiveBufferHandle [friend]

friend class GFXVertexBufferHandleBase [friend]

friend class GFXTextureObject [friend]

friend class GFXTexHandle [friend]

friend class GFXTestFullscreenToggle [friend]

friend class TestGFXTextureCube [friend]

friend class TestGFXRenderTargetCube [friend]

friend class TestGFXRenderTargetStack [friend]

friend class GFXResource [friend]

Reimplemented in GFXD3D9Device.


Member Data Documentation

Vector<GFXDevice *> GFXDevice::smGFXDevice [static, private]

Global GFXDevice vector.

Active GFX Device index, signed so -1 can be uninitialized.

Device ID for this device.

Adapter for this device.

List of valid video modes for this device.

The CardProfiler for this device.

Head of the resource list.

See also:
GFXResource

Set once the device is active.

Set if we're in a mode where we want rendering to occur.

This will allow querying to see if a device is initialized and ready to have operations performed on it.

Set if ANY state is dirty, including matrices or primitive buffers.

GFXTexHandle GFXDevice::mCurrentTexture[TEXTURE_STAGE_COUNT] [protected]

GFXTexHandle GFXDevice::mNewTexture[TEXTURE_STAGE_COUNT] [protected]

GFXCubemapHandle GFXDevice::mCurrentCubemap[TEXTURE_STAGE_COUNT] [protected]

GFXCubemapHandle GFXDevice::mNewCubemap[TEXTURE_STAGE_COUNT] [protected]

TexDirtyType GFXDevice::mTexType[TEXTURE_STAGE_COUNT] [protected]

bool GFXDevice::mTextureDirty[TEXTURE_STAGE_COUNT] [protected]

bool GFXDevice::mSamplerAddressModeOverride[TEXTURE_STAGE_COUNT] [protected]

bool GFXDevice::mSamplerMipLODBiasOverride[TEXTURE_STAGE_COUNT] [protected]

F32 GFXDevice::mSamplerMipLODBiasOverrides[TEXTURE_STAGE_COUNT] [protected]

GFXLightInfo GFXDevice::mCurrentLight[LIGHT_STAGE_COUNT] [protected]

bool GFXDevice::mCurrentLightEnable[LIGHT_STAGE_COUNT] [protected]

bool GFXDevice::mLightDirty[LIGHT_STAGE_COUNT] [protected]

MatrixF GFXDevice::mWorldMatrix[WORLD_STACK_MAX] [protected]

MatrixF GFXDevice::mTextureMatrix[TEXTURE_STAGE_COUNT] [protected]

bool GFXDevice::mTextureMatrixDirty[TEXTURE_STAGE_COUNT] [protected]

S32 GFXDevice::smSfxBackBufferSize [static, protected]