newspeoplefor developersdocumentationdownloads

nD3D9Server Class Reference

#include <nd3d9server.h>

Inheritance diagram for nD3D9Server:

nGfxServer2 nRoot nObject nNode nReferenced nSignalEmitter List of all members.

Detailed Description

D3D9 based gfx server.

(C) 2002 RadonLabs GmbH

Definition at line 52 of file nd3d9server.h.


Public Member Functions

 nD3D9Server ()
 constructor
virtual ~nD3D9Server ()
 destructor
virtual nMesh2NewMesh (const nString &rsrcName)
 create a shared mesh object
virtual nMeshArrayNewMeshArray (const nString &rsrcName)
 create a mesh array object
virtual nTexture2NewTexture (const nString &rsrcName)
 create a shared texture object
virtual nShader2NewShader (const nString &rsrcName)
 create a shared shader object
virtual nFont2NewFont (const nString &rsrcName, const nFontDesc &fontDesc)
 create a font object
virtual nTexture2NewRenderTarget (const nString &rsrcName, int width, int height, nTexture2::Format fmt, int usageFlags)
 create a render target object
virtual nOcclusionQueryNewOcclusionQuery ()
 create a new occlusion query object
virtual void SetDisplayMode (const nDisplayMode2 &mode)
 set display mode
virtual const nDisplayMode2GetDisplayMode () const
 get display mode
virtual void SetWindowTitle (const char *title)
 set the window title
virtual void SetCamera (nCamera2 &cam)
 set the current camera description
virtual void SetViewport (nViewport &vp)
 set the viewport
virtual bool OpenDisplay ()
 open the display
virtual void CloseDisplay ()
 close the display
virtual FeatureSet GetFeatureSet ()
 get the best supported feature set
virtual bool AreVertexShadersEmulated ()
 return true if vertex shader run in software emulation
virtual HWND GetAppHwnd () const
 get window handle
virtual HWND GetParentHwnd () const
 get parent window handle
virtual int GetNumStencilBits () const
 returns the number of available stencil bits
virtual int GetNumDepthBits () const
 returns the number of available z bits
virtual void SetScissorRect (const rectangle &r)
 set scissor rect
virtual void SetClipPlanes (const nArray< plane > &planes)
 set or clear user defined clip planes in clip space
virtual void SetRenderTarget (int index, nTexture2 *t)
 set a new render target texture
virtual bool BeginFrame ()
 start rendering the current frame
virtual bool BeginScene ()
 start rendering to current render target
virtual void EndScene ()
 finish rendering to current render target
virtual void PresentScene ()
 present the contents of the back buffer
virtual void EndFrame ()
 end rendering the current frame
virtual void Clear (int bufferTypes, float red, float green, float blue, float alpha, float z, int stencil)
 clear buffers
virtual void ClearLights ()
 reset the light array
virtual void ClearLight (int index)
 remove a light
virtual int AddLight (const nLight &light)
 add a light to the light array (reset in BeginScene)
virtual void SetMesh (nMesh2 *vbMesh, nMesh2 *ibMesh)
 set current mesh
virtual void SetMeshArray (nMeshArray *meshArray)
 set current mesh array, clearing the single mesh
virtual void SetShader (nShader2 *shader)
 set current shader
virtual void SetTransform (TransformType type, const matrix44 &matrix)
 set transform
virtual void DrawIndexed (PrimitiveType primType)
 draw the current mesh with indexed primitives
virtual void Draw (PrimitiveType primType)
 draw the current mesh with non-indexed primitives
virtual void DrawIndexedNS (PrimitiveType primType)
 render indexed primitives without applying shader state (NS == No Shader)
virtual void DrawNS (PrimitiveType primType)
 render non-indexed primitives without applying shader state (NS == No Shader)
virtual bool Trigger ()
 trigger the window system message pump
virtual void DrawText (const nString &text, const vector4 &color, const rectangle &rect, uint flags, bool immediate=true)
 draw text (immediately)
virtual vector2 GetTextExtent (const nString &text)
 get text extents
virtual void DrawTextBuffer ()
 draw accumulated text buffer
virtual void EnterDialogBoxMode ()
 enter dialog box mode (display mode must have DialogBoxMode enabled!)
