Main Page   Modules   Alphabetical List   Data Structures   Data Fields  

RwIm2D
[Immediate Mode]


Functions

RwReal  RwIm2DGetNearScreenZ (void)
RwReal  RwIm2DGetFarScreenZ (void)
RwBool  RwIm2DRenderLine (RwIm2DVertex *vertices, RwInt32 numVertices, RwInt32 vert1, RwInt32 vert2)
RwBool  RwIm2DRenderTriangle (RwIm2DVertex *vertices, RwInt32 numVertices, RwInt32 vert1, RwInt32 vert2, RwInt32 vert3)
RwBool  RwIm2DRenderPrimitive (RwPrimitiveType primType, RwIm2DVertex *vertices, RwInt32 numVertices)
RwBool  RwIm2DRenderIndexedPrimitive (RwPrimitiveType primType, RwIm2DVertex *vertices, RwInt32 numVertices, RwImVertexIndex *indices, RwInt32 numIndices)

Detailed Description

2D immediate mode support

RwIm2D Overview

Requirements

Overview

This object exposes RenderWare' 2D Immediate Mode API.

2D Immediate Mode graphics support is provided for such basic primitives as lines and triangles. It is primarily intended for such tasks as GUI overlays, superimposing text onto a scene and other similar work.

Most developers may prefer to work with the Rt2d Toolkit for applications making intensive use of 2D rendering. This Toolkit sits on top of the 3D Immediate Mode API.


Function Documentation

RwReal RwIm2DGetFarScreenZ void   
 

RwIm2DGetFarScreenZ is used to determine the screen Z value needed to be put into a 2D immediate mode vertex to place the vertex at the back of the Z-buffer range.

Returns:
Returns an RwReal value equal to the Z-buffer value of the far clip plane.
See also:
RwIm2DGetNearScreenZ , RwCameraGetFarClipPlane
RwReal RwIm2DGetNearScreenZ void   
 

RwIm2DGetNearScreenZ is used to determine the screen Z value needed to be put into a 2D immediate mode vertex to place the vertex at the front of the Z-buffer range.

Returns:
Returns an RwReal value equal to the Z-buffer value of the near clip plane.
See also:
RwIm2DGetFarScreenZ , RwCameraGetNearClipPlane
RwBool RwIm2DRenderIndexedPrimitive RwPrimitiveType    primType,
RwIm2DVertex   vertices,
RwInt32    numVertices,
RwImVertexIndex   indices,
RwInt32    numIndices
 

RwIm2DRenderIndexedPrimitive is used to render a screen space 2D immediate mode primitive defined by the given vertices. Use this function to render individual line segments, connected poly-lines, discrete triangles, triangle strips and triangle fans. Note that all vertices specified for 2D immediate mode rendering must lie within the screen space otherwise the results are unpredictable.

Note that 2D immediate mode routines must initialize their required renderstate before starting to render. They must share the renderstate resource and must not make any assumptions about what the existing renderstate is. The renderstate may be queried but in practice on many platforms it is faster to just establish the required renderstate blindly.

This API function should only be used between calls to RwCameraBeginUpdate and RwCameraEndUpdate.

Parameters:
primType  An RwInt32 value equal to the type of indexed primitive:
  • rwPRIMTYPELINELIST - Render lines as a list of unconnected line segments
  • rwPRIMTYPEPOLYLINE - Render lines as a connected polyline
  • rwPRIMTYPETRILIST - Render triangles as a sequence of isolated triangles
  • rwPRIMTYPETRISTRIP - Render triangles as a triangle strip
  • rwPRIMTYPETRIFAN - Render triangles as a triangle fan
