D3D Class Reference

List of all members.

Classes

struct  CachedTexture
struct  Options
struct  SimpleVertex
struct  TextureMetaData
struct  Vec2
struct  Vec3
struct  Vec4
struct  Vec4_byte
struct  Vertex

Public Types

enum  TexturePass {
  PASS_DIFFUSE, PASS_LIGHT, PASS_DETAIL, PASS_FOG,
  PASS_MACRO, DUMMY_NUM_PASSES
}
enum  ProjectionMode { PROJ_NORMAL, PROJ_Z_ONLY, PROJ_COMPENSATE_Z_NEAR }

Static Public Member Functions

API initialization/upkeep
static int init (HWND hwnd, D3D::Options &createOptions)
static void uninit ()
static int resize (int X, int Y, bool fullScreen)
Setup/clear frame
static void newFrame ()
static void clear (D3D::Vec4 &clearColor)
static void clearDepth ()
Prepare and render buffers
static void map (bool clear)
static void render ()
static void present ()
Index and buffer vertices
static void indexTriangleFan (int num)
static void indexQuad ()
static D3D::VertexgetVertex ()
Set state (projection, flags)
static void setViewPort (int X, int Y, int left, int top)
static void setProjectionMode (D3D::ProjectionMode mode)
static void setProjection (float aspect, float XoverZ)
static void setFlags (int flags, int d3dflags)
Texture cache
static ID3D10Texture2D * createTexture (D3D10_TEXTURE2D_DESC &desc, D3D10_SUBRESOURCE_DATA &data)
static void updateMip (DWORD64 id, int mipNum, D3D10_SUBRESOURCE_DATA &data)
static void cacheTexture (DWORD64 id, TextureMetaData &metadata, ID3D10Texture2D *tex)
static bool textureIsCached (DWORD64 id)
static D3D::TextureMetaDatagetTextureMetaData (DWORD64 id)
static D3D::TextureMetaDatasetTexture (D3D::TexturePass pass, DWORD64 id)
static void deleteTexture (DWORD64 id)
static void flush ()
Misc
static void flash (bool enable, D3D::Vec4 &color)
static void fog (float dist, D3D::Vec4 *color)
static TCHAR * getModes ()
static void getScreenshot (D3D::Vec4_byte *buf)
static void setBrightness (float brightness)

Static Private Member Functions

static int createRenderTargetViews ()
static int findAALevel ()
static void commit ()
static ID3D10EffectPass * switchToPass (int index)


Detailed Description

Main Direct3D functionality; self-contained, does not call external functions apart from the debug output one. Does not use Unreal data apart from a couple of PolyFlags. Does not require the renderer interface to deal with Direct3D structures. Quite a lot of code, but splitting this up does not really seem worth it.

An effort is made to reduce the amount of needed draw() calls. As such, state is only changed when absolutely necessary.

TODO: Take out d3dx? Different shaders/input layouts for different drawXXXX renderer calls for smaller vertex size?


Member Enumeration Documentation

Projection modes. PROJ_NORMAL is normal projection. PROJ_Z_ONLY only applies the projection to the Z coordinate. PROJ_COMPENSATE_Z_NEAR projects vertices but adjusts their W value to compensate for being moved inside zNear

List of texture passes that can be bound.

Note:
DUMMY_NUM_PASSES is so arrays can be indexed etc. for each pass.


Member Function Documentation

void D3D::clear ( D3D::Vec4 clearColor  )  [static]

Clear backbuffer(s)

Parameters:
clearColor The color with which the screen is cleared.

void D3D::clearDepth (  )  [static]

Clear depth

void D3D::commit (  )  [static, private]

Commit buffered polys; i.e. draw and remap. Do this before changing state.

int D3D::createRenderTargetViews (  )  [static, private]

Create a render target view from the backbuffer and depth stencil buffer.

ID3D10Texture2D * D3D::createTexture ( D3D10_TEXTURE2D_DESC &  desc,
D3D10_SUBRESOURCE_DATA &  data 
) [static]

Create a texture from a descriptor and data to fill it with.

Parameters:
desc Direct3D texture description.
data Data to fill the texture with.

void D3D::deleteTexture ( DWORD64  id  )  [static]

Delete a texture (so it can be overwritten with an updated one).

int D3D::findAALevel (  )  [static, private]

Find the maximum level of MSAA supported by the device and clamp the options.MSAA setting to this.

Returns:
1 if succesful.

void D3D::flash ( bool  enable,
D3D::Vec4 color 
) [static]

Notify the shader a flash effect should be drawn.

void D3D::flush (  )  [static]

Clear texture cache.

void D3D::fog ( float  dist,
D3D::Vec4 color 
) [static]

