RenderWare V2.1

Previous Page Index Next Page

RwBool

RwGetDeviceInfo(RwDeviceInfo info, void *value, RwInt32 size);

Description

Retrieves information about an aspect of the current RenderWare device driver. The specific information to query is given by info.

Arguments

info Aspect of current device driver to query.

value Pointer to a buffer to receive the result of the query. The actual data type of value is dependent on the value of info.

size Size in bytes of the buffer pointed to by param2.

Return Value

TRUE if successful, and FALSE otherwise.

Comments

The value parameter of each device information type is as follows:

• rwRENDERDEPTH A pointer to an RwInt32 to receive the current depth (in bits) of rendering.

• rwINDEXEDRENDERING A pointer to an RwBool which will be non-zero if rendering is indexed color based and zero if direct color based.

• rwPALETTEBASED A pointer to an RwBool which will be non-zero if the output device has a palette that RenderWare will attempt to modify, and zero if the output device uses direct color.

The following options apply when the output device is palette based:

• rwPALETTE A pointer to a device specific value which will receive a device dependent RenderWare palette object. See Appendix B for a description of this parameter.

• rwPALETTESIZE A pointer to an RwInt32 to receive the number of entries in the entire palette (this will normally be 256 for 8-bit devices).

• rwFIRSTPALETTEENTRY
A pointer to an RwInt32 to receive the palette index of the first palette entry available for use by an application.

• rwLASTPALETTEENTRY A pointer to an RwInt32 to receive the palette index of the last palette entry available for use by an application.

• rwGETPSEUDOPHONG param1 should point to a RwBool. If TRUE is returned then 'pseudo phong' shading is enabled otherwise gouraud shading is enabled.

• rwGETSATURATION param1 should point to an RwReal. The value returned is the position along the lighting scale where saturation occurs. See rwSETSATURATION for more details.

• rwMAXLUMINANCE Returns the maximum luminance value. Any value between this value and zero may be used for setting the luminance of a polygon or vertex. Note that the number is returned as an RwReal, luminance values in polygons and vertices are held in RwFixed form so it is necessary to perform a conversion (using REAL2FIX) before using a value.

The example below sets the lighting on a vertex of a clump to a value of half the maximum luminance (it is assumed that the light sampling on the clump has been turned off).

