Team Fortress 2 Source Code as on 22/4/2020
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.

1770 lines
55 KiB

  1. /*
  2. File: QD3DRenderer.h
  3. Contains: Q3Renderer types and routines
  4. Version: Technology: Quickdraw 3D 1.6
  5. Release: QuickTime 7.3
  6. Copyright: (c) 2007 (c) 1995-1999 by Apple Computer, Inc., all rights reserved.
  7. Bugs?: For bug reports, consult the following page on
  8. the World Wide Web:
  9. http://developer.apple.com/bugreporter/
  10. */
  11. #ifndef __QD3DRENDERER__
  12. #define __QD3DRENDERER__
  13. #ifndef __QD3D__
  14. #include <QD3D.h>
  15. #endif
  16. #ifndef __QD3DSET__
  17. #include <QD3DSet.h>
  18. #endif
  19. #ifndef __QD3DVIEW__
  20. #include <QD3DView.h>
  21. #endif
  22. #ifndef __RAVE__
  23. #include <RAVE.h>
  24. #endif
  25. #if TARGET_OS_MAC
  26. #ifndef __EVENTS__
  27. #include <Events.h>
  28. #endif
  29. #endif /* TARGET_OS_MAC */
  30. #if PRAGMA_ONCE
  31. #pragma once
  32. #endif
  33. #ifdef __cplusplus
  34. extern "C" {
  35. #endif
  36. #if PRAGMA_IMPORT
  37. #pragma import on
  38. #endif
  39. #if PRAGMA_STRUCT_ALIGN
  40. #pragma options align=power
  41. #elif PRAGMA_STRUCT_PACKPUSH
  42. #pragma pack(push, 2)
  43. #elif PRAGMA_STRUCT_PACK
  44. #pragma pack(2)
  45. #endif
  46. #if PRAGMA_ENUM_ALWAYSINT
  47. #if defined(__fourbyteints__) && !__fourbyteints__
  48. #define __QD3DRENDERER__RESTORE_TWOBYTEINTS
  49. #pragma fourbyteints on
  50. #endif
  51. #pragma enumsalwaysint on
  52. #elif PRAGMA_ENUM_OPTIONS
  53. #pragma option enum=int
  54. #elif PRAGMA_ENUM_PACK
  55. #if __option(pack_enums)
  56. #define __QD3DRENDERER__RESTORE_PACKED_ENUMS
  57. #pragma options(!pack_enums)
  58. #endif
  59. #endif
  60. /******************************************************************************
  61. ** **
  62. ** User Interface Things **
  63. ** **
  64. *****************************************************************************/
  65. #if TARGET_OS_MAC
  66. /*
  67. * A callback to an application's event handling code. This is needed to
  68. * support movable modal dialogs. The dialog's event filter calls this
  69. * callback with events it does not handle.
  70. * If an application handles the event it should return kQ3True.
  71. * If the application does not handle the event it must return kQ3False and
  72. * the dialog's event filter will pass the event to the system unhandled.
  73. */
  74. typedef CALLBACK_API_C( TQ3Boolean , TQ3MacOSDialogEventHandler )(const EventRecord * event);
  75. struct TQ3DialogAnchor {
  76. TQ3MacOSDialogEventHandler clientEventHandler;
  77. };
  78. typedef struct TQ3DialogAnchor TQ3DialogAnchor;
  79. #endif /* TARGET_OS_MAC */
  80. #if TARGET_OS_WIN32
  81. struct TQ3DialogAnchor {
  82. HWND ownerWindow;
  83. };
  84. typedef struct TQ3DialogAnchor TQ3DialogAnchor;
  85. #endif /* TARGET_OS_WIN32 */
  86. #if TARGET_OS_UNIX
  87. struct TQ3DialogAnchor {
  88. void * notUsed; /* place holder */
  89. };
  90. typedef struct TQ3DialogAnchor TQ3DialogAnchor;
  91. #endif /* TARGET_OS_UNIX */
  92. /******************************************************************************
  93. ** **
  94. ** Renderer Functions **
  95. ** **
  96. *****************************************************************************/
  97. #if CALL_NOT_IN_CARBON
  98. /*
  99. * Q3Renderer_NewFromType()
  100. *
  101. * Availability:
  102. * Non-Carbon CFM: not available
  103. * CarbonLib: not available
  104. * Mac OS X: not available
  105. */
  106. EXTERN_API_C( TQ3RendererObject )
  107. Q3Renderer_NewFromType(TQ3ObjectType rendererObjectType);
  108. /*
  109. * Q3Renderer_GetType()
  110. *
  111. * Availability:
  112. * Non-Carbon CFM: not available
  113. * CarbonLib: not available
  114. * Mac OS X: not available
  115. */
  116. EXTERN_API_C( TQ3ObjectType )
  117. Q3Renderer_GetType(TQ3RendererObject renderer);
  118. /* Q3Renderer_Flush has been replaced by Q3View_Flush */
  119. /* Q3Renderer_Sync has been replaced by Q3View_Sync */
  120. #endif /* CALL_NOT_IN_CARBON */
  121. /*
  122. * Q3Renderer_IsInteractive
  123. * Determine if this renderer is intended to be used interactively.
  124. */
  125. #if CALL_NOT_IN_CARBON
  126. /*
  127. * Q3Renderer_IsInteractive()
  128. *
  129. * Availability:
  130. * Non-Carbon CFM: not available
  131. * CarbonLib: not available
  132. * Mac OS X: not available
  133. */
  134. EXTERN_API_C( TQ3Boolean )
  135. Q3Renderer_IsInteractive(TQ3RendererObject renderer);
  136. /*
  137. * Q3Renderer_HasModalConfigure
  138. * Determine if this renderer has a modal settings dialog.
  139. *
  140. * Q3Renderer_ModalConfigure
  141. * Have the renderer pop up a modal dialog box to configure its settings.
  142. * dialogAnchor - is platform specific data passed by the client to support
  143. * movable modal dialogs.
  144. * MacOS: this is a callback to the calling application's event handler.
  145. * The renderer calls this function with events not handled by the
  146. * settings dialog. This is necessary in order to support movable modal
  147. * dialogs. An application's event handler must return kQ3True if it
  148. * handles the event passed to the callback or kQ3False if not.
  149. * An application which doesn't want to support a movable modal configure
  150. * dialog should pass NULL for the clientEventHandler of TQ3DialogAnchor.
  151. * Win32: this is the HWND of the owning window (typically an application's
  152. * main window).
  153. * canceled - returns a boolean inditacating that the user canceled the
  154. * dialog.
  155. *
  156. */
  157. /*
  158. * Q3Renderer_HasModalConfigure()
  159. *
  160. * Availability:
  161. * Non-Carbon CFM: not available
  162. * CarbonLib: not available
  163. * Mac OS X: not available
  164. */
  165. EXTERN_API_C( TQ3Boolean )
  166. Q3Renderer_HasModalConfigure(TQ3RendererObject renderer);
  167. /*
  168. * Q3Renderer_ModalConfigure()
  169. *
  170. * Availability:
  171. * Non-Carbon CFM: not available
  172. * CarbonLib: not available
  173. * Mac OS X: not available
  174. */
  175. EXTERN_API_C( TQ3Status )
  176. Q3Renderer_ModalConfigure(
  177. TQ3RendererObject renderer,
  178. TQ3DialogAnchor dialogAnchor,
  179. TQ3Boolean * canceled);
  180. /*
  181. * Q3RendererClass_GetNickNameString
  182. * Allows an application to get a renderers name string, the
  183. * renderer is responsible for storing this in a localizable format
  184. * for example as a resource. This string can then be used to provide
  185. * a selection mechanism for an application (for example in a menu).
  186. *
  187. * If this call returns nil in the supplied string, then the App may
  188. * choose to use the class name for the renderer. You should always
  189. * try to get the name string before using the class name, since the
  190. * class name is not localizable.
  191. */
  192. /*
  193. * Q3RendererClass_GetNickNameString()
  194. *
  195. * Availability:
  196. * Non-Carbon CFM: not available
  197. * CarbonLib: not available
  198. * Mac OS X: not available
  199. */
  200. EXTERN_API_C( TQ3Status )
  201. Q3RendererClass_GetNickNameString(
  202. TQ3ObjectType rendererClassType,
  203. TQ3ObjectClassNameString rendererClassString);
  204. /*
  205. * Q3Renderer_GetConfigurationData
  206. * Allows an application to collect private renderer configuration data
  207. * which it will then save. For example in a preference file or in a
  208. * style template. An application should tag this data with the
  209. * Renderer's object name.
  210. *
  211. * if dataBuffer is NULL actualDataSize returns the required size in
  212. * bytes of a data buffer large enough to store private data.
  213. *
  214. * bufferSize is the actual size of the memory block pointed to by
  215. * dataBuffer
  216. *
  217. * actualDataSize - on return the actual number of bytes written to the
  218. * buffer or if dataBuffer is NULL the required size of dataBuffer
  219. *
  220. */
  221. /*
  222. * Q3Renderer_GetConfigurationData()
  223. *
  224. * Availability:
  225. * Non-Carbon CFM: not available
  226. * CarbonLib: not available
  227. * Mac OS X: not available
  228. */
  229. EXTERN_API_C( TQ3Status )
  230. Q3Renderer_GetConfigurationData(
  231. TQ3RendererObject renderer,
  232. unsigned char * dataBuffer,
  233. unsigned long bufferSize,
  234. unsigned long * actualDataSize);
  235. /*
  236. * Q3Renderer_SetConfigurationData()
  237. *
  238. * Availability:
  239. * Non-Carbon CFM: not available
  240. * CarbonLib: not available
  241. * Mac OS X: not available
  242. */
  243. EXTERN_API_C( TQ3Status )
  244. Q3Renderer_SetConfigurationData(
  245. TQ3RendererObject renderer,
  246. unsigned char * dataBuffer,
  247. unsigned long bufferSize);
  248. /******************************************************************************
  249. ** **
  250. ** Interactive Renderer Specific Functions **
  251. ** **
  252. *****************************************************************************/
  253. /* CSG IDs attribute */
  254. #define kQ3AttributeTypeConstructiveSolidGeometryID Q3_OBJECT_TYPE('c','s','g','i')
  255. /* Object IDs, to be applied as attributes on geometries */
  256. #endif /* CALL_NOT_IN_CARBON */
  257. #define kQ3SolidGeometryObjNone (-1)
  258. #define kQ3SolidGeometryObjA 0
  259. #define kQ3SolidGeometryObjB 1
  260. #define kQ3SolidGeometryObjC 2
  261. #define kQ3SolidGeometryObjD 3
  262. #define kQ3SolidGeometryObjE 4
  263. /* Possible CSG equations */
  264. enum TQ3CSGEquation {
  265. kQ3CSGEquationAandB = (long)0x88888888,
  266. kQ3CSGEquationAandnotB = 0x22222222,
  267. kQ3CSGEquationAanBonCad = 0x2F222F22,
  268. kQ3CSGEquationnotAandB = 0x44444444,
  269. kQ3CSGEquationnAaBorCanB = 0x74747474
  270. };
  271. typedef enum TQ3CSGEquation TQ3CSGEquation;
  272. #if CALL_NOT_IN_CARBON
  273. /*
  274. * Q3InteractiveRenderer_SetCSGEquation()
  275. *
  276. * Availability:
  277. * Non-Carbon CFM: not available
  278. * CarbonLib: not available
  279. * Mac OS X: not available
  280. */
  281. EXTERN_API_C( TQ3Status )
  282. Q3InteractiveRenderer_SetCSGEquation(
  283. TQ3RendererObject renderer,
  284. TQ3CSGEquation equation);
  285. /*
  286. * Q3InteractiveRenderer_GetCSGEquation()
  287. *
  288. * Availability:
  289. * Non-Carbon CFM: not available
  290. * CarbonLib: not available
  291. * Mac OS X: not available
  292. */
  293. EXTERN_API_C( TQ3Status )
  294. Q3InteractiveRenderer_GetCSGEquation(
  295. TQ3RendererObject renderer,
  296. TQ3CSGEquation * equation);
  297. /*
  298. * Q3InteractiveRenderer_SetPreferences()
  299. *
  300. * Availability:
  301. * Non-Carbon CFM: not available
  302. * CarbonLib: not available
  303. * Mac OS X: not available
  304. */
  305. EXTERN_API_C( TQ3Status )
  306. Q3InteractiveRenderer_SetPreferences(
  307. TQ3RendererObject renderer,
  308. long vendorID,
  309. long engineID);
  310. /*
  311. * Q3InteractiveRenderer_GetPreferences()
  312. *
  313. * Availability:
  314. * Non-Carbon CFM: not available
  315. * CarbonLib: not available
  316. * Mac OS X: not available
  317. */
  318. EXTERN_API_C( TQ3Status )
  319. Q3InteractiveRenderer_GetPreferences(
  320. TQ3RendererObject renderer,
  321. long * vendorID,
  322. long * engineID);
  323. /*
  324. * Q3InteractiveRenderer_SetDoubleBufferBypass()
  325. *
  326. * Availability:
  327. * Non-Carbon CFM: not available
  328. * CarbonLib: not available
  329. * Mac OS X: not available
  330. */
  331. EXTERN_API_C( TQ3Status )
  332. Q3InteractiveRenderer_SetDoubleBufferBypass(
  333. TQ3RendererObject renderer,
  334. TQ3Boolean bypass);
  335. /*
  336. * Q3InteractiveRenderer_GetDoubleBufferBypass()
  337. *
  338. * Availability:
  339. * Non-Carbon CFM: not available
  340. * CarbonLib: not available
  341. * Mac OS X: not available
  342. */
  343. EXTERN_API_C( TQ3Status )
  344. Q3InteractiveRenderer_GetDoubleBufferBypass(
  345. TQ3RendererObject renderer,
  346. TQ3Boolean * bypass);
  347. /*
  348. * Q3InteractiveRenderer_SetRAVEContextHints()
  349. *
  350. * Availability:
  351. * Non-Carbon CFM: not available
  352. * CarbonLib: not available
  353. * Mac OS X: not available
  354. */
  355. EXTERN_API_C( TQ3Status )
  356. Q3InteractiveRenderer_SetRAVEContextHints(
  357. TQ3RendererObject renderer,
  358. unsigned long RAVEContextHints);
  359. /*
  360. * Q3InteractiveRenderer_GetRAVEContextHints()
  361. *
  362. * Availability:
  363. * Non-Carbon CFM: not available
  364. * CarbonLib: not available
  365. * Mac OS X: not available
  366. */
  367. EXTERN_API_C( TQ3Status )
  368. Q3InteractiveRenderer_GetRAVEContextHints(
  369. TQ3RendererObject renderer,
  370. unsigned long * RAVEContextHints);
  371. /*
  372. * Q3InteractiveRenderer_SetRAVETextureFilter()
  373. *
  374. * Availability:
  375. * Non-Carbon CFM: not available
  376. * CarbonLib: not available
  377. * Mac OS X: not available
  378. */
  379. EXTERN_API_C( TQ3Status )
  380. Q3InteractiveRenderer_SetRAVETextureFilter(
  381. TQ3RendererObject renderer,
  382. unsigned long RAVEtextureFilterValue);
  383. /*
  384. * Q3InteractiveRenderer_GetRAVETextureFilter()
  385. *
  386. * Availability:
  387. * Non-Carbon CFM: not available
  388. * CarbonLib: not available
  389. * Mac OS X: not available
  390. */
  391. EXTERN_API_C( TQ3Status )
  392. Q3InteractiveRenderer_GetRAVETextureFilter(
  393. TQ3RendererObject renderer,
  394. unsigned long * RAVEtextureFilterValue);
  395. /*
  396. * Q3InteractiveRenderer_CountRAVEDrawContexts()
  397. *
  398. * Availability:
  399. * Non-Carbon CFM: not available
  400. * CarbonLib: not available
  401. * Mac OS X: not available
  402. */
  403. EXTERN_API_C( TQ3Status )
  404. Q3InteractiveRenderer_CountRAVEDrawContexts(
  405. TQ3RendererObject renderer,
  406. unsigned long * numRAVEContexts);
  407. #endif /* CALL_NOT_IN_CARBON */
  408. typedef CALLBACK_API_C( void , TQ3RaveDestroyCallback )(TQ3RendererObject renderer);
  409. #if CALL_NOT_IN_CARBON
  410. /*
  411. * Q3InteractiveRenderer_GetRAVEDrawContexts()
  412. *
  413. * Availability:
  414. * Non-Carbon CFM: not available
  415. * CarbonLib: not available
  416. * Mac OS X: not available
  417. */
  418. EXTERN_API_C( TQ3Status )
  419. Q3InteractiveRenderer_GetRAVEDrawContexts(
  420. TQ3RendererObject renderer,
  421. TQADrawContext ** raveDrawContextList,
  422. TQAEngine ** raveDrawingEnginesList,
  423. unsigned long * numRAVEContexts,
  424. TQ3RaveDestroyCallback raveDestroyCallback);
  425. /******************************************************************************
  426. ** **
  427. ** Renderer View Tools **
  428. ** **
  429. ** You may only call these methods from a plug-in **
  430. ** **
  431. *****************************************************************************/
  432. /*
  433. * Call by a renderer to call the user "idle" method, with progress
  434. * information.
  435. *
  436. * Pass in (view, 0, n) on first call
  437. * Pass in (view, 1..n-1, n) during rendering
  438. * Pass in (view, n, n) upon completion
  439. *
  440. * Note: The user must have supplied an idleProgress method with
  441. * Q3XView_SetIdleProgressMethod. Otherwise, the generic idle method is
  442. * called with no progress data. e.g. the Q3View_SetIdleMethod method
  443. * is called instead. (current and final are ignored, essentially.)
  444. *
  445. * Returns kQ3Failure if rendering is cancelled.
  446. */
  447. /*
  448. * Q3XView_IdleProgress()
  449. *
  450. * Availability:
  451. * Non-Carbon CFM: not available
  452. * CarbonLib: not available
  453. * Mac OS X: not available
  454. */
  455. EXTERN_API_C( TQ3Status )
  456. Q3XView_IdleProgress(
  457. TQ3ViewObject view,
  458. unsigned long current,
  459. unsigned long completed);
  460. /*
  461. * Called by an asynchronous renderer when it completes a frame.
  462. */
  463. /*
  464. * Q3XView_EndFrame()
  465. *
  466. * Availability:
  467. * Non-Carbon CFM: not available
  468. * CarbonLib: not available
  469. * Mac OS X: not available
  470. */
  471. EXTERN_API_C( TQ3Status )
  472. Q3XView_EndFrame(TQ3ViewObject view);
  473. /******************************************************************************
  474. ** **
  475. ** Renderer AttributeSet Tools **
  476. ** **
  477. ** You may only call these methods from a plug-in **
  478. ** **
  479. *****************************************************************************/
  480. /*
  481. * Faster access to geometry attribute sets.
  482. *
  483. * Returns pointer to INTERNAL data structure for elements and attributes
  484. * in an attributeSet, or NULL if no attribute exists.
  485. *
  486. * For attributes of type kQ3AttributeType..., the internal data structure
  487. * is identical to the data structure used in Q3AttributeSet_Add.
  488. */
  489. /*
  490. * Q3XAttributeSet_GetPointer()
  491. *
  492. * Availability:
  493. * Non-Carbon CFM: not available
  494. * CarbonLib: not available
  495. * Mac OS X: not available
  496. */
  497. EXTERN_API_C( void * )
  498. Q3XAttributeSet_GetPointer(
  499. TQ3AttributeSet attributeSet,
  500. TQ3AttributeType attributeType);
  501. #endif /* CALL_NOT_IN_CARBON */
  502. enum {
  503. kQ3XAttributeMaskNone = 0L,
  504. kQ3XAttributeMaskSurfaceUV = 1 << (kQ3AttributeTypeSurfaceUV - 1),
  505. kQ3XAttributeMaskShadingUV = 1 << (kQ3AttributeTypeShadingUV - 1),
  506. kQ3XAttributeMaskNormal = 1 << (kQ3AttributeTypeNormal - 1),
  507. kQ3XAttributeMaskAmbientCoefficient = 1 << (kQ3AttributeTypeAmbientCoefficient - 1),
  508. kQ3XAttributeMaskDiffuseColor = 1 << (kQ3AttributeTypeDiffuseColor - 1),
  509. kQ3XAttributeMaskSpecularColor = 1 << (kQ3AttributeTypeSpecularColor - 1),
  510. kQ3XAttributeMaskSpecularControl = 1 << (kQ3AttributeTypeSpecularControl - 1),
  511. kQ3XAttributeMaskTransparencyColor = 1 << (kQ3AttributeTypeTransparencyColor - 1),
  512. kQ3XAttributeMaskSurfaceTangent = 1 << (kQ3AttributeTypeSurfaceTangent - 1),
  513. kQ3XAttributeMaskHighlightState = 1 << (kQ3AttributeTypeHighlightState - 1),
  514. kQ3XAttributeMaskSurfaceShader = 1 << (kQ3AttributeTypeSurfaceShader - 1),
  515. kQ3XAttributeMaskCustomAttribute = (long)0x80000000,
  516. kQ3XAttributeMaskAll = 0x800007FF,
  517. kQ3XAttributeMaskInherited = 0x03FF,
  518. kQ3XAttributeMaskInterpolated = kQ3XAttributeMaskSurfaceUV | kQ3XAttributeMaskShadingUV | kQ3XAttributeMaskNormal | kQ3XAttributeMaskAmbientCoefficient | kQ3XAttributeMaskDiffuseColor | kQ3XAttributeMaskSpecularColor | kQ3XAttributeMaskSpecularControl | kQ3XAttributeMaskTransparencyColor | kQ3XAttributeMaskSurfaceTangent
  519. };
  520. typedef unsigned long TQ3XAttributeMask;
  521. #if CALL_NOT_IN_CARBON
  522. /*
  523. * Q3XAttributeSet_GetMask()
  524. *
  525. * Availability:
  526. * Non-Carbon CFM: not available
  527. * CarbonLib: not available
  528. * Mac OS X: not available
  529. */
  530. EXTERN_API_C( TQ3XAttributeMask )
  531. Q3XAttributeSet_GetMask(TQ3AttributeSet attributeSet);
  532. /******************************************************************************
  533. ** **
  534. ** Renderer Draw Context Tools **
  535. ** **
  536. *****************************************************************************/
  537. #endif /* CALL_NOT_IN_CARBON */
  538. typedef struct OpaqueTQ3XDrawRegion* TQ3XDrawRegion;
  539. #if CALL_NOT_IN_CARBON
  540. /*
  541. * Q3XDrawContext_GetDrawRegion()
  542. *
  543. * Availability:
  544. * Non-Carbon CFM: not available
  545. * CarbonLib: not available
  546. * Mac OS X: not available
  547. */
  548. EXTERN_API_C( TQ3Status )
  549. Q3XDrawContext_GetDrawRegion(
  550. TQ3DrawContextObject drawContext,
  551. TQ3XDrawRegion * drawRegion);
  552. #endif /* CALL_NOT_IN_CARBON */
  553. enum TQ3XDrawContextValidationMasks {
  554. kQ3XDrawContextValidationClearFlags = 0x00000000,
  555. kQ3XDrawContextValidationDoubleBuffer = 1 << 0,
  556. kQ3XDrawContextValidationShader = 1 << 1,
  557. kQ3XDrawContextValidationClearFunction = 1 << 2,
  558. kQ3XDrawContextValidationActiveBuffer = 1 << 3,
  559. kQ3XDrawContextValidationInternalOffScreen = 1 << 4,
  560. kQ3XDrawContextValidationPane = 1 << 5,
  561. kQ3XDrawContextValidationMask = 1 << 6,
  562. kQ3XDrawContextValidationDevice = 1 << 7,
  563. kQ3XDrawContextValidationWindow = 1 << 8,
  564. kQ3XDrawContextValidationWindowSize = 1 << 9,
  565. kQ3XDrawContextValidationWindowClip = 1 << 10,
  566. kQ3XDrawContextValidationWindowPosition = 1 << 11,
  567. kQ3XDrawContextValidationPlatformAttributes = 1 << 12,
  568. kQ3XDrawContextValidationForegroundShader = 1 << 13,
  569. kQ3XDrawContextValidationBackgroundShader = 1 << 14,
  570. kQ3XDrawContextValidationColorPalette = 1 << 15,
  571. kQ3XDrawContextValidationAll = (long)0xFFFFFFFF
  572. };
  573. typedef enum TQ3XDrawContextValidationMasks TQ3XDrawContextValidationMasks;
  574. typedef unsigned long TQ3XDrawContextValidation;
  575. #if CALL_NOT_IN_CARBON
  576. /*
  577. * Q3XDrawContext_ClearValidationFlags()
  578. *
  579. * Availability:
  580. * Non-Carbon CFM: not available
  581. * CarbonLib: not available
  582. * Mac OS X: not available
  583. */
  584. EXTERN_API_C( TQ3Status )
  585. Q3XDrawContext_ClearValidationFlags(TQ3DrawContextObject drawContext);
  586. /*
  587. * Q3XDrawContext_GetValidationFlags()
  588. *
  589. * Availability:
  590. * Non-Carbon CFM: not available
  591. * CarbonLib: not available
  592. * Mac OS X: not available
  593. */
  594. EXTERN_API_C( TQ3Status )
  595. Q3XDrawContext_GetValidationFlags(
  596. TQ3DrawContextObject drawContext,
  597. TQ3XDrawContextValidation * validationFlags);
  598. /******************************************************************************
  599. ** **
  600. ** Renderer Draw Region Tools **
  601. ** **
  602. *****************************************************************************/
  603. #endif /* CALL_NOT_IN_CARBON */
  604. enum TQ3XDevicePixelType {
  605. /* These do not indicate byte ordering */
  606. kQ3XDevicePixelTypeInvalid = 0, /* Unknown, un-initialized type */
  607. kQ3XDevicePixelTypeRGB32 = 1, /* Alpha:8 (ignored), R:8, G:8, B:8 */
  608. kQ3XDevicePixelTypeARGB32 = 2, /* Alpha:8, R:8, G:8, B:8 */
  609. kQ3XDevicePixelTypeRGB24 = 3, /* 24 bits/pixel, R:8, G:8, B:8 */
  610. kQ3XDevicePixelTypeRGB16 = 4, /* Alpha:1 (ignored), R:5, G:5, B:5 */
  611. kQ3XDevicePixelTypeARGB16 = 5, /* Alpha:1, R:5, G:5, B:5 */
  612. kQ3XDevicePixelTypeRGB16_565 = 6, /* 16 bits/pixel, R:5, G:6, B:5 */
  613. kQ3XDevicePixelTypeIndexed8 = 7, /* 8-bit color table index */
  614. kQ3XDevicePixelTypeIndexed4 = 8, /* 4-bit color table index */
  615. kQ3XDevicePixelTypeIndexed2 = 9, /* 2-bit color table index */
  616. kQ3XDevicePixelTypeIndexed1 = 10 /* 1-bit color table index */
  617. };
  618. typedef enum TQ3XDevicePixelType TQ3XDevicePixelType;
  619. enum TQ3XClipMaskState {
  620. kQ3XClipMaskFullyExposed = 0,
  621. kQ3XClipMaskPartiallyExposed = 1,
  622. kQ3XClipMaskNotExposed = 2
  623. };
  624. typedef enum TQ3XClipMaskState TQ3XClipMaskState;
  625. struct TQ3XColorDescriptor {
  626. unsigned long redShift;
  627. unsigned long redMask;
  628. unsigned long greenShift;
  629. unsigned long greenMask;
  630. unsigned long blueShift;
  631. unsigned long blueMask;
  632. unsigned long alphaShift;
  633. unsigned long alphaMask;
  634. };
  635. typedef struct TQ3XColorDescriptor TQ3XColorDescriptor;
  636. struct TQ3XDrawRegionDescriptor {
  637. unsigned long width;
  638. unsigned long height;
  639. unsigned long rowBytes;
  640. unsigned long pixelSize;
  641. TQ3XDevicePixelType pixelType;
  642. TQ3XColorDescriptor colorDescriptor;
  643. TQ3Endian bitOrder;
  644. TQ3Endian byteOrder;
  645. TQ3Bitmap * clipMask;
  646. };
  647. typedef struct TQ3XDrawRegionDescriptor TQ3XDrawRegionDescriptor;
  648. enum TQ3XDrawRegionServicesMasks {
  649. kQ3XDrawRegionServicesNoneFlag = 0L,
  650. kQ3XDrawRegionServicesClearFlag = 1 << 0,
  651. kQ3XDrawRegionServicesDontLockDDSurfaceFlag = 1 << 1
  652. };
  653. typedef enum TQ3XDrawRegionServicesMasks TQ3XDrawRegionServicesMasks;
  654. typedef unsigned long TQ3XDrawRegionServices;
  655. typedef CALLBACK_API_C( void , TQ3XDrawRegionRendererPrivateDeleteMethod )(void * rendererPrivate);
  656. #if CALL_NOT_IN_CARBON
  657. /*
  658. * Q3XDrawRegion_GetDeviceScaleX()
  659. *
  660. * Availability:
  661. * Non-Carbon CFM: not available
  662. * CarbonLib: not available
  663. * Mac OS X: not available
  664. */
  665. EXTERN_API_C( TQ3Status )
  666. Q3XDrawRegion_GetDeviceScaleX(
  667. TQ3XDrawRegion drawRegion,
  668. float * deviceScaleX);
  669. /*
  670. * Q3XDrawRegion_GetDeviceScaleY()
  671. *
  672. * Availability:
  673. * Non-Carbon CFM: not available
  674. * CarbonLib: not available
  675. * Mac OS X: not available
  676. */
  677. EXTERN_API_C( TQ3Status )
  678. Q3XDrawRegion_GetDeviceScaleY(
  679. TQ3XDrawRegion drawRegion,
  680. float * deviceScaleY);
  681. /*
  682. * Q3XDrawRegion_GetDeviceOffsetX()
  683. *
  684. * Availability:
  685. * Non-Carbon CFM: not available
  686. * CarbonLib: not available
  687. * Mac OS X: not available
  688. */
  689. EXTERN_API_C( TQ3Status )
  690. Q3XDrawRegion_GetDeviceOffsetX(
  691. TQ3XDrawRegion drawRegion,
  692. float * deviceOffsetX);
  693. /*
  694. * Q3XDrawRegion_GetDeviceOffsetY()
  695. *
  696. * Availability:
  697. * Non-Carbon CFM: not available
  698. * CarbonLib: not available
  699. * Mac OS X: not available
  700. */
  701. EXTERN_API_C( TQ3Status )
  702. Q3XDrawRegion_GetDeviceOffsetY(
  703. TQ3XDrawRegion drawRegion,
  704. float * deviceOffsetX);
  705. /*
  706. * Q3XDrawRegion_GetWindowScaleX()
  707. *
  708. * Availability:
  709. * Non-Carbon CFM: not available
  710. * CarbonLib: not available
  711. * Mac OS X: not available
  712. */
  713. EXTERN_API_C( TQ3Status )
  714. Q3XDrawRegion_GetWindowScaleX(
  715. TQ3XDrawRegion drawRegion,
  716. float * windowScaleX);
  717. /*
  718. * Q3XDrawRegion_GetWindowScaleY()
  719. *
  720. * Availability:
  721. * Non-Carbon CFM: not available
  722. * CarbonLib: not available
  723. * Mac OS X: not available
  724. */
  725. EXTERN_API_C( TQ3Status )
  726. Q3XDrawRegion_GetWindowScaleY(
  727. TQ3XDrawRegion drawRegion,
  728. float * windowScaleY);
  729. /*
  730. * Q3XDrawRegion_GetWindowOffsetX()
  731. *
  732. * Availability:
  733. * Non-Carbon CFM: not available
  734. * CarbonLib: not available
  735. * Mac OS X: not available
  736. */
  737. EXTERN_API_C( TQ3Status )
  738. Q3XDrawRegion_GetWindowOffsetX(
  739. TQ3XDrawRegion drawRegion,
  740. float * windowOffsetX);
  741. /*
  742. * Q3XDrawRegion_GetWindowOffsetY()
  743. *
  744. * Availability:
  745. * Non-Carbon CFM: not available
  746. * CarbonLib: not available
  747. * Mac OS X: not available
  748. */
  749. EXTERN_API_C( TQ3Status )
  750. Q3XDrawRegion_GetWindowOffsetY(
  751. TQ3XDrawRegion drawRegion,
  752. float * windowOffsetY);
  753. /*
  754. * Q3XDrawRegion_IsActive()
  755. *
  756. * Availability:
  757. * Non-Carbon CFM: not available
  758. * CarbonLib: not available
  759. * Mac OS X: not available
  760. */
  761. EXTERN_API_C( TQ3Status )
  762. Q3XDrawRegion_IsActive(
  763. TQ3XDrawRegion drawRegion,
  764. TQ3Boolean * isActive);
  765. /*
  766. * Q3XDrawRegion_GetNextRegion()
  767. *
  768. * Availability:
  769. * Non-Carbon CFM: not available
  770. * CarbonLib: not available
  771. * Mac OS X: not available
  772. */
  773. EXTERN_API_C( TQ3Status )
  774. Q3XDrawRegion_GetNextRegion(
  775. TQ3XDrawRegion drawRegion,
  776. TQ3XDrawRegion * nextDrawRegion);
  777. /*
  778. * One of the next two functions must be called before using a draw region
  779. */
  780. /*
  781. * Use this Start function if double buffering/image access services from the
  782. * Draw Context are not needed, you may still request clear for example
  783. */
  784. /*
  785. * Q3XDrawRegion_Start()
  786. *
  787. * Availability:
  788. * Non-Carbon CFM: not available
  789. * CarbonLib: not available
  790. * Mac OS X: not available
  791. */
  792. EXTERN_API_C( TQ3Status )
  793. Q3XDrawRegion_Start(
  794. TQ3XDrawRegion drawRegion,
  795. TQ3XDrawRegionServices services,
  796. TQ3XDrawRegionDescriptor ** descriptor);
  797. /*
  798. * Use this Start function if double buffering or image access services from
  799. * the Draw Context are needed.
  800. */
  801. /*
  802. * Q3XDrawRegion_StartAccessToImageBuffer()
  803. *
  804. * Availability:
  805. * Non-Carbon CFM: not available
  806. * CarbonLib: not available
  807. * Mac OS X: not available
  808. */
  809. EXTERN_API_C( TQ3Status )
  810. Q3XDrawRegion_StartAccessToImageBuffer(
  811. TQ3XDrawRegion drawRegion,
  812. TQ3XDrawRegionServices services,
  813. TQ3XDrawRegionDescriptor ** descriptor,
  814. void ** image);
  815. /*
  816. * This function is used to indicate that access to a DrawRegion is ended.
  817. */
  818. /*
  819. * Q3XDrawRegion_End()
  820. *
  821. * Availability:
  822. * Non-Carbon CFM: not available
  823. * CarbonLib: not available
  824. * Mac OS X: not available
  825. */
  826. EXTERN_API_C( TQ3Status )
  827. Q3XDrawRegion_End(TQ3XDrawRegion drawRegion);
  828. /*
  829. * Q3XDrawRegion_GetDeviceTransform()
  830. *
  831. * Availability:
  832. * Non-Carbon CFM: not available
  833. * CarbonLib: not available
  834. * Mac OS X: not available
  835. */
  836. EXTERN_API_C( TQ3Status )
  837. Q3XDrawRegion_GetDeviceTransform(
  838. TQ3XDrawRegion drawRegion,
  839. TQ3Matrix4x4 ** deviceTransform);
  840. /*
  841. * Q3XDrawRegion_GetClipFlags()
  842. *
  843. * Availability:
  844. * Non-Carbon CFM: not available
  845. * CarbonLib: not available
  846. * Mac OS X: not available
  847. */
  848. EXTERN_API_C( TQ3Status )
  849. Q3XDrawRegion_GetClipFlags(
  850. TQ3XDrawRegion drawRegion,
  851. TQ3XClipMaskState * clipMaskState);
  852. /*
  853. * Q3XDrawRegion_GetClipMask()
  854. *
  855. * Availability:
  856. * Non-Carbon CFM: not available
  857. * CarbonLib: not available
  858. * Mac OS X: not available
  859. */
  860. EXTERN_API_C( TQ3Status )
  861. Q3XDrawRegion_GetClipMask(
  862. TQ3XDrawRegion drawRegion,
  863. TQ3Bitmap ** clipMask);
  864. #endif /* CALL_NOT_IN_CARBON */
  865. #if TARGET_OS_MAC
  866. #if CALL_NOT_IN_CARBON
  867. /*
  868. * Q3XDrawRegion_GetClipRegion()
  869. *
  870. * Availability:
  871. * Non-Carbon CFM: not available
  872. * CarbonLib: not available
  873. * Mac OS X: not available
  874. */
  875. EXTERN_API_C( TQ3Status )
  876. Q3XDrawRegion_GetClipRegion(
  877. TQ3XDrawRegion drawRegion,
  878. RgnHandle * rgnHandle);
  879. /*
  880. * Q3XDrawRegion_GetGDHandle()
  881. *
  882. * Availability:
  883. * Non-Carbon CFM: not available
  884. * CarbonLib: not available
  885. * Mac OS X: not available
  886. */
  887. EXTERN_API_C( TQ3Status )
  888. Q3XDrawRegion_GetGDHandle(
  889. TQ3XDrawRegion drawRegion,
  890. GDHandle * gdHandle);
  891. #endif /* CALL_NOT_IN_CARBON */
  892. #endif /* TARGET_OS_MAC */
  893. #if CALL_NOT_IN_CARBON
  894. /*
  895. * Q3XDrawRegion_GetRendererPrivate()
  896. *
  897. * Availability:
  898. * Non-Carbon CFM: not available
  899. * CarbonLib: not available
  900. * Mac OS X: not available
  901. */
  902. EXTERN_API_C( TQ3Status )
  903. Q3XDrawRegion_GetRendererPrivate(
  904. TQ3XDrawRegion drawRegion,
  905. void ** rendererPrivate);
  906. /*
  907. * Q3XDrawRegion_SetRendererPrivate()
  908. *
  909. * Availability:
  910. * Non-Carbon CFM: not available
  911. * CarbonLib: not available
  912. * Mac OS X: not available
  913. */
  914. EXTERN_API_C( TQ3Status )
  915. Q3XDrawRegion_SetRendererPrivate(
  916. TQ3XDrawRegion drawRegion,
  917. const void * rendererPrivate,
  918. TQ3XDrawRegionRendererPrivateDeleteMethod deleteMethod);
  919. /*
  920. * Q3XDrawRegion_SetUseDefaultRendererFlag()
  921. *
  922. * Availability:
  923. * Non-Carbon CFM: not available
  924. * CarbonLib: not available
  925. * Mac OS X: not available
  926. */
  927. EXTERN_API_C( TQ3Status )
  928. Q3XDrawRegion_SetUseDefaultRendererFlag(
  929. TQ3XDrawRegion drawRegion,
  930. TQ3Boolean flag);
  931. /*
  932. * Q3XDrawRegion_GetUseDefaultRendererFlag()
  933. *
  934. * Availability:
  935. * Non-Carbon CFM: not available
  936. * CarbonLib: not available
  937. * Mac OS X: not available
  938. */
  939. EXTERN_API_C( TQ3Status )
  940. Q3XDrawRegion_GetUseDefaultRendererFlag(
  941. TQ3XDrawRegion drawRegion,
  942. TQ3Boolean * useDefaultRenderingFlag);
  943. /******************************************************************************
  944. ** **
  945. ** Renderer Class Methods **
  946. ** **
  947. *****************************************************************************/
  948. /*
  949. * Methods from Object
  950. * kQ3XMethodTypeObjectClassRegister
  951. * kQ3XMethodTypeObjectClassUnregister
  952. * kQ3XMethodTypeObjectNew
  953. * kQ3XMethodTypeObjectDelete
  954. * kQ3XMethodTypeObjectRead
  955. * kQ3XMethodTypeObjectTraverse
  956. * kQ3XMethodTypeObjectWrite
  957. *
  958. * Methods from Shared
  959. * kQ3MethodTypeSharedEdited
  960. *
  961. * Renderer Methods
  962. *
  963. * The renderer methods should be implemented according to the type
  964. * of renderer being written.
  965. *
  966. * For the purposes of documentation, there are two basic types of
  967. * renderers:
  968. *
  969. * Interactive
  970. * Interactive Renderer
  971. * WireFrame Renderer
  972. *
  973. * Deferred
  974. * a ray-tracer
  975. * painter's algorithm renderer (cached in a BSP triangle tree)
  976. * an artistic renderer (simulates a pencil drawing, etc.)
  977. *
  978. * The main difference is how each renderer handles incoming state and
  979. * geometry.
  980. *
  981. * An interactive renderer immediately transforms, culls, and shades
  982. * incoming geometry and performs rasterization. For example, in a
  983. * single-buffered WireFrame renderer, you will see a new triangle
  984. * immediately after Q3Triangle_Draw (if it's visible, of course).
  985. *
  986. * A deferred renderer caches the view state and each geometry,
  987. * converting into any internal queue of drawing commands. Rasterization
  988. * is not actually performed until all data has been submitted.
  989. *
  990. * For example, a ray-tracer may not rasterize anything until the
  991. * end of the rendering loop, or until an EndFrame call is made.
  992. */
  993. /******************************************************************************
  994. ** **
  995. ** Renderer User Interface Methods **
  996. ** **
  997. *****************************************************************************/
  998. /*
  999. * kQ3XMethodTypeRendererIsInteractive
  1000. *
  1001. * There is no actual method with this - the metahandler simply returns
  1002. * "(TQ3XFunctionPointer)kQ3True" for this "method" if the renderer is
  1003. * intended to be used in interactive settings, and
  1004. * "(TQ3XFunctionPointer)kQ3False" otherwise.
  1005. *
  1006. * If neither value is specified in the metahandler, the renderer
  1007. * is *assumed to be non-interactive*!!!
  1008. *
  1009. * OPTIONAL
  1010. */
  1011. #endif /* CALL_NOT_IN_CARBON */
  1012. enum {
  1013. kQ3XMethodTypeRendererIsInteractive = FOUR_CHAR_CODE('isin')
  1014. };
  1015. /*
  1016. * TQ3XRendererModalConfigureMethod
  1017. *
  1018. * This method should pop up a modal dialog to edit the renderer settings
  1019. * found in the renderer private.
  1020. *
  1021. * dialogAnchor - is platform specific data passed by the client to support
  1022. * movable modal dialogs.
  1023. * MacOS: this is a callback to the calling application's event handler.
  1024. * The renderer calls this function with events not handled by the
  1025. * settings dialog. This is necessary in order to support movable modal
  1026. * dialogs. An application's event handler must return kQ3True if it
  1027. * handles the event passed to the callback or kQ3False if not.
  1028. * An application which doesn't want to support a movable modal configure
  1029. * dialog should pass NULL for the clientEventHandler of TQ3DialogAnchor.
  1030. * A renderer should implement a non-movable style dialog in that case.
  1031. * Win32: this is the HWND of the owning window (typically an application's
  1032. * main window). (Win32 application modal dialogs are always movable.)
  1033. * canceled - returns a boolean inditacating that the user canceled the
  1034. * dialog.
  1035. *
  1036. * OPTIONAL
  1037. */
  1038. enum {
  1039. kQ3XMethodTypeRendererModalConfigure = FOUR_CHAR_CODE('rdmc')
  1040. };
  1041. typedef CALLBACK_API_C( TQ3Status , TQ3XRendererModalConfigureMethod )(TQ3RendererObject renderer, TQ3DialogAnchor dialogAnchor, TQ3Boolean *canceled, void *rendererPrivate);
  1042. /*
  1043. * kQ3XMethodTypeRendererGetNickNameString
  1044. *
  1045. * Allows an application to collect the name of the renderer for
  1046. * display in a user interface item such as a menu.
  1047. *
  1048. * If dataBuffer is NULL actualDataSize returns the required size in
  1049. * bytes of a data buffer large enough to store the renderer name.
  1050. *
  1051. * bufferSize is the actual size of the memory block pointed to by
  1052. * dataBuffer
  1053. *
  1054. * actualDataSize - on return the actual number of bytes written to the
  1055. * buffer or if dataBuffer is NULL the required size of dataBuffer
  1056. *
  1057. * OPTIONAL
  1058. */
  1059. enum {
  1060. kQ3XMethodTypeRendererGetNickNameString = FOUR_CHAR_CODE('rdns')
  1061. };
  1062. typedef CALLBACK_API_C( TQ3Status , TQ3XRendererGetNickNameStringMethod )(unsigned char *dataBuffer, unsigned long bufferSize, unsigned long *actualDataSize);
  1063. /*
  1064. * kQ3XMethodTypeRendererGetConfigurationData
  1065. *
  1066. * Allows an application to collect private configuration data from the
  1067. * renderer which it will then save. For example in a preference file,
  1068. * a registry key (on Windows) or in a style template. An application
  1069. * should tag this data with the renderer's object name.
  1070. *
  1071. * If dataBuffer is NULL actualDataSize returns the required size in
  1072. * bytes of a data buffer large enough to store private data.
  1073. *
  1074. * bufferSize is the actual size of the memory block pointed to by
  1075. * dataBuffer
  1076. *
  1077. * actualDataSize - on return the actual number of bytes written to the
  1078. * buffer or if dataBuffer is NULL the required size of dataBuffer
  1079. *
  1080. * OPTIONAL
  1081. */
  1082. enum {
  1083. kQ3XMethodTypeRendererGetConfigurationData = FOUR_CHAR_CODE('rdgp')
  1084. };
  1085. typedef CALLBACK_API_C( TQ3Status , TQ3XRendererGetConfigurationDataMethod )(TQ3RendererObject renderer, unsigned char *dataBuffer, unsigned long bufferSize, unsigned long *actualDataSize, void *rendererPrivate);
  1086. /*
  1087. * TQ3XRendererSetConfigurationDataMethod
  1088. *
  1089. * Allows an application to pass private configuration data which has
  1090. * previously been obtained from a renderer via
  1091. * Q3Renderer_GetConfigurationData. For example in a preference file or
  1092. * in a style template. An application should tag this data with the
  1093. * renderer's object name.
  1094. *
  1095. * bufferSize is the actual size of the memory block pointed to by
  1096. * dataBuffer
  1097. *
  1098. * OPTIONAL
  1099. */
  1100. enum {
  1101. kQ3XMethodTypeRendererSetConfigurationData = FOUR_CHAR_CODE('rdsp')
  1102. };
  1103. typedef CALLBACK_API_C( TQ3Status , TQ3XRendererSetConfigurationDataMethod )(TQ3RendererObject renderer, unsigned char *dataBuffer, unsigned long bufferSize, void *rendererPrivate);
  1104. /******************************************************************************
  1105. ** **
  1106. ** Renderer Drawing State Methods **
  1107. ** **
  1108. *****************************************************************************/
  1109. /*
  1110. * TQ3RendererStartFrame
  1111. *
  1112. * The StartFrame method is called first at Q3View_StartRendering
  1113. * and should:
  1114. * - initialize any renderer state to defaults
  1115. * - extract any and all useful data from the drawContext
  1116. *
  1117. * If your renderer passed in kQ3RendererFlagClearBuffer at
  1118. * registration, then it should also:
  1119. * - clear the drawContext
  1120. *
  1121. * When clearing, your renderer may opt to:
  1122. * - NOT clear anything (if you touch every pixel, for example)
  1123. * - to clear with your own routine, or
  1124. * - to use the draw context default clear method by calling
  1125. * Q3DrawContext_Clear. Q3DrawContext_Clear takes advantage of
  1126. * any available hardware in the system for clearing.
  1127. *
  1128. * This call also signals the start of all default submit commands from
  1129. * the view. The renderer will receive updates for the default view
  1130. * state via its Update methods before StartPass is called.
  1131. *
  1132. * REQUIRED
  1133. */
  1134. enum {
  1135. kQ3XMethodTypeRendererStartFrame = FOUR_CHAR_CODE('rdcl')
  1136. };
  1137. typedef CALLBACK_API_C( TQ3Status , TQ3XRendererStartFrameMethod )(TQ3ViewObject view, void *rendererPrivate, TQ3DrawContextObject drawContext);
  1138. /*
  1139. * kQ3XMethodTypeRendererStartPass
  1140. * TQ3XRendererStartPassMethod
  1141. *
  1142. * The StartPass method is called during Q3View_StartRendering but after
  1143. * the StartFrame command. It should:
  1144. * - collect camera and light information
  1145. *
  1146. * If your renderer supports deferred camera transformation, camera is the
  1147. * main camera which will be submitted in the hierarchy somewhere. It
  1148. * is never NULL.
  1149. *
  1150. * If your renderer does not support deferred camera transformation, camera
  1151. * is the transformed camera.
  1152. *
  1153. * If your renderer supports deferred light transformation, lights will be
  1154. * NULL, and will be submitted to your light draw methods instead.
  1155. *
  1156. * This call signals the end of the default update state, and the start of
  1157. * submit commands from the user to the view.
  1158. *
  1159. * REQUIRED
  1160. */
  1161. enum {
  1162. kQ3XMethodTypeRendererStartPass = FOUR_CHAR_CODE('rdst')
  1163. };
  1164. typedef CALLBACK_API_C( TQ3Status , TQ3XRendererStartPassMethod )(TQ3ViewObject view, void *rendererPrivate, TQ3CameraObject camera, TQ3GroupObject lightGroup);
  1165. /*
  1166. * kQ3XMethodTypeRendererFlushFrame
  1167. * TQ3XRendererFlushFrameMethod
  1168. *
  1169. * This call is only implemented by asynchronous renderers.
  1170. *
  1171. * The FlushFrame method is called between the StartPass and EndPass
  1172. * methods and is called when the user wishes to flush any asynchronous
  1173. * drawing tasks (which draw to the drawcontext), but does not want
  1174. * to block.
  1175. *
  1176. * The result of this call is that an image should "eventually" appear
  1177. * asynchronously.
  1178. *
  1179. * For asynchronous rendering, this call is non-blocking.
  1180. *
  1181. * An interactive renderer should ensure that all received
  1182. * geometries are drawn in the image.
  1183. *
  1184. * An interactive renderer that talks to hardware should force
  1185. * the hardware to generate an image.
  1186. *
  1187. * A deferred renderer should exhibit a similar behaviour,
  1188. * though it is not required. A deferred renderer should spawn
  1189. * a process that generates a partial image from the currently
  1190. * accumulated drawing state.
  1191. *
  1192. * However, for renderers such as ray-tracers which generally are
  1193. * quite compute-intensive, FlushFrame is not required and is a no-op.
  1194. *
  1195. * OPTIONAL
  1196. */
  1197. enum {
  1198. kQ3XMethodTypeRendererFlushFrame = FOUR_CHAR_CODE('rdfl')
  1199. };
  1200. typedef CALLBACK_API_C( TQ3Status , TQ3XRendererFlushFrameMethod )(TQ3ViewObject view, void *rendererPrivate, TQ3DrawContextObject drawContext);
  1201. /*
  1202. * kQ3XMethodTypeRendererEndPass
  1203. * TQ3XRendererEndPassMethod
  1204. *
  1205. * The EndPass method is called at Q3View_EndRendering and signals
  1206. * the end of submit commands to the view.
  1207. *
  1208. * If an error occurs, the renderer should call Q3XError_Post and
  1209. * return kQ3ViewStatusError.
  1210. *
  1211. * If a renderer requires another pass on the renderering data,
  1212. * it should return kQ3ViewStatusRetraverse.
  1213. *
  1214. * If rendering was cancelled, this function will not be called
  1215. * and the view will handle returning kQ3ViewStatusCancelled;
  1216. *
  1217. * Otherwise, your renderer should begin completing the process of
  1218. * generating the image in the drawcontext. If you have buffered
  1219. * any drawing data, flush it. RendererEnd should have a similar
  1220. * effect as RendererFlushFrame.
  1221. *
  1222. * If the renderer is synchronous:
  1223. * - complete rendering of the entire frame
  1224. * if the renderer supports kQ3RendererClassSupportDoubleBuffer
  1225. * - Update the front buffer
  1226. * else
  1227. * - DrawContext will update the front buffer after returning
  1228. *
  1229. * If the renderer is asynchronous
  1230. * - spawn rendering thread for entire frame
  1231. * if the renderer supports kQ3RendererClassSupportDoubleBuffer,
  1232. * - you must eventually update the front buffer asynchronously
  1233. * else
  1234. * - you must eventually update the back buffer asynchronously
  1235. *
  1236. * REQUIRED
  1237. */
  1238. enum {
  1239. kQ3XMethodTypeRendererEndPass = FOUR_CHAR_CODE('rded')
  1240. };
  1241. typedef CALLBACK_API_C( TQ3ViewStatus , TQ3XRendererEndPassMethod )(TQ3ViewObject view, void *rendererPrivate);
  1242. /*
  1243. * kQ3XMethodTypeRendererEndFrame
  1244. * TQ3XRendererEndFrame
  1245. *
  1246. * This call is only implemented by asynchronous renderers.
  1247. *
  1248. * The EndFrame method is called from Q3View_Sync, which is
  1249. * called after Q3View_EndRendering and signals that the user
  1250. * wishes to see the completed image and is willing to block.
  1251. *
  1252. * If your renderer supports kQ3RendererFlagDoubleBuffer
  1253. * - update the front buffer completely
  1254. * else
  1255. * - update the back buffer completely
  1256. *
  1257. * This call is equivalent in functionality to RendererFlushFrame
  1258. * but blocks until the image is completed.
  1259. *
  1260. * If no method is supplied, the default is a no-op.
  1261. *
  1262. * NOTE: Registering a method of this type indicates that your renderer will
  1263. * be rendering after Q3View_EndRendering has been called.
  1264. *
  1265. * OPTIONAL
  1266. */
  1267. enum {
  1268. kQ3XMethodTypeRendererEndFrame = FOUR_CHAR_CODE('rdsy')
  1269. };
  1270. typedef CALLBACK_API_C( TQ3Status , TQ3XRendererEndFrameMethod )(TQ3ViewObject view, void *rendererPrivate, TQ3DrawContextObject drawContext);
  1271. /*
  1272. * The RendererCancel method is called after Q3View_StartRendering
  1273. * and signals the termination of all rendering operations.
  1274. *
  1275. * A renderer should clean up any cached data, and cancel all
  1276. * rendering operations.
  1277. *
  1278. * If called before Q3View_EndRendering, the RendererEnd method
  1279. * is NOT called.
  1280. *
  1281. * If called after Q3View_EndRendering, the renderer should kill
  1282. * any threads and terminate any further rendering.
  1283. *
  1284. * REQUIRED
  1285. */
  1286. enum {
  1287. kQ3XMethodTypeRendererCancel = FOUR_CHAR_CODE('rdab')
  1288. };
  1289. typedef CALLBACK_API_C( void , TQ3XRendererCancelMethod )(TQ3ViewObject view, void *rendererPrivate);
  1290. /******************************************************************************
  1291. ** **
  1292. ** Renderer DrawContext Methods **
  1293. ** **
  1294. *****************************************************************************/
  1295. /*
  1296. * kQ3XMethodTypeRendererPush
  1297. * TQ3XRendererPushMethod
  1298. *
  1299. * kQ3XMethodTypeRendererPop
  1300. * TQ3XRendererPopMethod
  1301. *
  1302. * These methods are called whenever the graphics state in the view
  1303. * is pushed or popped. The user may isolate state by calling:
  1304. *
  1305. * Q3Attribute_Submit(kQ3AttributeTypeDiffuseColor, &red, view);
  1306. * Q3Attribute_Submit(kQ3AttributeTypeTransparencyColor, &blue, view);
  1307. * Q3Attribute_Submit(kQ3AttributeTypeSpecularColor, &white, view);
  1308. * Q3Box_Submit(&unitBox, view);
  1309. * Q3TranslateTransform_Submit(&unitVector, view);
  1310. * Q3Push_Submit(view);
  1311. * Q3Attribute_Submit(kQ3AttributeTypeDiffuseColor, &blue, view);
  1312. * Q3Attribute_Submit(kQ3AttributeTypeTransparencyColor, &green, view);
  1313. * Q3Box_Submit(&unitBox, view);
  1314. * Q3Pop_Submit(view);
  1315. * Q3TranslateTransform_Submit(&unitVector, view);
  1316. * Q3Box_Submit(&unitBox, view);
  1317. *
  1318. * or by submitting a display group which pushes and pops.
  1319. *
  1320. * If you support RendererPush and RendererPop in your renderer:
  1321. * - you must maintain your drawing state as a stack, as well.
  1322. * - you will not be updated with the popped state after
  1323. * RendererPop is called.
  1324. *
  1325. * If you do not support Push and Pop in your renderer:
  1326. * - you may maintain a single copy of the drawing state.
  1327. * - you will be updated with changed fields after the view stack is
  1328. * popped.
  1329. *
  1330. * A renderer that supports Push and Pop gets called in the following
  1331. * sequence (from example above):
  1332. *
  1333. * RendererUpdateAttributeDiffuseColor(&red,...)
  1334. * RendererUpdateAttributeTransparencyColor(&blue,...)
  1335. * RendererUpdateAttributeSpecularColor(&white,...)
  1336. * RendererUpdateMatrixLocalToWorld(...)
  1337. * RendererSubmitGeometryBox(...)
  1338. * RendererPush(...)
  1339. * RendererUpdateAttributeDiffuseColor(&blue,...)
  1340. * RendererUpdateAttributeTransparencyColor(&green,...)
  1341. * RendererSubmitGeometryBox(...)
  1342. * RendererPop(...)
  1343. * RendererUpdateMatrixLocalToWorld(...)
  1344. * RendererSubmitGeometryBox(...)
  1345. *
  1346. * A renderer that does not supports Push and Pop gets called in the
  1347. * following sequence:
  1348. *
  1349. * RendererUpdateAttributeDiffuseColor(&red,...)
  1350. * RendererUpdateAttributeTransparencyColor(&blue,...)
  1351. * RendererUpdateAttributeSpecularColor(&white,...)
  1352. * RendererUpdateMatrixLocalToWorld(...)
  1353. * RendererSubmitGeometryBox(...)
  1354. * RendererUpdateAttributeDiffuseColor(&blue,...)
  1355. * RendererUpdateAttributeTransparencyColor(&green,...)
  1356. * RendererSubmitGeometryBox(...)
  1357. * RendererUpdateAttributeDiffuseColor(&red,...)
  1358. * RendererUpdateAttributeTransparencyColor(&blue,...)
  1359. * RendererUpdateMatrixLocalToWorld(...)
  1360. * RendererSubmitGeometryBox(...)
  1361. *
  1362. */
  1363. enum {
  1364. kQ3XMethodTypeRendererPush = FOUR_CHAR_CODE('rdps')
  1365. };
  1366. typedef CALLBACK_API_C( TQ3Status , TQ3XRendererPushMethod )(TQ3ViewObject view, void *rendererPrivate);
  1367. enum {
  1368. kQ3XMethodTypeRendererPop = FOUR_CHAR_CODE('rdpo')
  1369. };
  1370. typedef CALLBACK_API_C( TQ3Status , TQ3XRendererPopMethod )(TQ3ViewObject view, void *rendererPrivate);
  1371. /******************************************************************************
  1372. ** **
  1373. ** Renderer Cull Methods **
  1374. ** **
  1375. *****************************************************************************/
  1376. /*
  1377. * kQ3XMethodTypeRendererIsBoundingBoxVisible
  1378. * TQ3XRendererIsBoundingBoxVisibleMethod
  1379. *
  1380. * This method is called to cull complex groups and geometries
  1381. * given their bounding box in local space.
  1382. *
  1383. * It should transform the local-space bounding box coordinates to
  1384. * frustum space and return a TQ3Boolean return value indicating
  1385. * whether the box appears within the viewing frustum.
  1386. *
  1387. * If no method is supplied, the default behavior is to return
  1388. * kQ3True.
  1389. *
  1390. */
  1391. enum {
  1392. kQ3XMethodTypeRendererIsBoundingBoxVisible = FOUR_CHAR_CODE('rdbx')
  1393. };
  1394. typedef CALLBACK_API_C( TQ3Boolean , TQ3XRendererIsBoundingBoxVisibleMethod )(TQ3ViewObject view, void *rendererPrivate, const TQ3BoundingBox *bBox);
  1395. /******************************************************************************
  1396. ** **
  1397. ** Renderer Object Support Methods **
  1398. ** **
  1399. *****************************************************************************/
  1400. /*
  1401. * Drawing methods (Geometry, Camera, Lights)
  1402. *
  1403. */
  1404. /*
  1405. * Geometry MetaHandler
  1406. *
  1407. * This metaHandler is required to support
  1408. *
  1409. * kQ3GeometryTypeTriangle
  1410. * kQ3GeometryTypeLine
  1411. * kQ3GeometryTypePoint
  1412. * kQ3GeometryTypeMarker
  1413. * kQ3GeometryTypePixmapMarker
  1414. *
  1415. * REQUIRED
  1416. */
  1417. enum {
  1418. kQ3XMethodTypeRendererSubmitGeometryMetaHandler = FOUR_CHAR_CODE('rdgm')
  1419. };
  1420. typedef CALLBACK_API_C( TQ3XFunctionPointer , TQ3XRendererSubmitGeometryMetaHandlerMethod )(TQ3ObjectType geometryType);
  1421. /*
  1422. * The TQ3XRendererSubmitGeometryMetaHandlerMethod switches on geometryType
  1423. * of kQ3GeometryTypeFoo and returns methods of type:
  1424. */
  1425. typedef CALLBACK_API_C( TQ3Status , TQ3XRendererSubmitGeometryMethod )(TQ3ViewObject view, void *rendererPrivate, TQ3GeometryObject geometry, const void *publicData);
  1426. /*
  1427. * Camera MetaHandler
  1428. *
  1429. * This metaHandler, if supplied, indicates that your renderer
  1430. * handles deferred transformation of the main camera within a scene.
  1431. *
  1432. * If not supplied, or an unsupported camera is used, the view will do
  1433. * the transformation for the renderer and pass in a camera in the
  1434. * StartPass method.
  1435. *
  1436. * OPTIONAL
  1437. */
  1438. enum {
  1439. kQ3XMethodTypeRendererSubmitCameraMetaHandler = FOUR_CHAR_CODE('rdcm')
  1440. };
  1441. typedef CALLBACK_API_C( TQ3XFunctionPointer , TQ3XRendererSubmitCameraMetaHandlerMethod )(TQ3ObjectType cameraType);
  1442. /*
  1443. * The TQ3XRendererSubmitCameraMetaHandlerMethod switches on cameraType
  1444. * of kQ3CameraTypeFoo and returns methods of type:
  1445. */
  1446. typedef CALLBACK_API_C( TQ3Status , TQ3XRendererSubmitCameraMethod )(TQ3ViewObject view, void *rendererPrivate, TQ3CameraObject camera, const void *publicData);
  1447. /*
  1448. * Light MetaHandler
  1449. *
  1450. * This metaHandler, if supplied, indicates that your renderer
  1451. * handles deferred transformation of lights within a scene.
  1452. *
  1453. * If an unsupported light is encountered, it is ignored.
  1454. *
  1455. * OPTIONAL
  1456. */
  1457. enum {
  1458. kQ3XMethodTypeRendererSubmitLightMetaHandler = FOUR_CHAR_CODE('rdlg')
  1459. };
  1460. typedef CALLBACK_API_C( TQ3XFunctionPointer , TQ3XRendererSubmitLightMetaHandlerMethod )(TQ3ObjectType lightType);
  1461. /*
  1462. * The TQ3XRendererSubmitLightMetaHandlerMethod switches on lightType
  1463. * of kQ3LightTypeFoo and returns methods of type:
  1464. */
  1465. typedef CALLBACK_API_C( TQ3Status , TQ3XRendererSubmitLightMethod )(TQ3ViewObject view, void *rendererPrivate, TQ3LightObject light, const void *publicData);
  1466. /*
  1467. *
  1468. * Update methods
  1469. *
  1470. * They are called whenever the state has changed. If the renderer supports
  1471. * the RendererPush and RendererPop methods, it must maintain its own state
  1472. * stack. Updates are not called for changed data when the view stack is
  1473. * popped.
  1474. *
  1475. * See the comments for the RendererPush and RendererPop methods above
  1476. * for an example of how data is updated.
  1477. *
  1478. */
  1479. /*
  1480. * Style
  1481. */
  1482. enum {
  1483. kQ3XMethodTypeRendererUpdateStyleMetaHandler = FOUR_CHAR_CODE('rdyu')
  1484. };
  1485. typedef CALLBACK_API_C( TQ3XFunctionPointer , TQ3XRendererUpdateStyleMetaHandlerMethod )(TQ3ObjectType styleType);
  1486. /*
  1487. * The TQ3XRendererUpdateStyleMetaHandlerMethod switches on styleType
  1488. * of kQ3StyleTypeFoo and returns methods of type:
  1489. */
  1490. typedef CALLBACK_API_C( TQ3Status , TQ3XRendererUpdateStyleMethod )(TQ3ViewObject view, void *rendererPrivate, const void *publicData);
  1491. /*
  1492. * Attributes
  1493. */
  1494. enum {
  1495. kQ3XMethodTypeRendererUpdateAttributeMetaHandler = FOUR_CHAR_CODE('rdau')
  1496. };
  1497. typedef CALLBACK_API_C( TQ3XFunctionPointer , TQ3XRendererUpdateAttributeMetaHandlerMethod )(TQ3AttributeType attributeType);
  1498. /*
  1499. * The TQ3XRendererUpdateStyleMetaHandlerMethod switches on attributeType
  1500. * of kQ3AttributeTypeFoo and returns methods of type:
  1501. */
  1502. typedef CALLBACK_API_C( TQ3Status , TQ3XRendererUpdateAttributeMethod )(TQ3ViewObject view, void *rendererPrivate, const void *publicData);
  1503. /*
  1504. * Shaders
  1505. */
  1506. enum {
  1507. kQ3XMethodTypeRendererUpdateShaderMetaHandler = FOUR_CHAR_CODE('rdsu')
  1508. };
  1509. typedef CALLBACK_API_C( TQ3XFunctionPointer , TQ3XRendererUpdateShaderMetaHandlerMethod )(TQ3ObjectType shaderType);
  1510. /*
  1511. * The TQ3XRendererUpdateShaderMetaHandlerMethod switches on shaderType
  1512. * of kQ3ShaderTypeFoo and returns methods of type:
  1513. */
  1514. typedef CALLBACK_API_C( TQ3Status , TQ3XRendererUpdateShaderMethod )(TQ3ViewObject view, void *rendererPrivate, TQ3Object *shaderObject);
  1515. /*
  1516. * Matrices
  1517. */
  1518. enum {
  1519. kQ3XMethodTypeRendererUpdateMatrixMetaHandler = FOUR_CHAR_CODE('rdxu')
  1520. };
  1521. typedef TQ3XMetaHandler TQ3XRendererUpdateMatrixMetaHandlerMethod;
  1522. /*
  1523. * The TQ3XRendererUpdateShaderMetaHandlerMethod switches on methods
  1524. * of the form kQ3MethodTypeRendererUpdateMatrixFoo:
  1525. */
  1526. enum {
  1527. kQ3XMethodTypeRendererUpdateMatrixLocalToWorld = FOUR_CHAR_CODE('ulwx')
  1528. };
  1529. enum {
  1530. kQ3XMethodTypeRendererUpdateMatrixLocalToWorldInverse = FOUR_CHAR_CODE('ulwi')
  1531. };
  1532. enum {
  1533. kQ3XMethodTypeRendererUpdateMatrixLocalToWorldInverseTranspose = FOUR_CHAR_CODE('ulwt')
  1534. };
  1535. enum {
  1536. kQ3XMethodTypeRendererUpdateMatrixLocalToCamera = FOUR_CHAR_CODE('ulcx')
  1537. };
  1538. enum {
  1539. kQ3XMethodTypeRendererUpdateMatrixLocalToFrustum = FOUR_CHAR_CODE('ulfx')
  1540. };
  1541. enum {
  1542. kQ3XMethodTypeRendererUpdateMatrixWorldToFrustum = FOUR_CHAR_CODE('uwfx')
  1543. };
  1544. /*
  1545. * and returns methods of type:
  1546. */
  1547. typedef CALLBACK_API_C( TQ3Status , TQ3XRendererUpdateMatrixMethod )(TQ3ViewObject view, void *rendererPrivate, const TQ3Matrix4x4 *matrix);
  1548. #if PRAGMA_ENUM_ALWAYSINT
  1549. #pragma enumsalwaysint reset
  1550. #ifdef __QD3DRENDERER__RESTORE_TWOBYTEINTS
  1551. #pragma fourbyteints off
  1552. #endif
  1553. #elif PRAGMA_ENUM_OPTIONS
  1554. #pragma option enum=reset
  1555. #elif defined(__QD3DRENDERER__RESTORE_PACKED_ENUMS)
  1556. #pragma options(pack_enums)
  1557. #endif
  1558. #if PRAGMA_STRUCT_ALIGN
  1559. #pragma options align=reset
  1560. #elif PRAGMA_STRUCT_PACKPUSH
  1561. #pragma pack(pop)
  1562. #elif PRAGMA_STRUCT_PACK
  1563. #pragma pack()
  1564. #endif
  1565. #ifdef PRAGMA_IMPORT_OFF
  1566. #pragma import off
  1567. #elif PRAGMA_IMPORT
  1568. #pragma import reset
  1569. #endif
  1570. #ifdef __cplusplus
  1571. }
  1572. #endif
  1573. #endif /* __QD3DRENDERER__ */