virtual void LeaveDialogBoxMode ()
 leave dialog box mode
virtual bool SaveScreenshot (const char *fileName, nTexture2::FileFormat fileFormat)
 save a screen shot
virtual void BeginLines ()
 begin rendering lines
virtual void DrawLines3d (const vector3 *vertexList, int numVertices, const vector4 &color)
 draw 3d lines, using the current transforms
virtual void DrawLines2d (const vector2 *vertexList, int numVertices, const vector4 &color)
 draw 2d lines in screen space
virtual void EndLines ()
 finish line rendering
virtual void BeginShapes ()
 begin shape rendering (for debug visualizations)
virtual void DrawShape (ShapeType type, const matrix44 &model, const vector4 &color)
 draw a shape with the given model matrix with given color
virtual void DrawShapeNS (ShapeType type, const matrix44 &model)
 draw a shape without shader management
virtual void DrawShapePrimitives (PrimitiveType type, int numPrimitives, const vector3 *vertexList, int vertexWidth, const matrix44 &model, const vector4 &color)
 draw direct primitives
virtual void DrawShapeIndexedPrimitives (PrimitiveType type, int numPrimitives, const vector3 *vertexList, int numVertices, int vertexWidth, void *indices, IndexType indexType, const matrix44 &model, const vector4 &color)
 draw direct indexed primitives (slow, use for debug visual visualization only!)
virtual void EndShapes ()
 end shape rendering
IDirect3DDevice9 * GetD3DDevice () const
 Access Direct3D Device directly. Might be Null!
IDirect3D9 * GetD3D () const
 Access Direct3D object directly. Might be Null!
virtual void AdjustGamma ()
 adjust gamma.
virtual void RestoreGamma ()
 restore gamma.
virtual void SetSkipMsgLoop (bool skip)
 skip message loop in trigger

Static Public Member Functions

static nD3D9ServerInstance ()
 get instance pointer

Public Attributes

IDirect3DDevice9 * d3d9Device
 pointer to device object
IDirect3D9 * d3d9
 pointer to D3D9 object

Friends

class nD3D9Mesh
class nD3D9Texture
class nD3D9Shader

Classes

class  TextElement

Constructor & Destructor Documentation

nD3D9Server::nD3D9Server  ) 
 

constructor

Definition at line 16 of file nd3d9server_main.cc.

nD3D9Server::~nD3D9Server  )  [virtual]
 

destructor

Definition at line 68 of file nd3d9server_main.cc.


Member Function Documentation

nD3D9Server * nD3D9Server::Instance  )  [inline, static]
 

get instance pointer

Reimplemented from nGfxServer2.

Definition at line 333 of file nd3d9server.h.

nMesh2 * nD3D9Server::NewMesh const nString rsrcName  )  [virtual]
 

create a shared mesh object

Create a new shared mesh object. If the object already exists, its refcount is increment.

Parameters:
rsrcName a resource name (used for resource sharing)
Returns:
pointer to a nD3D9Mesh2 object

Reimplemented from nGfxServer2.

Definition at line 22 of file nd3d9server_resource.cc.

nMeshArray * nD3D9Server::NewMeshArray const nString rsrcName  )  [virtual]
 

create a mesh array object

Create a new mesh array object.

Returns:
pointer to a nD3D9MeshArray object

Reimplemented from nGfxServer2.

Definition at line 34 of file nd3d9server_resource.cc.

nTexture2 * nD3D9Server::NewTexture const nString rsrcName  )  [virtual]
 

create a shared texture object

Create a new shared texture object. If the object already exists, its refcount is incremented.

Parameters:
rsrcName a resource name (used for resource sharing)
Returns:
pointer to a nD3D9Texture2 object

Reimplemented from nGfxServer2.

Definition at line 48 of file nd3d9server_resource.cc.

nShader2 * nD3D9Server::NewShader const nString rsrcName  )  [virtual]
 

create a shared shader object

Create a new shared shader object. If the object already exists, its refcount is incremented.

Parameters:
rsrcName a resource name (used for resource sharing)
Returns:
pointer to a nD3D9Shader2 object

Reimplemented from nGfxServer2.

Definition at line 62 of file nd3d9server_resource.cc.

