glu.nim 15 KB

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