QD3DDrawContext.h
上传用户:xjjlds
上传日期:2015-12-05
资源大小:22823k
文件大小:20k
源码类别:

多媒体编程

开发平台:

Visual C++

  1. /*
  2.      File:       QD3DDrawContext.h
  3.  
  4.      Contains:   Draw context class types and routines
  5.  
  6.      Version:    Technology: Quickdraw 3D 1.6
  7.                  Release:    QuickTime 6.0.2
  8.  
  9.      Copyright:  (c) 1995-2001 by Apple Computer, Inc., all rights reserved.
  10.  
  11.      Bugs?:      For bug reports, consult the following page on
  12.                  the World Wide Web:
  13.  
  14.                      http://developer.apple.com/bugreporter/
  15.  
  16. */
  17. #ifndef __QD3DDRAWCONTEXT__
  18. #define __QD3DDRAWCONTEXT__
  19. #ifndef __QD3D__
  20. #include "QD3D.h"
  21. #endif
  22. #if TARGET_OS_MAC
  23. #ifndef __QUICKDRAW__
  24. #include "Quickdraw.h"
  25. #endif
  26. #ifndef __FIXMATH__
  27. #include "FixMath.h"
  28. #endif
  29. #ifndef __GXTYPES__
  30. #include "GXTypes.h"
  31. #endif
  32. #endif  /* TARGET_OS_MAC */
  33. #if TARGET_OS_UNIX
  34.     #include "X11/Xlib.h"
  35.   #include "X11/Xutil.h"
  36. #endif   /* TARGET_OS_WIN32 */
  37. #if TARGET_OS_WIN32
  38.    /******************************************************************************
  39.      *                                                                           **
  40.      * ABOUT   QD3D_NO_DIRECTDRAW:   (Win32 Only)                                **
  41.      *                                                                           **
  42.      * NOTE: Define QD3D_NO_DIRECTDRAW for your application makefile/project     **
  43.      *       only if you don't need Q3DDSurfaceDrawContext support and don't     **
  44.      *       have access to ddraw.h.                                             ** 
  45.     *                                                                           **
  46.      *****************************************************************************/
  47.     #include "windows.h"
  48.    #if !defined(QD3D_NO_DIRECTDRAW)
  49.        #include "ddraw.h"
  50.  #endif /* !QD3D_NO_DIRECTDRAW */
  51. #endif  /*  TARGET_OS_WIN32  */
  52. #if PRAGMA_ONCE
  53. #pragma once
  54. #endif
  55. #ifdef __cplusplus
  56. extern "C" {
  57. #endif
  58. #if PRAGMA_IMPORT
  59. #pragma import on
  60. #endif
  61. #if PRAGMA_STRUCT_ALIGN
  62.     #pragma options align=power
  63. #elif PRAGMA_STRUCT_PACKPUSH
  64.     #pragma pack(push, 2)
  65. #elif PRAGMA_STRUCT_PACK
  66.     #pragma pack(2)
  67. #endif
  68. #if PRAGMA_ENUM_ALWAYSINT
  69.     #if defined(__fourbyteints__) && !__fourbyteints__ 
  70.         #define __QD3DDRAWCONTEXT__RESTORE_TWOBYTEINTS
  71.         #pragma fourbyteints on
  72.     #endif
  73.     #pragma enumsalwaysint on
  74. #elif PRAGMA_ENUM_OPTIONS
  75.     #pragma option enum=int
  76. #elif PRAGMA_ENUM_PACK
  77.     #if __option(pack_enums)
  78.         #define __QD3DDRAWCONTEXT__RESTORE_PACKED_ENUMS
  79.         #pragma options(!pack_enums)
  80.     #endif
  81. #endif
  82. /******************************************************************************
  83.  **                                                                          **
  84.  **                         DrawContext Data Structures                      **
  85.  **                                                                          **
  86.  *****************************************************************************/
  87. enum TQ3DrawContextClearImageMethod {
  88.     kQ3ClearMethodNone          = 0,
  89.     kQ3ClearMethodWithColor     = 1
  90. };
  91. typedef enum TQ3DrawContextClearImageMethod TQ3DrawContextClearImageMethod;
  92. struct TQ3DrawContextData {
  93.     TQ3DrawContextClearImageMethod  clearImageMethod;
  94.     TQ3ColorARGB                    clearImageColor;
  95.     TQ3Area                         pane;
  96.     TQ3Boolean                      paneState;
  97.     TQ3Bitmap                       mask;
  98.     TQ3Boolean                      maskState;
  99.     TQ3Boolean                      doubleBufferState;
  100. };
  101. typedef struct TQ3DrawContextData       TQ3DrawContextData;
  102. /******************************************************************************
  103.  **                                                                          **
  104.  **                             DrawContext Routines                         **
  105.  **                                                                          **
  106.  *****************************************************************************/
  107. #if CALL_NOT_IN_CARBON
  108. EXTERN_API_C( TQ3ObjectType )
  109. Q3DrawContext_GetType           (TQ3DrawContextObject   drawContext);
  110. EXTERN_API_C( TQ3Status )
  111. Q3DrawContext_SetData           (TQ3DrawContextObject   context,
  112.                                  const TQ3DrawContextData * contextData);
  113. EXTERN_API_C( TQ3Status )
  114. Q3DrawContext_GetData           (TQ3DrawContextObject   context,
  115.                                  TQ3DrawContextData *   contextData);
  116. EXTERN_API_C( TQ3Status )
  117. Q3DrawContext_SetClearImageColor (TQ3DrawContextObject  context,
  118.                                  const TQ3ColorARGB *   color);
  119. EXTERN_API_C( TQ3Status )
  120. Q3DrawContext_GetClearImageColor (TQ3DrawContextObject  context,
  121.                                  TQ3ColorARGB *         color);
  122. EXTERN_API_C( TQ3Status )
  123. Q3DrawContext_SetPane           (TQ3DrawContextObject   context,
  124.                                  const TQ3Area *        pane);
  125. EXTERN_API_C( TQ3Status )
  126. Q3DrawContext_GetPane           (TQ3DrawContextObject   context,
  127.                                  TQ3Area *              pane);
  128. EXTERN_API_C( TQ3Status )
  129. Q3DrawContext_SetPaneState      (TQ3DrawContextObject   context,
  130.                                  TQ3Boolean             state);
  131. EXTERN_API_C( TQ3Status )
  132. Q3DrawContext_GetPaneState      (TQ3DrawContextObject   context,
  133.                                  TQ3Boolean *           state);
  134. EXTERN_API_C( TQ3Status )
  135. Q3DrawContext_SetClearImageMethod (TQ3DrawContextObject  context,
  136.                                  TQ3DrawContextClearImageMethod  method);
  137. EXTERN_API_C( TQ3Status )
  138. Q3DrawContext_GetClearImageMethod (TQ3DrawContextObject  context,
  139.                                  TQ3DrawContextClearImageMethod * method);
  140. EXTERN_API_C( TQ3Status )
  141. Q3DrawContext_SetMask           (TQ3DrawContextObject   context,
  142.                                  const TQ3Bitmap *      mask);
  143. EXTERN_API_C( TQ3Status )
  144. Q3DrawContext_GetMask           (TQ3DrawContextObject   context,
  145.                                  TQ3Bitmap *            mask);
  146. EXTERN_API_C( TQ3Status )
  147. Q3DrawContext_SetMaskState      (TQ3DrawContextObject   context,
  148.                                  TQ3Boolean             state);
  149. EXTERN_API_C( TQ3Status )
  150. Q3DrawContext_GetMaskState      (TQ3DrawContextObject   context,
  151.                                  TQ3Boolean *           state);
  152. EXTERN_API_C( TQ3Status )
  153. Q3DrawContext_SetDoubleBufferState (TQ3DrawContextObject  context,
  154.                                  TQ3Boolean             state);
  155. EXTERN_API_C( TQ3Status )
  156. Q3DrawContext_GetDoubleBufferState (TQ3DrawContextObject  context,
  157.                                  TQ3Boolean *           state);
  158. /******************************************************************************
  159.  **                                                                          **
  160.  **                         Pixmap Data Structure                            **
  161.  **                                                                          **
  162.  *****************************************************************************/
  163. #endif  /* CALL_NOT_IN_CARBON */
  164. struct TQ3PixmapDrawContextData {
  165.     TQ3DrawContextData              drawContextData;
  166.     TQ3Pixmap                       pixmap;
  167. };
  168. typedef struct TQ3PixmapDrawContextData TQ3PixmapDrawContextData;
  169. /******************************************************************************
  170.  **                                                                          **
  171.  **                     Pixmap DrawContext Routines                          **
  172.  **                                                                          **
  173.  *****************************************************************************/
  174. #if CALL_NOT_IN_CARBON
  175. EXTERN_API_C( TQ3DrawContextObject )
  176. Q3PixmapDrawContext_New         (const TQ3PixmapDrawContextData * contextData);
  177. EXTERN_API_C( TQ3Status )
  178. Q3PixmapDrawContext_SetPixmap   (TQ3DrawContextObject   drawContext,
  179.                                  const TQ3Pixmap *      pixmap);
  180. EXTERN_API_C( TQ3Status )
  181. Q3PixmapDrawContext_GetPixmap   (TQ3DrawContextObject   drawContext,
  182.                                  TQ3Pixmap *            pixmap);
  183. #endif  /* CALL_NOT_IN_CARBON */
  184. #if TARGET_OS_MAC
  185. /******************************************************************************
  186.  **                                                                          **
  187.  **                     Macintosh DrawContext Data Structures                **
  188.  **                                                                          **
  189.  *****************************************************************************/
  190. enum TQ3MacDrawContext2DLibrary {
  191.     kQ3Mac2DLibraryNone         = 0,
  192.     kQ3Mac2DLibraryQuickDraw    = 1,
  193.     kQ3Mac2DLibraryQuickDrawGX  = 2
  194. };
  195. typedef enum TQ3MacDrawContext2DLibrary TQ3MacDrawContext2DLibrary;
  196. struct TQ3MacDrawContextData {
  197.     TQ3DrawContextData              drawContextData;
  198.     CWindowPtr                      window;
  199.     TQ3MacDrawContext2DLibrary      library;
  200.     gxViewPort                      viewPort;
  201.     CGrafPtr                        grafPort;
  202. };
  203. typedef struct TQ3MacDrawContextData    TQ3MacDrawContextData;
  204. /******************************************************************************
  205.  **                                                                          **
  206.  **                     Macintosh DrawContext Routines                       **
  207.  **                                                                          **
  208.  *****************************************************************************/
  209. #if CALL_NOT_IN_CARBON
  210. EXTERN_API_C( TQ3DrawContextObject )
  211. Q3MacDrawContext_New            (const TQ3MacDrawContextData * drawContextData);
  212. EXTERN_API_C( TQ3Status )
  213. Q3MacDrawContext_SetWindow      (TQ3DrawContextObject   drawContext,
  214.                                  CWindowPtr             window);
  215. EXTERN_API_C( TQ3Status )
  216. Q3MacDrawContext_GetWindow      (TQ3DrawContextObject   drawContext,
  217.                                  CWindowPtr *           window);
  218. EXTERN_API_C( TQ3Status )
  219. Q3MacDrawContext_SetGXViewPort  (TQ3DrawContextObject   drawContext,
  220.                                  gxViewPort             viewPort);
  221. EXTERN_API_C( TQ3Status )
  222. Q3MacDrawContext_GetGXViewPort  (TQ3DrawContextObject   drawContext,
  223.                                  gxViewPort *           viewPort);
  224. EXTERN_API_C( TQ3Status )
  225. Q3MacDrawContext_SetGrafPort    (TQ3DrawContextObject   drawContext,
  226.                                  CGrafPtr               grafPort);
  227. EXTERN_API_C( TQ3Status )
  228. Q3MacDrawContext_GetGrafPort    (TQ3DrawContextObject   drawContext,
  229.                                  CGrafPtr *             grafPort);
  230. EXTERN_API_C( TQ3Status )
  231. Q3MacDrawContext_Set2DLibrary   (TQ3DrawContextObject   drawContext,
  232.                                  TQ3MacDrawContext2DLibrary  library);
  233. EXTERN_API_C( TQ3Status )
  234. Q3MacDrawContext_Get2DLibrary   (TQ3DrawContextObject   drawContext,
  235.                                  TQ3MacDrawContext2DLibrary * library);
  236. #endif  /* CALL_NOT_IN_CARBON */
  237. #endif  /* TARGET_OS_MAC */
  238. #if TARGET_OS_UNIX
  239. /******************************************************************************
  240.  **                                                                          **
  241.  **                     X/Windows DrawContext Data Structures                **
  242.  **                                                                          **
  243.  *****************************************************************************/
  244. typedef struct OpaqueTQ3XBufferObject*  TQ3XBufferObject;
  245. struct TQ3XColormapData {
  246.     long                            baseEntry;
  247.     long                            maxRed;
  248.     long                            maxGreen;
  249.     long                            maxBlue;
  250.     long                            multRed;
  251.     long                            multGreen;
  252.     long                            multBlue;
  253. };
  254. typedef struct TQ3XColormapData         TQ3XColormapData;
  255. struct TQ3XDrawContextData {
  256.     TQ3DrawContextData              contextData;
  257.     Display *                       display;
  258.     Drawable                        drawable;
  259.     Visual *                        visual;
  260.     Colormap                        cmap;
  261.     TQ3XColormapData *              colorMapData;
  262. };
  263. typedef struct TQ3XDrawContextData      TQ3XDrawContextData;
  264. /******************************************************************************
  265.  **                                                                          **
  266.  **                     X/Windows DrawContext Routines                       **
  267.  **                                                                          **
  268.  *****************************************************************************/
  269. #ifdef XDC_OLD
  270. #if CALL_NOT_IN_CARBON
  271. EXTERN_API_C( TQ3DrawContextObject )
  272. Q3XDrawContext_New              (void);
  273. EXTERN_API_C( void )
  274. Q3XDrawContext_Set              (TQ3DrawContextObject   drawContext,
  275.                                  unsigned long          flag,
  276.                                  void *                 data);
  277. EXTERN_API_C( void )
  278. Q3XDrawContext_Get              (TQ3DrawContextObject   drawContext,
  279.                                  unsigned long          flag,
  280.                                  void *                 data);
  281. #endif  /* CALL_NOT_IN_CARBON */
  282. #endif  /* defined(XDC_OLD) */
  283. #if CALL_NOT_IN_CARBON
  284. EXTERN_API_C( TQ3XBufferObject )
  285. Q3XBuffers_New                  (Display *              dpy,
  286.                                  unsigned long          numBuffers,
  287.                                  Window                 window);
  288. EXTERN_API_C( void )
  289. Q3XBuffers_Swap                 (Display *              dpy,
  290.                                  TQ3XBufferObject       buffers);
  291. EXTERN_API_C( XVisualInfo *)
  292. Q3X_GetVisualInfo               (Display *              dpy,
  293.                                  Screen *               screen);
  294. EXTERN_API_C( TQ3DrawContextObject )
  295. Q3XDrawContext_New              (const TQ3XDrawContextData * xContextData);
  296. EXTERN_API_C( TQ3Status )
  297. Q3XDrawContext_SetDisplay       (TQ3DrawContextObject   drawContext,
  298.                                  const Display *        display);
  299. EXTERN_API_C( TQ3Status )
  300. Q3XDrawContext_GetDisplay       (TQ3DrawContextObject   drawContext,
  301.                                  Display **             display);
  302. EXTERN_API_C( TQ3Status )
  303. Q3XDrawContext_SetDrawable      (TQ3DrawContextObject   drawContext,
  304.                                  Drawable               drawable);
  305. EXTERN_API_C( TQ3Status )
  306. Q3XDrawContext_GetDrawable      (TQ3DrawContextObject   drawContext,
  307.                                  Drawable *             drawable);
  308. EXTERN_API_C( TQ3Status )
  309. Q3XDrawContext_SetVisual        (TQ3DrawContextObject   drawContext,
  310.                                  const Visual *         visual);
  311. EXTERN_API_C( TQ3Status )
  312. Q3XDrawContext_GetVisual        (TQ3DrawContextObject   drawContext,
  313.                                  Visual **              visual);
  314. EXTERN_API_C( TQ3Status )
  315. Q3XDrawContext_SetColormap      (TQ3DrawContextObject   drawContext,
  316.                                  Colormap               colormap);
  317. EXTERN_API_C( TQ3Status )
  318. Q3XDrawContext_GetColormap      (TQ3DrawContextObject   drawContext,
  319.                                  Colormap *             colormap);
  320. EXTERN_API_C( TQ3Status )
  321. Q3XDrawContext_SetColormapData  (TQ3DrawContextObject   drawContext,
  322.                                  const TQ3XColormapData * colormapData);
  323. EXTERN_API_C( TQ3Status )
  324. Q3XDrawContext_GetColormapData  (TQ3DrawContextObject   drawContext,
  325.                                  TQ3XColormapData *     colormapData);
  326. #endif  /* CALL_NOT_IN_CARBON */
  327. #endif  /* TARGET_OS_UNIX */
  328. #if TARGET_OS_WIN32
  329. /******************************************************************************
  330.  **                                                                          **
  331.  **                      Win32 DrawContext Data Structures                   **
  332.  **                                                                          **
  333.  *****************************************************************************/
  334. struct TQ3Win32DCDrawContextData {
  335.     TQ3DrawContextData              drawContextData;
  336.     HDC                             hdc;
  337. };
  338. typedef struct TQ3Win32DCDrawContextData TQ3Win32DCDrawContextData;
  339. #ifndef QD3D_NO_DIRECTDRAW
  340. enum TQ3DirectDrawObjectSelector {
  341.     kQ3DirectDrawObject         = 1,
  342.     kQ3DirectDrawObject2        = 2
  343. };
  344. typedef enum TQ3DirectDrawObjectSelector TQ3DirectDrawObjectSelector;
  345. enum TQ3DirectDrawSurfaceSelector {
  346.     kQ3DirectDrawSurface        = 1,
  347.     kQ3DirectDrawSurface2       = 2
  348. };
  349. typedef enum TQ3DirectDrawSurfaceSelector TQ3DirectDrawSurfaceSelector;
  350. struct TQ3DDSurfaceDescriptor {
  351.    TQ3DirectDrawObjectSelector     objectSelector;
  352.     union
  353.   {
  354.       LPDIRECTDRAW                lpDirectDraw;
  355.       LPDIRECTDRAW2               lpDirectDraw2;
  356.  };
  357.     TQ3DirectDrawSurfaceSelector    surfaceSelector;
  358.    union
  359.   {
  360.       LPDIRECTDRAWSURFACE         lpDirectDrawSurface;
  361.        LPDIRECTDRAWSURFACE2        lpDirectDrawSurface2;
  362.   };
  363. };
  364. typedef struct TQ3DDSurfaceDescriptor TQ3DDSurfaceDescriptor;
  365. struct TQ3DDSurfaceDrawContextData {
  366.   TQ3DrawContextData              drawContextData;
  367.    TQ3DDSurfaceDescriptor          ddSurfaceDescriptor;
  368. };
  369. typedef struct TQ3DDSurfaceDrawContextData TQ3DDSurfaceDrawContextData;
  370. #endif  /* !defined(QD3D_NO_DIRECTDRAW) */
  371. /******************************************************************************
  372.  **                                                                          **
  373.  **                         Win32DC DrawContext Routines                     **
  374.  **                                                                          **
  375.  *****************************************************************************/
  376. #if CALL_NOT_IN_CARBON
  377. EXTERN_API_C( TQ3DrawContextObject )
  378. Q3Win32DCDrawContext_New        (const TQ3Win32DCDrawContextData * drawContextData);
  379. EXTERN_API_C( TQ3Status )
  380. Q3Win32DCDrawContext_SetDC      (TQ3DrawContextObject   drawContext,
  381.                                  HDC                    newHDC);
  382. EXTERN_API_C( TQ3Status )
  383. Q3Win32DCDrawContext_GetDC      (TQ3DrawContextObject   drawContext,
  384.                                  HDC *                  curHDC);
  385. /******************************************************************************
  386.  **                                                                          **
  387.  **                         DDSurface DrawContext Routines                   **
  388.  **                                                                          **
  389.  *****************************************************************************/
  390. #endif  /* CALL_NOT_IN_CARBON */
  391. #ifndef QD3D_NO_DIRECTDRAW
  392. #if CALL_NOT_IN_CARBON
  393. EXTERN_API_C( TQ3DrawContextObject )
  394. Q3DDSurfaceDrawContext_New      (const TQ3DDSurfaceDrawContextData * drawContextData);
  395. EXTERN_API_C( TQ3Status )
  396. Q3DDSurfaceDrawContext_SetDirectDrawSurface (TQ3DrawContextObject  drawContext,
  397.                                  const TQ3DDSurfaceDescriptor * ddSurfaceDescriptor);
  398. EXTERN_API_C( TQ3Status )
  399. Q3DDSurfaceDrawContext_GetDirectDrawSurface (TQ3DrawContextObject  drawContext,
  400.                                  TQ3DDSurfaceDescriptor * ddSurfaceDescriptor);
  401. #endif  /* CALL_NOT_IN_CARBON */
  402. #endif  /* !defined(QD3D_NO_DIRECTDRAW) */
  403. #endif  /* TARGET_OS_WIN32 */
  404. #if PRAGMA_ENUM_ALWAYSINT
  405.     #pragma enumsalwaysint reset
  406.     #ifdef __QD3DDRAWCONTEXT__RESTORE_TWOBYTEINTS
  407.         #pragma fourbyteints off
  408.     #endif
  409. #elif PRAGMA_ENUM_OPTIONS
  410.     #pragma option enum=reset
  411. #elif defined(__QD3DDRAWCONTEXT__RESTORE_PACKED_ENUMS)
  412.     #pragma options(pack_enums)
  413. #endif
  414. #if PRAGMA_STRUCT_ALIGN
  415.     #pragma options align=reset
  416. #elif PRAGMA_STRUCT_PACKPUSH
  417.     #pragma pack(pop)
  418. #elif PRAGMA_STRUCT_PACK
  419.     #pragma pack()
  420. #endif
  421. #ifdef PRAGMA_IMPORT_OFF
  422. #pragma import off
  423. #elif PRAGMA_IMPORT
  424. #pragma import reset
  425. #endif
  426. #ifdef __cplusplus
  427. }
  428. #endif
  429. #endif /* __QD3DDRAWCONTEXT__ */