GFXGLDevice Class Reference

#include <gfxGLDevice.h>

Inheritance diagram for GFXGLDevice:

Inheritance graph
[legend]
List of all members.

Shader functions

virtual F32 getPixelShaderVersion () const
virtual void setPixelShaderVersion (F32 version)
virtual void setShader (GFXShader *shd)
virtual void disableShaders ()
 Equivalent to setShader(NULL).
virtual GFXFormat selectSupportedFormat (GFXTextureProfile *profile, const Vector< GFXFormat > &formats, bool texture, bool mustblend)
virtual U32 getNumSamplers () const
 Returns the number of texture samplers that can be used in a shader rendering pass.
virtual GFXShadercreateShader (const char *vertFile, const char *pixFile, F32 pixVersion, const Vector< GFXShaderMacro > &macros)
 Creates a shader.
virtual void clear (U32 flags, ColorI color, F32 z, U32 stencil)
virtual bool beginSceneInternal ()
virtual void endSceneInternal ()
virtual void drawPrimitive (GFXPrimitiveType primType, U32 vertexStart, U32 primitiveCount)
virtual void drawIndexedPrimitive (GFXPrimitiveType primType, U32 minIndex, U32 numVerts, U32 startIndex, U32 primitiveCount)
virtual void setViewport (const RectI &rect)
virtual const RectIgetViewport () const
virtual void setClipRect (const RectI &rect)
virtual const RectIgetClipRect () const
virtual void preDestroy ()
 This is called before this, or any other device, is deleted in the global destroy() method.
virtual U32 getMaxDynamicVerts ()
virtual U32 getMaxDynamicIndices ()
GFXFencecreateFence ()
 Allocate a fence.
GFXGLStateBlockRef getCurrentStateBlock ()
virtual GFXStateBlockRef createStateBlockInternal (const GFXStateBlockDesc &desc)
 Called by GFXDevice to create a device specific stateblock.
virtual void setStateBlockInternal (GFXStateBlock *block, bool force)
 Called by GFXDevice to actually set a stateblock.
virtual void setShaderConstBufferInternal (GFXShaderConstBuffer *buffer)
 Called by base GFXDevice to actually set a const buffer.
virtual void setTextureInternal (U32 textureUnit, const GFXTextureObject *texture)
virtual void setCubemapInternal (U32 cubemap, const GFXGLCubemap *texture)
virtual void setLightInternal (U32 lightStage, const GFXLightInfo light, bool lightEnable)
virtual void setLightMaterialInternal (const GFXLightMaterial mat)
virtual void setGlobalAmbientInternal (ColorF color)

State Initalization.

virtual void initStates ()
 State initalization.
virtual void setMatrix (GFXMatrixType mtype, const MatrixF &mat)
 This function must be implemented differently per API and it should set ONLY the current matrix.
virtual GFXVertexBufferallocVertexBuffer (U32 numVerts, U32 vertFlags, U32 vertSize, GFXBufferType bufferType)
 This allocates a vertex buffer and returns a pointer to the allocated buffer.
virtual GFXPrimitiveBufferallocPrimitiveBuffer (U32 numIndices, U32 numPrimitives, GFXBufferType bufferType)
 This allocates a primitive buffer and returns a pointer to the allocated buffer.
typedef GFXDevice Parent
GLsizei primCountToIndexCount (GFXPrimitiveType primType, U32 primitiveCount)
void preDrawPrimitive ()
void postDrawPrimitive (U32 primitiveCount)
void blitWindowToRT (GFXGLTextureTarget *targ, RectI src, RectI dst, bool filter)
GFXVertexBufferfindVolatileVBO (U32 numVerts, U32 vertFlags, U32 vertSize)
 Returns an existing volatile VB which has >= numVerts and the same vert flags/size, or creates a new VB if necessary.
GFXPrimitiveBufferfindVolatilePBO (U32 numIndices, U32 numPrimitives)
 Returns an existing volatile PB which has >= numIndices, or creates a new PB if necessary.
