glu.nim 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  1. #
  2. #
  3. # Adaption of the delphi3d.net OpenGL units to FreePascal
  4. # Sebastian Guenther (sg@freepascal.org) in 2002
  5. # These units are free to use
  6. #******************************************************************************
  7. # Converted to Delphi by Tom Nuydens (tom@delphi3d.net)
  8. # For the latest updates, visit Delphi3D: http://www.delphi3d.net
  9. #******************************************************************************
  10. import
  11. GL
  12. when defined(windows):
  13. {.push, callconv: stdcall.}
  14. else:
  15. {.push, callconv: cdecl.}
  16. when defined(windows):
  17. const
  18. dllname = "glu32.dll"
  19. elif defined(macosx):
  20. const
  21. dllname = "/System/Library/Frameworks/OpenGL.framework/Libraries/libGLU.dylib"
  22. else:
  23. const
  24. dllname = "libGLU.so.1"
  25. type
  26. TViewPortArray* = array[0..3, TGLint]
  27. T16dArray* = array[0..15, TGLdouble]
  28. TCallBack* = proc ()
  29. T3dArray* = array[0..2, TGLdouble]
  30. T4pArray* = array[0..3, Pointer]
  31. T4fArray* = array[0..3, TGLfloat]
  32. PPointer* = ptr Pointer
  33. type
  34. GLUnurbs*{.final.} = object
  35. PGLUnurbs* = ptr GLUnurbs
  36. GLUquadric*{.final.} = object
  37. PGLUquadric* = ptr GLUquadric
  38. GLUtesselator*{.final.} = object
  39. PGLUtesselator* = ptr GLUtesselator # backwards compatibility:
  40. GLUnurbsObj* = GLUnurbs
  41. PGLUnurbsObj* = PGLUnurbs
  42. GLUquadricObj* = GLUquadric
  43. PGLUquadricObj* = PGLUquadric
  44. GLUtesselatorObj* = GLUtesselator
  45. PGLUtesselatorObj* = PGLUtesselator
  46. GLUtriangulatorObj* = GLUtesselator
  47. PGLUtriangulatorObj* = PGLUtesselator
  48. TGLUnurbs* = GLUnurbs
  49. TGLUquadric* = GLUquadric
  50. TGLUtesselator* = GLUtesselator
  51. TGLUnurbsObj* = GLUnurbsObj
  52. TGLUquadricObj* = GLUquadricObj
  53. TGLUtesselatorObj* = GLUtesselatorObj
  54. TGLUtriangulatorObj* = GLUtriangulatorObj
  55. proc gluErrorString*(errCode: TGLenum): cstring{.dynlib: dllname,
  56. importc: "gluErrorString".}
  57. proc gluErrorUnicodeStringEXT*(errCode: TGLenum): ptr int16{.dynlib: dllname,
  58. importc: "gluErrorUnicodeStringEXT".}
  59. proc gluGetString*(name: TGLenum): cstring{.dynlib: dllname,
  60. importc: "gluGetString".}
  61. proc gluOrtho2D*(left, right, bottom, top: TGLdouble){.dynlib: dllname,
  62. importc: "gluOrtho2D".}
  63. proc gluPerspective*(fovy, aspect, zNear, zFar: TGLdouble){.dynlib: dllname,
  64. importc: "gluPerspective".}
  65. proc gluPickMatrix*(x, y, width, height: TGLdouble, viewport: var TViewPortArray){.
  66. dynlib: dllname, importc: "gluPickMatrix".}
  67. proc gluLookAt*(eyex, eyey, eyez, centerx, centery, centerz, upx, upy, upz: TGLdouble){.
  68. dynlib: dllname, importc: "gluLookAt".}
  69. proc gluProject*(objx, objy, objz: TGLdouble,
  70. modelMatrix, projMatrix: var T16dArray,
  71. viewport: var TViewPortArray, winx, winy, winz: PGLdouble): int{.
  72. dynlib: dllname, importc: "gluProject".}
  73. proc gluUnProject*(winx, winy, winz: TGLdouble,
  74. modelMatrix, projMatrix: var T16dArray,
  75. viewport: var TViewPortArray, objx, objy, objz: PGLdouble): int{.
  76. dynlib: dllname, importc: "gluUnProject".}
  77. proc gluScaleImage*(format: TGLenum, widthin, heightin: TGLint, typein: TGLenum,
  78. datain: Pointer, widthout, heightout: TGLint,
  79. typeout: TGLenum, dataout: Pointer): int{.dynlib: dllname,
  80. importc: "gluScaleImage".}
  81. proc gluBuild1DMipmaps*(target: TGLenum, components, width: TGLint,
  82. format, atype: TGLenum, data: Pointer): int{.
  83. dynlib: dllname, importc: "gluBuild1DMipmaps".}
  84. proc gluBuild2DMipmaps*(target: TGLenum, components, width, height: TGLint,
  85. format, atype: TGLenum, data: Pointer): int{.
  86. dynlib: dllname, importc: "gluBuild2DMipmaps".}
  87. proc gluNewQuadric*(): PGLUquadric{.dynlib: dllname, importc: "gluNewQuadric".}
  88. proc gluDeleteQuadric*(state: PGLUquadric){.dynlib: dllname,
  89. importc: "gluDeleteQuadric".}
  90. proc gluQuadricNormals*(quadObject: PGLUquadric, normals: TGLenum){.
  91. dynlib: dllname, importc: "gluQuadricNormals".}
  92. proc gluQuadricTexture*(quadObject: PGLUquadric, textureCoords: TGLboolean){.
  93. dynlib: dllname, importc: "gluQuadricTexture".}
  94. proc gluQuadricOrientation*(quadObject: PGLUquadric, orientation: TGLenum){.
  95. dynlib: dllname, importc: "gluQuadricOrientation".}
  96. proc gluQuadricDrawStyle*(quadObject: PGLUquadric, drawStyle: TGLenum){.
  97. dynlib: dllname, importc: "gluQuadricDrawStyle".}
  98. proc gluCylinder*(qobj: PGLUquadric, baseRadius, topRadius, height: TGLdouble,
  99. slices, stacks: TGLint){.dynlib: dllname,
  100. importc: "gluCylinder".}
  101. proc gluDisk*(qobj: PGLUquadric, innerRadius, outerRadius: TGLdouble,
  102. slices, loops: TGLint){.dynlib: dllname, importc: "gluDisk".}
  103. proc gluPartialDisk*(qobj: PGLUquadric, innerRadius, outerRadius: TGLdouble,
  104. slices, loops: TGLint, startAngle, sweepAngle: TGLdouble){.
  105. dynlib: dllname, importc: "gluPartialDisk".}
  106. proc gluSphere*(qobj: PGLuquadric, radius: TGLdouble, slices, stacks: TGLint){.
  107. dynlib: dllname, importc: "gluSphere".}
  108. proc gluQuadricCallback*(qobj: PGLUquadric, which: TGLenum, fn: TCallBack){.
  109. dynlib: dllname, importc: "gluQuadricCallback".}
  110. proc gluNewTess*(): PGLUtesselator{.dynlib: dllname, importc: "gluNewTess".}
  111. proc gluDeleteTess*(tess: PGLUtesselator){.dynlib: dllname,
  112. importc: "gluDeleteTess".}
  113. proc gluTessBeginPolygon*(tess: PGLUtesselator, polygon_data: Pointer){.
  114. dynlib: dllname, importc: "gluTessBeginPolygon".}
  115. proc gluTessBeginContour*(tess: PGLUtesselator){.dynlib: dllname,
  116. importc: "gluTessBeginContour".}
  117. proc gluTessVertex*(tess: PGLUtesselator, coords: var T3dArray, data: Pointer){.
  118. dynlib: dllname, importc: "gluTessVertex".}
  119. proc gluTessEndContour*(tess: PGLUtesselator){.dynlib: dllname,
  120. importc: "gluTessEndContour".}
  121. proc gluTessEndPolygon*(tess: PGLUtesselator){.dynlib: dllname,
  122. importc: "gluTessEndPolygon".}
  123. proc gluTessProperty*(tess: PGLUtesselator, which: TGLenum, value: TGLdouble){.
  124. dynlib: dllname, importc: "gluTessProperty".}
  125. proc gluTessNormal*(tess: PGLUtesselator, x, y, z: TGLdouble){.dynlib: dllname,
  126. importc: "gluTessNormal".}
  127. proc gluTessCallback*(tess: PGLUtesselator, which: TGLenum, fn: TCallBack){.
  128. dynlib: dllname, importc: "gluTessCallback".}
  129. proc gluGetTessProperty*(tess: PGLUtesselator, which: TGLenum, value: PGLdouble){.
  130. dynlib: dllname, importc: "gluGetTessProperty".}
  131. proc gluNewNurbsRenderer*(): PGLUnurbs{.dynlib: dllname,
  132. importc: "gluNewNurbsRenderer".}
  133. proc gluDeleteNurbsRenderer*(nobj: PGLUnurbs){.dynlib: dllname,
  134. importc: "gluDeleteNurbsRenderer".}
  135. proc gluBeginSurface*(nobj: PGLUnurbs){.dynlib: dllname,
  136. importc: "gluBeginSurface".}
  137. proc gluBeginCurve*(nobj: PGLUnurbs){.dynlib: dllname, importc: "gluBeginCurve".}
  138. proc gluEndCurve*(nobj: PGLUnurbs){.dynlib: dllname, importc: "gluEndCurve".}
  139. proc gluEndSurface*(nobj: PGLUnurbs){.dynlib: dllname, importc: "gluEndSurface".}
  140. proc gluBeginTrim*(nobj: PGLUnurbs){.dynlib: dllname, importc: "gluBeginTrim".}
  141. proc gluEndTrim*(nobj: PGLUnurbs){.dynlib: dllname, importc: "gluEndTrim".}
  142. proc gluPwlCurve*(nobj: PGLUnurbs, count: TGLint, aarray: PGLfloat,
  143. stride: TGLint, atype: TGLenum){.dynlib: dllname,
  144. importc: "gluPwlCurve".}
  145. proc gluNurbsCurve*(nobj: PGLUnurbs, nknots: TGLint, knot: PGLfloat,
  146. stride: TGLint, ctlarray: PGLfloat, order: TGLint,
  147. atype: TGLenum){.dynlib: dllname, importc: "gluNurbsCurve".}
  148. proc gluNurbsSurface*(nobj: PGLUnurbs, sknot_count: TGLint, sknot: PGLfloat,
  149. tknot_count: TGLint, tknot: PGLfloat,
  150. s_stride, t_stride: TGLint, ctlarray: PGLfloat,
  151. sorder, torder: TGLint, atype: TGLenum){.dynlib: dllname,
  152. importc: "gluNurbsSurface".}
  153. proc gluLoadSamplingMatrices*(nobj: PGLUnurbs,
  154. modelMatrix, projMatrix: var T16dArray,
  155. viewport: var TViewPortArray){.dynlib: dllname,
  156. importc: "gluLoadSamplingMatrices".}
  157. proc gluNurbsProperty*(nobj: PGLUnurbs, aproperty: TGLenum, value: TGLfloat){.
  158. dynlib: dllname, importc: "gluNurbsProperty".}
  159. proc gluGetNurbsProperty*(nobj: PGLUnurbs, aproperty: TGLenum, value: PGLfloat){.
  160. dynlib: dllname, importc: "gluGetNurbsProperty".}
  161. proc gluNurbsCallback*(nobj: PGLUnurbs, which: TGLenum, fn: TCallBack){.
  162. dynlib: dllname, importc: "gluNurbsCallback".}
  163. #*** Callback function prototypes ***
  164. type # gluQuadricCallback
  165. GLUquadricErrorProc* = proc (p: TGLenum) # gluTessCallback
  166. GLUtessBeginProc* = proc (p: TGLenum)
  167. GLUtessEdgeFlagProc* = proc (p: TGLboolean)
  168. GLUtessVertexProc* = proc (p: Pointer)
  169. GLUtessEndProc* = proc ()
  170. GLUtessErrorProc* = proc (p: TGLenum)
  171. GLUtessCombineProc* = proc (p1: var T3dArray, p2: T4pArray, p3: T4fArray,
  172. p4: PPointer)
  173. GLUtessBeginDataProc* = proc (p1: TGLenum, p2: Pointer)
  174. GLUtessEdgeFlagDataProc* = proc (p1: TGLboolean, p2: Pointer)
  175. GLUtessVertexDataProc* = proc (p1, p2: Pointer)
  176. GLUtessEndDataProc* = proc (p: Pointer)
  177. GLUtessErrorDataProc* = proc (p1: TGLenum, p2: Pointer)
  178. GLUtessCombineDataProc* = proc (p1: var T3dArray, p2: var T4pArray,
  179. p3: var T4fArray, p4: PPointer, p5: Pointer) #
  180. #
  181. # gluNurbsCallback
  182. GLUnurbsErrorProc* = proc (p: TGLenum) #*** Generic constants ****/
  183. const # Version
  184. GLU_VERSION_1_1* = 1
  185. GLU_VERSION_1_2* = 1 # Errors: (return value 0 = no error)
  186. GLU_INVALID_ENUM* = 100900
  187. GLU_INVALID_VALUE* = 100901
  188. GLU_OUT_OF_MEMORY* = 100902
  189. GLU_INCOMPATIBLE_GL_VERSION* = 100903 # StringName
  190. GLU_VERSION* = 100800
  191. GLU_EXTENSIONS* = 100801 # Boolean
  192. GLU_TRUE* = GL_TRUE
  193. GLU_FALSE* = GL_FALSE #*** Quadric constants ****/
  194. # QuadricNormal
  195. GLU_SMOOTH* = 100000
  196. GLU_FLAT* = 100001
  197. GLU_NONE* = 100002 # QuadricDrawStyle
  198. GLU_POINT* = 100010
  199. GLU_LINE* = 100011
  200. GLU_FILL* = 100012
  201. GLU_SILHOUETTE* = 100013 # QuadricOrientation
  202. GLU_OUTSIDE* = 100020
  203. GLU_INSIDE* = 100021 # Callback types:
  204. # GLU_ERROR = 100103;
  205. #*** Tesselation constants ****/
  206. GLU_TESS_MAX_COORD* = 1.00000e+150 # TessProperty
  207. GLU_TESS_WINDING_RULE* = 100140
  208. GLU_TESS_BOUNDARY_ONLY* = 100141
  209. GLU_TESS_TOLERANCE* = 100142 # TessWinding
  210. GLU_TESS_WINDING_ODD* = 100130
  211. GLU_TESS_WINDING_NONZERO* = 100131
  212. GLU_TESS_WINDING_POSITIVE* = 100132
  213. GLU_TESS_WINDING_NEGATIVE* = 100133
  214. GLU_TESS_WINDING_ABS_GEQ_TWO* = 100134 # TessCallback
  215. GLU_TESS_BEGIN* = 100100 # void (CALLBACK*)(TGLenum type)
  216. constGLU_TESS_VERTEX* = 100101 # void (CALLBACK*)(void *data)
  217. GLU_TESS_END* = 100102 # void (CALLBACK*)(void)
  218. GLU_TESS_ERROR* = 100103 # void (CALLBACK*)(TGLenum errno)
  219. GLU_TESS_EDGE_FLAG* = 100104 # void (CALLBACK*)(TGLboolean boundaryEdge)
  220. GLU_TESS_COMBINE* = 100105 # void (CALLBACK*)(TGLdouble coords[3],
  221. # void *data[4],
  222. # TGLfloat weight[4],
  223. # void **dataOut)
  224. GLU_TESS_BEGIN_DATA* = 100106 # void (CALLBACK*)(TGLenum type,
  225. # void *polygon_data)
  226. GLU_TESS_VERTEX_DATA* = 100107 # void (CALLBACK*)(void *data,
  227. # void *polygon_data)
  228. GLU_TESS_END_DATA* = 100108 # void (CALLBACK*)(void *polygon_data)
  229. GLU_TESS_ERROR_DATA* = 100109 # void (CALLBACK*)(TGLenum errno,
  230. # void *polygon_data)
  231. GLU_TESS_EDGE_FLAG_DATA* = 100110 # void (CALLBACK*)(TGLboolean boundaryEdge,
  232. # void *polygon_data)
  233. GLU_TESS_COMBINE_DATA* = 100111 # void (CALLBACK*)(TGLdouble coords[3],
  234. # void *data[4],
  235. # TGLfloat weight[4],
  236. # void **dataOut,
  237. # void *polygon_data)
  238. # TessError
  239. GLU_TESS_ERROR1* = 100151
  240. GLU_TESS_ERROR2* = 100152
  241. GLU_TESS_ERROR3* = 100153
  242. GLU_TESS_ERROR4* = 100154
  243. GLU_TESS_ERROR5* = 100155
  244. GLU_TESS_ERROR6* = 100156
  245. GLU_TESS_ERROR7* = 100157
  246. GLU_TESS_ERROR8* = 100158
  247. GLU_TESS_MISSING_BEGIN_POLYGON* = GLU_TESS_ERROR1
  248. GLU_TESS_MISSING_BEGIN_CONTOUR* = GLU_TESS_ERROR2
  249. GLU_TESS_MISSING_END_POLYGON* = GLU_TESS_ERROR3
  250. GLU_TESS_MISSING_END_CONTOUR* = GLU_TESS_ERROR4
  251. GLU_TESS_COORD_TOO_LARGE* = GLU_TESS_ERROR5
  252. GLU_TESS_NEED_COMBINE_CALLBACK* = GLU_TESS_ERROR6 #*** NURBS constants ****/
  253. # NurbsProperty
  254. GLU_AUTO_LOAD_MATRIX* = 100200
  255. GLU_CULLING* = 100201
  256. GLU_SAMPLING_TOLERANCE* = 100203
  257. GLU_DISPLAY_MODE* = 100204
  258. GLU_PARAMETRIC_TOLERANCE* = 100202
  259. GLU_SAMPLING_METHOD* = 100205
  260. GLU_U_STEP* = 100206
  261. GLU_V_STEP* = 100207 # NurbsSampling
  262. GLU_PATH_LENGTH* = 100215
  263. GLU_PARAMETRIC_ERROR* = 100216
  264. GLU_DOMAIN_DISTANCE* = 100217 # NurbsTrim
  265. GLU_MAP1_TRIM_2* = 100210
  266. GLU_MAP1_TRIM_3* = 100211 # NurbsDisplay
  267. # GLU_FILL = 100012;
  268. GLU_OUTLINE_POLYGON* = 100240
  269. GLU_OUTLINE_PATCH* = 100241 # NurbsCallback
  270. # GLU_ERROR = 100103;
  271. # NurbsErrors
  272. GLU_NURBS_ERROR1* = 100251
  273. GLU_NURBS_ERROR2* = 100252
  274. GLU_NURBS_ERROR3* = 100253
  275. GLU_NURBS_ERROR4* = 100254
  276. GLU_NURBS_ERROR5* = 100255
  277. GLU_NURBS_ERROR6* = 100256
  278. GLU_NURBS_ERROR7* = 100257
  279. GLU_NURBS_ERROR8* = 100258
  280. GLU_NURBS_ERROR9* = 100259
  281. GLU_NURBS_ERROR10* = 100260
  282. GLU_NURBS_ERROR11* = 100261
  283. GLU_NURBS_ERROR12* = 100262
  284. GLU_NURBS_ERROR13* = 100263
  285. GLU_NURBS_ERROR14* = 100264
  286. GLU_NURBS_ERROR15* = 100265
  287. GLU_NURBS_ERROR16* = 100266
  288. GLU_NURBS_ERROR17* = 100267
  289. GLU_NURBS_ERROR18* = 100268
  290. GLU_NURBS_ERROR19* = 100269
  291. GLU_NURBS_ERROR20* = 100270
  292. GLU_NURBS_ERROR21* = 100271
  293. GLU_NURBS_ERROR22* = 100272
  294. GLU_NURBS_ERROR23* = 100273
  295. GLU_NURBS_ERROR24* = 100274
  296. GLU_NURBS_ERROR25* = 100275
  297. GLU_NURBS_ERROR26* = 100276
  298. GLU_NURBS_ERROR27* = 100277
  299. GLU_NURBS_ERROR28* = 100278
  300. GLU_NURBS_ERROR29* = 100279
  301. GLU_NURBS_ERROR30* = 100280
  302. GLU_NURBS_ERROR31* = 100281
  303. GLU_NURBS_ERROR32* = 100282
  304. GLU_NURBS_ERROR33* = 100283
  305. GLU_NURBS_ERROR34* = 100284
  306. GLU_NURBS_ERROR35* = 100285
  307. GLU_NURBS_ERROR36* = 100286
  308. GLU_NURBS_ERROR37* = 100287 #*** Backwards compatibility for old tesselator ****/
  309. proc gluBeginPolygon*(tess: PGLUtesselator){.dynlib: dllname,
  310. importc: "gluBeginPolygon".}
  311. proc gluNextContour*(tess: PGLUtesselator, atype: TGLenum){.dynlib: dllname,
  312. importc: "gluNextContour".}
  313. proc gluEndPolygon*(tess: PGLUtesselator){.dynlib: dllname,
  314. importc: "gluEndPolygon".}
  315. const # Contours types -- obsolete!
  316. GLU_CW* = 100120
  317. GLU_CCW* = 100121
  318. GLU_INTERIOR* = 100122
  319. GLU_EXTERIOR* = 100123
  320. GLU_UNKNOWN* = 100124 # Names without "TESS_" prefix
  321. GLU_BEGIN* = GLU_TESS_BEGIN
  322. GLU_VERTEX* = constGLU_TESS_VERTEX
  323. GLU_END* = GLU_TESS_END
  324. GLU_ERROR* = GLU_TESS_ERROR
  325. GLU_EDGE_FLAG* = GLU_TESS_EDGE_FLAG
  326. {.pop.}
  327. # implementation