Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

318 lines
17 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: mcdcx.h
  3. *
  4. * MCD support: structures, variables, constants, and functions.
  5. *
  6. * Created: 26-Feb-1996 12:30:41
  7. * Author: Gilman Wong [gilmanw]
  8. *
  9. * Copyright (c) 1995 Microsoft Corporation
  10. *
  11. \**************************************************************************/
  12. #ifndef _MCDCX_H_
  13. #define _MCDCX_H_
  14. //
  15. // Handy forward declaration.
  16. //
  17. typedef struct __GLGENbuffersRec __GLGENbuffers;
  18. typedef struct __GLGENcontextRec __GLGENcontext;
  19. //
  20. // Macros to maintain MCD dirty state:
  21. //
  22. // MCD_STATE_DIRTY set specified dirty flag
  23. // MCD_STATE_CLEAR clear specified dirty flag
  24. // MCD_STATE_RESET clear all dirty flags
  25. // MCD_STATE_DIRTYTEST check state flag (TRUE if dirty)
  26. //
  27. #define MCD_STATE_DIRTY(gc, stateName)\
  28. {\
  29. if (((__GLGENcontext *) (gc))->pMcdState)\
  30. ((__GLGENcontext *) (gc))->pMcdState->mcdDirtyState |= MCD_DIRTY_##stateName;\
  31. }
  32. #define MCD_STATE_CLEAR(gc, stateName)\
  33. {\
  34. if (((__GLGENcontext *) (gc))->pMcdState)\
  35. ((__GLGENcontext *) (gc))->pMcdState->mcdDirtyState &= ~MCD_DIRTY_##stateName;\
  36. }
  37. #define MCD_STATE_RESET(gc)\
  38. {\
  39. if (((__GLGENcontext *) (gc))->pMcdState)\
  40. ((__GLGENcontext *) (gc))->pMcdState->mcdDirtyState = 0;\
  41. }
  42. #define MCD_STATE_DIRTYTEST(gc, stateName)\
  43. (\
  44. (((__GLGENcontext *) (gc))->pMcdState) &&\
  45. (((__GLGENcontext *) (gc))->pMcdState->mcdDirtyState & MCD_DIRTY_##stateName)\
  46. )
  47. //
  48. // MCD interface functions. These functions call the MCD client interface.
  49. // The function implementations are found in generic\mcdcx.c.
  50. //
  51. BOOL FASTCALL bInitMcd(HDC hdc);
  52. BOOL FASTCALL bInitMcdContext(__GLGENcontext *, GLGENwindow *);
  53. BOOL FASTCALL bInitMcdSurface(__GLGENcontext *, GLGENwindow *, __GLGENbuffers *);
  54. void FASTCALL GenMcdDeleteContext(GENMCDSTATE *);
  55. void FASTCALL GenMcdDeleteSurface(GENMCDSURFACE *);
  56. BOOL FASTCALL GenMcdMakeCurrent(__GLGENcontext *gengc, GLGENwindow *pwnd);
  57. void FASTCALL GenMcdInitDepth(__GLcontext *, __GLdepthBuffer *);
  58. void FASTCALL GenMcdClear(__GLGENcontext *, ULONG *);
  59. void FASTCALL GenMcdClearDepth16(__GLdepthBuffer *);
  60. void FASTCALL GenMcdClearDepth32(__GLdepthBuffer *);
  61. void FASTCALL GenMcdUpdateRenderState(__GLGENcontext *);
  62. void FASTCALL GenMcdViewport(__GLGENcontext *);
  63. void FASTCALL GenMcdScissor(__GLGENcontext *);
  64. void FASTCALL GenMcdUpdateScissorState(__GLGENcontext *);
  65. void FASTCALL GenMcdUpdateTexEnvState(__GLGENcontext *);
  66. POLYARRAY * FASTCALL GenMcdDrawPrim(__GLGENcontext *, POLYARRAY *);
  67. void FASTCALL GenMcdSwapBatch(__GLGENcontext *);
  68. BOOL FASTCALL GenMcdSwapBuffers(HDC, GLGENwindow *pwnd);
  69. BOOL FASTCALL GenMcdResizeBuffers(__GLGENcontext *);
  70. BOOL FASTCALL GenMcdUpdateBufferInfo(__GLGENcontext *);
  71. void GenMcdCopyPixels(__GLGENcontext *, __GLcolorBuffer *, GLint, GLint, GLint, BOOL);
  72. void FASTCALL GenMcdSynchronize(__GLGENcontext *);
  73. BOOL FASTCALL GenMcdConvertContext(__GLGENcontext *, __GLGENbuffers *);
  74. PVOID FASTCALL GenMcdReadZRawSpan(__GLdepthBuffer *fb, GLint x, GLint y, GLint cx);
  75. void FASTCALL GenMcdWriteZRawSpan(__GLdepthBuffer *fb, GLint x, GLint y, GLint cx);
  76. MCDHANDLE FASTCALL GenMcdCreateTexture(__GLGENcontext *gengc, __GLtexture *tex,
  77. ULONG flags);
  78. BOOL FASTCALL GenMcdDeleteTexture(__GLGENcontext *gengc, MCDHANDLE texHandle);
  79. BOOL FASTCALL GenMcdUpdateSubTexture(__GLGENcontext *ggenc, __GLtexture *tex,
  80. MCDHANDLE texHandle, GLint lod,
  81. GLint xoffset, GLint yoffset,
  82. GLsizei w, GLsizei h);
  83. BOOL FASTCALL GenMcdUpdateTexturePalette(__GLGENcontext *gengc, __GLtexture *tex,
  84. MCDHANDLE texHandle, GLsizei start,
  85. GLsizei count);
  86. BOOL FASTCALL GenMcdUpdateTexturePriority(__GLGENcontext *gengc, __GLtexture *tex,
  87. MCDHANDLE texHandle);
  88. BOOL FASTCALL GenMcdUpdateTextureState(__GLGENcontext *gengc, __GLtexture *tex,
  89. MCDHANDLE texHandle);
  90. void FASTCALL GenMcdUpdateFineState(__GLGENcontext *gengc);
  91. DWORD FASTCALL GenMcdTextureStatus(__GLGENcontext *gengc, MCDHANDLE texHandle);
  92. DWORD FASTCALL GenMcdTextureKey(__GLGENcontext *gengc, MCDHANDLE texHandle);
  93. VOID FASTCALL GenMcdSetScaling(__GLGENcontext *gengc);
  94. typedef enum { VP_FIXBIAS, VP_NOBIAS } VP_BIAS_TYPE;
  95. BOOL FASTCALL GenMcdResetViewportAdj(__GLcontext *, VP_BIAS_TYPE);
  96. BOOL FASTCALL GenMcdDescribeLayerPlane(HDC hdc, int iPixelFormat,
  97. int iLayerPlane, UINT nBytes,
  98. LPLAYERPLANEDESCRIPTOR plpd);
  99. int FASTCALL GenMcdSetLayerPaletteEntries(HDC hdc, int iLayerPlane,
  100. int iStart, int cEntries,
  101. CONST COLORREF *pcr);
  102. int FASTCALL GenMcdGetLayerPaletteEntries(HDC hdc, int iLayerPlane,
  103. int iStart, int cEntries,
  104. COLORREF *pcr);
  105. int FASTCALL GenMcdRealizeLayerPalette(HDC hdc, int iLayerPlane,
  106. BOOL bRealize);
  107. BOOL FASTCALL GenMcdSwapLayerBuffers(HDC hdc, UINT fuFlags);
  108. void FASTCALL GenMcdUpdatePixelState(__GLGENcontext *gengc);
  109. ULONG FASTCALL GenMcdDrawPix(__GLGENcontext *gengc, ULONG width,
  110. ULONG height, ULONG format, ULONG type,
  111. VOID *pPixels, BOOL packed);
  112. ULONG FASTCALL GenMcdReadPix(__GLGENcontext *gengc, LONG x, LONG y, ULONG width,
  113. ULONG height, ULONG format, ULONG type,
  114. VOID *pPixels);
  115. ULONG FASTCALL GenMcdCopyPix(__GLGENcontext *gengc, LONG x, LONG y, ULONG width,
  116. ULONG height, ULONG type);
  117. ULONG FASTCALL GenMcdPixelMap(__GLGENcontext *gengc, ULONG mapType,
  118. ULONG mapSize, VOID *pMap);
  119. void FASTCALL GenMcdDestroyWindow(GLGENwindow *pwnd);
  120. int FASTCALL GenMcdGetTextureFormats(__GLGENcontext *gengc, int nFmts,
  121. struct _DDSURFACEDESC *pddsd);
  122. DWORD FASTCALL GenMcdSwapMultiple(UINT cBuffers, GENMCDSWAP *pgms);
  123. // Note:
  124. // GenMcdGenericCompatibleFormat is implemented in pixelfmt.c
  125. BOOL FASTCALL GenMcdGenericCompatibleFormat(__GLGENcontext *gengc);
  126. //
  127. // Depth test drawing functions that utilize an intermediate scanline
  128. // depth buffer to access the MCD depth buffer.
  129. //
  130. GLboolean FASTCALL GenMcdDepthTestLine(__GLcontext *);
  131. GLboolean FASTCALL GenMcdDepthTestStippledLine(__GLcontext *);
  132. GLboolean FASTCALL GenMcdDepthTestStencilLine(__GLcontext *);
  133. GLboolean FASTCALL GenMcdDepthTestStencilStippledLine(__GLcontext *);
  134. GLboolean FASTCALL GenMcdDepthTestSpan(__GLcontext *);
  135. GLboolean FASTCALL GenMcdDepthTestStippledSpan(__GLcontext *);
  136. GLboolean FASTCALL GenMcdDepthTestStencilSpan(__GLcontext *);
  137. GLboolean FASTCALL GenMcdDepthTestStencilStippledSpan(__GLcontext *);
  138. GLboolean FASTCALL GenMcdStippleAnyDepthTestSpan(__GLcontext *);
  139. // 2.0 Front-end processing call
  140. POLYARRAY * FASTCALL GenMcdProcessPrim(__GLGENcontext *gengc, POLYARRAY *pa,
  141. ULONG cmdFlagsAll, ULONG primFlags,
  142. MCDTRANSFORM *pMCDTransform,
  143. MCDMATERIALCHANGES *pMCDMatChanges);
  144. //
  145. // "Safe" version of __fastGenFillTriangle that does not allow floating
  146. // point divides to straddle an MCD function call.
  147. //
  148. extern void FASTCALL __fastGenMcdFillTriangle(__GLcontext *, __GLvertex *,
  149. __GLvertex *, __GLvertex *, GLboolean);
  150. //
  151. // MCD32.DLL entry points.
  152. //
  153. // Rather than link directly to MCD32.DLL (thereby requiring its existence
  154. // to run OPENGL32.DLL), we load it and hook its entry points as needed.
  155. // This table stores the function pointers we hook.
  156. //
  157. typedef BOOL (APIENTRY *MCDGETDRIVERINFOFUNC)(HDC hdc, struct _MCDDRIVERINFOI *pMCDDriverInfo);
  158. typedef LONG (APIENTRY *MCDDESCRIBEMCDPIXELFORMATFUNC)(HDC hdc, LONG iPixelFormat,
  159. MCDPIXELFORMAT *pMcdPixelFmt);
  160. typedef LONG (APIENTRY *MCDDESCRIBEPIXELFORMATFUNC)(HDC hdc, LONG iPixelFormat,
  161. LPPIXELFORMATDESCRIPTOR ppfd);
  162. typedef BOOL (APIENTRY *MCDCREATECONTEXTFUNC)(MCDCONTEXT *pMCDContext,
  163. MCDRCINFOPRIV *pMcdRcInfo,
  164. struct _GLSURF *pgsurf,
  165. int ipfd,
  166. ULONG flags);
  167. typedef BOOL (APIENTRY *MCDDELETECONTEXTFUNC)(MCDCONTEXT *pMCDContext);
  168. typedef UCHAR * (APIENTRY *MCDALLOCFUNC)(MCDCONTEXT *pMCDContext, ULONG numBytes, MCDHANDLE *pMCDHandle,
  169. ULONG flags);
  170. typedef BOOL (APIENTRY *MCDFREEFUNC)(MCDCONTEXT *pMCDContext, VOID *pMCDMem);
  171. typedef VOID (APIENTRY *MCDBEGINSTATEFUNC)(MCDCONTEXT *pMCDContext, VOID *pMCDMem);
  172. typedef BOOL (APIENTRY *MCDFLUSHSTATEFUNC)(VOID *pMCDMem);
  173. typedef BOOL (APIENTRY *MCDADDSTATEFUNC)(VOID *pMCDMem, ULONG stateToChange,
  174. ULONG stateValue);
  175. typedef BOOL (APIENTRY *MCDADDSTATESTRUCTFUNC)(VOID *pMCDMem, ULONG stateToChange,
  176. VOID *pStateValue, ULONG stateValueSize);
  177. typedef BOOL (APIENTRY *MCDSETVIEWPORTFUNC)(MCDCONTEXT *pMCDContext, VOID *pMCDMem,
  178. MCDVIEWPORT *pMCDViewport);
  179. typedef BOOL (APIENTRY *MCDSETSCISSORRECTFUNC)(MCDCONTEXT *pMCDContext, RECTL *pRect,
  180. BOOL bEnabled);
  181. typedef ULONG (APIENTRY *MCDQUERYMEMSTATUSFUNC)(VOID *pMCDMem);
  182. typedef PVOID (APIENTRY *MCDPROCESSBATCHFUNC)(MCDCONTEXT *pMCDContext, VOID *pMCDMem,
  183. ULONG batchSize, VOID *pMCDFirstCmd,
  184. int cExtraSurfaces,
  185. struct IDirectDrawSurface **pdds);
  186. typedef BOOL (APIENTRY *MCDREADSPANFUNC)(MCDCONTEXT *pMCDContext, VOID *pMCDMem,
  187. ULONG x, ULONG y, ULONG numPixels, ULONG type);
  188. typedef BOOL (APIENTRY *MCDWRITESPANFUNC)(MCDCONTEXT *pMCDContext, VOID *pMCDMem,
  189. ULONG x, ULONG y, ULONG numPixels, ULONG type);
  190. typedef BOOL (APIENTRY *MCDCLEARFUNC)(MCDCONTEXT *pMCDContext, RECTL rect, ULONG buffers);
  191. typedef BOOL (APIENTRY *MCDSWAPFUNC)(MCDCONTEXT *pMCDContext, ULONG flags);
  192. typedef BOOL (APIENTRY *MCDGETBUFFERSFUNC)(MCDCONTEXT *pMCDContext, MCDRECTBUFFERS *pMCDBuffers);
  193. typedef BOOL (APIENTRY *MCDALLOCBUFFERSFUNC)(MCDCONTEXT *pMCDContext, RECTL *pWndRect);
  194. typedef ULONG (APIENTRY *MCDLOCKFUNC)(MCDCONTEXT *pMCDContext);
  195. typedef VOID (APIENTRY *MCDUNLOCKFUNC)(MCDCONTEXT *pMCDContext);
  196. typedef BOOL (APIENTRY *MCDBINDCONTEXT)(MCDCONTEXT *pMCDContext, HDC hdc,
  197. struct GLGENwindowRec *pwnd);
  198. typedef BOOL (APIENTRY *MCDSYNCFUNC)(MCDCONTEXT *pMCDContext);
  199. typedef MCDHANDLE (APIENTRY *MCDCREATETEXTUREFUNC)(MCDCONTEXT *pMCDContext,
  200. MCDTEXTUREDATA *pTexData,
  201. ULONG flags, VOID *pSurface);
  202. typedef BOOL (APIENTRY *MCDDELETETEXTUREFUNC)(MCDCONTEXT *pMCDContext, MCDHANDLE hTex);
  203. typedef BOOL (APIENTRY *MCDUPDATESUBTEXTUREFUNC)(MCDCONTEXT *pMCDContext,
  204. MCDTEXTUREDATA *pTexData, MCDHANDLE hTex,
  205. ULONG lod, RECTL *pRect);
  206. typedef BOOL (APIENTRY *MCDUPDATETEXTUREPALETTEFUNC)(MCDCONTEXT *pMCDContext,
  207. MCDTEXTUREDATA *pTexData, MCDHANDLE hTex,
  208. ULONG start, ULONG numEntries);
  209. typedef BOOL (APIENTRY *MCDUPDATETEXTUREPRIORITYFUNC)(MCDCONTEXT *pMCDContext,
  210. MCDTEXTUREDATA *pTexData,
  211. MCDHANDLE hTex);
  212. typedef ULONG (APIENTRY *MCDTEXTURESTATUSFUNC)(MCDCONTEXT *pMCDContext, MCDHANDLE hTex);
  213. typedef ULONG (APIENTRY *MCDTEXTUREKEYFUNC)(MCDCONTEXT *pMCDContext, MCDHANDLE hTex);
  214. typedef BOOL (APIENTRY *MCDDESCRIBEMCDLAYERPLANEFUNC)(HDC hdc,
  215. LONG iPixelFormat, LONG iLayerPlane,
  216. MCDLAYERPLANE *pMcdLayer);
  217. typedef BOOL (APIENTRY *MCDDESCRIBELAYERPLANEFUNC)(HDC hdc,
  218. LONG iPixelFormat, LONG iLayerPlane,
  219. LPLAYERPLANEDESCRIPTOR plpd);
  220. typedef LONG (APIENTRY *MCDSETLAYERPALETTEFUNC)(HDC hdc, LONG iLayerPlane,
  221. BOOL bRealize, LONG cEntries, COLORREF *pcr);
  222. typedef ULONG (APIENTRY *MCDDRAWPIXELS)(MCDCONTEXT *pMCDContext, ULONG width,
  223. ULONG height, ULONG format, ULONG type,
  224. VOID *pPixels, BOOL packed);
  225. typedef ULONG (APIENTRY *MCDREADPIXELS)(MCDCONTEXT *pMCDContext, LONG x, LONG y, ULONG width,
  226. ULONG height, ULONG format, ULONG type,
  227. VOID *pPixels);
  228. typedef ULONG (APIENTRY *MCDCOPYPIXELS)(MCDCONTEXT *pMCDContext, LONG x, LONG y, ULONG width,
  229. ULONG height, ULONG type);
  230. typedef ULONG (APIENTRY *MCDPIXELMAP)(MCDCONTEXT *pMCDContext, ULONG mapType,
  231. ULONG mapSize, VOID *pMap);
  232. typedef void (APIENTRY *MCDDESTROYWINDOW)(HDC hdc, ULONG_PTR dwMcdWindow);
  233. typedef int (APIENTRY *MCDGETTEXTUREFORMATS)(MCDCONTEXT *pMCDContext,
  234. int nFmts,
  235. struct _DDSURFACEDESC *pddsd);
  236. typedef DWORD (APIENTRY *MCDSWAPMULTIPLE)(HDC hdc,
  237. UINT cBuffers,
  238. GENMCDSWAP *pgms);
  239. typedef PVOID (APIENTRY *MCDPROCESSBATCH2FUNC)(MCDCONTEXT *pMCDContext,
  240. VOID *pMCDCmdMem,
  241. VOID *pMCDPrimMem,
  242. MCDCOMMAND *pMCDFirstCmd,
  243. int cExtraSurfaces,
  244. struct
  245. IDirectDrawSurface **pdds,
  246. ULONG cmdFlagsAll,
  247. ULONG primFlags,
  248. MCDTRANSFORM *pMCDTransform,
  249. MCDMATERIALCHANGES
  250. *pMCDMatChanges);
  251. typedef struct _MCDTABLE_ {
  252. MCDGETDRIVERINFOFUNC pMCDGetDriverInfo;
  253. MCDDESCRIBEMCDPIXELFORMATFUNC pMCDDescribeMcdPixelFormat;
  254. MCDDESCRIBEPIXELFORMATFUNC pMCDDescribePixelFormat;
  255. MCDCREATECONTEXTFUNC pMCDCreateContext;
  256. MCDDELETECONTEXTFUNC pMCDDeleteContext;
  257. MCDALLOCFUNC pMCDAlloc;
  258. MCDFREEFUNC pMCDFree;
  259. MCDBEGINSTATEFUNC pMCDBeginState;
  260. MCDFLUSHSTATEFUNC pMCDFlushState;
  261. MCDADDSTATEFUNC pMCDAddState;
  262. MCDADDSTATESTRUCTFUNC pMCDAddStateStruct;
  263. MCDSETVIEWPORTFUNC pMCDSetViewport;
  264. MCDSETSCISSORRECTFUNC pMCDSetScissorRect;
  265. MCDQUERYMEMSTATUSFUNC pMCDQueryMemStatus;
  266. MCDPROCESSBATCHFUNC pMCDProcessBatch;
  267. MCDREADSPANFUNC pMCDReadSpan;
  268. MCDWRITESPANFUNC pMCDWriteSpan;
  269. MCDCLEARFUNC pMCDClear;
  270. MCDSWAPFUNC pMCDSwap;
  271. MCDGETBUFFERSFUNC pMCDGetBuffers;
  272. MCDALLOCBUFFERSFUNC pMCDAllocBuffers;
  273. MCDLOCKFUNC pMCDLock;
  274. MCDUNLOCKFUNC pMCDUnlock;
  275. MCDBINDCONTEXT pMCDBindContext;
  276. MCDSYNCFUNC pMCDSync;
  277. MCDCREATETEXTUREFUNC pMCDCreateTexture;
  278. MCDDELETETEXTUREFUNC pMCDDeleteTexture;
  279. MCDUPDATESUBTEXTUREFUNC pMCDUpdateSubTexture;
  280. MCDUPDATETEXTUREPALETTEFUNC pMCDUpdateTexturePalette;
  281. MCDUPDATETEXTUREPRIORITYFUNC pMCDUpdateTexturePriority;
  282. MCDUPDATETEXTUREPRIORITYFUNC pMCDUpdateTextureState;
  283. MCDTEXTURESTATUSFUNC pMCDTextureStatus;
  284. MCDTEXTUREKEYFUNC pMCDTextureKey;
  285. MCDDESCRIBEMCDLAYERPLANEFUNC pMCDDescribeMcdLayerPlane;
  286. MCDDESCRIBELAYERPLANEFUNC pMCDDescribeLayerPlane;
  287. MCDSETLAYERPALETTEFUNC pMCDSetLayerPalette;
  288. MCDDRAWPIXELS pMCDDrawPixels;
  289. MCDREADPIXELS pMCDReadPixels;
  290. MCDCOPYPIXELS pMCDCopyPixels;
  291. MCDPIXELMAP pMCDPixelMap;
  292. MCDDESTROYWINDOW pMCDDestroyWindow;
  293. MCDGETTEXTUREFORMATS pMCDGetTextureFormats;
  294. MCDSWAPMULTIPLE pMCDSwapMultiple;
  295. MCDPROCESSBATCH2FUNC pMCDProcessBatch2;
  296. } MCDTABLE;
  297. extern MCDTABLE *gpMcdTable;
  298. extern MCDDRIVERINFOI McdDriverInfo;
  299. #endif