UD3D10RenderDevice Class Reference

List of all members.

Public Member Functions

Abstract in parent class
UBOOL Init (UViewport *InViewport, INT NewX, INT NewY, INT NewColorBytes, UBOOL Fullscreen)
UBOOL SetRes (INT NewX, INT NewY, INT NewColorBytes, UBOOL Fullscreen)
void Exit ()
void Flush (UBOOL AllowPrecache)
void Lock (FPlane FlashScale, FPlane FlashFog, FPlane ScreenClear, DWORD RenderLockFlags, BYTE *HitData, INT *HitSize)
void Unlock (UBOOL Blit)
void DrawComplexSurface (FSceneNode *Frame, FSurfaceInfo &Surface, FSurfaceFacet &Facet)
void DrawGouraudPolygon (FSceneNode *Frame, FTextureInfo &Info, FTransTexture **Pts, int NumPts, DWORD PolyFlags, FSpanBuffer *Span)
void DrawTile (FSceneNode *Frame, FTextureInfo &Info, FLOAT X, FLOAT Y, FLOAT XL, FLOAT YL, FLOAT U, FLOAT V, FLOAT UL, FLOAT VL, class FSpanBuffer *Span, FLOAT Z, FPlane Color, FPlane Fog, DWORD PolyFlags)
void Draw2DLine (FSceneNode *Frame, FPlane Color, DWORD LineFlags, FVector P1, FVector P2)
void Draw2DPoint (FSceneNode *Frame, FPlane Color, DWORD LineFlags, FLOAT X1, FLOAT Y1, FLOAT X2, FLOAT Y2, FLOAT Z)
void ClearZ (FSceneNode *Frame)
void PushHit (const BYTE *Data, INT Count)
void PopHit (INT Count, UBOOL bForce)
void GetStats (TCHAR *Result)
void ReadPixels (FColor *Pixels)
Optional but implemented
UBOOL Exec (const TCHAR *Cmd, FOutputDevice &Ar)
void SetSceneNode (FSceneNode *Frame)
void PrecacheTexture (FTextureInfo &Info, DWORD PolyFlags)
void EndFlash ()
void StaticConstructor ()

Private Attributes