vertices  A pointer to an array of immediate mode vertices
numVertices  An RwInt32 value equal to the number of vertices in the array
indices  A pointer to an array of vertex indices
numIndices  An RwInt32 value equal to the number of vertex indices in the array
Returns:
Returns TRUE if successful or FALSE if there is an error
See also:
RwIm2DVertexSetScreenX , RwIm2DVertexSetScreenY , RwIm2DVertexSetScreenZ , RwIm2DVertexSetRecipCameraZ , RwIm2DVertexSetRealRGBA , RwIm2DVertexSetIntRGBA , RwIm2DRenderTriangle , RwIm2DRenderLine , RwRenderStateSet , RwRenderStateGet , RwIm2DGetNearScreenZ , RwIm2DGetFarScreenZ
   To set up and render a 2D immediate mode polyline square with
   flat shading, but without Z-buffering: 
 
   RwIm2DVertex square[4];
   RwImVertexIndex index[5] = {0, 1, 2, 3, 0};
  
   // Set up the vertices...
   RwIm2DVertexSetScreenX(&square[0], (RwReal)((220)) );
   RwIm2DVertexSetScreenY(&square[0], (RwReal)((140)) );
  
   RwIm2DVertexSetScreenX(&square[1], (RwReal)((220)) );
   RwIm2DVertexSetScreenY(&square[1], (RwReal)((240)) );
  
   RwIm2DVertexSetScreenX(&square[2], (RwReal)((420)) );
   RwIm2DVertexSetScreenY(&square[2], (RwReal)((240)) );
  
   RwIm2DVertexSetScreenX(&square[3], (RwReal)((420)) );
   RwIm2DVertexSetScreenY(&square[3], (RwReal)((140)) );
  
   RwIm2DVertexSetIntRGBA(&square[0], 255, 0, 0, 255);
   RwIm2DVertexSetIntRGBA(&square[1], 0, 255, 0, 255);
   RwIm2DVertexSetIntRGBA(&square[2], 0, 0, 255, 255);
   RwIm2DVertexSetIntRGBA(&square[3], 255, 255, 0, 255);
  
   // Flat shading on...
   RwRenderStateSet(rwRENDERSTATESHADEMODE, (void *)rwSHADEMODEFLAT);
  
   // Z-buffering off..
   RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void *)FALSE);
  
   // Render polyline...
   RwIm2DRenderIndexedPrimitive(rwPRIMTYPEPOLYLINE, square, 4, index, 5);

   
RwBool RwIm2DRenderLine RwIm2DVertex   vertices,
RwInt32    numVertices,
RwInt32    vert1,
RwInt32    vert2
 

RwIm2DRenderLine is used to render a screen space 2D immediate mode line defined by the given two vertices. All vertices specified for 2D immediate mode rendering must lie within the screen space otherwise the results are unpredictable.

Note that 2D immediate mode routines must initialize their required renderstate before starting to render. They must share the renderstate resource and must not make any assumptions about what the existing renderstate is. The renderstate may be queried but in practice on many platforms it is faster to just establish the required renderstate blindly.

This API function should only be used between calls to RwCameraBeginUpdate and RwCameraEndUpdate.