nFont2 * nD3D9Server::NewFont const nString rsrcName,
const nFontDesc fontDesc
[virtual]
 

create a font object

Create a new shared font object. If the object already exists, its refcount is incremented.

Parameters:
rsrcName a resource name (used for resource sharing)
Returns:
pointer to a nD3D9Shader2 object

Reimplemented from nGfxServer2.

Definition at line 76 of file nd3d9server_resource.cc.

nTexture2 * nD3D9Server::NewRenderTarget const nString rsrcName,
int  width,
int  height,
nTexture2::Format  format,
int  usageFlags
[virtual]
 

create a render target object

Create a new render target object.

Parameters:
rsrcName a resource name for resource sharing
width width of render target
height height of render target
format pixel format of render target
usageFlags a combination of nTexture2::Usage flags

Reimplemented from nGfxServer2.

Definition at line 95 of file nd3d9server_resource.cc.

nOcclusionQuery * nD3D9Server::NewOcclusionQuery  )  [virtual]
 

create a new occlusion query object

Create a new occlusion query object.

Returns:
pointer to a new occlusion query object

Reimplemented from nGfxServer2.

Definition at line 129 of file nd3d9server_resource.cc.

void nD3D9Server::SetDisplayMode const nDisplayMode2 mode  )  [virtual]
 

set display mode

Set the current display mode. This will not take effect until OpenDisplay() has been called!

Reimplemented from nGfxServer2.

Definition at line 270 of file nd3d9server_main.cc.

const nDisplayMode2 & nD3D9Server::GetDisplayMode  )  const [virtual]
 

get display mode

Get the current display mode.

Reimplemented from nGfxServer2.

Definition at line 280 of file nd3d9server_main.cc.

void nD3D9Server::SetWindowTitle const char *  title  )  [virtual]
 

set the window title

Reimplemented from nGfxServer2.

Definition at line 289 of file nd3d9server_main.cc.

void nD3D9Server::SetCamera nCamera2 cam  )  [virtual]
 

set the current camera description

Update the d3d projection matrix from the new camera settings.

Reimplemented from nGfxServer2.

Definition at line 17 of file nd3d9server_render.cc.

void nD3D9Server::SetViewport nViewport vp  )  [virtual]
 

set the viewport

Update the device viewport.

Reimplemented from nGfxServer2.

Definition at line 33 of file nd3d9server_render.cc.

bool nD3D9Server::OpenDisplay  )  [virtual]
 

open the display

Open the display.

Reimplemented from nGfxServer2.

Definition at line 129 of file nd3d9server_main.cc.

void nD3D9Server::CloseDisplay  )  [virtual]
 

close the display

Close the display.

Reimplemented from nGfxServer2.

Definition at line 165 of file nd3d9server_main.cc.

nGfxServer2::FeatureSet nD3D9Server::GetFeatureSet  )  [virtual]
 

get the best supported feature set

Get the supported feature set.

Reimplemented from nGfxServer2.

Definition at line 626 of file nd3d9server_device.cc.

bool nD3D9Server::AreVertexShadersEmulated  )  [virtual]
 

return true if vertex shader run in software emulation

Return true when vertex shaders are running in emulation.

Reimplemented from nGfxServer2.

Definition at line 299 of file nd3d9server_main.cc.

HWND nD3D9Server::GetAppHwnd  )  const [inline, virtual]
 

get window handle

Definition at line 454 of file nd3d9server.h.

HWND nD3D9Server::GetParentHwnd  )  const [inline, virtual]
 

get parent window handle

Definition at line 464 of file nd3d9server.h.

int nD3D9Server::GetNumStencilBits  )  const [virtual]
 

returns the number of available stencil bits

This method should return the number of currently available stencil bits (override in subclass).

Reimplemented from nGfxServer2.

Definition at line 776 of file nd3d9server_device.cc.

int nD3D9Server::GetNumDepthBits  )  const [virtual]
 

returns the number of available z bits

This method should return the number of currently available depth bits (override in subclass).

Reimplemented from nGfxServer2.

Definition at line 793 of file nd3d9server_device.cc.

void nD3D9Server::SetScissorRect const rectangle r  )  [virtual]
 

set scissor rect

