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

多媒体编程

开发平台:

Visual C++

  1. /*
  2.      File:       QD3DView.h
  3.  
  4.      Contains:   View 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 __QD3DVIEW__
  18. #define __QD3DVIEW__
  19. #ifndef __QD3D__
  20. #include "QD3D.h"
  21. #endif
  22. #ifndef __QD3DSTYLE__
  23. #include "QD3DStyle.h"
  24. #endif
  25. #ifndef __QD3DSET__
  26. #include "QD3DSet.h"
  27. #endif
  28. #if PRAGMA_ONCE
  29. #pragma once
  30. #endif
  31. #ifdef __cplusplus
  32. extern "C" {
  33. #endif
  34. #if PRAGMA_IMPORT
  35. #pragma import on
  36. #endif
  37. #if PRAGMA_STRUCT_ALIGN
  38.     #pragma options align=power
  39. #elif PRAGMA_STRUCT_PACKPUSH
  40.     #pragma pack(push, 2)
  41. #elif PRAGMA_STRUCT_PACK
  42.     #pragma pack(2)
  43. #endif
  44. #if PRAGMA_ENUM_ALWAYSINT
  45.     #if defined(__fourbyteints__) && !__fourbyteints__ 
  46.         #define __QD3DVIEW__RESTORE_TWOBYTEINTS
  47.         #pragma fourbyteints on
  48.     #endif
  49.     #pragma enumsalwaysint on
  50. #elif PRAGMA_ENUM_OPTIONS
  51.     #pragma option enum=int
  52. #elif PRAGMA_ENUM_PACK
  53.     #if __option(pack_enums)
  54.         #define __QD3DVIEW__RESTORE_PACKED_ENUMS
  55.         #pragma options(!pack_enums)
  56.     #endif
  57. #endif
  58. /******************************************************************************
  59.  **                                                                          **
  60.  **                     View Type Definitions                                **
  61.  **                                                                          **
  62.  *****************************************************************************/
  63. enum TQ3ViewStatus {
  64.     kQ3ViewStatusDone           = 0,
  65.     kQ3ViewStatusRetraverse     = 1,
  66.     kQ3ViewStatusError          = 2,
  67.     kQ3ViewStatusCancelled      = 3
  68. };
  69. typedef enum TQ3ViewStatus TQ3ViewStatus;
  70. /******************************************************************************
  71.  **                                                                          **
  72.  **                     Default Attribute Set                                **
  73.  **                                                                          **
  74.  *****************************************************************************/
  75. #define kQ3ViewDefaultAmbientCoefficient    1.0
  76. #define kQ3ViewDefaultDiffuseColor          1.0, 1.0, 1.0
  77. #define kQ3ViewDefaultSpecularColor         0.5, 0.5, 0.5
  78. #define kQ3ViewDefaultSpecularControl       4.0
  79. #define kQ3ViewDefaultTransparency          1.0, 1.0, 1.0
  80. #define kQ3ViewDefaultHighlightState        kQ3Off
  81. #define kQ3ViewDefaultHighlightColor        1.0, 0.0, 0.0
  82. #define kQ3ViewDefaultSubdivisionMethod     kQ3SubdivisionMethodScreenSpace
  83. #define kQ3ViewDefaultSubdivisionC1         20.0
  84. #define kQ3ViewDefaultSubdivisionC2         20.0
  85. /******************************************************************************
  86.  **                                                                          **
  87.  **                         View Routines                                    **
  88.  **                                                                          **
  89.  *****************************************************************************/
  90. #if CALL_NOT_IN_CARBON
  91. EXTERN_API_C( TQ3ViewObject )
  92. Q3View_New                      (void);
  93. EXTERN_API_C( TQ3Status )
  94. Q3View_Cancel                   (TQ3ViewObject          view);
  95. /******************************************************************************
  96.  **                                                                          **
  97.  **                     View Rendering routines                              **
  98.  **                                                                          **
  99.  *****************************************************************************/
  100. EXTERN_API_C( TQ3Status )
  101. Q3View_SetRendererByType        (TQ3ViewObject          view,
  102.                                  TQ3ObjectType          theType);
  103. EXTERN_API_C( TQ3Status )
  104. Q3View_SetRenderer              (TQ3ViewObject          view,
  105.                                  TQ3RendererObject      renderer);
  106. EXTERN_API_C( TQ3Status )
  107. Q3View_GetRenderer              (TQ3ViewObject          view,
  108.                                  TQ3RendererObject *    renderer);
  109. EXTERN_API_C( TQ3Status )
  110. Q3View_StartRendering           (TQ3ViewObject          view);
  111. EXTERN_API_C( TQ3ViewStatus )
  112. Q3View_EndRendering             (TQ3ViewObject          view);
  113. EXTERN_API_C( TQ3Status )
  114. Q3View_Flush                    (TQ3ViewObject          view);
  115. EXTERN_API_C( TQ3Status )
  116. Q3View_Sync                     (TQ3ViewObject          view);
  117. /******************************************************************************
  118.  **                                                                          **
  119.  **                     View/Bounds/Pick routines                            **
  120.  **                                                                          **
  121.  *****************************************************************************/
  122. EXTERN_API_C( TQ3Status )
  123. Q3View_StartBoundingBox         (TQ3ViewObject          view,
  124.                                  TQ3ComputeBounds       computeBounds);
  125. EXTERN_API_C( TQ3ViewStatus )
  126. Q3View_EndBoundingBox           (TQ3ViewObject          view,
  127.                                  TQ3BoundingBox *       result);
  128. EXTERN_API_C( TQ3Status )
  129. Q3View_StartBoundingSphere      (TQ3ViewObject          view,
  130.                                  TQ3ComputeBounds       computeBounds);
  131. EXTERN_API_C( TQ3ViewStatus )
  132. Q3View_EndBoundingSphere        (TQ3ViewObject          view,
  133.                                  TQ3BoundingSphere *    result);
  134. EXTERN_API_C( TQ3Status )
  135. Q3View_StartPicking             (TQ3ViewObject          view,
  136.                                  TQ3PickObject          pick);
  137. EXTERN_API_C( TQ3ViewStatus )
  138. Q3View_EndPicking               (TQ3ViewObject          view);
  139. /******************************************************************************
  140.  **                                                                          **
  141.  **                         View/Camera routines                             **
  142.  **                                                                          **
  143.  *****************************************************************************/
  144. EXTERN_API_C( TQ3Status )
  145. Q3View_GetCamera                (TQ3ViewObject          view,
  146.                                  TQ3CameraObject *      camera);
  147. EXTERN_API_C( TQ3Status )
  148. Q3View_SetCamera                (TQ3ViewObject          view,
  149.                                  TQ3CameraObject        camera);
  150. /******************************************************************************
  151.  **                                                                          **
  152.  **                         View/Lights routines                             **
  153.  **                                                                          **
  154.  *****************************************************************************/
  155. EXTERN_API_C( TQ3Status )
  156. Q3View_SetLightGroup            (TQ3ViewObject          view,
  157.                                  TQ3GroupObject         lightGroup);
  158. EXTERN_API_C( TQ3Status )
  159. Q3View_GetLightGroup            (TQ3ViewObject          view,
  160.                                  TQ3GroupObject *       lightGroup);
  161. /******************************************************************************
  162.  **                                                                          **
  163.  **                             Idle Method                                  **
  164.  **                                                                          **
  165.  *****************************************************************************/
  166. /*
  167.  *  The idle methods allow the application to register callback routines 
  168.  *  which will be called by the view during especially long operations.
  169.  *
  170.  *  The idle methods may also be used to interrupt long renderings or
  171.  *  traversals.  Inside the idler callback the application can check for
  172.  *  Command-Period, Control-C or clicking a "Cancel" button or whatever else
  173.  *  may be used to let the user interrupt rendering.    
  174.  *
  175.  *  It is NOT LEGAL to call QD3D routines inside an idler callback.
  176.  *
  177.  *  Return kQ3Failure to cancel rendering, kQ3Success to continue. Don't
  178.  *  bother posting an error.
  179.  *
  180.  *  Q3View_SetIdleMethod registers a callback that can be called
  181.  *  by the system during rendering.  Unfortunately there is no way yet
  182.  *  to set timer intervals when you want to be called.  Basically, it is
  183.  *  up to the application's idler callback to check clocks to see if you
  184.  *  were called back only a millisecond ago or an hour ago!
  185.  *
  186.  *  Q3View_SetIdleProgressMethod registers a callback that also gives
  187.  *  progress information. This information is supplied by the renderer, and
  188.  *  may or may not be based on real time.
  189.  *
  190.  *  If a renderer doesn't support the progress method, your method will be
  191.  *  called with current == 0 and completed == 0.
  192.  *  
  193.  *  Otherwise, you are GUARANTEED to get called at least 2 or more times:
  194.  *  
  195.  *  ONCE            idleMethod(view, 0, n)      -> Initialize, Show Dialog
  196.  *  zero or more    idleMethod(view, 1..n-1, n) -> Update progress
  197.  *  ONCE            idleMethod(view, n, n)      -> Exit, Hide Dialog
  198.  *  
  199.  *  "current" is guaranteed to be less than or equal to "completed"
  200.  *  "completed" may change values, but current/complete always indicates
  201.  *  the degree of completion.
  202.  *
  203.  *  The calling conventions aid in managing any data associated with a 
  204.  *  progress user interface indicator.
  205.  */
  206. #endif  /* CALL_NOT_IN_CARBON */
  207. typedef CALLBACK_API_C( TQ3Status , TQ3ViewIdleMethod )(TQ3ViewObject view, const void *idlerData);
  208. typedef CALLBACK_API_C( TQ3Status , TQ3ViewIdleProgressMethod )(TQ3ViewObject view, const void *idlerData, unsigned long current, unsigned long completed);
  209. #if CALL_NOT_IN_CARBON
  210. EXTERN_API_C( TQ3Status )
  211. Q3View_SetIdleMethod            (TQ3ViewObject          view,
  212.                                  TQ3ViewIdleMethod      idleMethod,
  213.                                  const void *           idleData);
  214. EXTERN_API_C( TQ3Status )
  215. Q3View_SetIdleProgressMethod    (TQ3ViewObject          view,
  216.                                  TQ3ViewIdleProgressMethod  idleMethod,
  217.                                  const void *           idleData);
  218. /******************************************************************************
  219.  **                                                                          **
  220.  **                             EndFrame Method                              **
  221.  **                                                                          **
  222.  *****************************************************************************/
  223. /*
  224.  *  The end frame method is an alternate way of determining when an
  225.  *  asynchronous renderer has completed rendering a frame. It differs from
  226.  *  Q3View_Sync in that notification of the frame completion is the opposite
  227.  *  direction. 
  228.  *  
  229.  *  With Q3View_Sync the application asks a renderer to finish rendering
  230.  *  a frame, and blocks until the frame is complete.
  231.  *  
  232.  *  With the EndFrame method, the renderer tells the application that is has
  233.  *  completed a frame.
  234.  *
  235.  *  If "Q3View_Sync" is called BEFORE this method has been called, this
  236.  *  method will NOT be called ever.
  237.  *  
  238.  *  If "Q3View_Sync" is called AFTER this method has been called, the
  239.  *  call will return immediately (as the frame has already been completed).
  240.  */
  241. #endif  /* CALL_NOT_IN_CARBON */
  242. typedef CALLBACK_API_C( void , TQ3ViewEndFrameMethod )(TQ3ViewObject view, void *endFrameData);
  243. #if CALL_NOT_IN_CARBON
  244. EXTERN_API_C( TQ3Status )
  245. Q3View_SetEndFrameMethod        (TQ3ViewObject          view,
  246.                                  TQ3ViewEndFrameMethod  endFrame,
  247.                                  void *                 endFrameData);
  248. /******************************************************************************
  249.  **                                                                          **
  250.  **                         Push/Pop routines                                **
  251.  **                                                                          **
  252.  *****************************************************************************/
  253. EXTERN_API_C( TQ3Status )
  254. Q3Push_Submit                   (TQ3ViewObject          view);
  255. EXTERN_API_C( TQ3Status )
  256. Q3Pop_Submit                    (TQ3ViewObject          view);
  257. EXTERN_API_C( TQ3StateOperatorObject )
  258. Q3Push_New                      (void);
  259. EXTERN_API_C( TQ3StateOperatorObject )
  260. Q3Pop_New                       (void);
  261. EXTERN_API_C( TQ3Status )
  262. Q3StateOperator_Submit          (TQ3StateOperatorObject  stateOperator,
  263.                                  TQ3ViewObject          view);
  264. /******************************************************************************
  265.  **                                                                          **
  266.  **     Check if bounding box is visible in the viewing frustum.  Transforms **
  267.  **     the bbox by the current local_to_world transformation matrix and     **
  268.  **     does a clip test to see if it lies in the viewing frustum.           **
  269.  **     This can be used by applications to cull out large chunks of scenes  **
  270.  **     that are not going to be visible.                                    **
  271.  **                                                                          **
  272.  **     The default implementation is to always return kQ3True.  Renderers   **
  273.  **     may override this routine however to do the checking.                **
  274.  **                                                                          **
  275.  *****************************************************************************/
  276. EXTERN_API_C( TQ3Boolean )
  277. Q3View_IsBoundingBoxVisible     (TQ3ViewObject          view,
  278.                                  const TQ3BoundingBox * bbox);
  279. /******************************************************************************
  280.  **                                                                          **
  281.  **     Allows display groups to be culled if they are assigned bounding     **
  282.  **     boxes.                                                               **
  283.  **                                                                          **
  284.  *****************************************************************************/
  285. EXTERN_API_C( TQ3Status )
  286. Q3View_AllowAllGroupCulling     (TQ3ViewObject          view,
  287.                                  TQ3Boolean             allowCulling);
  288. /******************************************************************************
  289.  **                                                                          **
  290.  **                         DrawContext routines                             **
  291.  **                                                                          **
  292.  *****************************************************************************/
  293. EXTERN_API_C( TQ3Status )
  294. Q3View_SetDrawContext           (TQ3ViewObject          view,
  295.                                  TQ3DrawContextObject   drawContext);
  296. EXTERN_API_C( TQ3Status )
  297. Q3View_GetDrawContext           (TQ3ViewObject          view,
  298.                                  TQ3DrawContextObject * drawContext);
  299. /******************************************************************************
  300.  **                                                                          **
  301.  **                         Graphics State routines                          **
  302.  **                                                                          **
  303.  ** The graphics state routines can only be called while rendering (ie. in   **
  304.  ** between calls to start and end rendering calls).  If they are called     **
  305.  ** outside of a rendering loop, they will return with error.                **
  306.  **                                                                          **
  307.  *****************************************************************************/
  308. /******************************************************************************
  309.  **                                                                          **
  310.  **                         Transform routines                               **
  311.  **                                                                          **
  312.  *****************************************************************************/
  313. EXTERN_API_C( TQ3Status )
  314. Q3View_GetLocalToWorldMatrixState (TQ3ViewObject        view,
  315.                                  TQ3Matrix4x4 *         matrix);
  316. EXTERN_API_C( TQ3Status )
  317. Q3View_GetWorldToFrustumMatrixState (TQ3ViewObject      view,
  318.                                  TQ3Matrix4x4 *         matrix);
  319. EXTERN_API_C( TQ3Status )
  320. Q3View_GetFrustumToWindowMatrixState (TQ3ViewObject     view,
  321.                                  TQ3Matrix4x4 *         matrix);
  322. /******************************************************************************
  323.  **                                                                          **
  324.  **                         Style state routines                             **
  325.  **                                                                          **
  326.  *****************************************************************************/
  327. EXTERN_API_C( TQ3Status )
  328. Q3View_GetBackfacingStyleState  (TQ3ViewObject          view,
  329.                                  TQ3BackfacingStyle *   backfacingStyle);
  330. EXTERN_API_C( TQ3Status )
  331. Q3View_GetInterpolationStyleState (TQ3ViewObject        view,
  332.                                  TQ3InterpolationStyle * interpolationType);
  333. EXTERN_API_C( TQ3Status )
  334. Q3View_GetFillStyleState        (TQ3ViewObject          view,
  335.                                  TQ3FillStyle *         fillStyle);
  336. EXTERN_API_C( TQ3Status )
  337. Q3View_GetHighlightStyleState   (TQ3ViewObject          view,
  338.                                  TQ3AttributeSet *      highlightStyle);
  339. EXTERN_API_C( TQ3Status )
  340. Q3View_GetSubdivisionStyleState (TQ3ViewObject          view,
  341.                                  TQ3SubdivisionStyleData * subdivisionStyle);
  342. EXTERN_API_C( TQ3Status )
  343. Q3View_GetOrientationStyleState (TQ3ViewObject          view,
  344.                                  TQ3OrientationStyle *  fontFacingDirectionStyle);
  345. EXTERN_API_C( TQ3Status )
  346. Q3View_GetReceiveShadowsStyleState (TQ3ViewObject       view,
  347.                                  TQ3Boolean *           receives);
  348. EXTERN_API_C( TQ3Status )
  349. Q3View_GetPickIDStyleState      (TQ3ViewObject          view,
  350.                                  unsigned long *        pickIDStyle);
  351. EXTERN_API_C( TQ3Status )
  352. Q3View_GetPickPartsStyleState   (TQ3ViewObject          view,
  353.                                  TQ3PickParts *         pickPartsStyle);
  354. EXTERN_API_C( TQ3Status )
  355. Q3View_GetAntiAliasStyleState   (TQ3ViewObject          view,
  356.                                  TQ3AntiAliasStyleData * antiAliasData);
  357. /******************************************************************************
  358.  **                                                                          **
  359.  **                     Attribute state routines                             **
  360.  **                                                                          **
  361.  *****************************************************************************/
  362. EXTERN_API_C( TQ3Status )
  363. Q3View_GetDefaultAttributeSet   (TQ3ViewObject          view,
  364.                                  TQ3AttributeSet *      attributeSet);
  365. EXTERN_API_C( TQ3Status )
  366. Q3View_SetDefaultAttributeSet   (TQ3ViewObject          view,
  367.                                  TQ3AttributeSet        attributeSet);
  368. EXTERN_API_C( TQ3Status )
  369. Q3View_GetAttributeSetState     (TQ3ViewObject          view,
  370.                                  TQ3AttributeSet *      attributeSet);
  371. EXTERN_API_C( TQ3Status )
  372. Q3View_GetAttributeState        (TQ3ViewObject          view,
  373.                                  TQ3AttributeType       attributeType,
  374.                                  void *                 data);
  375. #endif  /* CALL_NOT_IN_CARBON */
  376. #if PRAGMA_ENUM_ALWAYSINT
  377.     #pragma enumsalwaysint reset
  378.     #ifdef __QD3DVIEW__RESTORE_TWOBYTEINTS
  379.         #pragma fourbyteints off
  380.     #endif
  381. #elif PRAGMA_ENUM_OPTIONS
  382.     #pragma option enum=reset
  383. #elif defined(__QD3DVIEW__RESTORE_PACKED_ENUMS)
  384.     #pragma options(pack_enums)
  385. #endif
  386. #if PRAGMA_STRUCT_ALIGN
  387.     #pragma options align=reset
  388. #elif PRAGMA_STRUCT_PACKPUSH
  389.     #pragma pack(pop)
  390. #elif PRAGMA_STRUCT_PACK
  391.     #pragma pack()
  392. #endif
  393. #ifdef PRAGMA_IMPORT_OFF
  394. #pragma import off
  395. #elif PRAGMA_IMPORT
  396. #pragma import reset
  397. #endif
  398. #ifdef __cplusplus
  399. }
  400. #endif
  401. #endif /* __QD3DVIEW__ */