newspeoplefor developersdocumentationdownloads

nGLServer2 Class Reference
[OpenGL Graphics Subsystem]

#include <nglserver2.h>

Inheritance diagram for nGLServer2:

nGfxServer2 nRoot nObject nNode nReferenced nSignalEmitter List of all members.

Detailed Description

OpenGL 2 based gfx server.

2003 cubejk created 2003-2006 Haron

Definition at line 23 of file nglserver2.h.


Public Types

enum  GLShaderSystem {
  GLSL,
  CGFX,
  CG,
  GLES
}
 skip message loop in trigger More...

Public Member Functions

 nGLServer2 ()
 constructor
virtual ~nGLServer2 ()
 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
 parent window handle
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 witn 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 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

Static Public Member Functions

static nGLServer2Instance ()
 get instance pointer

Friends

class nGLMesh
 minimize window when d3d device is destroyed
class nGLTexture
class nCgFXShader
class nGLSLShader

Member Enumeration Documentation

enum nGLServer2::GLShaderSystem
 

skip message loop in trigger

Enumerator:
GLSL 
CGFX 
CG 
GLES 

Definition at line 165 of file nglserver2.h.


Constructor & Destructor Documentation

nGLServer2::nGLServer2  ) 
 

constructor

Definition at line 80 of file nglserver2_main.cc.

nGLServer2::~nGLServer2  )  [virtual]
 

destructor

Definition at line 145 of file nglserver2_main.cc.


Member Function Documentation

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

get instance pointer

Reimplemented from nGfxServer2.

Definition at line 376 of file nglserver2.h.

nMesh2 * nGLServer2::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 nD3D8Mesh2 object

Reimplemented from nGfxServer2.

Definition at line 26 of file nglserver2_resource.cc.

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

create a mesh array object

Create a new mesh array object.

Returns:
pointer to a nGLMeshArray object

Reimplemented from nGfxServer2.

Definition at line 39 of file nglserver2_resource.cc.

nTexture2 * nGLServer2::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 nD3D8Texture2 object

Reimplemented from nGfxServer2.

Definition at line 54 of file nglserver2_resource.cc.

nShader2 * nGLServer2::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 nCgGLShaderObject object

Reimplemented from nGfxServer2.

Definition at line 68 of file nglserver2_resource.cc.

nFont2 * nGLServer2::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 nCgFXShader object

Reimplemented from nGfxServer2.

Definition at line 84 of file nglserver2_resource.cc.

nTexture2 * nGLServer2::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 combination of nTexture2::Usage flags

Reimplemented from nGfxServer2.

Definition at line 104 of file nglserver2_resource.cc.

nOcclusionQuery * nGLServer2::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 138 of file nglserver2_resource.cc.

void nGLServer2::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 306 of file nglserver2_main.cc.

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

get display mode

Get the current display mode.

Reimplemented from nGfxServer2.

Definition at line 316 of file nglserver2_main.cc.

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

set the window title

Reimplemented from nGfxServer2.

Definition at line 325 of file nglserver2_main.cc.

void nGLServer2::SetCamera nCamera2 cam  )  [virtual]
 

set the current camera description

Update the gl projection matrix from the new camera settings.

Reimplemented from nGfxServer2.

Definition at line 18 of file nglserver2_render.cc.

void nGLServer2::SetViewport nViewport vp  )  [virtual]
 

set the viewport

Update the device viewport.

Reimplemented from nGfxServer2.

Definition at line 34 of file nglserver2_render.cc.

bool nGLServer2::OpenDisplay  )  [virtual]
 

open the display

Open the display, show the window

Reimplemented from nGfxServer2.

Definition at line 165 of file nglserver2_main.cc.

void nGLServer2::CloseDisplay  )  [virtual]
 

close the display

Close the display

Reimplemented from nGfxServer2.

Definition at line 201 of file nglserver2_main.cc.

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

get the best supported feature set

Get the supported feature set.

Reimplemented from nGfxServer2.

Definition at line 278 of file nglserver2_device.cc.

bool nGLServer2::AreVertexShadersEmulated  )  [virtual]
 

return true if vertex shader run in software emulation

Returns:
true if vertex shader run in software emulation

Reimplemented from nGfxServer2.

Definition at line 334 of file nglserver2_main.cc.

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

get window handle

Definition at line 387 of file nglserver2.h.

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

parent window handle

Definition at line 397 of file nglserver2.h.

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

set a new render target texture

Reimplemented from nGfxServer2.

bool nGLServer2::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 382 of file nglserver2_render.cc.

virtual bool nGLServer2::BeginScene  )  [virtual]
 

start rendering to current render target