Set the scissor rectangle. Note that this method doesn't enable/disable scissoring, this must be done externally in the shader.

Reimplemented from nGfxServer2.

Definition at line 1035 of file nd3d9server_device.cc.

void nD3D9Server::SetClipPlanes const nArray< plane > &  planes  )  [virtual]
 

set or clear user defined clip planes in clip space

Set user defined clip planes in clip space. Clip space is where outgoing vertex shader vertices live in. Up to 6 clip planes can be defined. Provide an empty array to clear all clip planes.

NOTE: this method does not work in the DX7 render path (check the D3D docs why)

Reimplemented from nGfxServer2.

Definition at line 1071 of file nd3d9server_device.cc.

void nD3D9Server::SetRenderTarget int  index,
nTexture2 t
[virtual]
 

set a new render target texture

Set the current render target at a given index (for simultaneous render targets). This method must be called outside BeginScene()/EndScene(). The method will increment the refcount of the render target object and decrement the refcount of the previous render target. Setting a render target of 0 at index 0 will restore the original back buffer as render target.

Parameters:
index render target index
t pointer to nTexture2 object or 0

Reimplemented from nGfxServer2.

Definition at line 707 of file nd3d9server_render.cc.

bool nD3D9Server::BeginFrame  )  [virtual]
 

start rendering the current frame

Begin rendering the current frame. This is guaranteed to be called exactly once per frame.

Reimplemented from nGfxServer2.

Definition at line 377 of file nd3d9server_render.cc.

bool nD3D9Server::BeginScene  )  [virtual]
 

start rendering to current render target

Start rendering the scene. This can be called several times per frame (each render target requires its own BeginScene()/EndScene().

Reimplemented from nGfxServer2.

Definition at line 422 of file nd3d9server_render.cc.

void nD3D9Server::EndScene  )  [virtual]
 

finish rendering to current render target

Finish rendering the scene and present the backbuffer.

Reimplemented from nGfxServer2.

Definition at line 454 of file nd3d9server_render.cc.

void nD3D9Server::PresentScene  )  [virtual]
 

present the contents of the back buffer

Present the scene.

Reimplemented from nGfxServer2.

Definition at line 509 of file nd3d9server_render.cc.

void nD3D9Server::EndFrame  )  [virtual]
 

end rendering the current frame

Finish rendering the current frame. This is guaranteed to be called exactly once per frame after PresentScene() has happened.

Reimplemented from nGfxServer2.

Definition at line 406 of file nd3d9server_render.cc.

void nD3D9Server::Clear int  bufferTypes,
float  red,
float  green,
float  blue,
float  alpha,
float  z,
int  stencil
[virtual]
 

clear buffers

Clear buffers.

  • 01-Jun-04 floh only clear stencil when current display mode has stencil

Parameters:
bufferTypes a combination of nBufferType flags (COLOR | DEPTH | STENCIL)
red the red value to write into the color buffer
green the green value to write into the color buffer
blue the blue value to write into the color buffer
alpha the alpha value to write into the color buffer
z the z value to write into the depth buffer
stencil the stencil value to write into the stencil buffer

Reimplemented from nGfxServer2.

Definition at line 479 of file nd3d9server_render.cc.

void nD3D9Server::ClearLights  )  [virtual]
 

reset the light array

Reset lighting.

Reimplemented from nGfxServer2.

Definition at line 54 of file nd3d9server_render.cc.

void nD3D9Server::ClearLight int  index  )  [virtual]
 

remove a light

Reset lighting.

Reimplemented from nGfxServer2.

Definition at line 79 of file nd3d9server_render.cc.

int nD3D9Server::AddLight const nLight light  )  [virtual]
 

add a light to the light array (reset in BeginScene)

Add a light to the light array. This will update the shared light effect state.

Reimplemented from nGfxServer2.

Definition at line 97 of file nd3d9server_render.cc.

void nD3D9Server::SetMesh nMesh2 vbMesh,
nMesh2 ibMesh
[virtual]
 

set current mesh

Bind vertex buffer and index buffer to vertex stream 0.

  • 26-Sep-04 floh moved the software vertex processing stuff to SetShader()

Parameters:
vbMesh mesh which delivers the vertex buffer
ibMesh mesh which delivers the index buffer

