freeglut.pp 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. { FreeGlut extensions, see http://freeglut.sourceforge.net/ .
  2. Complements the Glut unit that defines standard Glut functionality.
  3. Function entry points will be nil if freeglut is not
  4. actually available (or if freeglut version necessary for specific extension
  5. is not available).
  6. Includes all the extensions up to FreeGlut 2.6.0 version.
  7. Omitted is only deprecated stuff, and glutGetProcAddress
  8. (which is not needed as we have nice glext unit in FPC). }
  9. unit FreeGlut;
  10. {$mode Delphi} {< to keep assignments to proc vars look the same as in glut.pp }
  11. {$MACRO ON}
  12. { Keep this synched with glut.pp "extdecl" definition. }
  13. {$IFDEF Windows}
  14. {$DEFINE extdecl := stdcall}
  15. {$ELSE}
  16. {$DEFINE extdecl := cdecl}
  17. {$ENDIF}
  18. interface
  19. uses DynLibs, GL, Glut;
  20. type
  21. TGLdouble3 = array [0..2] of GLdouble;
  22. PGLdouble3 = ^TGLdouble3;
  23. const
  24. // Additional GLUT Key definitions for the Special key function
  25. GLUT_KEY_NUM_LOCK = $006D;
  26. GLUT_KEY_BEGIN = $006E;
  27. GLUT_KEY_DELETE = $006F;
  28. // GLUT API Extension macro definitions -- behaviour when the user clicks on an "x" to close a window
  29. GLUT_ACTION_EXIT = 0;
  30. GLUT_ACTION_GLUTMAINLOOP_RETURNS = 1;
  31. GLUT_ACTION_CONTINUE_EXECUTION = 2;
  32. // Create a new rendering context when the user opens a new window?
  33. GLUT_CREATE_NEW_CONTEXT = 0;
  34. GLUT_USE_CURRENT_CONTEXT = 1;
  35. // Direct/Indirect rendering context options (has meaning only in Unix/X11)
  36. GLUT_FORCE_INDIRECT_CONTEXT = 0;
  37. GLUT_ALLOW_DIRECT_CONTEXT = 1;
  38. GLUT_TRY_DIRECT_CONTEXT = 2;
  39. GLUT_FORCE_DIRECT_CONTEXT = 3;
  40. // GLUT API Extension macro definitions -- the glutGet parameters
  41. GLUT_INIT_STATE = $007C;
  42. GLUT_ACTION_ON_WINDOW_CLOSE = $01F9;
  43. GLUT_WINDOW_BORDER_WIDTH = $01FA;
  44. GLUT_WINDOW_HEADER_HEIGHT = $01FB;
  45. GLUT_VERSION = $01FC;
  46. GLUT_RENDERING_CONTEXT = $01FD;
  47. GLUT_DIRECT_RENDERING = $01FE;
  48. GLUT_FULL_SCREEN = $01FF;
  49. // New tokens for glutInitDisplayMode.
  50. // Only one GLUT_AUXn bit may be used at a time.
  51. // Value 0x0400 is defined in OpenGLUT.
  52. GLUT_AUX = $1000;
  53. GLUT_AUX1 = $1000;
  54. GLUT_AUX2 = $2000;
  55. GLUT_AUX3 = $4000;
  56. GLUT_AUX4 = $8000;
  57. // Context-related flags
  58. GLUT_INIT_MAJOR_VERSION = $0200;
  59. GLUT_INIT_MINOR_VERSION = $0201;
  60. GLUT_INIT_FLAGS = $0202;
  61. GLUT_INIT_PROFILE = $0203;
  62. // Flags for glutInitContextFlags
  63. GLUT_DEBUG = $0001;
  64. GLUT_FORWARD_COMPATIBLE = $0002;
  65. // Flags for glutInitContextProfile
  66. GLUT_CORE_PROFILE = $0001;
  67. GLUT_COMPATIBILITY_PROFILE = $0002;
  68. // GLUT API macro definitions -- the display mode definitions
  69. GLUT_CAPTIONLESS = $0400;
  70. GLUT_BORDERLESS = $0800;
  71. GLUT_SRGB = $1000;
  72. var
  73. // Process loop function
  74. glutMainLoopEvent: procedure; extdecl;
  75. glutLeaveMainLoop: procedure; extdecl;
  76. glutExit: procedure; extdecl;
  77. // Window management functions
  78. glutFullScreenToggle: procedure; extdecl;
  79. // Window-specific callback functions
  80. glutMouseWheelFunc: procedure(callback: TGlut4IntCallback); extdecl;
  81. glutCloseFunc: procedure(callback: TGlutVoidCallback); extdecl;
  82. // A. Donev: Also a destruction callback for menus
  83. glutMenuDestroyFunc: procedure(callback: TGlutVoidCallback); extdecl;
  84. // State setting and retrieval functions
  85. glutSetOption: procedure(option_flag: GLenum; value: Integer); extdecl;
  86. glutGetModeValues: function(mode: GLenum; size: PInteger): Integer; extdecl;
  87. // A.Donev: User-data manipulation
  88. glutGetWindowData: function: Pointer; extdecl;
  89. glutSetWindowData: procedure(data: Pointer); extdecl;
  90. glutGetMenuData: function: Pointer; extdecl;
  91. glutSetMenuData: procedure(data: Pointer); extdecl;
  92. // Font stuff
  93. glutBitmapHeight: function(font : pointer): Integer; extdecl;
  94. glutStrokeHeight: function(font : pointer): GLfloat; extdecl;
  95. glutBitmapString: procedure(font : pointer; const str: PChar); extdecl;
  96. glutStrokeString: procedure(font : pointer; const str: PChar); extdecl;
  97. // Geometry functions
  98. glutWireRhombicDodecahedron: procedure; extdecl;
  99. glutSolidRhombicDodecahedron: procedure; extdecl;
  100. glutWireSierpinskiSponge: procedure(num_levels: Integer; offset: PGLdouble3; scale: GLdouble); extdecl;
  101. glutSolidSierpinskiSponge: procedure(num_levels: Integer; offset: PGLdouble3; scale: GLdouble); extdecl;
  102. glutWireCylinder: procedure(radius: GLdouble; height: GLdouble; slices: GLint; stacks: GLint); extdecl;
  103. glutSolidCylinder: procedure(radius: GLdouble; height: GLdouble; slices: GLint; stacks: GLint); extdecl;
  104. // Initialization functions
  105. glutInitContextVersion: procedure(majorVersion: Integer; minorVersion: Integer); extdecl;
  106. glutInitContextFlags: procedure(flags: Integer); extdecl;
  107. glutInitContextProfile: procedure(profile: Integer); extdecl;
  108. { Load all freeglut functions from given library.
  109. Called automatically from Glut unit when standard Glut stuff is loaded. }
  110. procedure LoadFreeGlut(hDLL: TLibHandle);
  111. { Set to nil all freeglut functions.
  112. Called automatically from Glut unit when standard Glut stuff is unloaded. }
  113. procedure UnloadFreeGlut;
  114. implementation
  115. procedure LoadFreeGlut(hDLL: TLibHandle);
  116. begin
  117. @glutMainLoopEvent := GetProcAddress(hDLL, 'glutMainLoopEvent');
  118. @glutLeaveMainLoop := GetProcAddress(hDLL, 'glutLeaveMainLoop');
  119. @glutExit := GetProcAddress(hDLL, 'glutExit');
  120. @glutFullScreenToggle := GetProcAddress(hDLL, 'glutFullScreenToggle');
  121. @glutMouseWheelFunc := GetProcAddress(hDLL, 'glutMouseWheelFunc');
  122. @glutCloseFunc := GetProcAddress(hDLL, 'glutCloseFunc');
  123. @glutMenuDestroyFunc := GetProcAddress(hDLL, 'glutMenuDestroyFunc');
  124. @glutSetOption := GetProcAddress(hDLL, 'glutSetOption');
  125. @glutGetModeValues := GetProcAddress(hDLL, 'glutGetModeValues');
  126. @glutGetWindowData := GetProcAddress(hDLL, 'glutGetWindowData');
  127. @glutSetWindowData := GetProcAddress(hDLL, 'glutSetWindowData');
  128. @glutGetMenuData := GetProcAddress(hDLL, 'glutGetMenuData');
  129. @glutSetMenuData := GetProcAddress(hDLL, 'glutSetMenuData');
  130. @glutBitmapHeight := GetProcAddress(hDLL, 'glutBitmapHeight');
  131. @glutStrokeHeight := GetProcAddress(hDLL, 'glutStrokeHeight');
  132. @glutBitmapString := GetProcAddress(hDLL, 'glutBitmapString');
  133. @glutStrokeString := GetProcAddress(hDLL, 'glutStrokeString');
  134. @glutWireRhombicDodecahedron := GetProcAddress(hDLL, 'glutWireRhombicDodecahedron');
  135. @glutSolidRhombicDodecahedron := GetProcAddress(hDLL, 'glutSolidRhombicDodecahedron');
  136. @glutWireSierpinskiSponge := GetProcAddress(hDLL, 'glutWireSierpinskiSponge');
  137. @glutSolidSierpinskiSponge := GetProcAddress(hDLL, 'glutSolidSierpinskiSponge');
  138. @glutWireCylinder := GetProcAddress(hDLL, 'glutWireCylinder');
  139. @glutSolidCylinder := GetProcAddress(hDLL, 'glutSolidCylinder');
  140. @glutInitContextVersion := GetProcAddress(hDLL, 'glutInitContextVersion');
  141. @glutInitContextFlags := GetProcAddress(hDLL, 'glutInitContextFlags');
  142. @glutInitContextProfile := GetProcAddress(hDLL, 'glutInitContextProfile');
  143. end;
  144. procedure UnloadFreeGlut;
  145. begin
  146. @glutMainLoopEvent := nil;
  147. @glutLeaveMainLoop := nil;
  148. @glutExit := nil;
  149. @glutFullScreenToggle := nil;
  150. @glutMouseWheelFunc := nil;
  151. @glutCloseFunc := nil;
  152. @glutMenuDestroyFunc := nil;
  153. @glutSetOption := nil;
  154. @glutGetModeValues := nil;
  155. @glutGetWindowData := nil;
  156. @glutSetWindowData := nil;
  157. @glutGetMenuData := nil;
  158. @glutSetMenuData := nil;
  159. @glutBitmapHeight := nil;
  160. @glutStrokeHeight := nil;
  161. @glutBitmapString := nil;
  162. @glutStrokeString := nil;
  163. @glutWireRhombicDodecahedron := nil;
  164. @glutSolidRhombicDodecahedron := nil;
  165. @glutWireSierpinskiSponge := nil;
  166. @glutSolidSierpinskiSponge := nil;
  167. @glutWireCylinder := nil;
  168. @glutSolidCylinder := nil;
  169. @glutInitContextVersion := nil;
  170. @glutInitContextFlags := nil;
  171. @glutInitContextProfile := nil;
  172. end;
  173. end.