# This is the definition file for all GLU stuff

%COPY_INTERFACE
// ===================================================================
//   GLU consts, types and functions
// ===================================================================

const
  GLU_TRUE                              = GL_TRUE;
  GLU_FALSE                             = GL_FALSE;

  // Normal vectors
  GLU_SMOOTH                            = 100000;
  GLU_FLAT                              = 100001;
  GLU_NONE                              = 100002;

  // Quadric draw styles
  GLU_POINT                             = 100010;
  GLU_LINE                              = 100011;
  GLU_FILL                              = 100012;
  GLU_SILHOUETTE                        = 100013;

  // Quadric orientation
  GLU_OUTSIDE                           = 100020;
  GLU_INSIDE                            = 100021;

  // Tesselator
  GLU_TESS_BEGIN                        = 100100;
  GLU_TESS_VERTEX                       = 100101;
  GLU_TESS_END                          = 100102;
  GLU_TESS_ERROR                        = 100103;
  GLU_TESS_EDGE_FLAG                    = 100104;
  GLU_TESS_COMBINE			= 100105;
  GLU_TESS_BEGIN_DATA			= 100106;
  GLU_TESS_VERTEX_DATA			= 100107;
  GLU_TESS_END_DATA			= 100108;
  GLU_TESS_ERROR_DATA			= 100109;
  GLU_TESS_EDGE_FLAG_DATA		= 100110;
  GLU_TESS_COMBINE_DATA			= 100111;

  // Winding rules
  GLU_TESS_WINDING_ODD			= 100130;
  GLU_TESS_WINDING_NONZERO		= 100131;
  GLU_TESS_WINDING_POSITIVE		= 100132;
  GLU_TESS_WINDING_NEGATIVE		= 100133;
  GLU_TESS_WINDING_ABS_GEQ_TWO		= 100134;

  // Tessellation properties
  GLU_TESS_WINDING_RULE			= 100140;
  GLU_TESS_BOUNDARY_ONLY		= 100141;
  GLU_TESS_TOLERANCE			= 100142;

  // Tessellation errors
  GLU_TESS_ERROR1			= 100151;   // Missing gluBeginPolygon
  GLU_TESS_ERROR2			= 100152;   // Missing gluBeginContour
  GLU_TESS_ERROR3			= 100153;   // Missing gluEndPolygon
  GLU_TESS_ERROR4			= 100154;   // Missing gluEndContour
  GLU_TESS_ERROR5			= 100155;
  GLU_TESS_ERROR6			= 100156;
  GLU_TESS_ERROR7			= 100157;
  GLU_TESS_ERROR8			= 100158;

  // NURBS
  GLU_AUTO_LOAD_MATRIX                  = 100200;
  GLU_CULLING                           = 100201;
  GLU_PARAMETRIC_TOLERANCE              = 100202;
  GLU_SAMPLING_TOLERANCE                = 100203;
  GLU_DISPLAY_MODE                      = 100204;
  GLU_SAMPLING_METHOD                   = 100205;
  GLU_U_STEP                            = 100206;
  GLU_V_STEP                            = 100207;

  GLU_PATH_LENGTH                       = 100215;
  GLU_PARAMETRIC_ERROR                  = 100216;
  GLU_DOMAIN_DISTANCE                   = 100217;

  GLU_MAP1_TRIM_2                       = 100210;
  GLU_MAP1_TRIM_3                       = 100211;

  GLU_OUTLINE_POLYGON                   = 100240;
  GLU_OUTLINE_PATCH                     = 100241;

  GLU_NURBS_ERROR1                      = 100251;   // spline order un-supported
  GLU_NURBS_ERROR2                      = 100252;   // too few knots
  GLU_NURBS_ERROR3                      = 100253;   // valid knot range is empty
  GLU_NURBS_ERROR4                      = 100254;   // decreasing knot sequence
  GLU_NURBS_ERROR5                      = 100255;   // knot multiplicity > spline order
  GLU_NURBS_ERROR6                      = 100256;   // endcurve() must follow bgncurve()
  GLU_NURBS_ERROR7                      = 100257;   // bgncurve() must precede endcurve()
  GLU_NURBS_ERROR8                      = 100258;   // ctrlarray or knot vector is NULL
  GLU_NURBS_ERROR9                      = 100259;   // cannot draw pwlcurves
  GLU_NURBS_ERROR10                     = 100260;   // missing gluNurbsCurve()
  GLU_NURBS_ERROR11                     = 100261;   // missing gluNurbsSurface()
  GLU_NURBS_ERROR12                     = 100262;   // endtrim() must precede endsurface()
  GLU_NURBS_ERROR13                     = 100263;   // bgnsurface() must precede endsurface()
  GLU_NURBS_ERROR14                     = 100264;   // curve of improper type passed as trim curve
  GLU_NURBS_ERROR15                     = 100265;   // bgnsurface() must precede bgntrim()
  GLU_NURBS_ERROR16                     = 100266;   // endtrim() must follow bgntrim()
  GLU_NURBS_ERROR17                     = 100267;   // bgntrim() must precede endtrim()*/
  GLU_NURBS_ERROR18                     = 100268;   // invalid or missing trim curve*/
  GLU_NURBS_ERROR19                     = 100269;   // bgntrim() must precede pwlcurve()
  GLU_NURBS_ERROR20                     = 100270;   // pwlcurve referenced twice*/
  GLU_NURBS_ERROR21                     = 100271;   // pwlcurve and nurbscurve mixed
  GLU_NURBS_ERROR22                     = 100272;   // improper usage of trim data type
  GLU_NURBS_ERROR23                     = 100273;   // nurbscurve referenced twice
  GLU_NURBS_ERROR24                     = 100274;   // nurbscurve and pwlcurve mixed
  GLU_NURBS_ERROR25                     = 100275;   // nurbssurface referenced twice
  GLU_NURBS_ERROR26                     = 100276;   // invalid property
  GLU_NURBS_ERROR27                     = 100277;   // endsurface() must follow bgnsurface()
  GLU_NURBS_ERROR28                     = 100278;   // intersecting or misoriented trim curves
  GLU_NURBS_ERROR29                     = 100279;   // intersecting trim curves
  GLU_NURBS_ERROR30                     = 100280;   // UNUSED
  GLU_NURBS_ERROR31                     = 100281;   // unconnected trim curves
  GLU_NURBS_ERROR32                     = 100282;   // unknown knot error
  GLU_NURBS_ERROR33                     = 100283;   // negative vertex count encountered
  GLU_NURBS_ERROR34                     = 100284;   // negative byte-stride
  GLU_NURBS_ERROR35                     = 100285;   // unknown type descriptor
  GLU_NURBS_ERROR36                     = 100286;   // null control point reference
  GLU_NURBS_ERROR37                     = 100287;   // duplicate point on pwlcurve

  // Errors
  GLU_INVALID_ENUM                      = 100900;
  GLU_INVALID_VALUE                     = 100901;
  GLU_OUT_OF_MEMORY                     = 100902;
  GLU_INCOMPATIBLE_GL_VERSION           = 100903;

  // New in GLU 1.1
  GLU_VERSION                           = 100800;
  GLU_EXTENSIONS                        = 100801;


  // === GLU 1.0 tessellation - obsolete! ===

  // Contour types
  GLU_CW                                = 100120;
  GLU_CCW                               = 100121;
  GLU_INTERIOR                          = 100122;
  GLU_EXTERIOR                          = 100123;
  GLU_UNKNOWN                           = 100124;

  // Tessellator
  GLU_BEGIN				= GLU_TESS_BEGIN;
  GLU_VERTEX				= GLU_TESS_VERTEX;
  GLU_END				= GLU_TESS_END;
  GLU_ERROR				= GLU_TESS_ERROR;
  GLU_EDGE_FLAG				= GLU_TESS_EDGE_FLAG;