Reimplemented from nGfxServer2.

Definition at line 537 of file nd3d9server_render.cc.

void nD3D9Server::SetMeshArray nMeshArray meshArray  )  [virtual]
 

set current mesh array, clearing the single mesh

Set a mesh array for multiple vertex streams. Must be a nD3D9MeshArray The mesh in the array at stream 0 must provide a index buffer!

  • 26-Sep-04 floh moved the software vertex processing stuff to SetShader()

Parameters:
meshArray pointer to a nD3D9MeshArray object or 0 to clear the current stream and index buffer

Reimplemented from nGfxServer2.

Definition at line 607 of file nd3d9server_render.cc.

void nD3D9Server::SetShader nShader2 shader  )  [virtual]
 

set current shader

Set the current shader object.

Reimplemented from nGfxServer2.

Definition at line 687 of file nd3d9server_render.cc.

void nD3D9Server::SetTransform TransformType  type,
const matrix44 matrix
[virtual]
 

set transform

Set a transformation matrix. This will update the shared state in the effect pool.

Reimplemented from nGfxServer2.

Definition at line 228 of file nd3d9server_render.cc.

void nD3D9Server::DrawIndexed PrimitiveType  primType  )  [virtual]
 

draw the current mesh with indexed primitives

Draw the currently set mesh with indexed primitives, texture and shader to the current render target.

FIXME: the multi-pass renderer should check if state actually needs to be applied again. This is not necessary if the effect only has 1 pass, and is the same effect with the same parameters as in the last invocation of Draw().

Reimplemented from nGfxServer2.

Definition at line 768 of file nd3d9server_render.cc.

void nD3D9Server::Draw PrimitiveType  primType  )  [virtual]
 

draw the current mesh with non-indexed primitives

Draw the currently set mesh with non-indexed primitives.

Reimplemented from nGfxServer2.

Definition at line 819 of file nd3d9server_render.cc.

void nD3D9Server::DrawIndexedNS PrimitiveType  primType  )  [virtual]
 

render indexed primitives without applying shader state (NS == No Shader)

Render the currently set mesh without applying any shader state. You must call nShader2::Begin(), nShader2::Pass() and nShader2::End() yourself as needed.

Reimplemented from nGfxServer2.

Definition at line 866 of file nd3d9server_render.cc.

void nD3D9Server::DrawNS PrimitiveType  primType  )  [virtual]
 

render non-indexed primitives without applying shader state (NS == No Shader)

Render the currently set mesh without applying any shader state. You must call nShader2::Begin(), nShader2::Pass() and nShader2::End() yourself as needed.

Reimplemented from nGfxServer2.

Definition at line 912 of file nd3d9server_render.cc.

bool nD3D9Server::Trigger  )  [virtual]
 

trigger the window system message pump

Implements the Windows message pump. Must be called once a frame OUTSIDE of BeginScene() / EndScene().

Returns:
false if nD3D9Server requests to shutdown the application

Reimplemented from nGfxServer2.

Definition at line 180 of file nd3d9server_main.cc.

void nD3D9Server::DrawText const nString text,
const vector4 color,
const rectangle rect,
uint  flags,
bool  immediate = true
[virtual]
 

draw text (immediately)

Public text rendering routine. Either draws the text immediately, or stores the text internally in a text element array and draws it towards the end of frame.

Reimplemented from nGfxServer2.

Definition at line 60 of file nd3d9server_text.cc.

vector2 nD3D9Server::GetTextExtent const nString text  )  [virtual]
 

get text extents

Get text extents.

  • 16-Feb-04 floh hmm, ID3DXFont extent computation is confused by spaces, now uses GDI functions to compute text extents

Reimplemented from nGfxServer2.

Definition at line 160 of file nd3d9server_text.cc.

void nD3D9Server::DrawTextBuffer  )  [virtual]
 

draw accumulated text buffer

Draws the accumulated text elements and flushes the text buffer.

Reimplemented from nGfxServer2.

Definition at line 81 of file nd3d9server_text.cc.

void nD3D9Server::EnterDialogBoxMode  )  [virtual]
 

enter dialog box mode (display mode must have DialogBoxMode enabled!)

Enter dialog box mode.