void initGLState ()
 Guaranteed to be called after all extensions have been loaded, use to init card profiler, shader version, max samplers, etc.
GFXFence_createPlatformSpecificFence ()
 If our platform (e.g. OS X) supports a fence extenstion (e.g. GL_APPLE_fence) this will create one, otherwise returns NULL.
void setVB (GFXGLVertexBuffer *vb)
 Sets mCurrentVB.
void setPB (GFXGLPrimitiveBuffer *pb)
 Sets mCurrentPB.
U32 mAdapterIndex
StrongRefPtr< GFXGLVertexBuffermCurrentVB
StrongRefPtr< GFXGLPrimitiveBuffermCurrentPB
MatrixF m_mCurrentWorld
 Since GL does not have separate world and view matrices we need to track them.
MatrixF m_mCurrentView
voidmContext
voidmPixelFormat
F32 mPixelShaderVersion
U32 mMaxShaderTextures
U32 mMaxFFTextures
RectI mViewport
RectI mClip
GFXGLStateBlockRef mCurrentGLStateBlock
GFXGLShaderMgr mShaderMgr
GLenum mActiveTextureType [TEXTURE_STAGE_COUNT]
GFXTexHandle mBackBufferCopyTexture
 When RTBlit is unsupported the entire backbuffer is copied into this for copyBBtoSfxBuff.
GFXTextureTargetRef mSfxBufferRT
 When RTBlit is unsupported this is used to render to backbuffer copy texture into the SfxBuff.
Vector< StrongRefPtr< GFXGLVertexBuffer > > mVolatileVBs
 Pool of existing volatile VBs so we can reuse previously created ones.
Vector< StrongRefPtr< GFXGLPrimitiveBuffer > > mVolatilePBs
 Pool of existing volatile PBs so we can reuse previously created ones.
static GFXAdapter::CreateDeviceInstanceDelegate mCreateDeviceInstance
class GFXGLTextureObject
class GFXGLCubemap
class GFXGLWindowTarget
class GFXGLPrimitiveBuffer
class GFXGLVertexBuffer

Public Member Functions

void zombify ()
void resurrect ()
 GFXGLDevice (U32 adapterIndex)
virtual ~GFXGLDevice ()
virtual void init (const GFXVideoMode &mode, PlatformWindow *window=NULL)
 Initialize this GFXDevice, optionally specifying a platform window to bind to.
virtual void activate ()
virtual void deactivate ()
virtual GFXAdapterType getAdapterType ()
 Returns active graphics adapter type.
virtual void enterDebugEvent (ColorI color, const char *name)
virtual void leaveDebugEvent ()
virtual void setDebugMarker (ColorI color, const char *name)
virtual void enumerateVideoModes ()
virtual U32 getTotalVideoMemory ()
virtual void copyBBToSfxBuff ()
virtual GFXCubemapcreateCubemap ()
virtual F32 getFillConventionOffset () const
 Get the fill convention for this device.
Render Target functions
virtual GFXTextureTargetallocRenderToTextureTarget ()
 Allocate a target for doing render to texture operations, with no depth/stencil buffer.
virtual GFXWindowTargetallocWindowTarget (PlatformWindow *window)
 Allocate a target for a given window.
virtual void setActiveRenderTarget (GFXTarget *target)
 Start rendering to to a specified render target.
virtual GFXTargetgetActiveRenderTarget ()
 Return a pointer to the current active render target.

Static Public Member Functions

static void enumerateAdapters (Vector< GFXAdapter * > &adapterList)
static GFXDevicecreateInstance (U32 adapterIndex)

Member Typedef Documentation

typedef GFXDevice GFXGLDevice::Parent [private]


Constructor & Destructor Documentation

GFXGLDevice::GFXGLDevice ( U32  adapterIndex  ) 

virtual GFXGLDevice::~GFXGLDevice (  )  [virtual]


Member Function Documentation

void GFXGLDevice::zombify (  ) 