Parameters:
vertices  A pointer to an array of 2D immediate mode vertices
numVertices  An RwInt32 value equal to the number of vertices in the array
vert1  An RwInt32 value specifying the index of the first vertex
vert2  An RwInt32 value specifying the index of the second vertex
Returns:
Returns TRUE if successful or FALSE if there is an error
See also:
RwIm2DVertexSetScreenX , RwIm2DVertexSetScreenY , RwIm2DVertexSetScreenZ , RwIm2DVertexSetRecipCameraZ , RwIm2DVertexSetRealRGBA , RwIm2DVertexSetIntRGBA , RwIm2DRenderTriangle , RwIm2DRenderIndexedPrimitive , RwRenderStateSet , RwRenderStateGet , RwIm2DGetNearScreenZ , RwIm2DGetFarScreenZ
   To set up and render a 2D immediate mode line with Gouraud shading
   and alpha-blending: 
  
   RwIm2DVertex vertex[2];
  
   // Set up the vertices...
   RwIm2DVertexSetScreenX(&vertex[0], (RwReal)((20)) );
   RwIm2DVertexSetScreenY(&vertex[0], (RwReal)((20)) );
   RwIm2DVertexSetScreenZ(&vertex[0], (RwReal)((3276)) );
   RwIm2DVertexSetRecipCameraZ(&vertex[0], (RwReal)((1.0/6.0)) );
  
   RwIm2DVertexSetScreenX(&vertex[1], (RwReal)((620)) );
   RwIm2DVertexSetScreenY(&vertex[1], (RwReal)((460)) );
   RwIm2DVertexSetScreenZ(&vertex[1], (RwReal)((3276)) );
   RwIm2DVertexSetRecipCameraZ(&vertex[1], (RwReal)((1.0/6.0)) );
  
   // Opaque red...
   RwIm2DVertexSetIntRGBA(&vertex[0], 255, 0, 0, 255);
  
   // Semi-transparent red...
   RwIm2DVertexSetIntRGBA(&vertex[1], 255, 0, 0, 128);
  
   // Texturing off...
   RwRenderStateSet(rwRENDERSTATETEXTURERASTER, NULL);
  
   // Gouraud shading on...
   RwRenderStateSet(rwRENDERSTATESHADEMODE, (void *)rwSHADEMODEGOURAUD);
  
   // Alpha-transparency on...
   RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void *)TRUE);
  
   //Render line...
   RwIm2DRenderLine(vertex, 2, 0, 1);

   
RwBool RwIm2DRenderPrimitive RwPrimitiveType    primType,
RwIm2DVertex   vertices,
RwInt32    numVertices
 

RwIm2DRenderPrimitive is used to render a screen space 2D immediate mode primitive defined by the given vertices. Use this function to render individual line segments, connected poly-lines, discrete triangles, triangle strips and triangle fans. Note that all vertices specified for 2D immediate mode rendering must lie within the screen space otherwise the results are unpredictable. The result is similar to what would be achieved with RwIm2DRenderIndexedPrimitive, but the indices are implicitly defined as (0, 1, 2, 3, ..., numVertices-1).

Note that 2D immediate mode routines must initialize their required renderstate before starting to render. They must share the renderstate resource and must not make any assumptions about what the existing renderstate is. Failure to do this may result in unexpected rendering artifacts. The renderstate may be queried but in practice on many platforms it is faster to just establish the required renderstate blindly.

This API function should only be used between calls to RwCameraBeginUpdate and RwCameraEndUpdate.

Parameters:
primType  An RwInt32 value equal to the type of indexed primitive:
  • rwPRIMTYPELINELIST - Render lines as a list of unconnected line segments
  • rwPRIMTYPEPOLYLINE - Render lines as a connected polyline
  • rwPRIMTYPETRILIST - Render triangles as a sequence of isolated triangles
  • rwPRIMTYPETRISTRIP - Render triangles as a triangle strip
  • rwPRIMTYPETRIFAN - Render triangles as a triangle fan
vertices  A pointer to an array of immediate mode vertices
numVertices  An RwInt32 value equal to the number of vertices in the array
Returns:
Returns TRUE if successful or FALSE if there is an error
See also:
RwIm2DVertexSetScreenX , RwIm2DVertexSetScreenY , RwIm2DVertexSetScreenZ , RwIm2DVertexSetRecipCameraZ , RwIm2DVertexSetRealRGBA , RwIm2DVertexSetIntRGBA , RwIm2DRenderTriangle , RwIm2DRenderLine , RwRenderStateSet , RwRenderStateGet , RwIm2DGetNearScreenZ , RwIm2DGetFarScreenZ
RwBool RwIm2DRenderTriangle RwIm2DVertex   vertices,
RwInt32    numVertices,
RwInt32    vert1,
RwInt32    vert2,
RwInt32    vert3
 