D3D::Options D3DOptions
struct {
   int   precache
options

Helpers

static void debugs (char *s)
int getOption (TCHAR *name, int defaultVal, bool isBool)


Detailed Description

This is the interface between the game and the graphics API. For the D3D10 renderer, an effort was made to have it not work directly with D3D types and objects; it is purely concerned with answering the game and putting data in correct structures for further processing. This leaves this class relatively clean and easy to understand, and should make it a good basis for further work. It contains only the bare essential functions to implement the renderer interface. There are two exceptions: UD3D10RenderDevice::debugs() and UD3D10RenderDevice::getOption are helpers not required by the game.

Called UD3D10RenderDevice as Unreal leaves out first letter when accessing the class; now it can be accessed as D3D10RenderDevice.


Member Function Documentation

void UD3D10RenderDevice::ClearZ ( FSceneNode *  Frame  ) 

Clear the depth buffer. Used to draw the skybox behind the rest of the geometry, and weapon in front.

Note:
It is important that any vertex buffer contents be commited before actually clearing the depth!

void UD3D10RenderDevice::debugs ( char *  s  )  [static]

Prints text to the game's log and the standard output if in debug mode.

Parameters:
s A the message to print.
Note:
Does not take a wide character string because not everything we want to print might be available as such (i.e. ID3D10Blobs).

void UD3D10RenderDevice::Draw2DLine ( FSceneNode *  Frame,
FPlane  Color,
DWORD  LineFlags,
FVector  P1,
FVector  P2 
)

For UnrealED.

void UD3D10RenderDevice::Draw2DPoint ( FSceneNode *  Frame,
FPlane  Color,
DWORD  LineFlags,
FLOAT  X1,
FLOAT  Y1,
FLOAT  X2,
FLOAT  Y2,
FLOAT  Z 
)

For UnrealED.

void UD3D10RenderDevice::DrawComplexSurface ( FSceneNode *  Frame,
FSurfaceInfo &  Surface,
FSurfaceFacet &  Facet 
)

Complex surfaces are used for map geometry. They consists of facets which in turn consist of polys (triangle fans).

Parameters:
Frame The scene. See SetSceneNode().
Surface Holds information on the various texture passes and the surface's PolyFlags.
  • PolyFlags contains the correct flags for this surface. See polyflags.h
  • Texture is the diffuse texture.
  • DetailTexture is the nice close-up detail that's modulated with the diffuse texture for walls. It's up to the renderer to only draw these on near surfaces.
  • LightMap is the precalculated map lighting. Should be drawn with a -.5 pan offset.
  • FogMap is precalculated fog. Should be drawn with a -.5 pan offset. Should be added, not modulated. Flags determine if it should be applied, see polyflags.h.
  • MacroTexture is similar to a detail texture but for far away surfaces. Rarely used.
Facet Contains coordinates and polygons.
  • MapCoords are used to calculate texture coordinates. Involved. See code.
  • Polys is a linked list of triangle fan arrays; each element is similar to the models used in DrawGouraudPolygon().
Note:
DetailTexture and FogMap are mutually exclusive; D3D10 renderer just uses seperate binds for them anyway.

D3D10 renderer handles DetailTexture range in shader.

void UD3D10RenderDevice::DrawGouraudPolygon ( FSceneNode *  Frame,
FTextureInfo &  Info,
FTransTexture **  Pts,
int  NumPts,
DWORD  PolyFlags,
FSpanBuffer *  Span 
)

Gouraud shaded polygons are used for 3D models and surprisingly shadows. They are sent with a call of this function per triangle fan, worldview transformed and lit. They do have normals and texture coordinates (no panning).

Parameters:
Frame The scene. See SetSceneNode().
Info The texture for the model. Models only come with diffuse textures.
Pts A triangle fan stored as an array. Each element has a normal, light (i.e. color) and fog (color due to being in fog).
NumPts Number of verts in fan.
PolyFlags Contains the correct flags for this model. See polyflags.h
Span Probably for software renderers.
Note:
Modulated models (i.e. shadows) shouldn't have a color, and fog should only be applied to models with the correct flags for that. The D3D10 renderer handles this in the shader.

void UD3D10RenderDevice::DrawTile ( FSceneNode *  Frame,
FTextureInfo &  Info,
FLOAT  X,
FLOAT  Y,
FLOAT  XL,
FLOAT  YL,
FLOAT  U,
FLOAT  V,
FLOAT  UL,
FLOAT  VL,
class FSpanBuffer *  Span,
FLOAT  Z,
FPlane  Color,
FPlane  Fog,
DWORD  PolyFlags 
)

Used for 2D UI elements, coronas, etc. Done by converting pixel coordinates to -1,1 ranges in vertex shader and drawing quads with X/Y perspective transform disabled. The Z coordinate however is transformed and divided by W; then W is set to 1 in the shader to get correct depth and yet preserve X and Y. Other renderers take the opposite approach and multiply X by RProjZ*Z and Y by RProjZ*Z*aspect so they are preserved and then tranform everything.

Parameters:
Frame The scene. See SetSceneNode().
Info The texture for the quad.
X X coord in screen space.
Y Y coord in screen space.
XL Width in pixels
YL Height in pixels
U Texure U coordinate for left.
V Texture V coordinate for top.
UL U+UL is coordinate for right.
VL V+VL is coordinate for bottom.
Span Probably for software renderers.
Z coordinate (similar to that of other primitives).
Color color
Fog fog
PolyFlags Contains the correct flags for this tile. See polyflags.h
Note:
Need to set scene node here otherwise Deus Ex dialogue letterboxes will look wrong; they aren't properly handled SetSceneNode() it seems.

void UD3D10RenderDevice::EndFlash (  ) 

Other renderers handle flashes here by saving the related structures; this one does it in Lock().

UBOOL UD3D10RenderDevice::Exec ( const TCHAR *  Cmd,
FOutputDevice &  Ar 
)

Various command from the game. Can be used to intercept input. First let the parent class handle the command.

Parameters:
Cmd The command
  • GetRes Should return a list of resolutions in string form "HxW HxW" etc.
  • Brightness is intercepted here
Ar A class to which to log responses using Ar.Log().
Note:
Deus Ex ignores resolutions it does not like.

void UD3D10RenderDevice::Exit (  ) 

Cleanup.

void UD3D10RenderDevice::Flush ( UBOOL  AllowPrecache  ) 

Empty texture cache.

Parameters:
AllowPrecache Enabled if the game allows us to precache; respond by setting URenderDevice::PrecacheOnFlip = 1 if wanted. This does make load times longer.

int UD3D10RenderDevice::getOption ( TCHAR *  name,
int  defaultVal,
bool  isBool 
)

Attempts to read a property from the game's config file; on failure, a default is written (so it can be changed by the user) and returned.

Parameters:
name A string identifying the config file options.
defaultVal The default value to write and return if the option is not found.
isBool Whether the parameter's a boolean or integer
Returns:
The value for the property.
Note:
The default value is written so it can be user modified (either from the config or preferences window) from then on.

void UD3D10RenderDevice::GetStats ( TCHAR *  Result  ) 

Something to do with FPS counters etc, not needed.

UBOOL UD3D10RenderDevice::Init ( UViewport *  InViewport,
INT  NewX,
INT  NewY,
INT  NewColorBytes,
UBOOL  Fullscreen 
)

Initialization of renderer.