void GFXGLDevice::resurrect (  ) 

static void GFXGLDevice::enumerateAdapters ( Vector< GFXAdapter * > &  adapterList  )  [static]

static GFXDevice* GFXGLDevice::createInstance ( U32  adapterIndex  )  [static]

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

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

Implements GFXDevice.

virtual void GFXGLDevice::activate (  )  [inline, virtual]

virtual void GFXGLDevice::deactivate (  )  [inline, virtual]

virtual GFXAdapterType GFXGLDevice::getAdapterType (  )  [inline, virtual]

Returns active graphics adapter type.

Implements GFXDevice.

virtual void GFXGLDevice::enterDebugEvent ( ColorI  color,
const char *  name 
) [inline, virtual]

Implements GFXDevice.

virtual void GFXGLDevice::leaveDebugEvent (  )  [inline, virtual]

Implements GFXDevice.

virtual void GFXGLDevice::setDebugMarker ( ColorI  color,
const char *  name 
) [inline, virtual]

Implements GFXDevice.

virtual void GFXGLDevice::enumerateVideoModes (  )  [virtual]

Implements GFXDevice.

virtual U32 GFXGLDevice::getTotalVideoMemory (  )  [virtual]

virtual void GFXGLDevice::copyBBToSfxBuff (  )  [virtual]

Implements GFXDevice.

virtual GFXCubemap* GFXGLDevice::createCubemap (  )  [virtual]

Implements GFXDevice.

virtual F32 GFXGLDevice::getFillConventionOffset (  )  const [inline, virtual]

Get the fill convention for this device.

Implements GFXDevice.

virtual GFXTextureTarget* GFXGLDevice::allocRenderToTextureTarget (  )  [virtual]

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

Implements GFXDevice.

virtual GFXWindowTarget* GFXGLDevice::allocWindowTarget ( PlatformWindow window  )  [virtual]

Allocate a target for a given window.

Implements GFXDevice.

virtual void GFXGLDevice::setActiveRenderTarget ( GFXTarget target  )  [virtual]

Start rendering to to a specified render target.

Implements GFXDevice.

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

Return a pointer to the current active render target.

Reimplemented from GFXDevice.

virtual F32 GFXGLDevice::getPixelShaderVersion (  )  const [inline, virtual]

Implements GFXDevice.

virtual void GFXGLDevice::setPixelShaderVersion ( F32  version  )  [inline, virtual]

Implements GFXDevice.

virtual void GFXGLDevice::setShader ( GFXShader shd  )  [virtual]

Reimplemented from GFXDevice.

virtual void GFXGLDevice::disableShaders (  )  [virtual]

Equivalent to setShader(NULL).

Reimplemented from GFXDevice.

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

Attention:
GL cannot check if the given format supports blending!

Implements GFXDevice.

virtual U32 GFXGLDevice::getNumSamplers (  )  const [virtual]

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

Implements GFXDevice.

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

Creates a shader.

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

Implements GFXDevice.

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

Implements GFXDevice.

virtual bool GFXGLDevice::beginSceneInternal (  )  [virtual]

Implements GFXDevice.

virtual void GFXGLDevice::endSceneInternal (  )  [virtual]

Implements GFXDevice.

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

Implements GFXDevice.

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

Implements GFXDevice.

virtual void GFXGLDevice::setViewport ( const RectI rect  )  [virtual]

Implements GFXDevice.

virtual const RectI& GFXGLDevice::getViewport (  )  const [virtual]

Implements GFXDevice.

virtual void GFXGLDevice::setClipRect ( const RectI rect  )  [virtual]

Implements GFXDevice.

virtual const RectI& GFXGLDevice::getClipRect (  )  const [inline, virtual]

Implements GFXDevice.

