glu.pp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563
  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. {$ENDIF}
  64. {$ENDIF}
  65. GL;
  66. type
  67. TViewPortArray = array [0..3] of GLint;
  68. T16dArray = array [0..15] of GLdouble;
  69. TCallBack = procedure;
  70. T3dArray = array [0..2] of GLdouble;
  71. T4pArray = array [0..3] of Pointer;
  72. T4fArray = array [0..3] of GLfloat;
  73. PPointer = ^Pointer;
  74. type
  75. GLUnurbs = record end; PGLUnurbs = ^GLUnurbs;
  76. GLUquadric = record end; PGLUquadric = ^GLUquadric;
  77. GLUtesselator = record end; PGLUtesselator = ^GLUtesselator;
  78. // backwards compatibility:
  79. GLUnurbsObj = GLUnurbs; PGLUnurbsObj = PGLUnurbs;
  80. GLUquadricObj = GLUquadric; PGLUquadricObj = PGLUquadric;
  81. GLUtesselatorObj = GLUtesselator; PGLUtesselatorObj = PGLUtesselator;
  82. GLUtriangulatorObj = GLUtesselator; PGLUtriangulatorObj = PGLUtesselator;
  83. {$IFDEF MORPHOS}
  84. { MorphOS GL works differently due to different dynamic-library handling on Amiga-like }
  85. { systems, so its headers are included here. }
  86. {$INCLUDE tinyglh.inc}
  87. {$ELSE MORPHOS}
  88. var
  89. gluErrorString: function(errCode: GLenum): PChar; extdecl;
  90. gluErrorUnicodeStringEXT: function(errCode: GLenum): PWideChar; extdecl;
  91. gluGetString: function(name: GLenum): PChar; extdecl;
  92. gluOrtho2D: procedure(left,right, bottom, top: GLdouble); extdecl;
  93. gluPerspective: procedure(fovy, aspect, zNear, zFar: GLdouble); extdecl;
  94. gluPickMatrix: procedure(x, y, width, height: GLdouble; var viewport: TViewPortArray); extdecl;
  95. gluLookAt: procedure(eyex, eyey, eyez, centerx, centery, centerz, upx, upy, upz: GLdouble); extdecl;
  96. gluProject: function(objx, objy, objz: GLdouble; var modelMatrix, projMatrix: T16dArray; var viewport: TViewPortArray; winx, winy, winz: PGLdouble): Integer; extdecl;
  97. gluUnProject: function(winx, winy, winz: GLdouble; var modelMatrix, projMatrix: T16dArray; var viewport: TViewPortArray; objx, objy, objz: PGLdouble): Integer; extdecl;
  98. gluScaleImage: function(format: GLenum; widthin, heightin: GLint; typein: GLenum; const datain: Pointer; widthout, heightout: GLint; typeout: GLenum; dataout: Pointer): Integer; extdecl;
  99. gluBuild1DMipmaps: function(target: GLenum; components, width: GLint; format, atype: GLenum; const data: Pointer): Integer; extdecl;
  100. gluBuild2DMipmaps: function(target: GLenum; components, width, height: GLint; format, atype: GLenum; const data: Pointer): Integer; extdecl;
  101. var
  102. gluNewQuadric: function: PGLUquadric; extdecl;
  103. gluDeleteQuadric: procedure(state: PGLUquadric); extdecl;
  104. gluQuadricNormals: procedure(quadObject: PGLUquadric; normals: GLenum); extdecl;
  105. gluQuadricTexture: procedure(quadObject: PGLUquadric; textureCoords: GLboolean); extdecl;
  106. gluQuadricOrientation: procedure(quadObject: PGLUquadric; orientation: GLenum); extdecl;
  107. gluQuadricDrawStyle: procedure(quadObject: PGLUquadric; drawStyle: GLenum); extdecl;
  108. gluCylinder: procedure(qobj: PGLUquadric; baseRadius, topRadius, height: GLdouble; slices, stacks: GLint); extdecl;
  109. gluDisk: procedure(qobj: PGLUquadric; innerRadius, outerRadius: GLdouble; slices, loops: GLint); extdecl;
  110. gluPartialDisk: procedure(qobj: PGLUquadric; innerRadius, outerRadius: GLdouble; slices, loops: GLint; startAngle, sweepAngle: GLdouble); extdecl;
  111. gluSphere: procedure(qobj: PGLuquadric; radius: GLdouble; slices, stacks: GLint); extdecl;
  112. gluQuadricCallback: procedure(qobj: PGLUquadric; which: GLenum; fn: TCallBack); extdecl;
  113. gluNewTess: function: PGLUtesselator; extdecl;
  114. gluDeleteTess: procedure(tess: PGLUtesselator); extdecl;
  115. gluTessBeginPolygon: procedure(tess: PGLUtesselator; polygon_data: Pointer); extdecl;
  116. gluTessBeginContour: procedure(tess: PGLUtesselator); extdecl;
  117. gluTessVertex: procedure(tess: PGLUtesselator; var coords: T3dArray; data: Pointer); extdecl;
  118. gluTessEndContour: procedure(tess: PGLUtesselator); extdecl;
  119. gluTessEndPolygon: procedure(tess: PGLUtesselator); extdecl;
  120. gluTessProperty: procedure(tess: PGLUtesselator; which: GLenum; value: GLdouble); extdecl;
  121. gluTessNormal: procedure(tess: PGLUtesselator; x, y, z: GLdouble); extdecl;
  122. gluTessCallback: procedure(tess: PGLUtesselator; which: GLenum;fn: TCallBack); extdecl;
  123. gluGetTessProperty: procedure(tess: PGLUtesselator; which: GLenum; value: PGLdouble); extdecl;
  124. gluNewNurbsRenderer: function: PGLUnurbs; extdecl;
  125. gluDeleteNurbsRenderer: procedure(nobj: PGLUnurbs); extdecl;
  126. gluBeginSurface: procedure(nobj: PGLUnurbs); extdecl;
  127. gluBeginCurve: procedure(nobj: PGLUnurbs); extdecl;
  128. gluEndCurve: procedure(nobj: PGLUnurbs); extdecl;
  129. gluEndSurface: procedure(nobj: PGLUnurbs); extdecl;
  130. gluBeginTrim: procedure(nobj: PGLUnurbs); extdecl;
  131. gluEndTrim: procedure(nobj: PGLUnurbs); extdecl;
  132. gluPwlCurve: procedure(nobj: PGLUnurbs; count: GLint; aarray: PGLfloat; stride: GLint; atype: GLenum); extdecl;
  133. gluNurbsCurve: procedure(nobj: PGLUnurbs; nknots: GLint; knot: PGLfloat; stride: GLint; ctlarray: PGLfloat; order: GLint; atype: GLenum); extdecl;
  134. 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;
  135. gluLoadSamplingMatrices: procedure(nobj: PGLUnurbs; var modelMatrix, projMatrix: T16dArray; var viewport: TViewPortArray); extdecl;
  136. gluNurbsProperty: procedure(nobj: PGLUnurbs; aproperty: GLenum; value: GLfloat); extdecl;
  137. gluGetNurbsProperty: procedure(nobj: PGLUnurbs; aproperty: GLenum; value: PGLfloat); extdecl;
  138. gluNurbsCallback: procedure(nobj: PGLUnurbs; which: GLenum; fn: TCallBack); extdecl;
  139. {$ENDIF MORPHOS}
  140. (**** Callback function prototypes ****)
  141. type
  142. // gluQuadricCallback
  143. GLUquadricErrorProc = procedure(p: GLenum); extdecl;
  144. // gluTessCallback
  145. GLUtessBeginProc = procedure(p: GLenum); extdecl;
  146. GLUtessEdgeFlagProc = procedure(p: GLboolean); extdecl;
  147. GLUtessVertexProc = procedure(p: Pointer); extdecl;
  148. GLUtessEndProc = procedure; extdecl;
  149. GLUtessErrorProc = procedure(p: GLenum); extdecl;
  150. GLUtessCombineProc = procedure(var p1: T3dArray; p2: T4pArray; p3: T4fArray; p4: PPointer); extdecl;
  151. GLUtessBeginDataProc = procedure(p1: GLenum; p2: Pointer); extdecl;
  152. GLUtessEdgeFlagDataProc = procedure(p1: GLboolean; p2: Pointer); extdecl;
  153. GLUtessVertexDataProc = procedure(p1, p2: Pointer); extdecl;
  154. GLUtessEndDataProc = procedure(p: Pointer); extdecl;
  155. GLUtessErrorDataProc = procedure(p1: GLenum; p2: Pointer); extdecl;
  156. GLUtessCombineDataProc = procedure(var p1: T3dArray; var p2: T4pArray; var p3: T4fArray;
  157. p4: PPointer; p5: Pointer); extdecl;
  158. // gluNurbsCallback
  159. GLUnurbsErrorProc = procedure(p: GLenum); extdecl;
  160. //*** Generic constants ****/
  161. const
  162. // Version
  163. GLU_VERSION_1_1 = 1;
  164. GLU_VERSION_1_2 = 1;
  165. // Errors: (return value 0 = no error)
  166. GLU_INVALID_ENUM = 100900;
  167. GLU_INVALID_VALUE = 100901;
  168. GLU_OUT_OF_MEMORY = 100902;
  169. GLU_INCOMPATIBLE_GL_VERSION = 100903;
  170. // StringName
  171. GLU_VERSION = 100800;
  172. GLU_EXTENSIONS = 100801;
  173. // Boolean
  174. GLU_TRUE = GL_TRUE;
  175. GLU_FALSE = GL_FALSE;
  176. //*** Quadric constants ****/
  177. // QuadricNormal
  178. GLU_SMOOTH = 100000;
  179. GLU_FLAT = 100001;
  180. GLU_NONE = 100002;
  181. // QuadricDrawStyle
  182. GLU_POINT = 100010;
  183. GLU_LINE = 100011;
  184. GLU_FILL = 100012;
  185. GLU_SILHOUETTE = 100013;
  186. // QuadricOrientation
  187. GLU_OUTSIDE = 100020;
  188. GLU_INSIDE = 100021;
  189. // Callback types:
  190. // GLU_ERROR = 100103;
  191. //*** Tesselation constants ****/
  192. GLU_TESS_MAX_COORD = 1.0e150;
  193. // TessProperty
  194. GLU_TESS_WINDING_RULE = 100140;
  195. GLU_TESS_BOUNDARY_ONLY = 100141;
  196. GLU_TESS_TOLERANCE = 100142;
  197. // TessWinding
  198. GLU_TESS_WINDING_ODD = 100130;
  199. GLU_TESS_WINDING_NONZERO = 100131;
  200. GLU_TESS_WINDING_POSITIVE = 100132;
  201. GLU_TESS_WINDING_NEGATIVE = 100133;
  202. GLU_TESS_WINDING_ABS_GEQ_TWO = 100134;
  203. // TessCallback
  204. GLU_TESS_BEGIN = 100100; // void (CALLBACK*)(GLenum type)
  205. GLU_TESS_VERTEX = 100101; // void (CALLBACK*)(void *data)
  206. GLU_TESS_END = 100102; // void (CALLBACK*)(void)
  207. GLU_TESS_ERROR = 100103; // void (CALLBACK*)(GLenum errno)
  208. GLU_TESS_EDGE_FLAG = 100104; // void (CALLBACK*)(GLboolean boundaryEdge)
  209. GLU_TESS_COMBINE = 100105; { void (CALLBACK*)(GLdouble coords[3],
  210. void *data[4],
  211. GLfloat weight[4],
  212. void **dataOut) }
  213. GLU_TESS_BEGIN_DATA = 100106; { void (CALLBACK*)(GLenum type,
  214. void *polygon_data) }
  215. GLU_TESS_VERTEX_DATA = 100107; { void (CALLBACK*)(void *data,
  216. void *polygon_data) }
  217. GLU_TESS_END_DATA = 100108; // void (CALLBACK*)(void *polygon_data)
  218. GLU_TESS_ERROR_DATA = 100109; { void (CALLBACK*)(GLenum errno,
  219. void *polygon_data) }
  220. GLU_TESS_EDGE_FLAG_DATA = 100110; { void (CALLBACK*)(GLboolean boundaryEdge,
  221. void *polygon_data) }
  222. GLU_TESS_COMBINE_DATA = 100111; { void (CALLBACK*)(GLdouble coords[3],
  223. void *data[4],
  224. GLfloat weight[4],
  225. void **dataOut,
  226. void *polygon_data) }
  227. // TessError
  228. GLU_TESS_ERROR1 = 100151;
  229. GLU_TESS_ERROR2 = 100152;
  230. GLU_TESS_ERROR3 = 100153;
  231. GLU_TESS_ERROR4 = 100154;
  232. GLU_TESS_ERROR5 = 100155;
  233. GLU_TESS_ERROR6 = 100156;
  234. GLU_TESS_ERROR7 = 100157;
  235. GLU_TESS_ERROR8 = 100158;
  236. GLU_TESS_MISSING_BEGIN_POLYGON = GLU_TESS_ERROR1;
  237. GLU_TESS_MISSING_BEGIN_CONTOUR = GLU_TESS_ERROR2;
  238. GLU_TESS_MISSING_END_POLYGON = GLU_TESS_ERROR3;
  239. GLU_TESS_MISSING_END_CONTOUR = GLU_TESS_ERROR4;
  240. GLU_TESS_COORD_TOO_LARGE = GLU_TESS_ERROR5;
  241. GLU_TESS_NEED_COMBINE_CALLBACK = GLU_TESS_ERROR6;
  242. //*** NURBS constants ****/
  243. // NurbsProperty
  244. GLU_AUTO_LOAD_MATRIX = 100200;
  245. GLU_CULLING = 100201;
  246. GLU_SAMPLING_TOLERANCE = 100203;
  247. GLU_DISPLAY_MODE = 100204;
  248. GLU_PARAMETRIC_TOLERANCE = 100202;
  249. GLU_SAMPLING_METHOD = 100205;
  250. GLU_U_STEP = 100206;
  251. GLU_V_STEP = 100207;
  252. // NurbsSampling
  253. GLU_PATH_LENGTH = 100215;
  254. GLU_PARAMETRIC_ERROR = 100216;
  255. GLU_DOMAIN_DISTANCE = 100217;
  256. // NurbsTrim
  257. GLU_MAP1_TRIM_2 = 100210;
  258. GLU_MAP1_TRIM_3 = 100211;
  259. // NurbsDisplay
  260. // GLU_FILL = 100012;
  261. GLU_OUTLINE_POLYGON = 100240;
  262. GLU_OUTLINE_PATCH = 100241;
  263. // NurbsCallback
  264. // GLU_ERROR = 100103;
  265. // NurbsErrors
  266. GLU_NURBS_ERROR1 = 100251;
  267. GLU_NURBS_ERROR2 = 100252;
  268. GLU_NURBS_ERROR3 = 100253;
  269. GLU_NURBS_ERROR4 = 100254;
  270. GLU_NURBS_ERROR5 = 100255;
  271. GLU_NURBS_ERROR6 = 100256;
  272. GLU_NURBS_ERROR7 = 100257;
  273. GLU_NURBS_ERROR8 = 100258;
  274. GLU_NURBS_ERROR9 = 100259;
  275. GLU_NURBS_ERROR10 = 100260;
  276. GLU_NURBS_ERROR11 = 100261;
  277. GLU_NURBS_ERROR12 = 100262;
  278. GLU_NURBS_ERROR13 = 100263;
  279. GLU_NURBS_ERROR14 = 100264;
  280. GLU_NURBS_ERROR15 = 100265;
  281. GLU_NURBS_ERROR16 = 100266;
  282. GLU_NURBS_ERROR17 = 100267;
  283. GLU_NURBS_ERROR18 = 100268;
  284. GLU_NURBS_ERROR19 = 100269;
  285. GLU_NURBS_ERROR20 = 100270;
  286. GLU_NURBS_ERROR21 = 100271;
  287. GLU_NURBS_ERROR22 = 100272;
  288. GLU_NURBS_ERROR23 = 100273;
  289. GLU_NURBS_ERROR24 = 100274;
  290. GLU_NURBS_ERROR25 = 100275;
  291. GLU_NURBS_ERROR26 = 100276;
  292. GLU_NURBS_ERROR27 = 100277;
  293. GLU_NURBS_ERROR28 = 100278;
  294. GLU_NURBS_ERROR29 = 100279;
  295. GLU_NURBS_ERROR30 = 100280;
  296. GLU_NURBS_ERROR31 = 100281;
  297. GLU_NURBS_ERROR32 = 100282;
  298. GLU_NURBS_ERROR33 = 100283;
  299. GLU_NURBS_ERROR34 = 100284;
  300. GLU_NURBS_ERROR35 = 100285;
  301. GLU_NURBS_ERROR36 = 100286;
  302. GLU_NURBS_ERROR37 = 100287;
  303. //*** Backwards compatibility for old tesselator ****/
  304. var
  305. gluBeginPolygon: procedure(tess: PGLUtesselator); extdecl;
  306. gluNextContour: procedure(tess: PGLUtesselator; atype: GLenum); extdecl;
  307. gluEndPolygon: procedure(tess: PGLUtesselator); extdecl;
  308. const
  309. // Contours types -- obsolete!
  310. GLU_CW = 100120;
  311. GLU_CCW = 100121;
  312. GLU_INTERIOR = 100122;
  313. GLU_EXTERIOR = 100123;
  314. GLU_UNKNOWN = 100124;
  315. // Names without "TESS_" prefix
  316. GLU_BEGIN = GLU_TESS_BEGIN;
  317. GLU_VERTEX = GLU_TESS_VERTEX;
  318. GLU_END = GLU_TESS_END;
  319. GLU_ERROR = GLU_TESS_ERROR;
  320. GLU_EDGE_FLAG = GLU_TESS_EDGE_FLAG;
  321. procedure LoadGLu(const dll: String);
  322. procedure FreeGLu;
  323. implementation
  324. {$IFDEF MORPHOS}
  325. { MorphOS GL works differently due to different dynamic-library handling on Amiga-like }
  326. { systems, so its functions are included here. }
  327. {$INCLUDE tinygl.inc}
  328. {$ELSE MORPHOS}
  329. uses
  330. dynlibs;
  331. var
  332. hDLL: TLibHandle;
  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. if (hDLL <> 0) then
  392. FreeLibrary(hDLL);
  393. {$ENDIF MORPHOS}
  394. end;
  395. procedure LoadGLu(const dll: String);
  396. {$IFDEF MORPHOS}
  397. begin
  398. // MorphOS's GL has own initialization in TinyGL unit, nothing is needed here.
  399. end;
  400. {$ELSE MORPHOS}
  401. var
  402. MethodName: string = '';
  403. function GetGLuProcAddress(Lib: PtrInt; ProcName: PChar): Pointer;
  404. begin
  405. MethodName:=ProcName;
  406. Result:=GetProcAddress(Lib, ProcName);
  407. end;
  408. begin
  409. FreeGLu;
  410. hDLL := LoadLibrary(PChar(dll));
  411. if hDLL = 0 then raise Exception.Create('Could not load GLu from ' + dll);
  412. try
  413. @gluErrorString := GetGLuProcAddress(hDLL, 'gluErrorString');
  414. @gluErrorUnicodeStringEXT := GetGLuProcAddress(hDLL, 'gluErrorUnicodeStringEXT');
  415. @gluGetString := GetGLuProcAddress(hDLL, 'gluGetString');
  416. @gluOrtho2D := GetGLuProcAddress(hDLL, 'gluOrtho2D');
  417. @gluPerspective := GetGLuProcAddress(hDLL, 'gluPerspective');
  418. @gluPickMatrix := GetGLuProcAddress(hDLL, 'gluPickMatrix');
  419. @gluLookAt := GetGLuProcAddress(hDLL, 'gluLookAt');
  420. @gluProject := GetGLuProcAddress(hDLL, 'gluProject');
  421. @gluUnProject := GetGLuProcAddress(hDLL, 'gluUnProject');
  422. @gluScaleImage := GetGLuProcAddress(hDLL, 'gluScaleImage');
  423. @gluBuild1DMipmaps := GetGLuProcAddress(hDLL, 'gluBuild1DMipmaps');
  424. @gluBuild2DMipmaps := GetGLuProcAddress(hDLL, 'gluBuild2DMipmaps');
  425. @gluNewQuadric := GetGLuProcAddress(hDLL, 'gluNewQuadric');
  426. @gluDeleteQuadric := GetGLuProcAddress(hDLL, 'gluDeleteQuadric');
  427. @gluQuadricNormals := GetGLuProcAddress(hDLL, 'gluQuadricNormals');
  428. @gluQuadricTexture := GetGLuProcAddress(hDLL, 'gluQuadricTexture');
  429. @gluQuadricOrientation := GetGLuProcAddress(hDLL, 'gluQuadricOrientation');
  430. @gluQuadricDrawStyle := GetGLuProcAddress(hDLL, 'gluQuadricDrawStyle');
  431. @gluCylinder := GetGLuProcAddress(hDLL, 'gluCylinder');
  432. @gluDisk := GetGLuProcAddress(hDLL, 'gluDisk');
  433. @gluPartialDisk := GetGLuProcAddress(hDLL, 'gluPartialDisk');
  434. @gluSphere := GetGLuProcAddress(hDLL, 'gluSphere');
  435. @gluQuadricCallback := GetGLuProcAddress(hDLL, 'gluQuadricCallback');
  436. @gluNewTess := GetGLuProcAddress(hDLL, 'gluNewTess');
  437. @gluDeleteTess := GetGLuProcAddress(hDLL, 'gluDeleteTess');
  438. @gluTessBeginPolygon := GetGLuProcAddress(hDLL, 'gluTessBeginPolygon');
  439. @gluTessBeginContour := GetGLuProcAddress(hDLL, 'gluTessBeginContour');
  440. @gluTessVertex := GetGLuProcAddress(hDLL, 'gluTessVertex');
  441. @gluTessEndContour := GetGLuProcAddress(hDLL, 'gluTessEndContour');
  442. @gluTessEndPolygon := GetGLuProcAddress(hDLL, 'gluTessEndPolygon');
  443. @gluTessProperty := GetGLuProcAddress(hDLL, 'gluTessProperty');
  444. @gluTessNormal := GetGLuProcAddress(hDLL, 'gluTessNormal');
  445. @gluTessCallback := GetGLuProcAddress(hDLL, 'gluTessCallback');
  446. @gluGetTessProperty := GetGLuProcAddress(hDLL, 'gluGetTessProperty');
  447. @gluNewNurbsRenderer := GetGLuProcAddress(hDLL, 'gluNewNurbsRenderer');
  448. @gluDeleteNurbsRenderer := GetGLuProcAddress(hDLL, 'gluDeleteNurbsRenderer');
  449. @gluBeginSurface := GetGLuProcAddress(hDLL, 'gluBeginSurface');
  450. @gluBeginCurve := GetGLuProcAddress(hDLL, 'gluBeginCurve');
  451. @gluEndCurve := GetGLuProcAddress(hDLL, 'gluEndCurve');
  452. @gluEndSurface := GetGLuProcAddress(hDLL, 'gluEndSurface');
  453. @gluBeginTrim := GetGLuProcAddress(hDLL, 'gluBeginTrim');
  454. @gluEndTrim := GetGLuProcAddress(hDLL, 'gluEndTrim');
  455. @gluPwlCurve := GetGLuProcAddress(hDLL, 'gluPwlCurve');
  456. @gluNurbsCurve := GetGLuProcAddress(hDLL, 'gluNurbsCurve');
  457. @gluNurbsSurface := GetGLuProcAddress(hDLL, 'gluNurbsSurface');
  458. @gluLoadSamplingMatrices := GetGLuProcAddress(hDLL, 'gluLoadSamplingMatrices');
  459. @gluNurbsProperty := GetGLuProcAddress(hDLL, 'gluNurbsProperty');
  460. @gluGetNurbsProperty := GetGLuProcAddress(hDLL, 'gluGetNurbsProperty');
  461. @gluNurbsCallback := GetGLuProcAddress(hDLL, 'gluNurbsCallback');
  462. @gluBeginPolygon := GetGLuProcAddress(hDLL, 'gluBeginPolygon');
  463. @gluNextContour := GetGLuProcAddress(hDLL, 'gluNextContour');
  464. @gluEndPolygon := GetGLuProcAddress(hDLL, 'gluEndPolygon');
  465. except
  466. raise Exception.Create('Could not load ' + MethodName + ' from ' + dll);
  467. end;
  468. end;
  469. {$ENDIF MORPHOS}
  470. initialization
  471. {$IFDEF Win32}
  472. LoadGLu('glu32.dll');
  473. {$ELSE}
  474. {$ifdef darwin}
  475. LoadGLu('/System/Library/Frameworks/OpenGL.framework/Libraries/libGLU.dylib');
  476. {$else}
  477. {$ifndef MorphOS}
  478. LoadGLu('libGLU.so.1');
  479. {$endif}
  480. {$ENDIF}
  481. {$endif}
  482. finalization
  483. FreeGLu;
  484. end.