1 /*===========================================================================*/
3 /* Mesa-3.0 DirectX 6 Driver */
7 /* http://www.altsoftware.com/ */
9 /* Copyright (c) 1999-1998 alt.software inc. All Rights Reserved */
10 /*===========================================================================*/
12 /*===========================================================================*/
13 /* Global variables. */
14 /*===========================================================================*/
15 DWORD g_DBGMask = DBG_ALL_ERROR;
16 /*===========================================================================*/
17 /* This is your basic DPF function with printf like support. The function */
18 /* also works with a global debug mask variable. I have written support that*/
19 /* allows for the user's enviroment variable space to be read and set the */
20 /* masks. This is done when the dll starts and is only in the debug version.*/
21 /*===========================================================================*/
23 /*===========================================================================*/
24 void _cdecl DebugPrint( int mask, char *pszFormat, ... )
29 /* A mask of 0 will always pass. Easy to remeber. */
30 if ( (mask == 0) || (mask & g_DBGMask) )
32 va_start( args, pszFormat );
34 if ( mask & DBG_ALL_ERROR )
35 OutputDebugString( "MesaD3D: (ERROR)" );
37 OutputDebugString( "MesaD3D: " );
39 vsprintf( buffer, pszFormat, args );
40 strcat( buffer, "\n" );
41 OutputDebugString( buffer );
46 /*===========================================================================*/
47 /* This call reads the users enviroment variables and sets any debug mask */
48 /* that they have set to TRUE. Now the value must be "TRUE". */
49 /*===========================================================================*/
51 /*===========================================================================*/
52 void ReadDBGEnv( void )
54 g_DBGMask = DBG_ALL_ERROR;
56 #define IS_VAR_SET(v) if ( getenv( # v ) && !strcmp(getenv( # v ),"TRUE") ) g_DBGMask |= v;
58 IS_VAR_SET( DBG_FUNC );
59 IS_VAR_SET( DBG_STATES );
61 IS_VAR_SET( DBG_CNTX_INFO );
62 IS_VAR_SET( DBG_CNTX_WARN );
63 IS_VAR_SET( DBG_CNTX_PROFILE );
64 IS_VAR_SET( DBG_CNTX_ERROR );
65 IS_VAR_SET( DBG_CNTX_ALL );
67 IS_VAR_SET( DBG_PRIM_INFO );
68 IS_VAR_SET( DBG_PRIM_WARN );
69 IS_VAR_SET( DBG_PRIM_PROFILE );
70 IS_VAR_SET( DBG_PRIM_ERROR );
71 IS_VAR_SET( DBG_PRIM_ALL );
73 IS_VAR_SET( DBG_TXT_INFO );
74 IS_VAR_SET( DBG_TXT_WARN );
75 IS_VAR_SET( DBG_TXT_PROFILE );
76 IS_VAR_SET( DBG_TXT_ERROR );
77 IS_VAR_SET( DBG_TXT_ALL );
79 IS_VAR_SET( DBG_ALL_INFO );
80 IS_VAR_SET( DBG_ALL_WARN );
81 IS_VAR_SET( DBG_ALL_PROFILE );
82 IS_VAR_SET( DBG_ALL_ERROR );
83 IS_VAR_SET( DBG_ALL );
87 /*===========================================================================*/
88 /* This function will take a pointer to a DDSURFACEDESC2 structure & display*/
89 /* the parsed information using a DPF call. */
90 /*===========================================================================*/
92 /*===========================================================================*/
93 void DebugPixelFormat( char *pszSurfaceName, DDPIXELFORMAT *pddpf )
97 /* Parse the flag type and write the string equivalent. */
98 if ( pddpf->dwFlags & DDPF_ALPHA )
99 strcat( buffer, "DDPF_ALPHA " );
100 if ( pddpf->dwFlags & DDPF_ALPHAPIXELS )
101 strcat( buffer, "DDPF_ALPHAPIXELS " );
102 if ( pddpf->dwFlags & DDPF_ALPHAPREMULT )
103 strcat( buffer, "DDPF_ALPHAPREMULT " );
104 if ( pddpf->dwFlags & DDPF_BUMPLUMINANCE )
105 strcat( buffer, "DDPF_BUMPLUMINANCE " );
106 if ( pddpf->dwFlags & DDPF_BUMPDUDV )
107 strcat( buffer, "DDPF_BUMPDUDV " );
108 if ( pddpf->dwFlags & DDPF_COMPRESSED )
109 strcat( buffer, "DDPF_COMPRESSED " );
110 if ( pddpf->dwFlags & DDPF_FOURCC )
111 strcat( buffer, "DDPF_FOURCC " );
112 if ( pddpf->dwFlags & DDPF_LUMINANCE )
113 strcat( buffer, "DDPF_LUMINANCE " );
114 if ( pddpf->dwFlags & DDPF_PALETTEINDEXED1 )
115 strcat( buffer, "DDPF_PALETTEINDEXED1 " );
116 if ( pddpf->dwFlags & DDPF_PALETTEINDEXED2 )
117 strcat( buffer, "DDPF_PALETTEINDEXED2 " );
118 if ( pddpf->dwFlags & DDPF_PALETTEINDEXED4 )
119 strcat( buffer, "DDPF_PALETTEINDEXED4 " );
120 if ( pddpf->dwFlags & DDPF_PALETTEINDEXED8 )
121 strcat( buffer, "DDPF_PALETTEINDEXED8 " );
122 if ( pddpf->dwFlags & DDPF_PALETTEINDEXEDTO8 )
123 strcat( buffer, "DDPF_PALETTEINDEXEDTO8 " );
124 if ( pddpf->dwFlags & DDPF_RGB )
125 strcat( buffer, "DDPF_RGB " );
126 if ( pddpf->dwFlags & DDPF_RGBTOYUV )
127 strcat( buffer, "DDPF_RGBTOYUV " );
128 if ( pddpf->dwFlags & DDPF_STENCILBUFFER )
129 strcat( buffer, "DDPF_STENCILBUFFER " );
130 if ( pddpf->dwFlags & DDPF_YUV )
131 strcat( buffer, "DDPF_YUV " );
132 if ( pddpf->dwFlags & DDPF_ZBUFFER )
133 strcat( buffer, "DDPF_ZBUFFER " );
134 if ( pddpf->dwFlags & DDPF_ZPIXELS )
135 strcat( buffer, "DDPF_ZPIXELS " );
137 DPF(( (DBG_TXT_INFO|DBG_CNTX_INFO),"%s", buffer ));