virtual void GFXGLDevice::preDestroy (  )  [inline, 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 from GFXDevice.

virtual U32 GFXGLDevice::getMaxDynamicVerts (  )  [inline, virtual]

Implements GFXDevice.

virtual U32 GFXGLDevice::getMaxDynamicIndices (  )  [inline, virtual]

Implements GFXDevice.

GFXFence* GFXGLDevice::createFence (  )  [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.

Implements GFXDevice.

GFXGLStateBlockRef GFXGLDevice::getCurrentStateBlock (  )  [inline]

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

Called by GFXDevice to create a device specific stateblock.

Implements GFXDevice.

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

Called by GFXDevice to actually set a stateblock.

Implements GFXDevice.

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

Called by base GFXDevice to actually set a const buffer.

Implements GFXDevice.

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

Implements GFXDevice.

virtual void GFXGLDevice::setCubemapInternal ( U32  cubemap,
const GFXGLCubemap texture 
) [protected, virtual]

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

Implements GFXDevice.

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

Implements GFXDevice.

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

Implements GFXDevice.

virtual void GFXGLDevice::initStates (  )  [inline, protected, virtual]

State initalization.

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

Implements GFXDevice.

virtual void GFXGLDevice::setMatrix ( GFXMatrixType  mtype,
const MatrixF mat 
) [protected, 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

Implements GFXDevice.

virtual GFXVertexBuffer* GFXGLDevice::allocVertexBuffer ( U32  numVerts,
U32  vertFlags,
U32  vertSize,
GFXBufferType  bufferType 
) [protected, 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.

Implements GFXDevice.

virtual GFXPrimitiveBuffer* GFXGLDevice::allocPrimitiveBuffer ( U32  numIndices,
U32  numPrimitives,
GFXBufferType  bufferType 
) [protected, 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.

Implements GFXDevice.

GLsizei GFXGLDevice::primCountToIndexCount ( GFXPrimitiveType  primType,
U32  primitiveCount 
) [private]

void GFXGLDevice::preDrawPrimitive (  )  [private]

void GFXGLDevice::postDrawPrimitive ( U32  primitiveCount  )  [private]

void GFXGLDevice::blitWindowToRT ( GFXGLTextureTarget targ,
RectI  src,
RectI  dst,
bool  filter 
) [private]

GFXVertexBuffer* GFXGLDevice::findVolatileVBO ( U32  numVerts,
U32  vertFlags,
U32  vertSize 
) [private]

Returns an existing volatile VB which has >= numVerts and the same vert flags/size, or creates a new VB if necessary.

GFXPrimitiveBuffer* GFXGLDevice::findVolatilePBO ( U32  numIndices,
U32  numPrimitives 
) [private]

Returns an existing volatile PB which has >= numIndices, or creates a new PB if necessary.

void GFXGLDevice::initGLState (  )  [private]

Guaranteed to be called after all extensions have been loaded, use to init card profiler, shader version, max samplers, etc.

GFXFence* GFXGLDevice::_createPlatformSpecificFence (  )  [private]

If our platform (e.g. OS X) supports a fence extenstion (e.g. GL_APPLE_fence) this will create one, otherwise returns NULL.

void GFXGLDevice::setVB ( GFXGLVertexBuffer vb  )  [private]

Sets mCurrentVB.

void GFXGLDevice::setPB ( GFXGLPrimitiveBuffer pb  )  [private]

Sets mCurrentPB.


Friends And Related Function Documentation

friend class GFXGLTextureObject [friend]

friend class GFXGLCubemap [friend]

friend class GFXGLWindowTarget [friend]

friend class GFXGLPrimitiveBuffer [friend]

friend class GFXGLVertexBuffer [friend]


Member Data Documentation

Since GL does not have separate world and view matrices we need to track them.

GLenum GFXGLDevice::mActiveTextureType[TEXTURE_STAGE_COUNT] [private]

When RTBlit is unsupported the entire backbuffer is copied into this for copyBBtoSfxBuff.

When RTBlit is unsupported this is used to render to backbuffer copy texture into the SfxBuff.

Pool of existing volatile VBs so we can reuse previously created ones.

Pool of existing volatile PBs so we can reuse previously created ones.