  • Set parent class options. Some of these are settings for the renderer to heed, others control what the game does.
    • URenderDevice::SpanBased; Probably for software renderers.
    • URenderDevice::Fullscreen; Only for Voodoo cards.
    • URenderDevice::SupportsTC; Game sends compressed textures if present.
    • URenderDevice::SupportsDistanceFog; Distance fog. Don't know how this is supposed to be implemented.
    • URenderDevice::SupportsLazyTextures; Renderer loads and unloads texture info when needed (???).
    • URenderDevice::PrefersDeferredLoad; Renderer prefers not to cache textures in advance (???).
    • URenderDevice::ShinySurfaces; Renderer supports detail textures. The game sends them always, so it's meant as a detail setting for the renderer.
    • URenderDevice::Coronas; If enabled, the game draws light coronas.
    • URenderDevice::HighDetailActors; If enabled, game sends more detailed models (???).
    • URenderDevice::VolumetricLighting; If enabled, the game sets fog textures for surfaces if needed.
    • URenderDevice::PrecacheOnFlip; The game will call the PrecacheTexture() function to load textures in advance. Also see Flush().
    • URenderDevice::Viewport; Always set to InViewport.
  • Initialize graphics api.
  • Resize buffers (convenient to use SetRes() for this).

Parameters:
InViewport viewport parameters, can get the window handle.
NewX Viewport width.
NewY Viewport height.
NewColorBytes Color depth.
Fullscreen Whether fullscreen mode should be used.
Returns:
1 if init succesful. On 0, game errors out.
Note:
D3D10 renderer ignores color depth.

void UD3D10RenderDevice::Lock ( FPlane  FlashScale,
FPlane  FlashFog,
FPlane  ScreenClear,
DWORD  RenderLockFlags,
BYTE *  InHitData,
INT *  InHitSize 
)

Clear screen and depth buffer, prepare buffers to receive data.

Parameters:
FlashScale To do with flash effects, see notes.
FlashFog To do with flash effects, see notes.
ScreenClear The color with which to clear the screen. Used for Rune fog.
RenderLockFlags Signify whether the screen should be cleared. Depth buffer should always be cleared.
InHitData Something to do with clipping planes; safe to ignore.
InHitSize Something to do with clipping planes; safe to ignore.
Note:
'Flash' effects are fullscreen colorization, for example when the player is underwater (blue) or being hit (red). Depending on the values of the related parameters (see source code) this should be drawn; the games don't always send a blank flash when none should be drawn. EndFlash() ends this, but other renderers actually save the parameters and start drawing it there (probably so it is drawn with the correct depth).

RenderLockFlags aren't always properly set, this results in for example glitching in the Unreal castle flyover, in the wall of the tower with the Nali on it.

void UD3D10RenderDevice::PopHit ( INT  Count,
UBOOL  bForce 
)

Something to do with clipping planes, not needed.

void UD3D10RenderDevice::PrecacheTexture ( FTextureInfo &  Info,
DWORD  PolyFlags 
)

Store a texture in the renderer-kept texture cache. Only called by the game if URenderDevice::PrecacheOnFlip is 1.

Parameters:
Info Texture (meta)data. Includes a CacheID with which to index.
PolyFlags Contains the correct flags for this texture. See polyflags.h
Note:
Already cached textures are skipped, unless it's a dynamic texture, in which case it is updated.

Extra care is taken to recache textures that aren't saved as masked, but now have flags indicating they should be (masking is not always properly set). as this couldn't be anticipated in advance, the texture needs to be deleted and recreated.

void UD3D10RenderDevice::PushHit ( const BYTE *  Data,
INT  Count 
)

Something to do with clipping planes, not needed.

void UD3D10RenderDevice::ReadPixels ( FColor *  Pixels  ) 

Used for screenshots and savegame previews.

Parameters:
Pixels An array of 32 bit pixels in which to dump the back buffer.

UBOOL UD3D10RenderDevice::SetRes ( INT  NewX,
INT  NewY,
INT  NewColorBytes,
UBOOL  Fullscreen 
)

Resize buffers and viewport.

Returns:
1 if resize succesful. On 0, game errors out.
Note:
Switching to fullscreen exits and reinitializes the renderer.

Fullscreen can have values other than 0 and 1 for some reason.

This function MUST call URenderDevice::Viewport->ResizeViewport() or the game will stall.

void UD3D10RenderDevice::SetSceneNode ( FSceneNode *  Frame  ) 

This optional function can be used to set the frustum and viewport parameters per scene change instead of per drawXXXX() call.

Parameters:
Frame Contains various information with which to build frustum and viewport.

void UD3D10RenderDevice::StaticConstructor (  ) 

Constructor called by the game when the renderer is first created.

Note:
Required to compile for Unreal Tournament.

Binding settings to the preferences window needs to done here instead of in init() or the game crashes when starting a map if the renderer's been restarted at least once.

void UD3D10RenderDevice::Unlock ( UBOOL  Blit  ) 

Finish rendering. /param Blit Whether the front and back buffers should be swapped.


Member Data Documentation

struct { ... } UD3D10RenderDevice::options [private]

User configurable options

Turn on precaching


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

Generated on Sun Jun 14 22:28:41 2009 for D3D10DRV by  doxygen 1.5.9