#include <revolution/gx.h>
typedef void (*GXVerifyCallback)(GXWarningLevel level,
u32 id,
char* msg);
GXVerifyCallback GXSetVerifyCallback( GXVerifyCallback cb );
cb |
pointer to the warning callback function |
Returns a pointer to a previously set callback function.
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 GXSetVerifyLevel. A default callback is installed by GXInit 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. 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 argument msg 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 printing 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 at GXBegin.
03/01/2006 Initial version.