glu.pp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562
  1. {
  2. Adaption of the delphi3d.net OpenGL units to FreePascal
  3. Sebastian Guenther ([email protected]) in 2002
  4. These units are free to use
  5. }
  6. (*++ BUILD Version: 0004 // Increment this if a change has global effects
  7. Copyright (c) 1985-95, Microsoft Corporation
  8. Module Name:
  9. glu.h
  10. Abstract:
  11. Procedure declarations, constant definitions and macros for the OpenGL
  12. Utility Library.
  13. --*)
  14. (*
  15. ** Copyright 1991-1993, Silicon Graphics, Inc.
  16. ** All Rights Reserved.
  17. **
  18. ** This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  19. ** the contents of this file may not be disclosed to third parties, copied or
  20. ** duplicated in any form, in whole or in part, without the prior written
  21. ** permission of Silicon Graphics, Inc.
  22. **
  23. ** RESTRICTED RIGHTS LEGEND:
  24. ** Use, duplication or disclosure by the Government is subject to restrictions
  25. ** as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  26. ** and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  27. ** successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  28. ** rights reserved under the Copyright Laws of the United States.
  29. *)
  30. (*
  31. ** Return the error string associated with a particular error code.
  32. ** This will return 0 for an invalid error code.
  33. **
  34. ** The generic function prototype that can be compiled for ANSI or Unicode
  35. ** is defined as follows:
  36. **
  37. ** LPCTSTR APIENTRY gluErrorStringWIN (GLenum errCode);
  38. *)
  39. {******************************************************************************}
  40. { Converted to Delphi by Tom Nuydens ([email protected]) }
  41. { For the latest updates, visit Delphi3D: http://www.delphi3d.net }
  42. {******************************************************************************}
  43. {$MACRO ON}
  44. {$MODE Delphi}
  45. {$IFDEF Win32}
  46. {$DEFINE extdecl := stdcall}
  47. {$ELSE}
  48. {$DEFINE extdecl := cdecl}
  49. {$ENDIF}
  50. {$IFDEF MORPHOS}
  51. {$INLINE ON}
  52. {$DEFINE GLU_UNIT}
  53. {$ENDIF}
  54. unit GLu;
  55. interface
  56. uses
  57. SysUtils,
  58. {$IFDEF Win32}
  59. Windows,
  60. {$ELSE}
  61. {$IFDEF MORPHOS}
  62. TinyGL,
  63. {$ELSE}
  64. DLLFuncs,
  65. {$ENDIF}
  66. {$ENDIF}
  67. GL;
  68. type
  69. TViewPortArray = array [0..3] of GLint;
  70. T16dArray = array [0..15] of GLdouble;
  71. TCallBack = procedure;
  72. T3dArray = array [0..2] of GLdouble;
  73. T4pArray = array [0..3] of Pointer;
  74. T4fArray = array [0..3] of GLfloat;
  75. PPointer = ^Pointer;
  76. type
  77. GLUnurbs = record end; PGLUnurbs = ^GLUnurbs;
  78. GLUquadric = record end; PGLUquadric = ^GLUquadric;
  79. GLUtesselator = record end; PGLUtesselator = ^GLUtesselator;
  80. // backwards compatibility:
  81. GLUnurbsObj = GLUnurbs; PGLUnurbsObj = PGLUnurbs;
  82. GLUquadricObj = GLUquadric; PGLUquadricObj = PGLUquadric;
  83. GLUtesselatorObj = GLUtesselator; PGLUtesselatorObj = PGLUtesselator;
  84. GLUtriangulatorObj = GLUtesselator; PGLUtriangulatorObj = PGLUtesselator;
  85. {$IFDEF MORPHOS}
  86. { MorphOS GL works differently due to different dynamic-library handling on Amiga-like }
  87. { systems, so its headers are included here. }
  88. {$INCLUDE tinyglh.inc}
  89. {$ELSE MORPHOS}
  90. var
  91. gluErrorString: function(errCode: GLenum): PChar; extdecl;
  92. gluErrorUnicodeStringEXT: function(errCode: GLenum): PWideChar; extdecl;
  93. gluGetString: function(name: GLenum): PChar; extdecl;
  94. gluOrtho2D: procedure(left,right, bottom, top: GLdouble); extdecl;
  95. gluPerspective: procedure(fovy, aspect, zNear, zFar: GLdouble); extdecl;
  96. gluPickMatrix: procedure(x, y, width, height: GLdouble; var viewport: TViewPortArray); extdecl;
  97. gluLookAt: procedure(eyex, eyey, eyez, centerx, centery, centerz, upx, upy, upz: GLdouble); extdecl;
  98. gluProject: function(objx, objy, objz: GLdouble; var modelMatrix, projMatrix: T16dArray; var viewport: TViewPortArray; winx, winy, winz: PGLdouble): Integer; extdecl;
  99. gluUnProject: function(winx, winy, winz: GLdouble; var modelMatrix, projMatrix: T16dArray; var viewport: TViewPortArray; objx, objy, objz: PGLdouble): Integer; extdecl;
  100. gluScaleImage: function(format: GLenum; widthin, heightin: GLint; typein: GLenum; const datain: Pointer; widthout, heightout: GLint; typeout: GLenum; dataout: Pointer): Integer; extdecl;
  101. gluBuild1DMipmaps: function(target: GLenum; components, width: GLint; format, atype: GLenum; const data: Pointer): Integer; extdecl;
  102. gluBuild2DMipmaps: function(target: GLenum; components, width, height: GLint; format, atype: GLenum; const data: Pointer): Integer; extdecl;
  103. var
  104. gluNewQuadric: function: PGLUquadric; extdecl;
  105. gluDeleteQuadric: procedure(state: PGLUquadric); extdecl;
  106. gluQuadricNormals: procedure(quadObject: PGLUquadric; normals: GLenum); extdecl;
  107. gluQuadricTexture: procedure(quadObject: PGLUquadric; textureCoords: GLboolean); extdecl;
  108. gluQuadricOrientation: procedure(quadObject: PGLUquadric; orientation: GLenum); extdecl;
  109. gluQuadricDrawStyle: procedure(quadObject: PGLUquadric; drawStyle: GLenum); extdecl;
  110. gluCylinder: procedure(qobj: PGLUquadric; baseRadius, topRadius, height: GLdouble; slices, stacks: GLint); extdecl;
  111. gluDisk: procedure(qobj: PGLUquadric; innerRadius, outerRadius: GLdouble; slices, loops: GLint); extdecl;
  112. gluPartialDisk: procedure(qobj: PGLUquadric; innerRadius, outerRadius: GLdouble; slices, loops: GLint; startAngle, sweepAngle: GLdouble); extdecl;
  113. gluSphere: procedure(qobj: PGLuquadric; radius: GLdouble; slices, stacks: GLint); extdecl;
  114. gluQuadricCallback: procedure(qobj: PGLUquadric; which: GLenum; fn: TCallBack); extdecl;
  115. gluNewTess: function: PGLUtesselator; extdecl;
  116. gluDeleteTess: procedure(tess: PGLUtesselator); extdecl;
  117. gluTessBeginPolygon: procedure(tess: PGLUtesselator; polygon_data: Pointer); extdecl;
  118. gluTessBeginContour: procedure(tess: PGLUtesselator); extdecl;
  119. gluTessVertex: procedure(tess: PGLUtesselator; var coords: T3dArray; data: Pointer); extdecl;
  120. gluTessEndContour: procedure(tess: PGLUtesselator); extdecl;
  121. gluTessEndPolygon: procedure(tess: PGLUtesselator); extdecl;
  122. gluTessProperty: procedure(tess: PGLUtesselator; which: GLenum; value: GLdouble); extdecl;
  123. gluTessNormal: procedure(tess: PGLUtesselator; x, y, z: GLdouble); extdecl;
  124. gluTessCallback: procedure(tess: PGLUtesselator; which: GLenum;fn: TCallBack); extdecl;
  125. gluGetTessProperty: procedure(tess: PGLUtesselator; which: GLenum; value: PGLdouble); extdecl;
  126. gluNewNurbsRenderer: function: PGLUnurbs; extdecl;
  127. gluDeleteNurbsRenderer: procedure(nobj: PGLUnurbs); extdecl;
  128. gluBeginSurface: procedure(nobj: PGLUnurbs); extdecl;
  129. gluBeginCurve: procedure(nobj: PGLUnurbs); extdecl;
  130. gluEndCurve: procedure(nobj: PGLUnurbs); extdecl;
  131. gluEndSurface: procedure(nobj: PGLUnurbs); extdecl;
  132. gluBeginTrim: procedure(nobj: PGLUnurbs); extdecl;
  133. gluEndTrim: procedure(nobj: PGLUnurbs); extdecl;
  134. gluPwlCurve: procedure(nobj: PGLUnurbs; count: GLint; aarray: PGLfloat; stride: GLint; atype: GLenum); extdecl;
  135. gluNurbsCurve: procedure(nobj: PGLUnurbs; nknots: GLint; knot: PGLfloat; stride: GLint; ctlarray: PGLfloat; order: GLint; atype: GLenum); extdecl;
  136. gluNurbsSurface: procedure(nobj: PGLUnurbs; sknot_count: GLint; sknot: PGLfloat; tknot_count: GLint; tknot: PGLfloat; s_stride, t_stride: GLint; ctlarray: PGLfloat; sorder, torder: GLint; atype: GLenum); extdecl;
  137. gluLoadSamplingMatrices: procedure(nobj: PGLUnurbs; var modelMatrix, projMatrix: T16dArray; var viewport: TViewPortArray); extdecl;
  138. gluNurbsProperty: procedure(nobj: PGLUnurbs; aproperty: GLenum; value: GLfloat); extdecl;
  139. gluGetNurbsProperty: procedure(nobj: PGLUnurbs; aproperty: GLenum; value: PGLfloat); extdecl;
  140. gluNurbsCallback: procedure(nobj: PGLUnurbs; which: GLenum; fn: TCallBack); extdecl;
  141. {$ENDIF MORPHOS}
  142. (**** Callback function prototypes ****)
  143. type
  144. // gluQuadricCallback
  145. GLUquadricErrorProc = procedure(p: GLenum); extdecl;
  146. // gluTessCallback
  147. GLUtessBeginProc = procedure(p: GLenum); extdecl;
  148. GLUtessEdgeFlagProc = procedure(p: GLboolean); extdecl;
  149. GLUtessVertexProc = procedure(p: Pointer); extdecl;
  150. GLUtessEndProc = procedure; extdecl;
  151. GLUtessErrorProc = procedure(p: GLenum); extdecl;
  152. GLUtessCombineProc = procedure(var p1: T3dArray; p2: T4pArray; p3: T4fArray; p4: PPointer); extdecl;
  153. GLUtessBeginDataProc = procedure(p1: GLenum; p2: Pointer); extdecl;
  154. GLUtessEdgeFlagDataProc = procedure(p1: GLboolean; p2: Pointer); extdecl;
  155. GLUtessVertexDataProc = procedure(p1, p2: Pointer); extdecl;
  156. GLUtessEndDataProc = procedure(p: Pointer); extdecl;
  157. GLUtessErrorDataProc = procedure(p1: GLenum; p2: Pointer); extdecl;
  158. GLUtessCombineDataProc = procedure(var p1: T3dArray; var p2: T4pArray; var p3: T4fArray;
  159. p4: PPointer; p5: Pointer); extdecl;
  160. // gluNurbsCallback
  161. GLUnurbsErrorProc = procedure(p: GLenum); extdecl;
  162. //*** Generic constants ****/
  163. const
  164. // Version
  165. GLU_VERSION_1_1 = 1;
  166. GLU_VERSION_1_2 = 1;
  167. // Errors: (return value 0 = no error)
  168. GLU_INVALID_ENUM = 100900;
  169. GLU_INVALID_VALUE = 100901;
  170. GLU_OUT_OF_MEMORY = 100902;
  171. GLU_INCOMPATIBLE_GL_VERSION = 100903;
  172. // StringName
  173. GLU_VERSION = 100800;
  174. GLU_EXTENSIONS = 100801;
  175. // Boolean
  176. GLU_TRUE = GL_TRUE;
  177. GLU_FALSE = GL_FALSE;
  178. //*** Quadric constants ****/
  179. // QuadricNormal
  180. GLU_SMOOTH = 100000;
  181. GLU_FLAT = 100001;
  182. GLU_NONE = 100002;
  183. // QuadricDrawStyle
  184. GLU_POINT = 100010;
  185. GLU_LINE = 100011;
  186. GLU_FILL = 100012;
  187. GLU_SILHOUETTE = 100013;
  188. // QuadricOrientation
  189. GLU_OUTSIDE = 100020;
  190. GLU_INSIDE = 100021;
  191. // Callback types:
  192. // GLU_ERROR = 100103;
  193. //*** Tesselation constants ****/
  194. GLU_TESS_MAX_COORD = 1.0e150;
  195. // TessProperty
  196. GLU_TESS_WINDING_RULE = 100140;
  197. GLU_TESS_BOUNDARY_ONLY = 100141;
  198. GLU_TESS_TOLERANCE = 100142;
  199. // TessWinding
  200. GLU_TESS_WINDING_ODD = 100130;
  201. GLU_TESS_WINDING_NONZERO = 100131;
  202. GLU_TESS_WINDING_POSITIVE = 100132;
  203. GLU_TESS_WINDING_NEGATIVE = 100133;
  204. GLU_TESS_WINDING_ABS_GEQ_TWO = 100134;
  205. // TessCallback
  206. GLU_TESS_BEGIN = 100100; // void (CALLBACK*)(GLenum type)
  207. GLU_TESS_VERTEX = 100101; // void (CALLBACK*)(void *data)
  208. GLU_TESS_END = 100102; // void (CALLBACK*)(void)
  209. GLU_TESS_ERROR = 100103; // void (CALLBACK*)(GLenum errno)
  210. GLU_TESS_EDGE_FLAG = 100104; // void (CALLBACK*)(GLboolean boundaryEdge)
  211. GLU_TESS_COMBINE = 100105; { void (CALLBACK*)(GLdouble coords[3],
  212. void *data[4],
  213. GLfloat weight[4],
  214. void **dataOut) }
  215. GLU_TESS_BEGIN_DATA = 100106; { void (CALLBACK*)(GLenum type,
  216. void *polygon_data) }
  217. GLU_TESS_VERTEX_DATA = 100107; { void (CALLBACK*)(void *data,
  218. void *polygon_data) }
  219. GLU_TESS_END_DATA = 100108; // void (CALLBACK*)(void *polygon_data)
  220. GLU_TESS_ERROR_DATA = 100109; { void (CALLBACK*)(GLenum errno,
  221. void *polygon_data) }
  222. GLU_TESS_EDGE_FLAG_DATA = 100110; { void (CALLBACK*)(GLboolean boundaryEdge,
  223. void *polygon_data) }
  224. GLU_TESS_COMBINE_DATA = 100111; { void (CALLBACK*)(GLdouble coords[3],
  225. void *data[4],
  226. GLfloat weight[4],
  227. void **dataOut,
  228. void *polygon_data) }
  229. // TessError
  230. GLU_TESS_ERROR1 = 100151;
  231. GLU_TESS_ERROR2 = 100152;
  232. GLU_TESS_ERROR3 = 100153;
  233. GLU_TESS_ERROR4 = 100154;
  234. GLU_TESS_ERROR5 = 100155;
  235. GLU_TESS_ERROR6 = 100156;
  236. GLU_TESS_ERROR7 = 100157;
  237. GLU_TESS_ERROR8 = 100158;
  238. GLU_TESS_MISSING_BEGIN_POLYGON = GLU_TESS_ERROR1;
  239. GLU_TESS_MISSING_BEGIN_CONTOUR = GLU_TESS_ERROR2;
  240. GLU_TESS_MISSING_END_POLYGON = GLU_TESS_ERROR3;
  241. GLU_TESS_MISSING_END_CONTOUR = GLU_TESS_ERROR4;
  242. GLU_TESS_COORD_TOO_LARGE = GLU_TESS_ERROR5;
  243. GLU_TESS_NEED_COMBINE_CALLBACK = GLU_TESS_ERROR6;
  244. //*** NURBS constants ****/
  245. // NurbsProperty
  246. GLU_AUTO_LOAD_MATRIX = 100200;
  247. GLU_CULLING = 100201;
  248. GLU_SAMPLING_TOLERANCE = 100203;
  249. GLU_DISPLAY_MODE = 100204;
  250. GLU_PARAMETRIC_TOLERANCE = 100202;
  251. GLU_SAMPLING_METHOD = 100205;
  252. GLU_U_STEP = 100206;
  253. GLU_V_STEP = 100207;
  254. // NurbsSampling
  255. GLU_PATH_LENGTH = 100215;
  256. GLU_PARAMETRIC_ERROR = 100216;
  257. GLU_DOMAIN_DISTANCE = 100217;
  258. // NurbsTrim
  259. GLU_MAP1_TRIM_2 = 100210;
  260. GLU_MAP1_TRIM_3 = 100211;
  261. // NurbsDisplay
  262. // GLU_FILL = 100012;
  263. GLU_OUTLINE_POLYGON = 100240;
  264. GLU_OUTLINE_PATCH = 100241;
  265. // NurbsCallback
  266. // GLU_ERROR = 100103;
  267. // NurbsErrors
  268. GLU_NURBS_ERROR1 = 100251;
  269. GLU_NURBS_ERROR2 = 100252;
  270. GLU_NURBS_ERROR3 = 100253;
  271. GLU_NURBS_ERROR4 = 100254;
  272. GLU_NURBS_ERROR5 = 100255;
  273. GLU_NURBS_ERROR6 = 100256;
  274. GLU_NURBS_ERROR7 = 100257;
  275. GLU_NURBS_ERROR8 = 100258;
  276. GLU_NURBS_ERROR9 = 100259;
  277. GLU_NURBS_ERROR10 = 100260;
  278. GLU_NURBS_ERROR11 = 100261;
  279. GLU_NURBS_ERROR12 = 100262;
  280. GLU_NURBS_ERROR13 = 100263;
  281. GLU_NURBS_ERROR14 = 100264;
  282. GLU_NURBS_ERROR15 = 100265;
  283. GLU_NURBS_ERROR16 = 100266;
  284. GLU_NURBS_ERROR17 = 100267;
  285. GLU_NURBS_ERROR18 = 100268;
  286. GLU_NURBS_ERROR19 = 100269;
  287. GLU_NURBS_ERROR20 = 100270;
  288. GLU_NURBS_ERROR21 = 100271;
  289. GLU_NURBS_ERROR22 = 100272;
  290. GLU_NURBS_ERROR23 = 100273;
  291. GLU_NURBS_ERROR24 = 100274;
  292. GLU_NURBS_ERROR25 = 100275;
  293. GLU_NURBS_ERROR26 = 100276;
  294. GLU_NURBS_ERROR27 = 100277;
  295. GLU_NURBS_ERROR28 = 100278;
  296. GLU_NURBS_ERROR29 = 100279;
  297. GLU_NURBS_ERROR30 = 100280;
  298. GLU_NURBS_ERROR31 = 100281;
  299. GLU_NURBS_ERROR32 = 100282;
  300. GLU_NURBS_ERROR33 = 100283;
  301. GLU_NURBS_ERROR34 = 100284;
  302. GLU_NURBS_ERROR35 = 100285;
  303. GLU_NURBS_ERROR36 = 100286;
  304. GLU_NURBS_ERROR37 = 100287;
  305. //*** Backwards compatibility for old tesselator ****/
  306. var
  307. gluBeginPolygon: procedure(tess: PGLUtesselator); extdecl;
  308. gluNextContour: procedure(tess: PGLUtesselator; atype: GLenum); extdecl;
  309. gluEndPolygon: procedure(tess: PGLUtesselator); extdecl;
  310. const
  311. // Contours types -- obsolete!
  312. GLU_CW = 100120;
  313. GLU_CCW = 100121;
  314. GLU_INTERIOR = 100122;
  315. GLU_EXTERIOR = 100123;
  316. GLU_UNKNOWN = 100124;
  317. // Names without "TESS_" prefix
  318. GLU_BEGIN = GLU_TESS_BEGIN;
  319. GLU_VERTEX = GLU_TESS_VERTEX;
  320. GLU_END = GLU_TESS_END;
  321. GLU_ERROR = GLU_TESS_ERROR;
  322. GLU_EDGE_FLAG = GLU_TESS_EDGE_FLAG;
  323. procedure LoadGLu(const dll: String);
  324. procedure FreeGLu;
  325. implementation
  326. {$IFDEF MORPHOS}
  327. { MorphOS GL works differently due to different dynamic-library handling on Amiga-like }
  328. { systems, so its functions are included here. }
  329. {$INCLUDE tinygl.inc}
  330. {$ELSE MORPHOS}
  331. var
  332. hDLL: THandle;
  333. {$ENDIF MORPHOS}
  334. procedure FreeGLu;
  335. begin
  336. {$IFDEF MORPHOS}
  337. // MorphOS's GL will closed down by TinyGL unit, nothing is needed here.
  338. {$ELSE MORPHOS}
  339. @gluErrorString := nil;
  340. @gluErrorUnicodeStringEXT := nil;
  341. @gluGetString := nil;
  342. @gluOrtho2D := nil;
  343. @gluPerspective := nil;
  344. @gluPickMatrix := nil;
  345. @gluLookAt := nil;
  346. @gluProject := nil;
  347. @gluUnProject := nil;
  348. @gluScaleImage := nil;
  349. @gluBuild1DMipmaps := nil;
  350. @gluBuild2DMipmaps := nil;
  351. @gluNewQuadric := nil;
  352. @gluDeleteQuadric := nil;
  353. @gluQuadricNormals := nil;
  354. @gluQuadricTexture := nil;
  355. @gluQuadricOrientation := nil;
  356. @gluQuadricDrawStyle := nil;
  357. @gluCylinder := nil;
  358. @gluDisk := nil;
  359. @gluPartialDisk := nil;
  360. @gluSphere := nil;
  361. @gluQuadricCallback := nil;
  362. @gluNewTess := nil;
  363. @gluDeleteTess := nil;
  364. @gluTessBeginPolygon := nil;
  365. @gluTessBeginContour := nil;
  366. @gluTessVertex := nil;
  367. @gluTessEndContour := nil;
  368. @gluTessEndPolygon := nil;
  369. @gluTessProperty := nil;
  370. @gluTessNormal := nil;
  371. @gluTessCallback := nil;
  372. @gluGetTessProperty := nil;
  373. @gluNewNurbsRenderer := nil;
  374. @gluDeleteNurbsRenderer := nil;
  375. @gluBeginSurface := nil;
  376. @gluBeginCurve := nil;
  377. @gluEndCurve := nil;
  378. @gluEndSurface := nil;
  379. @gluBeginTrim := nil;
  380. @gluEndTrim := nil;
  381. @gluPwlCurve := nil;
  382. @gluNurbsCurve := nil;
  383. @gluNurbsSurface := nil;
  384. @gluLoadSamplingMatrices := nil;
  385. @gluNurbsProperty := nil;
  386. @gluGetNurbsProperty := nil;
  387. @gluNurbsCallback := nil;
  388. @gluBeginPolygon := nil;
  389. @gluNextContour := nil;
  390. @gluEndPolygon := nil;
  391. FreeLibrary(hDLL);
  392. {$ENDIF MORPHOS}
  393. end;
  394. procedure LoadGLu(const dll: String);
  395. {$IFDEF MORPHOS}
  396. begin
  397. // MorphOS's GL has own initialization in TinyGL unit, nothing is needed here.
  398. end;
  399. {$ELSE MORPHOS}
  400. var
  401. MethodName: string = '';
  402. function GetGLuProcAddress(Lib: PtrInt; ProcName: PChar): Pointer;
  403. begin
  404. MethodName:=ProcName;
  405. Result:=GetProcAddress(Lib, ProcName);
  406. end;
  407. begin
  408. FreeGLu;
  409. hDLL := LoadLibrary(PChar(dll));
  410. if hDLL = 0 then raise Exception.Create('Could not load GLu from ' + dll);
  411. try
  412. @gluErrorString := GetGLuProcAddress(hDLL, 'gluErrorString');
  413. @gluErrorUnicodeStringEXT := GetGLuProcAddress(hDLL, 'gluErrorUnicodeStringEXT');
  414. @gluGetString := GetGLuProcAddress(hDLL, 'gluGetString');
  415. @gluOrtho2D := GetGLuProcAddress(hDLL, 'gluOrtho2D');
  416. @gluPerspective := GetGLuProcAddress(hDLL, 'gluPerspective');
  417. @gluPickMatrix := GetGLuProcAddress(hDLL, 'gluPickMatrix');
  418. @gluLookAt := GetGLuProcAddress(hDLL, 'gluLookAt');
  419. @gluProject := GetGLuProcAddress(hDLL, 'gluProject');
  420. @gluUnProject := GetGLuProcAddress(hDLL, 'gluUnProject');
  421. @gluScaleImage := GetGLuProcAddress(hDLL, 'gluScaleImage');
  422. @gluBuild1DMipmaps := GetGLuProcAddress(hDLL, 'gluBuild1DMipmaps');
  423. @gluBuild2DMipmaps := GetGLuProcAddress(hDLL, 'gluBuild2DMipmaps');
  424. @gluNewQuadric := GetGLuProcAddress(hDLL, 'gluNewQuadric');
  425. @gluDeleteQuadric := GetGLuProcAddress(hDLL, 'gluDeleteQuadric');
  426. @gluQuadricNormals := GetGLuProcAddress(hDLL, 'gluQuadricNormals');
  427. @gluQuadricTexture := GetGLuProcAddress(hDLL, 'gluQuadricTexture');
  428. @gluQuadricOrientation := GetGLuProcAddress(hDLL, 'gluQuadricOrientation');
  429. @gluQuadricDrawStyle := GetGLuProcAddress(hDLL, 'gluQuadricDrawStyle');
  430. @gluCylinder := GetGLuProcAddress(hDLL, 'gluCylinder');
  431. @gluDisk := GetGLuProcAddress(hDLL, 'gluDisk');
  432. @gluPartialDisk := GetGLuProcAddress(hDLL, 'gluPartialDisk');
  433. @gluSphere := GetGLuProcAddress(hDLL, 'gluSphere');
  434. @gluQuadricCallback := GetGLuProcAddress(hDLL, 'gluQuadricCallback');
  435. @gluNewTess := GetGLuProcAddress(hDLL, 'gluNewTess');
  436. @gluDeleteTess := GetGLuProcAddress(hDLL, 'gluDeleteTess');
  437. @gluTessBeginPolygon := GetGLuProcAddress(hDLL, 'gluTessBeginPolygon');
  438. @gluTessBeginContour := GetGLuProcAddress(hDLL, 'gluTessBeginContour');
  439. @gluTessVertex := GetGLuProcAddress(hDLL, 'gluTessVertex');
  440. @gluTessEndContour := GetGLuProcAddress(hDLL, 'gluTessEndContour');
  441. @gluTessEndPolygon := GetGLuProcAddress(hDLL, 'gluTessEndPolygon');
  442. @gluTessProperty := GetGLuProcAddress(hDLL, 'gluTessProperty');
  443. @gluTessNormal := GetGLuProcAddress(hDLL, 'gluTessNormal');
  444. @gluTessCallback := GetGLuProcAddress(hDLL, 'gluTessCallback');
  445. @gluGetTessProperty := GetGLuProcAddress(hDLL, 'gluGetTessProperty');
  446. @gluNewNurbsRenderer := GetGLuProcAddress(hDLL, 'gluNewNurbsRenderer');
  447. @gluDeleteNurbsRenderer := GetGLuProcAddress(hDLL, 'gluDeleteNurbsRenderer');
  448. @gluBeginSurface := GetGLuProcAddress(hDLL, 'gluBeginSurface');
  449. @gluBeginCurve := GetGLuProcAddress(hDLL, 'gluBeginCurve');
  450. @gluEndCurve := GetGLuProcAddress(hDLL, 'gluEndCurve');
  451. @gluEndSurface := GetGLuProcAddress(hDLL, 'gluEndSurface');
  452. @gluBeginTrim := GetGLuProcAddress(hDLL, 'gluBeginTrim');
  453. @gluEndTrim := GetGLuProcAddress(hDLL, 'gluEndTrim');
  454. @gluPwlCurve := GetGLuProcAddress(hDLL, 'gluPwlCurve');
  455. @gluNurbsCurve := GetGLuProcAddress(hDLL, 'gluNurbsCurve');
  456. @gluNurbsSurface := GetGLuProcAddress(hDLL, 'gluNurbsSurface');
  457. @gluLoadSamplingMatrices := GetGLuProcAddress(hDLL, 'gluLoadSamplingMatrices');
  458. @gluNurbsProperty := GetGLuProcAddress(hDLL, 'gluNurbsProperty');
  459. @gluGetNurbsProperty := GetGLuProcAddress(hDLL, 'gluGetNurbsProperty');
  460. @gluNurbsCallback := GetGLuProcAddress(hDLL, 'gluNurbsCallback');
  461. @gluBeginPolygon := GetGLuProcAddress(hDLL, 'gluBeginPolygon');
  462. @gluNextContour := GetGLuProcAddress(hDLL, 'gluNextContour');
  463. @gluEndPolygon := GetGLuProcAddress(hDLL, 'gluEndPolygon');
  464. except
  465. raise Exception.Create('Could not load ' + MethodName + ' from ' + dll);
  466. end;
  467. end;
  468. {$ENDIF MORPHOS}
  469. initialization
  470. {$IFDEF Win32}
  471. LoadGLu('glu32.dll');
  472. {$ELSE}
  473. {$ifdef darwin}
  474. LoadGLu('/System/Library/Frameworks/OpenGL.framework/Libraries/libGLU.dylib');
  475. {$else}
  476. {$ifndef MorphOS}
  477. LoadGLu('libGLU.so.1');
  478. {$endif}
  479. {$ENDIF}
  480. {$endif}
  481. finalization
  482. FreeGLu;
  483. end.