Reimplemented from nGfxServer2.

virtual void nGLServer2::EndScene  )  [virtual]
 

finish rendering to current render target

Reimplemented from nGfxServer2.

virtual void nGLServer2::PresentScene  )  [virtual]
 

present the contents of the back buffer

Reimplemented from nGfxServer2.

void nGLServer2::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 411 of file nglserver2_render.cc.

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

clear buffers

Clear buffers.

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 435 of file nglserver2_render.cc.

void nGLServer2::ClearLights  )  [virtual]
 

reset the light array

Reset lighting.

Reimplemented from nGfxServer2.

Definition at line 52 of file nglserver2_render.cc.

void nGLServer2::ClearLight int  index  )  [virtual]
 

remove a light

Reset lighting.

Reimplemented from nGfxServer2.

Definition at line 77 of file nglserver2_render.cc.

int nGLServer2::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 94 of file nglserver2_render.cc.

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

set current mesh

Bind vertex buffer and index buffer to vertex stream 0.

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

Reimplemented from nGfxServer2.

Definition at line 472 of file nglserver2_render.cc.

void nGLServer2::SetMeshArray nMeshArray meshArray  )  [virtual]
 

set current mesh array, clearing the single mesh

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

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

Reimplemented from nGfxServer2.

Definition at line 522 of file nglserver2_render.cc.

void nGLServer2::SetShader nShader2 shader  )  [virtual]
 

set current shader

Set the current shader object.

Reimplemented from nGfxServer2.

Definition at line 606 of file nglserver2_render.cc.

void nGLServer2::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 224 of file nglserver2_render.cc.

void nGLServer2::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 multipass 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 626 of file nglserver2_render.cc.

void nGLServer2::Draw PrimitiveType  primType  )  [virtual]
 

draw the current mesh witn non-indexed primitives

Draw the currently set mesh with non-indexed primitives.

Reimplemented from nGfxServer2.

Definition at line 674 of file nglserver2_render.cc.

void nGLServer2::DrawIndexedNS PrimitiveType  primType  )  [virtual]
 

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

Renders 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 723 of file nglserver2_render.cc.

void nGLServer2::DrawNS PrimitiveType  primType  )  [virtual]
 

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

Renders 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 758 of file nglserver2_render.cc.

bool nGLServer2::Trigger void   )  [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 nGLServer2 requests to shutdown the application

Reimplemented from nGfxServer2.

Definition at line 216 of file nglserver2_main.cc.

void nGLServer2::EnterDialogBoxMode  )  [virtual]
 

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

Enter dialog box mode.

Reimplemented from nGfxServer2.

Definition at line 257 of file nglserver2_main.cc.

void nGLServer2::LeaveDialogBoxMode  )  [virtual]
 

leave dialog box mode

Leave dialog box mode.

Reimplemented from nGfxServer2.

Definition at line 281 of file nglserver2_main.cc.

bool nGLServer2::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.

Reimplemented from nGfxServer2.

Definition at line 228 of file nglserver2_main.cc.

void nGLServer2::BeginLines  )  [virtual]
 

begin rendering lines

Begin rendering lines.

Reimplemented from nGfxServer2.

Definition at line 11 of file nglserver2_lines.cc.

void nGLServer2::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 21 of file nglserver2_lines.cc.

void nGLServer2::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 40 of file nglserver2_lines.cc.

void nGLServer2::EndLines  )  [virtual]
 

finish line rendering

Finish rendering lines.

Reimplemented from nGfxServer2.

Definition at line 58 of file nglserver2_lines.cc.

void nGLServer2::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 12 of file nglserver2_shapes.cc.

void nGLServer2::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 23 of file nglserver2_shapes.cc.

void nGLServer2::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 35 of file nglserver2_shapes.cc.

void nGLServer2::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 46 of file nglserver2_shapes.cc.

void nGLServer2::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 57 of file nglserver2_shapes.cc.

void nGLServer2::EndShapes  )  [virtual]
 

end shape rendering

Finish rendering shapes.

Reimplemented from nGfxServer2.

Definition at line 75 of file nglserver2_shapes.cc.


Friends And Related Function Documentation

friend class nGLMesh [friend]
 

minimize window when d3d device is destroyed

Definition at line 227 of file nglserver2.h.

friend class nGLTexture [friend]
 

Definition at line 228 of file nglserver2.h.

friend class nCgFXShader [friend]
 

Definition at line 229 of file nglserver2.h.

friend class nGLSLShader [friend]
 

Definition at line 230 of file nglserver2.h.


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

Copyright © 1999-2005 by the contributing authors. Ideas, requests, problems: Send feedback.