gl_w32d.tem 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  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. {$IFDEF Win32}
  33. {$DEFINE ogl_dll := }
  34. uses Windows;
  35. {$ELSE}
  36. {$MESSAGE Unsupported platform.}
  37. {$ENDIF}
  38. // =======================================================
  39. // Unit specific extensions
  40. // =======================================================
  41. function InitGLFromLibrary(libname: PChar): Boolean;
  42. // determines automatically which libraries to use:
  43. function InitGL: Boolean;
  44. var
  45. GLInitialized: Boolean;
  46. // =======================================================
  47. // GL consts, types and functions
  48. // =======================================================
  49. // -------------------------------------------------------
  50. // GL types
  51. // -------------------------------------------------------
  52. type
  53. PSingle = ^Single;
  54. PDouble = ^Double;
  55. GLvoid = Pointer;
  56. GLboolean = Byte;
  57. GLbyte = ShortInt; // 1-byte signed
  58. GLshort = Integer; // 2-byte signed
  59. GLint = LongInt; // 4-byte signed
  60. GLubyte = Byte; // 1-byte unsigned
  61. GLushort = Word; // 2-byte unsigned
  62. GLuint = DWord; // 4-byte signed
  63. GLsizei = LongInt; // 4-byte signed
  64. GLfloat = Single; // single precision float
  65. GLclampf = Single; // single precision float in [0,1]
  66. GLdouble = Double; // double precision float
  67. GLclampd = Double; // double precision float in [0,1]
  68. GLenum = DWord;
  69. type
  70. GLbitfield = DWord; { was an enum - no corresponding thing in pascal }
  71. const
  72. GL_CURRENT_BIT = $00000001;
  73. GL_POINT_BIT = $00000002;
  74. GL_LINE_BIT = $00000004;
  75. GL_POLYGON_BIT = $00000008;
  76. GL_POLYGON_STIPPLE_BIT= $00000010;
  77. GL_PIXEL_MODE_BIT = $00000020;
  78. GL_LIGHTING_BIT = $00000040;
  79. GL_FOG_BIT = $00000080;
  80. GL_DEPTH_BUFFER_BIT = $00000100;
  81. GL_ACCUM_BUFFER_BIT = $00000200;
  82. GL_STENCIL_BUFFER_BIT = $00000400;
  83. GL_VIEWPORT_BIT = $00000800;
  84. GL_TRANSFORM_BIT = $00001000;
  85. GL_ENABLE_BIT = $00002000;
  86. GL_COLOR_BUFFER_BIT = $00004000;
  87. GL_HINT_BIT = $00008000;
  88. GL_EVAL_BIT = $00010000;
  89. GL_LIST_BIT = $00020000;
  90. GL_TEXTURE_BIT = $00040000;
  91. GL_SCISSOR_BIT = $00080000;
  92. GL_ALL_ATTRIB_BITS = $000fffff;
  93. // -------------------------------------------------------
  94. // GL constants
  95. // -------------------------------------------------------
  96. {$IFDEF GL1_0}
  97. %GLDeclsIF10
  98. {$ENDIF GL1_0}
  99. {$IFDEF GL1_1}
  100. %GLDeclsIF11
  101. {$ENDIF GL1_1}
  102. {$IFDEF GL1_2}
  103. %GLDeclsIF12
  104. {$ENDIF GL1_2}
  105. const
  106. // Utility
  107. GL_VENDOR = $1F00;
  108. GL_RENDERER = $1F01;
  109. GL_VERSION = $1F02;
  110. GL_EXTENSIONS = $1F03;
  111. // Errors
  112. GL_INVALID_VALUE = $0501;
  113. GL_INVALID_ENUM = $0500;
  114. GL_INVALID_OPERATION = $0502;
  115. GL_STACK_OVERFLOW = $0503;
  116. GL_STACK_UNDERFLOW = $0504;
  117. GL_OUT_OF_MEMORY = $0505;
  118. // -------------------------------------------------------
  119. // GL extensions constants
  120. // -------------------------------------------------------
  121. {$IFDEF EXTENSIONS}
  122. %GLDeclsIF10Ext
  123. {$ENDIF EXTENSIONS}
  124. {$IFDEF SGI_EXTENSIONS}
  125. %GLDeclsIF10SGI
  126. {$ENDIF SGI_EXTENSIONS}
  127. {$IFDEF MESA}
  128. %GLDeclsIF10Mesa
  129. {$ENDIF MESA}
  130. // -------------------------------------------------------
  131. // GL procedures and functions
  132. // -------------------------------------------------------
  133. {$IFDEF GL1_0}
  134. var
  135. %GLProcsPD10
  136. {$ENDIF GL1_0}
  137. {$IFDEF GL1_1}
  138. var
  139. %GLProcsPD11
  140. {$ENDIF GL1_1}
  141. {$IFDEF GL1_2}
  142. var
  143. %GLProcsPD12
  144. {$ENDIF GL1_2}
  145. // -------------------------------------------------------
  146. // GL Extensions
  147. // -------------------------------------------------------
  148. {$IFDEF EXTENSIONS}
  149. var
  150. %GLProcsPD10Ext
  151. {$ENDIF EXTENSIONS}
  152. // library dependent extensions
  153. {$IFDEF SGI_EXTENSIONS}
  154. var
  155. %GLProcsPD10SGI
  156. {$ENDIF SGI_EXTENSIONS}
  157. {$ifdef MESA}
  158. var
  159. %GLProcsPD10Mesa
  160. {$endif MESA}
  161. // =======================================================
  162. // =======================================================
  163. implementation
  164. type
  165. HInstance = LongWord;
  166. var
  167. libGL : HInstance;
  168. function GetProc(handle: HInstance; name: PChar): Pointer;
  169. begin
  170. Result := GetProcAddress(handle, name);
  171. if Result = nil then WriteLn('Unresolved: ', name);
  172. end;
  173. function InitGLFromLibrary(libname: PChar): Boolean;
  174. begin
  175. Result := False;
  176. libGL := LoadLibrary(libname);
  177. if libGL = 0 then exit;
  178. {$ifdef GL1_0}
  179. %GLProcsPL10
  180. {$endif GL1_0}
  181. {$ifdef GL1_1}
  182. %GLProcsPL11
  183. {$endif GL1_1}
  184. {$ifdef GL1_2}
  185. %GLProcsPL12
  186. {$endif GL1_2}
  187. {$ifdef EXTENSIONS}
  188. %GLProcsPL10Ext
  189. {$endif EXTENSIONS}
  190. {$ifdef SGI_EXTENSIONS}
  191. %GLProcsPL10SGI
  192. {$endif SGI_EXTENSIONS}
  193. {$ifdef MESA}
  194. %GLProcsPL10Mesa
  195. {$endif MESA}
  196. GLInitialized := True;
  197. Result := True;
  198. end;
  199. function InitGL: Boolean;
  200. begin
  201. Result := InitGLFromLibrary('opengl32.dll');
  202. end;
  203. finalization
  204. if libGL <> 0 then FreeLibrary(libGL);
  205. end.
  206. {
  207. $Log$
  208. Revision 1.2 2000-05-31 00:34:28 alex
  209. made templates work
  210. }