{
RwImmVertex3d *immvertex;
RwReal maxluminance;

RwGetDeviceInfo(rwMAXLUMINANCE, &maxluminance,
sizeof(maxluminance));

immvertex = RwGetClumpImmVertex(clump,1);

RWSETIMMVERTEXLUM((*immvertex),
REAL2FIX( RDiv(maxluminance, CREAL(2)) );
}

• rwMAXZBUFFERZ Returns the maximum possible Z buffer value that can be used. This is the largest value that can be placed in the pixel space Z entry of a vertex.

The example below sets the pixel space Z value of a vertex to a value in the middle of the range.

{
RwImmediate imm;
RwUInt32 maxz, minz;
RwImmVertex3d *immvertex;

RwGetDeviceInfo(rwMAXZBUFFERZ, &maxz, sizeof(maxz));
RwGetDeviceInfo(rwMINZBUFFERZ, &minz, sizeof(minz));

immvertex = RwGetClumpImmVertex(clump,1);

RWSETIMMVERTEX2DZ((*immvertex),(maxz-minz)>>1);
}

• rwMINZBUFFERZ Returns the smallest possible Z buffer value that can be used. This value is the smallest value that can safely be placed in the pixel space Z entry of a vertex. See rwMAXZBUFFERZ for an example.

• rwGETPALETTERAMPLENGTH Returns the length of a 'meta palette' ramp. This value is useful when using the low level access device controls rwGETPALETTEENTRYNO and rwSETPALETTEENTRY. When getting a palette entry it is important to only give a ramp entry between 0 and the number returned by this device info. See rwGETPALETTEENTRYNO for an example.

• rwGETDEVICECAPABILITIES Returns a structure which holds the capabilities of a device. Generally this device info call is used before a device is started whilst looking through the available devices to check which ones have sufficient capabilities. For more details of the RwDeviceCapabilities structure, see the data types chapter.

The following section of code looks for a device with a 32 bit Z buffer. The number of the entry in the list of devices is given if an appropriate device is found (1 is the first entry). Otherwise 0 is returned.

RwInt32
Find32ZBuffer(void)
{
char *devices;
RwDeviceCapabilities *capabilities;
RwInt32 device;
char devicename[80];
RwDisplayDevice *displaydevice;

/* First initialize the library */

if (RwInitialize())
{
/* Get the list of all the available devices */
devices = RwGetDisplayDevices();

/* Start with first device in list */
device = 1;

/* Extract the device name from the list */
while (RwExtract(devices, device,
devicename, sizeof(devicename)))
{
/* Try to open the device */

if (displaydevice =
RwOpenDisplayDevice(devicename, NULL))
{
/* Get the devices capabilities */

RwGetDeviceInfo(rwGETDEVICECAPABILITIES,
&capabilities,
sizeof(capabilities));

/* Does the device have an 32 bit Z
buffer */

if (capabilities->zbuffer_depth == 32)
{
RwCloseDisplayDevice(displaydevice);
return device;
}
RwCloseDisplayDevice(displaydevice);
}

/* Onto the next device */

device++;
}
}
else
{
/* Unable to start the library */
}
return 0;
}

• rwGETNUMVIDEOMODES Returns the number of potential video modes which can be selected. If the device is incapable of setting video modes, FALSE will be returned.

The example below finds how many video modes the current device can switch between if at all.

RwInt32 nummodes;
if (RwGetDeviceInfo(rwGETNUMVIDEOMODES, &nummodes,
sizeof(nummodes))
{
/* There are nummodes, possible modes */
}
else
{
/* This device is unable change video modes */
}

• rwGETGAMMACORRECT Gets the status of gamma correction. If true then gamma correction has been set otherwise no gamma correction has taken place.

The example below checks the gamma correction status.

{
RwBool gammacorrect;

RwGetDeviceInfo(rwGETGAMMACORRECT,
&gammacorrect, sizeof(gammacorrect));
}

• rwGETDOUBLEBUFFER Determine if double buffering is going to be/or is in effect. Double buffering in this context means hardware double buffering on the video card. That is having two image buffers on the card, displaying one whilst updating the other. At a suitable time (vertical blank) the unseen buffer is displayed and the displayed image becomes the unseen buffer. This provides 'smoother' more rock steady display, but forces page flips to occur at fixed time intervals which can cause animation to appear to speed up and slow down if rendering time is around the time of a display refresh.

The example below checks if hardware double buffering is being used.

{
RwBool doublebuffer;

RwGetDeviceInfo(rwGETDOUBLEBUFFER,
&doublebuffer, sizeof(doublebuffer));

if (doublebuffer)
{
/* If before the device is started then double
buffering is being requested, otherwise double
buffering has been activated */
}
else
{
/* If before the device is started then double
buffering is not requested, otherwise double
buffering has not been activated */
}
}

• rwGETZBUFFERSTATE Returns the current Z buffer status. TRUE indicates that Z buffering is active. FALSE indicates that no Z buffering can occur.

The example below checks the current Z buffer status.

{

RwBool zbuffer;

RwGetDeviceInfo(rwGETZBUFFERSTATE, &zbuffer,
sizeof(zbuffer));

if (zbuffer)
{
/* Z buffering is active */
}
else
{
/* Z buffering is not active */
}

}

Further information types may be supported by specific device drivers. See Appendix B for more information.

size gives the size in bytes of the buffer pointed to by value. For example to determine RenderWare’s current render depth the following would be used:

RwInt32 depth;
RwGetDeviceInfo(rwRENDERDEPTH, &depth, sizeof(depth);

See Also

RwDeviceControl()

RwGetSystemInfo()

RwSetPaletteEntries()

RwOpenExt()