newspeoplefor developersdocumentationdownloads

nGfxServer2 Class Reference

#include <ngfxserver2.h>

Inheritance diagram for nGfxServer2:

nRoot nObject nNode nReferenced nSignalEmitter nD3D9Server nGLServer2 List of all members.

Detailed Description

New generation gfx server, completely vertex and pixel shader based.

See also nGfxServer2 Script Interface

(C) 2002 RadonLabs GmbH

Definition at line 50 of file ngfxserver2.h.


Public Types

enum  TransformType {
  Model = 0,
  View,
  Projection,
  InvModel,
  InvView,
  ModelView,
  InvModelView,
  ModelViewProjection,
  ViewProjection,
  Texture0,
  Texture1,
  Texture2,
  Texture3,
  Light,
  ModelLight,
  InvModelLight,
  ShadowProjection,
  NumTransformTypes
}
 transform types More...
enum  LightingType {
  Off = 0,
  FFP,
  Shader
}
 lighting types More...
enum  BufferType {
  NoBuffer = 0,
  ColorBuffer = (1<<0),
  DepthBuffer = (1<<1),
  StencilBuffer = (1<<2),
  AllBuffers = (ColorBuffer | DepthBuffer | StencilBuffer)
}
 buffer types More...
enum  PrimitiveType {
  PointList,
  LineList,
  LineStrip,
  TriangleList,
  TriangleStrip,
  TriangleFan
}
 primitive types More...
enum  IndexType {
  Index16,
  Index32
}
 index types More...
enum  ShapeType {
  Box = 0,
  Cylinder,
  Sphere,
  Torus,
  Teapot,
  NumShapeTypes
}
 shape types More...
enum  FeatureSet {
  DX7 = 0,
  DX8,
  DX8SB,
  DX9,
  DX9FLT,
  NumFeatureSets,
  InvalidFeatureSet
}
 feature sets (from worst to best) More...
enum  CursorVisibility {
  None,
  System,
  Custom,
  Gui
}
 the visible mouse cursor type More...
enum  {
  MaxVertexStreams = 16,
  MaxTextureStages = 4,
  MaxTransformStackDepth = 4,
  MaxRenderTargets = 4,
  MaxLights = 8
}
enum  DeviceIdentifier {
  GenericDevice,
  Intel_82865G,
  SiS_630,
  SiS_741
}
 list of devices that are known to cause bugs More...
enum  Hint {
  MvpOnly = (1<<0),
  CountStats = (1<<1)
}

Public Member Functions

 nGfxServer2 ()
 constructor
virtual ~nGfxServer2 ()
 destructor
virtual nMesh2NewMesh (const nString &rsrcName)
 create a shared mesh object
virtual nMeshArrayNewMeshArray (const nString &rsrcName)
 create a new 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 format, int usageFlags)
 create a render target object
virtual nInstanceStreamNewInstanceStream (const nString &rsrcName)
 create a new instance stream 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
void SetFontScale (float s)
 set global scale factor for fonts
float GetFontScale () const
 get global scale factor for fonts
void SetMinFontHeight (int s)
 set minimum font height
int GetMinFontHeight () const
 get minimum font height
virtual void SetCamera (nCamera2 &cam)
 set the current camera description
void SetFeatureSetOverride (FeatureSet f)
 override the feature set
virtual FeatureSet GetFeatureSet ()
 get the best supported feature set
virtual bool AreVertexShadersEmulated ()
 return true if vertex shader run in software emulation
nCamera2GetCamera ()
 get the current camera description
virtual void SetViewport (nViewport &vp)
 set the viewport
virtual nViewportGetViewport ()
 get the viewport
virtual bool OpenDisplay ()
 open the display
virtual void CloseDisplay ()
 close the display
virtual bool Trigger ()
 trigger the window system message pump
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 &rect)
 set scissor rect
const rectangleGetScissorRect () const
 get scissor rect
virtual void SetClipPlanes (const nArray< plane > &planes)
 set or clear user defined clip planes in clip space
const nArray< plane > & GetClipPlanes () const
 get user defined clip planes
void SetHint (Hint hint, bool enable)
 set or delete a render hint
bool GetHint (Hint hint) const
 get a render hint
virtual void SetRenderTarget (int index, nTexture2 *tex)
 set a new render target texture
nTexture2GetRenderTarget (int index) const
 get the current render target
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
bool InBeginScene () const
 Between BeginScene/EndScene?
virtual void Clear (int bufferTypes, float red, float green, float blue, float alpha, float z, int stencil)
 clear buffers
void SetLightingType (LightingType t)
 set lighting type
LightingType GetLightingType () const
 get lighting type
virtual void ClearLights ()
 reset the light array
virtual void ClearPointLights ()
 remove all point lights
virtual void ClearLight (int index)
 remove a light