type
  PGLUquadricObj = ^TGLUquadricObj;
  TGLUquadricObj = record end;
  PGLUnurbsObj = ^TGLUnurbsObj;
  TGLUnurbsObj = record end;
  PGLUtesselator = ^TGLUtesselator;
  TGLUtesselator = record end;
  PGLUtriangulatorObj = PGLUtesselator;

  // Callback function declarations
  TGLUQuadricCallback = procedure; cdecl;
  TGLUNurbsCallback = procedure; cdecl;
  TGLUTessCallback = procedure; cdecl;

  // We need some private array types
  TGLUViewport = array[0..3] of LongInt;
  TGLUMatrixd = array[0..15] of GLdouble;
  TGLUMatrixf = array[0..15] of GLfloat;
  TGLUVectord = array[0..2] of GLdouble;

var
%END


#=====================================================================
# Procedures and functions
#=====================================================================

%PROCS
  // Miscellaneous functions
  gluLookAt: procedure(eye, eyey, eyez, centerx, centery, centerz, upx, upy, upz: GLdouble);
  gluOrtho2D: procedure(left, right, bottom, top: GLdouble);
  gluPerspective: procedure(fovy, aspect, zNear, zFar: GLdouble);
  gluPickMatrix: procedure(x, y, width, height: GLdouble; const viewport: TGLUViewport);
  gluProject: function(objx, objy, objz: GLdouble; const modelMatrix, projMatrix: TGLUMatrixd; const viewport: TGLUViewport; var winx, winy, winz: GLdouble): LongInt;
  gluUnProject: function(winx, winy, winz: GLdouble; const modelMatrix, projMatrix: TGLUMatrixd; const viewport: TGLUViewport; var objx, objy, objz: GLdouble): LongInt;
  gluErrorString: function(errorCode: GLenum): PChar;

  // Mipmapping and image scaling
  gluScaleImage: procedure(format: GLenum; within, heightin: LongInt; typein: GLenum; const datain; widthout, heightout: LongInt; typeout: GLenum; var dataout);
  gluBuild1DMipmaps: procedure(target: GLenum; components, width: LongInt; format, AType: GLEnum; const data);
  gluBuild2DMipmaps: procedure(target: GLenum; components, width, height: LongInt; format, AType: GLEnum; const data);

  // Quadrics
  gluNewQuadric: function: PGLUquadricObj;
  gluDeleteQuadric: procedure(state: PGLUquadricObj);
  gluQuadricDrawStyle: procedure(quadObject: PGLUquadricObj; drawStyle: GLenum);
  gluQuadricOrientation: procedure(quadObject: PGLUquadricObj; orientation: GLenum);
  gluQuadricNormals: procedure(quadObject: PGLUquadricObj; normals: GLenum);
  gluQuadricTexture: procedure(quadObject: PGLUquadricObj; textureCoords: Boolean);
  gluQuadricCallback: procedure(quadObject: PGLUquadricObj; which: GLenum; fn: TGLUQuadricCallback);
  gluCylinder: procedure(qobj: PGLUquadricObj; baseRadius, topRadius, height: GLdouble; slices, stacks: LongInt);
  gluSphere: procedure(qobj: PGLUquadricObj; radius: GLdouble; slices, stacks: LongInt);
  gluDisk: procedure(qobj: PGLUquadricObj; innerRadius, outerRadius: GLdouble; slices, loops: LongInt);
  gluPartialDisk: procedure(qobj: PGLUquadricObj; innerRadius, outerRadius: GLdouble; slices, loops: LongInt; startAngle, sweepAngle: GLdouble);

  // Nurbs
  gluNewNurbsRenderer: function: PGLUnurbsObj;
  gluDeleteNurbsRenderer: procedure(nobj: PGLUnurbsObj);
  gluLoadSamplingMatrices: procedure(nobj: PGLUnurbsObj; const modelMatrix, projMatrix: TGLUMatrixf; const viewport: TGLUViewport);
  gluNurbsProperty: procedure(nobj: PGLUnurbsObj; AProperty: GLenum; value: GLfloat);
  gluGetNurbsProperty: procedure(nobj: PGLUnurbsObj; AProperty: GLEnum; var value: GLfloat);
  gluBeginCurve: procedure(nobj: PGLUnurbsObj);
  gluEndCurve: procedure(nobj: PGLUnurbsObj);
  gluNurbsCurve: procedure(nobj: PGLUnurbsObj; nknots: LongInt; var know: GLfloat; stride: LongInt; var ctlarray: GLfloat; order: LongInt; AType: GLenum);
  gluBeginSurface: procedure(nobj: PGLUnurbsObj);
  gluEndSurface: procedure(nobj: PGLUnurbsObj);
  gluNurbsSurface: procedure(nobj: PGLUnurbsObj; sknot_count: LongInt; var sknot: GLfloat; tknot_count: LongInt; var tknot: GLfloat; s_stride, t_stride: LongInt; var ctlarray: GLfloat; sorder, torder: LongInt; AType: GLenum);
  gluBeginTrim: procedure(nobj: PGLUnurbsObj);
  gluEndTrim: procedure(nobj: PGLUnurbsObj);
  gluPwlCurve: procedure(nobj: PGLUnurbsObj; count: LongInt; var AArray: GLfloat; stride: LongInt; AType: GLenum);
  gluNurbsCallback: procedure(nobj: PGLUnurbsObj; which: GLenum; fn: TGLUNurbsCallback);

  // Polygon tesselation
  gluNewTess: function: PGLUtesselator;
  gluDeleteTess: procedure(tobj: PGLUtesselator);
  gluTessBeginPolygon: procedure(tobj: PGLUtesselator; var polygon_data);
  gluTessBeginContour: procedure(tobj: PGLUtesselator);
  gluTessVertex: procedure(tobj: PGLUtesselator; v: TGLUVectord; var data);
  gluTessEndContour: procedure(tobj: PGLUtesselator);
  gluTessEndPolygon: procedure(tobj: PGLUtesselator);
  gluTessProperty: procedure(tobj: PGLUtesselator; which: GLenum; value: GLdouble);
  gluTessNormal: procedure(tobj: PGLUtesselator; x, y, z: GLdouble);
  gluTessCallback: procedure(tobj: PGLUtesselator; which: GLenum; fn: TGLUTessCallback);
  gluGetTessProperty: procedure(tobj: PGLUtesselator; which: GLenum; var value: GLdouble);

  // Obsolete 1.0 tessellation functions
  gluBeginPolygon: procedure(tobj: PGLUtesselator);
  gluNextContour: procedure(tobj: PGLUtesselator; AType: GLenum);
  gluEndPolygon: procedure(tobj: PGLUtesselator);

  // New functions in GLU 1.1
  gluGetString: function(name: GLenum): PChar;
%END