Reimplemented from nGfxServer2.

Definition at line 221 of file nd3d9server_main.cc.

void nD3D9Server::LeaveDialogBoxMode  )  [virtual]
 

leave dialog box mode

Leave dialog box mode.

Reimplemented from nGfxServer2.

Definition at line 246 of file nd3d9server_main.cc.

bool nD3D9Server::SaveScreenshot const char *  fileName,
nTexture2::FileFormat  fileFormat
[virtual]
 

save a screen shot

Create screen shot and save it to given filename. (.jpg file)

Parameters:
fileName filename for screen shot.
  • 25-Apr-05 floh rewritten for performance

Reimplemented from nGfxServer2.

Definition at line 194 of file nd3d9server_main.cc.

void nD3D9Server::BeginLines  )  [virtual]
 

begin rendering lines

Begin rendering lines.

Reimplemented from nGfxServer2.

Definition at line 12 of file nd3d9server_lines.cc.

void nD3D9Server::DrawLines3d const vector3 vertexList,
int  numVertices,
const vector4 color
[virtual]
 

draw 3d lines, using the current transforms

Render a 3d line strip using the current transformations.

Reimplemented from nGfxServer2.

Definition at line 25 of file nd3d9server_lines.cc.

void nD3D9Server::DrawLines2d const vector2 vertexList,
int  numVertices,
const vector4 color
[virtual]
 

draw 2d lines in screen space

Render a 3d line strip using the current transformations. Careful: Clipping doesn't work correctly!

Reimplemented from nGfxServer2.

Definition at line 43 of file nd3d9server_lines.cc.

void nD3D9Server::EndLines  )  [virtual]
 

finish line rendering

Finish rendering lines.

Reimplemented from nGfxServer2.

Definition at line 71 of file nd3d9server_lines.cc.

void nD3D9Server::BeginShapes  )  [virtual]
 

begin shape rendering (for debug visualizations)

Begin rendering shape primitives. Shape primitives are handy for quickly rendering debug visualizations.

Reimplemented from nGfxServer2.

Definition at line 15 of file nd3d9server_shapes.cc.

void nD3D9Server::DrawShape ShapeType  type,
const matrix44 model,
const vector4 color
[virtual]
 

draw a shape with the given model matrix with given color

Render a standard shape using the provided model matrix and color.

Reimplemented from nGfxServer2.

Definition at line 30 of file nd3d9server_shapes.cc.

void nD3D9Server::DrawShapeNS ShapeType  type,
const matrix44 model
[virtual]
 

draw a shape without shader management

Render a standard shape using the provided model matrix without any shader management.

Reimplemented from nGfxServer2.

Definition at line 57 of file nd3d9server_shapes.cc.

void nD3D9Server::DrawShapePrimitives PrimitiveType  type,
int  numPrimitives,
const vector3 vertexList,
int  vertexWidth,
const matrix44 model,
const vector4 color
[virtual]
 

draw direct primitives

Draw non-indexed primitives. This is slow, so it should only be used for debug visualizations. Vertex width is number of float's!

Reimplemented from nGfxServer2.

Definition at line 73 of file nd3d9server_shapes.cc.

void nD3D9Server::DrawShapeIndexedPrimitives PrimitiveType  type,
int  numPrimitives,
const vector3 vertices,
int  numVertices,
int  vertexWidth,
void *  indices,
IndexType  indexType,
const matrix44 model,
const vector4 color
[virtual]
 

draw direct indexed primitives (slow, use for debug visual visualization only!)

Directly Draw indexed primitives. This is slow, so it should only be used for debug visualizations. Vertex width is number of float's!

Reimplemented from nGfxServer2.

Definition at line 108 of file nd3d9server_shapes.cc.

void nD3D9Server::EndShapes  )  [virtual]
 

end shape rendering

Finish rendering shapes.

Reimplemented from nGfxServer2.

Definition at line 164 of file nd3d9server_shapes.cc.

IDirect3DDevice9 * nD3D9Server::GetD3DDevice  )  const [inline]
 

Access Direct3D Device directly. Might be Null!

Definition at line 484 of file nd3d9server.h.

IDirect3D9 * nD3D9Server::GetD3D  )  const [inline]
 

Access Dire