virtual int AddLight (const nLight &light)
 set a light
const nArray< nLight > & GetLightArray () const
 access to light array
virtual void SetMesh (nMesh2 *vbMesh, nMesh2 *ibMesh)
 set current vertex and index buffer mesh
nMesh2GetMesh () const
 get current mesh
virtual void SetMeshArray (nMeshArray *meshArray)
 set current mesh array (for multiple streams)
nMeshArrayGetMeshArray () const
 get current mesh array
virtual void SetShader (nShader2 *shader)
 set current shader
nShader2GetShader () const
 get current shader
virtual void SetFont (nFont2 *font)
 set current font
nFont2GetFont () const
 get current font
void SetInstanceStream (nInstanceStream *stream)
 set current instance stream, a valid instance stream triggers instance rendering
nInstanceStreamGetInstanceStream () const
 get current instance stream
virtual void SetTransform (TransformType type, const matrix44 &matrix)
 set transform
const matrix44GetTransform (TransformType type) const
 get transform
void PushTransform (TransformType type, const matrix44 &matrix)
 push transform
const matrix44PopTransform (TransformType type)
 pop transform
void SetVertexRange (int firstVertex, int numVertices)
 set vertex range to render from current mesh
void SetIndexRange (int firstIndex, int numIndices)
 set index range to render from current mesh
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 void DrawText (const nString &text, const vector4 &color, const rectangle &rect, uint flags, bool immediate=true)
 draw text (immediately, or "when the time is right")
virtual vector2 GetTextExtent (const nString &text)
 get text extents
void BreakLines (const nString &text, const rectangle &rect, nString &outString)
 insert newline chars to break the text manual in lines - must be public because the ticker needs to break lines.
virtual void Text (const nString &text, const vector4 &color, float xPos, float yPos)
 add text to the text buffer (OLD STYLE)
virtual void DrawTextBuffer ()
 draw the text buffer (OLD STYLE)
virtual void SetMouseCursor (const nMouseCursor &cursor)
 set mouse cursor image and hotspot
virtual const nMouseCursorGetMouseCursor () const
 get mouse cursor image
virtual void SetCursorVisibility (CursorVisibility type)
 show/hide the mouse cursor
virtual CursorVisibility GetCursorVisibility () const
 get mouse cursor display status
virtual void EnterDialogBoxMode ()
 enter dialog box mode (display mode must have DialogBoxMode enabled!)
virtual void LeaveDialogBoxMode ()
 leave dialog box mode
bool InDialogBoxMode () const
 return true if currently in dialog box mode
virtual bool SaveScreenshot (const char *filename, nTexture2::FileFormat fileFormat)
 save a screen shot
DeviceIdentifier GetDeviceIdentifier () const
 get the device identifier
line3 ComputeWorldMouseRay (const vector2 &mousePos, float length)
 compute a mouse ray in world space
void SetGamma (float g)
 set gamma value.
void SetBrightness (float b)
 set brightness value.
void SetContrast (float c)
 set contrast value.
float GetGamma () const
 get gamma value.
float GetBrightness () const
 get brightness value.
float GetContrast () const
 get contrast value.
virtual void AdjustGamma ()
 adjust gamma.
virtual void RestoreGamma ()
 restore gamma.
virtual void SetSkipMsgLoop (bool skip)
 skip message loop in trigger
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
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

Static Public Member Functions

static nGfxServer2Instance ()
 get instance pointer
static FeatureSet StringToFeatureSet (const char *str)
 convert feature set string to enum
static const char * FeatureSetToString (FeatureSet f)
 convert feature set enum to string
static const vector4 GetShadowLightIndexVector (int shadowLightIndex, float value)
 get a vector4 of an int shadowLightIndex to set as shader parameter

Public Attributes

CursorVisibility cursorVisibility
 note: this stuff is public because WinProcs may need to access it

Protected Attributes

bool displayOpen
bool inBeginFrame
bool inBeginScene
bool inBeginLines
bool inBeginShapes
nAutoRef< nResourceServerrefResource
nCamera2 camera
nViewport viewport
nFixedArray< nRef< nTexture2 > > refRenderTargets
nRef< nMesh2refVbMesh
nRef< nMesh2refIbMesh
nRef< nMeshArrayrefMeshArray
nRef< nFont2refFont
nRef< nShader2refShader
nRef< nInstanceStreamrefInstanceStream
nMouseCursor curMouseCursor
int vertexRangeFirst
int vertexRangeNum
int indexRangeFirst
int indexRangeNum
FeatureSet featureSetOverride
matrix44 transform [NumTransformTypes]
int transformTopOfStack [NumTransformTypes]
matrix44 transformStack [NumTransformTypes][MaxTransformStackDepth]
bool cursorDirty
bool inDialogBoxMode
nArray< nLightlightArray
float gamma
float brightness
float contrast
float fontScale
int fontMinHeight
DeviceIdentifier deviceIdentifier
LightingType lightingType
rectangle scissorRect
uint hints
nArray< planeclipPlanes