RwIm2DRenderTriangle is used to render a screen space 2D immediate mode triangle defined by the given three vertices. All vertices specified for 2D immediate mode rendering must lie within the screen space otherwise the results are unpredictable.

Note that 2D immediate mode routines must initialize their required renderstate before starting to render. They must share the renderstate resource and must not make any assumptions about what the existing renderstate is. Failure to do this may result in unexpected rending artifacts. The renderstate may be queried but in practice on many platforms it is faster to just establish the required renderstate blindly.

This API function should only be used between calls to RwCameraBeginUpdate and RwCameraEndUpdate.

Parameters:
vertices  A pointer to an array of immediate mode vertices
numVertices  An RwInt32 value equal to the number of vertices in the array
vert1  An RwInt32 value specifying the index of the first vertex
vert2  An RwInt32 value specifying the index of the second vertex
vert3  An RwInt32 value specifying the index of the third vertex
Returns:
Returns TRUE if successful or FALSE if there is an error
See also:
RwIm2DVertexSetScreenX , RwIm2DVertexSetScreenY , RwIm2DVertexSetScreenZ , RwIm2DVertexSetRecipCameraZ , RwIm2DVertexSetRealRGBA , RwIm2DVertexSetIntRGBA , RwIm2DRenderLine , RwIm2DRenderIndexedPrimitive , RwRenderStateSet , RwRenderStateGet , RwIm2DGetNearScreenZ , RwIm2DGetFarScreenZ
To set up and render a 2D immediate mode triangle with Gouraud shading and alpha-blending:
   RwIm2DVertex vertex[3];
 
   //Set up the vertices...
   RwIm2DVertexSetScreenX(&vertex[0], (RwReal)((20)) );
   RwIm2DVertexSetScreenY(&vertex[0], (RwReal)((20)) );
   RwIm2DVertexSetScreenZ(&vertex[0], (RwReal)((3276)) );
   RwIm2DVertexSetRecipCameraZ(&vertex[0], (RwReal)((1.0/6.0)) );
  
   RwIm2DVertexSetScreenX(&vertex[1], (RwReal)((20)) );
   RwIm2DVertexSetScreenY(&vertex[1], (RwReal)((40)) );
   RwIm2DVertexSetScreenZ(&vertex[1], (RwReal)((3276)) );
   RwIm2DVertexSetRecipCameraZ(&vertex[1], (RwReal)((1.0/6.0)) );
  
   RwIm2DVertexSetScreenX(&vertex[2], (RwReal)((40)) );
   RwIm2DVertexSetScreenY(&vertex[2], (RwReal)((40)) );
   RwIm2DVertexSetScreenZ(&vertex[2], (RwReal)((3276)) );
   RwIm2DVertexSetRecipCameraZ(&vertex[2], (RwReal)((1.0/6.0)) );
  
   // Opaque yellow...
   RwIm2DVertexSetIntRGBA(&vertex[0], 255, 255, 0, 255);
  
   // Semi-transparent magenta...
   RwIm2DVertexSetIntRGBA(&vertex[1], 255, 0, 255, 128);
  
   // Fully-transparent cyan...
   RwIm2DVertexSetIntRGBA(&vertex[2], 0, 255, 255, 0);
  
   // Texturing off...
   RwRenderStateSet(rwRENDERSTATETEXTURERASTER, NULL);
  
   // Gouraud shading on...
   RwRenderStateSet(rwRENDERSTATESHADEMODE, (void *)rwSHADEMODEGOURAUD);
  
   // Alpha-transparency on...
   RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void *)TRUE);
  
   // Render triangle...
   RwIm2DRenderTriangle(vertex, 3, 0, 1, 2);

   

Criterion Software © 1993-2003 Criterion Software Limited. All rights reserved. Built Tue Apr 22 12:46:16 2003. Send Feedback
Converted from CHM to HTML with chm2web Pro 2.85 (unicode)