Set the shader's fog settings.

TCHAR * D3D::getModes (  )  [static]

Create a string of supported display modes.

Returns:
String of modes. Caller must delete[] this.
Note:
No error checking.

Deus Ex only shows 16 resolutions, so for it make it the 16 highest ones.

void D3D::getScreenshot ( D3D::Vec4_byte buf  )  [static]

Return screen data by copying the back buffer to a staging resource and copying this into an array.

Parameters:
buf Array in which the data will be written.
Note:
No error checking.

D3D::TextureMetaData & D3D::getTextureMetaData ( DWORD64  id  )  [static]

Returns texture metadata.

Parameters:
id CacheID for texture.

D3D::Vertex * D3D::getVertex (  )  [static]

Returns a pointer to the next vertex in the buffer; this can then be set to buffer a model etc.

Returns:
Vertex pointer.

void D3D::indexQuad (  )  [static]

Generate index data for a quad. See indexTriangleFan().

void D3D::indexTriangleFan ( int  num  )  [static]

Generate index data so a triangle fan with 'num' vertices is converted to a triangle list. Should be called BEFORE those vertices are buffered.

Parameters:
num Number of vertices in the triangle fan.

int D3D::init ( HWND  hWnd,
D3D::Options createOptions 
) [static]

Create Direct3D device, swapchain, etc. Purely boilerplate stuff.

Parameters:
hWnd Window to use as a surface.
createOptions the D3D::Options which to use.
zNear Near Z value.

void D3D::map ( bool  clear  )  [static]

Memory map index and vertex buffer for writing.

Parameters:
Clear Sets whether the buffer is restarted from the beginning; This is done when the buffers are about to overflow, and at the start of a new frame (Microsoft recommendation).

void D3D::newFrame (  )  [static]

Set up things for rendering a new frame. For example, update shader time.

void D3D::present (  )  [static]

Postprocess and Flip

void D3D::render (  )  [static]

Draw current buffer contents.

int D3D::resize ( int  X,
int  Y,
bool  fullScreen 
) [static]

Set resolution and windowed/fullscreen.

Note:
DX10 is volatile; the order in which the steps are taken is critical.

void D3D::setBrightness ( float  brightness  )  [static]

Sets the in-shader brightness.

Parameters:
brightness Brightness 0-1.

void D3D::setFlags ( int  flags,
int  D3DFlags 
) [static]

Handle flags that change depth or blend state. See polyflags.h. Only done if flag is different from current. If there's any buffered geometry, it will drawn before setting the new flags.

Parameters:
flags Unreal polyflags.
d3dflags Custom flags defined in d3d.h.
Note:
Bottleneck; make sure buffers are only rendered due to flag changes when absolutely necessary

Deus Ex requires other different precedence rules for holoconvos with glasses-wearing characters to look good.

void D3D::setProjection ( float  aspect,
float  XoverZ 
) [static]

Set projection matrix parameters.

Parameters:
aspect The viewport aspect ratio.
XoverZ Ratio between frustum X and Z. Projection parameters are for z=1, so x over z gives x coordinate; and x/z*aspect=y/z=y.

D3D::TextureMetaData * D3D::setTexture ( D3D::TexturePass  pass,
DWORD64  id 
) [static]

Set the texture for a texture pass (diffuse, lightmap, etc). Texture is only set if it's not already the current one for that pass. Cached polygons (using the previous set of textures) are drawn before the switch is made.

Parameters:
id CacheID for texture. NULL sets no texture for the pass (by disabling it using a shader constant).
Returns:
texture metadata so renderer can use parameters such as scale/pan; NULL is texture not found

void D3D::setViewPort ( int  X,
int  Y,
int  left,
int  top 
) [static]

Set up the viewport. Also sets height and width in shader.

Note:
Buffered polys must be committed first, otherwise glitches will occur (for example, Deus Ex security cams).

ID3D10EffectPass * D3D::switchToPass ( int  index  )  [static, private]

Set up render targets, textures, etc. for the chosen pass.

Parameters:
index The number of the pass.

bool D3D::textureIsCached ( DWORD64  id  )  [static]

Returns true if texture is in cache.

Parameters:
id CacheID for texture.

void D3D::uninit (  )  [static]

Cleanup

void D3D::updateMip ( DWORD64  id,
int  mipNum,
D3D10_SUBRESOURCE_DATA &  data 
) [static]

Update a single texture mip using a copy operation.

Parameters:
id CacheID to insert texture with.
mipNum Mip level to update.
data Data to write to the mip.


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

Generated on Sat Jun 27 15:41:20 2009 for D3D10DRV by  doxygen 1.5.9