Member Enumeration Documentation

enum nGfxServer2::TransformType
 

transform types

Enumerator:
Model  model -> world matrix (read/write)
View  world -> view matrix (read/write)
Projection  view -> projection matrix (read/write)
InvModel  world -> model matrix (read only)
InvView  view -> world matrix (read only)
ModelView  model -> view matrix (read only)
InvModelView  view -> model matrix (read only)
ModelViewProjection  model -> projection matrix (read only)
ViewProjection  current view * projection matrix
Texture0  texture transform for layer 0 (read/write)
Texture1 
Texture2 
Texture3 
Light  the current light's matrix in world space
ModelLight 
InvModelLight 
ShadowProjection 
NumTransformTypes 

Definition at line 54 of file ngfxserver2.h.

enum nGfxServer2::LightingType
 

lighting types

Enumerator:
Off  no lighting
FFP  fixed function per-vertex lighting
Shader  shader controlled lighting

Definition at line 78 of file ngfxserver2.h.

enum nGfxServer2::BufferType
 

buffer types

Enumerator:
NoBuffer 
ColorBuffer 
DepthBuffer 
StencilBuffer 
AllBuffers 

Definition at line 86 of file ngfxserver2.h.

enum nGfxServer2::PrimitiveType
 

primitive types

Enumerator:
PointList 
LineList 
LineStrip 
TriangleList 
TriangleStrip 
TriangleFan 

Definition at line 96 of file ngfxserver2.h.

enum nGfxServer2::IndexType
 

index types

Enumerator:
Index16 
Index32 

Definition at line 107 of file ngfxserver2.h.

enum nGfxServer2::ShapeType
 

shape types

Enumerator:
Box 
Cylinder 
Sphere 
Torus 
Teapot 
NumShapeTypes 

Definition at line 114 of file ngfxserver2.h.

enum nGfxServer2::FeatureSet
 

feature sets (from worst to best)

Enumerator:
DX7  a typical dx7 card with fixed function pipeline
DX8  a typical dx8 card with at least vs/ps 1.1
DX8SB  a typical dx8 card with support for shadow buffers
DX9  a dx9 card with at least vs/ps 2.0
DX9FLT  a dx9 card with floating point textures/render targets
NumFeatureSets  Number of feature sets.
InvalidFeatureSet  Open() hasn't been called yet.

Definition at line 126 of file ngfxserver2.h.

enum nGfxServer2::CursorVisibility
 

the visible mouse cursor type

Enumerator:
None  no mouse cursor visible
System  use Window's system mouse cursor
Custom  use the custom mouse cursor
Gui  use a custom Software mouse cursor

Definition at line 139 of file ngfxserver2.h.

anonymous enum
 

Enumerator:
MaxVertexStreams 
MaxTextureStages 
MaxTransformStackDepth 
MaxRenderTargets 
MaxLights 

Reimplemented from nRoot.

Definition at line 147 of file ngfxserver2.h.

enum nGfxServer2::DeviceIdentifier
 

list of devices that are known to cause bugs

Enumerator:
GenericDevice 
Intel_82865G 
SiS_630 
SiS_741 

Definition at line 157 of file ngfxserver2.h.

enum nGfxServer2::Hint
 

Enumerator:
MvpOnly 
CountStats 

Definition at line 165 of file ngfxserver2.h.


Constructor & Destructor Documentation

nGfxServer2::nGfxServer2  ) 
 

constructor

Definition at line 19 of file ngfxserver2_main.cc.

nGfxServer2::~nGfxServer2  )  [virtual]
 

destructor

Definition at line 58 of file ngfxserver2_main.cc.


Member Function Documentation

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

get instance pointer

Reimplemented in nD3D9Server, and nGLServer2.

Definition at line 471 of file ngfxserver2.h.

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

create a shared mesh object

Create a new static mesh object.

Parameters:
rsrcName a resource name for resource sharing
Returns:
a new nMesh2 object

Reimplemented in nD3D9Server, and nGLServer2.

Definition at line 72 of file ngfxserver2_main.cc.

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

create a new mesh array object

Create a new static mesh array object.

Returns:
a new nMeshArray object

Reimplemented in nD3D9Server, and nGLServer2.

Definition at line 84 of file ngfxserver2_main.cc.

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

create a shared texture object

Create a new shared texture object.

Parameters:
rsrcName a resource name for resource sharing
Returns:
a new nTexture2 object

Reimplemented in nD3D9Server, and nGLServer2.

Definition at line 97 of file ngfxserver2_main.cc.

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

create a shared shader object

Create a new shared shader object

Parameters:
rsrcName a resource name for resource sharing
Returns:
a new nShader2 object

