gl_w32d.tem 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  1. {
  2. $Id$
  3. Translation of the Mesa GL headers for FreePascal
  4. Copyright (C) 1999 Sebastian Guenther
  5. Mesa 3-D graphics library
  6. Version: 3.0
  7. Copyright (C) 1995-1998 Brian Paul
  8. This library is free software; you can redistribute it and/or
  9. modify it under the terms of the GNU Library General Public
  10. License as published by the Free Software Foundation; either
  11. version 2 of the License, or (at your option) any later version.
  12. This library is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. Library General Public License for more details.
  16. You should have received a copy of the GNU Library General Public
  17. License along with this library; if not, write to the Free
  18. Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19. }
  20. {$MODE delphi} // objfpc would not work because of direct proc var assignments
  21. {You have to enable Macros (compiler switch "-Sm") for compiling this unit!
  22. This is necessary for supporting different platforms with different calling
  23. conventions via a single unit.}
  24. unit GL;
  25. interface
  26. {$DEFINE GL1_0}
  27. {x$DEFINE GL1_1}
  28. {x$DEFINE GL1_2}
  29. {x$DEFINE MESA} {enable if you want to use some special mesa extensions}
  30. {x$DEFINE EXTENSIONS} {enable if you need one/all of extensions}
  31. {x$DEFINE SGI_EXTENSIONS} {enable if you need one/all of extensions}
  32. {$MACRO ON}
  33. {$IFDEF Win32}
  34. {$DEFINE ogl_dll := }
  35. uses Windows;
  36. {$ELSE}
  37. {$MESSAGE Unsupported platform.}
  38. {$ENDIF}
  39. // =======================================================
  40. // Unit specific extensions
  41. // =======================================================
  42. function InitGLFromLibrary(libname: PChar): Boolean;
  43. // determines automatically which libraries to use:
  44. function InitGL: Boolean;
  45. var
  46. GLDumpUnresolvedFunctions,
  47. GLInitialized: Boolean;
  48. // =======================================================
  49. // GL consts, types and functions
  50. // =======================================================
  51. // -------------------------------------------------------
  52. // GL types
  53. // -------------------------------------------------------
  54. type
  55. PSingle = ^Single;
  56. PDouble = ^Double;
  57. GLvoid = Pointer;
  58. GLboolean = Byte;
  59. GLbyte = ShortInt; // 1-byte signed
  60. GLshort = Integer; // 2-byte signed
  61. GLint = LongInt; // 4-byte signed
  62. GLubyte = Byte; // 1-byte unsigned
  63. GLushort = Word; // 2-byte unsigned
  64. GLuint = DWord; // 4-byte signed
  65. GLsizei = LongInt; // 4-byte signed
  66. GLfloat = Single; // single precision float
  67. GLclampf = Single; // single precision float in [0,1]
  68. GLdouble = Double; // double precision float
  69. GLclampd = Double; // double precision float in [0,1]
  70. GLenum = DWord;
  71. PGLBoolean = ^GLBoolean;
  72. PGLFloat = ^GLfloat;
  73. PGLDouble = ^GLDouble;
  74. type
  75. GLbitfield = DWord; { was an enum - no corresponding thing in pascal }
  76. const
  77. GL_CURRENT_BIT = $00000001;
  78. GL_POINT_BIT = $00000002;
  79. GL_LINE_BIT = $00000004;
  80. GL_POLYGON_BIT = $00000008;
  81. GL_POLYGON_STIPPLE_BIT= $00000010;
  82. GL_PIXEL_MODE_BIT = $00000020;
  83. GL_LIGHTING_BIT = $00000040;
  84. GL_FOG_BIT = $00000080;
  85. GL_DEPTH_BUFFER_BIT = $00000100;
  86. GL_ACCUM_BUFFER_BIT = $00000200;
  87. GL_STENCIL_BUFFER_BIT = $00000400;
  88. GL_VIEWPORT_BIT = $00000800;
  89. GL_TRANSFORM_BIT = $00001000;
  90. GL_ENABLE_BIT = $00002000;
  91. GL_COLOR_BUFFER_BIT = $00004000;
  92. GL_HINT_BIT = $00008000;
  93. GL_EVAL_BIT = $00010000;
  94. GL_LIST_BIT = $00020000;
  95. GL_TEXTURE_BIT = $00040000;
  96. GL_SCISSOR_BIT = $00080000;
  97. GL_ALL_ATTRIB_BITS = $000fffff;
  98. // -------------------------------------------------------
  99. // GL constants
  100. // -------------------------------------------------------
  101. {$IFDEF GL1_0}
  102. %GLDeclsIF10
  103. {$ENDIF GL1_0}
  104. {$IFDEF GL1_1}
  105. %GLDeclsIF11
  106. {$ENDIF GL1_1}
  107. {$IFDEF GL1_2}
  108. %GLDeclsIF12
  109. {$ENDIF GL1_2}
  110. const
  111. // Utility
  112. GL_VENDOR = $1F00;
  113. GL_RENDERER = $1F01;
  114. GL_VERSION = $1F02;
  115. GL_EXTENSIONS = $1F03;
  116. // Errors
  117. GL_INVALID_VALUE = $0501;
  118. GL_INVALID_ENUM = $0500;
  119. GL_INVALID_OPERATION = $0502;
  120. GL_STACK_OVERFLOW = $0503;
  121. GL_STACK_UNDERFLOW = $0504;
  122. GL_OUT_OF_MEMORY = $0505;
  123. // -------------------------------------------------------
  124. // GL extensions constants
  125. // -------------------------------------------------------
  126. {$IFDEF EXTENSIONS}
  127. %GLDeclsIF10Ext
  128. {$ENDIF EXTENSIONS}
  129. {$IFDEF SGI_EXTENSIONS}
  130. %GLDeclsIF10SGI
  131. {$ENDIF SGI_EXTENSIONS}
  132. {$IFDEF MESA}
  133. %GLDeclsIF10Mesa
  134. {$ENDIF MESA}
  135. // -------------------------------------------------------
  136. // GL procedures and functions
  137. // -------------------------------------------------------
  138. {$IFDEF GL1_0}
  139. var
  140. %GLProcsPD10
  141. {$ENDIF GL1_0}
  142. {$IFDEF GL1_1}
  143. var
  144. %GLProcsPD11
  145. {$ENDIF GL1_1}
  146. {$IFDEF GL1_2}
  147. var
  148. %GLProcsPD12
  149. {$ENDIF GL1_2}
  150. // -------------------------------------------------------
  151. // GL Extensions
  152. // -------------------------------------------------------
  153. {$IFDEF EXTENSIONS}
  154. var
  155. %GLProcsPD10Ext
  156. {$ENDIF EXTENSIONS}
  157. // library dependent extensions
  158. {$IFDEF SGI_EXTENSIONS}
  159. var
  160. %GLProcsPD10SGI
  161. {$ENDIF SGI_EXTENSIONS}
  162. {$ifdef MESA}
  163. var
  164. %GLProcsPD10Mesa
  165. {$endif MESA}
  166. // =======================================================
  167. // =======================================================
  168. implementation
  169. type
  170. HInstance = LongWord;
  171. var
  172. libGL : HInstance;
  173. function GetProc(handle: HInstance; name: PChar): Pointer;
  174. begin
  175. Result := GetProcAddress(handle, name);
  176. if (Result = nil) and GLDumpUnresolvedFunctions then
  177. WriteLn('Unresolved: ', name);
  178. end;
  179. function InitGLFromLibrary(libname: PChar): Boolean;
  180. begin
  181. Result := False;
  182. libGL := LoadLibrary(libname);
  183. if libGL = 0 then exit;
  184. {$ifdef GL1_0}
  185. %GLProcsPL10
  186. {$endif GL1_0}
  187. {$ifdef GL1_1}
  188. %GLProcsPL11
  189. {$endif GL1_1}
  190. {$ifdef GL1_2}
  191. %GLProcsPL12
  192. {$endif GL1_2}
  193. {$ifdef EXTENSIONS}
  194. %GLProcsPL10Ext
  195. {$endif EXTENSIONS}
  196. {$ifdef SGI_EXTENSIONS}
  197. %GLProcsPL10SGI
  198. {$endif SGI_EXTENSIONS}
  199. {$ifdef MESA}
  200. %GLProcsPL10Mesa
  201. {$endif MESA}
  202. GLInitialized := True;
  203. Result := True;
  204. end;
  205. function InitGL: Boolean;
  206. begin
  207. Result := InitGLFromLibrary('opengl32.dll');
  208. end;
  209. initialization
  210. InitGL;
  211. finalization
  212. if libGL <> 0 then FreeLibrary(libGL);
  213. end.
  214. {
  215. $Log$
  216. Revision 1.2 2000-09-03 22:17:17 peter
  217. * merged
  218. Revision 1.1.2.1 2000/09/03 22:15:06 peter
  219. * typo fix
  220. Revision 1.1 2000/09/03 21:25:45 peter
  221. * new updated version
  222. * gtkglarea unit and demo
  223. * win32 opengl headers
  224. * morph3d demo
  225. Revision 1.1 2000/07/13 06:34:17 michael
  226. + Initial import
  227. Revision 1.2 2000/05/31 00:34:28 alex
  228. made templates work
  229. }