GXSetVerifyCallback

Syntax

#include <revolution/gx.h>

typedef void (*GXVerifyCallback)(GXWarningLevel level, 
                                 u32            id, 
                                 char*          msg);

GXVerifyCallback GXSetVerifyCallback( GXVerifyCallback cb );

Arguments

cb Pointer to the warning callback function.

Return Values

Returns a pointer to a previously set callback function.

Description

This function installs a callback that is invoked whenever a verify warning is encountered by the GX API (only in debug builds). GX verification is enabled using the GXSetVerifyLevel function. A default callback is installed by the GXInit function as shown below.

void __GXVerifyDefaultCallback(GXWarningLevel level,
                               u32           id,
                               const char*   msg)
{
    OSReport("Level %d, Warning $03d: %s\n", level, id, msg);
}

The callback's argument id is a number unique for each warning. The level is the level of the warning encountered. Level 1 represents severe warnings, level 2 signifies medium warnings, and level 3 denotes minor warnings. The msg argument is a pointer to the warning string. Be aware that the warning ID numbers and message strings are subject to change as GX is revised.

id allows for selective output of warnings based on their frequency. For example, to turn off a particular warning after it has been encountered three times:

u32 myWarningCount[GXWARN_MAX];

void myVerifyCallback(GXWarningLevel level,
                      GXVerifyID     id,
                      const char*   msg)
{
    if (myWarningCount[id] < 3)
        OSReport("Level %d, Warning $03d: %s\n", level, id, msg);
    myWarningCount[id]++;
}

By placing a breakpoint in the verify callback function with the debugger, you can ascertain the approximate location in the source code that a warning occurred by examining the stack trace when the breakpoint is encountered. The location is only approximate, because many of the warning conditions are evaluated in the GXBegin function.

See Also

None.

Revision History

2006/03/01 Initial version.


CONFIDENTIAL