Reimplemented in nD3D9Server, and nGLServer2.

Definition at line 110 of file ngfxserver2_main.cc.

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

create a font object

Create a new shared font object.

Parameters:
rsrcName a resource name for resource sharing
fontDesc a valid font description object
Returns:
a nFont2 object

Reimplemented in nD3D9Server, and nGLServer2.

Definition at line 124 of file ngfxserver2_main.cc.

nTexture2 * nGfxServer2::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 (RenderTargetXXX only)

Reimplemented in nD3D9Server, and nGLServer2.

Definition at line 165 of file ngfxserver2_main.cc.

nInstanceStream * nGfxServer2::NewInstanceStream const nString rsrcName  )  [virtual]
 

create a new instance stream object

Create a new shared instance stream object.

Parameters:
rsrcName a resource name for resource sharing (0 if no sharing)
Returns:
pointer to a new nInstanceStream object

Definition at line 137 of file ngfxserver2_main.cc.

nOcclusionQuery * nGfxServer2::NewOcclusionQuery  )  [virtual]
 

create a new occlusion query object

Create a new occlusion query object.

Returns:
pointer to a new nOcclusionQuery object

Reimplemented in nD3D9Server, and nGLServer2.

Definition at line 149 of file ngfxserver2_main.cc.

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

set display mode

Set the preferred display mode. This must be called outside OpenDisplay()/CloseDisplay().

Reimplemented in nD3D9Server, and nGLServer2.

Definition at line 180 of file ngfxserver2_main.cc.

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

get display mode

Reimplemented in nD3D9Server, and nGLServer2.

Definition at line 189 of file ngfxserver2_main.cc.

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

set the window title

Set the window title.

Parameters:
title the new window title

Reimplemented in nD3D9Server, and nGLServer2.

Definition at line 203 of file ngfxserver2_main.cc.

void nGfxServer2::SetFontScale float  s  )  [inline]
 

set global scale factor for fonts

Definition at line 523 of file ngfxserver2.h.

float nGfxServer2::GetFontScale  )  const [inline]
 

get global scale factor for fonts

Definition at line 533 of file ngfxserver2.h.

void nGfxServer2::SetMinFontHeight int  s  )  [inline]
 

set minimum font height

Definition at line 503 of file ngfxserver2.h.

int nGfxServer2::GetMinFontHeight  )  const [inline]
 

get minimum font height

Definition at line 513 of file ngfxserver2.h.

void nGfxServer2::SetCamera nCamera2 camera  )  [virtual]
 

set the current camera description

Set the current camera. Subclasses should adjust their projection matrix accordingly when this method is called.

Parameters:
camera a camera object with valid parameters

Reimplemented in nD3D9Server, and nGLServer2.

Definition at line 216 of file ngfxserver2_main.cc.

void nGfxServer2::SetFeatureSetOverride FeatureSet  f  )  [inline]
 

override the feature set

Definition at line 600 of file ngfxserver2.h.

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

get the best supported feature set

Return the supported feature set.

Reimplemented in nD3D9Server, and nGLServer2.

Definition at line 727 of file ngfxserver2_main.cc.

bool nGfxServer2::AreVertexShadersEmulated  )  [virtual]
 

return true if vertex shader run in software emulation

Returns true when vertex shaders run in emulation. This is needed by mesh handling classes when running in the Fixed Function pipeline code path. The method must be overwritten in subclasses.

Reimplemented in nD3D9Server, and nGLServer2.

Definition at line 955 of file ngfxserver2_main.cc.

nCamera2 & nGfxServer2::GetCamera  )  [inline]
 

get the current camera description

Get the current camera object.

Definition at line 612 of file ngfxserver2.h.

void nGfxServer2::SetViewport nViewport vp  )  [virtual]
 

set the viewport

Set the current viewport. Subclasses should adjust the device accordingly.

Reimplemented in nD3D9Server, and nGLServer2.

Definition at line 228 of file ngfxserver2_main.cc.

nViewport & nGfxServer2::GetViewport  )  [inline, virtual]
 

get the viewport

Get the current viewport.

Definition at line 590 of file ngfxserver2.h.

bool nGfxServer2::OpenDisplay  )  [virtual]
 

open the display

Open the display.

Returns:
true if display successfully opened

Reimplemented in nD3D9Server, and nGLServer2.

Definition at line 240 of file ngfxserver2_main.cc.

void nGfxServer2::CloseDisplay  )  [virtual]
 

close the display

Close the display.

23-Aug-04 kims added calling RestoreGamma().

Reimplemented in nD3D9Server, and nGLServer2.

Definition at line 258 of file ngfxserver2_main.cc.

bool nGfxServer2::Trigger  )  [virtual]
 

trigger the window system message pump

Trigger the windows system message pump. Return false if application should be closed