From 1ddaaf773e68325eab1988fb10836c1faf5c3ca2 Mon Sep 17 00:00:00 2001 From: Caspian Rychlik-Prince Date: Fri, 1 Aug 2003 17:53:44 +0000 Subject: [PATCH] Major change to use overloaded buffer functions and buffer positions. In addition, quadrics and default shapes have been removed from GLU. --- src/java/org/lwjgl/opengl/GLU.java | 301 +++++--------------- src/java/org/lwjgl/opengl/GLUConstants.java | 161 ----------- 2 files changed, 74 insertions(+), 388 deletions(-) diff --git a/src/java/org/lwjgl/opengl/GLU.java b/src/java/org/lwjgl/opengl/GLU.java index 8821d2d5..ecf697f5 100644 --- a/src/java/org/lwjgl/opengl/GLU.java +++ b/src/java/org/lwjgl/opengl/GLU.java @@ -93,7 +93,7 @@ public class GLU implements GLUConstants { double upy, double upz); - public static native int gluProject( + public static int gluProject( double objx, double objy, double objz, @@ -101,9 +101,25 @@ public class GLU implements GLUConstants { DoubleBuffer projMatrix, IntBuffer viewport, DoubleBuffer win + ) { + return ngluProject(objx, objy, objz, modelMatrix, modelMatrix.position(), projMatrix, projMatrix.position(), viewport, viewport.position(), win, win.position()); + } + + private static native int ngluProject( + double objx, + double objy, + double objz, + DoubleBuffer modelMatrix, + int modelMatrix_offset, + DoubleBuffer projMatrix, + int projMatrix_offset, + IntBuffer viewport, + int viewport_ofset, + DoubleBuffer win, + int win_offset ); - public static native int gluUnProject( + public static int gluUnProject( double winx, double winy, double winz, @@ -111,27 +127,67 @@ public class GLU implements GLUConstants { DoubleBuffer projMatrix, IntBuffer viewport, DoubleBuffer obj + ) { + return ngluUnProject(winx, winy, winz, modelMatrix, modelMatrix.position(), projMatrix, projMatrix.position(), viewport, viewport.position(), obj, obj.position()); + } + + private static native int ngluUnProject( + double winx, + double winy, + double winz, + DoubleBuffer modelMatrix, + int modelMatrix_offset, + DoubleBuffer projMatrix, + int projMatrix_offset, + IntBuffer viewport, + int viewport_offset, + DoubleBuffer obj, + int obj_offset ); - public static native int gluScaleImage( + public static int gluScaleImage( int format, int widthin, int heightin, int typein, ByteBuffer datain, int widthout, int heightout, int typeout, ByteBuffer dataout + ) { + return ngluScaleImage(format, widthin, heightin, typein, datain, datain.position(), widthout, heightout, typeout, dataout, dataout.position()); + } + + private static native int ngluScaleImage( + int format, + int widthin, + int heightin, + int typein, + ByteBuffer datain, + int datain_offset, + int widthout, int heightout, int typeout, ByteBuffer dataout, int dataout_offset ); - public static native int gluBuild1DMipmaps( + public static int gluBuild1DMipmaps( int target, int components, int width, int format, int type, ByteBuffer data + ) { + return ngluBuild1DMipmaps(target, components, width, format, type, data, data.position()); + } + + private static native int ngluBuild1DMipmaps( + int target, + int components, + int width, + int format, + int type, + ByteBuffer data, + int data_offset ); - public static native int gluBuild2DMipmaps( + public static int gluBuild2DMipmaps( int target, int components, int width, @@ -139,228 +195,19 @@ public class GLU implements GLUConstants { int format, int type, ByteBuffer data + ) { + return ngluBuild2DMipmaps(target, components, width, height, format, type, data, data.position()); + } + + private static native int ngluBuild2DMipmaps( + int target, + int components, + int width, + int height, + int format, + int type, + ByteBuffer data, + int data_offset ); - /** - * creates and returns a pointer to a new quadrics object. This - * object must be referred to when calling quadrics rendering and control - * functions. A return value of null means that there is not enough memory to - * allocate the object - * - * @return ByteBuffer representing a new quadrics object - */ - public static native ByteBuffer gluNewQuadric(); - - /** - * draws a cylinder oriented along the z axis. The base of the - * cylinder is placed at z = 0, and the top at z=height. Like a sphere, a - * cylinder is subdivided around the z axis into slices, and along the z axis - * into stacks. - * - * Note that if topRadius is set to zero, then this routine will generate a - * cone. - * - * If the orientation is set to GLU.OUTSIDE (with glu.quadricOrientation), then - * any generated normals point away from the z axis. Otherwise, they point - * toward the z axis. - * - * If texturing is turned on (with glu.quadricTexture), then texture - * coordinates are generated so that t ranges linearly from 0.0 at z = 0 to - * 1.0 at z = height, and s ranges from 0.0 at the +y axis, to 0.25 at the +x - * axis, to 0.5 at the -y axis, to 0.75 at the -x axis, and back to 1.0 at the - * +y axis. - * - * @param target Specifies the quadrics object (created with glu.newQuadric). - * - * @param baseRadius Specifies the radius of the cylinder at z = 0. - * - * @param topRadius Specifies the radius of the cylinder at z = height. - * - * @param height Specifies the height of the cylinder. - * - * @param slices Specifies the number of subdivisions around the z axis. - * - * @param stacks Specifies the number of subdivisions along the z axis. - */ - public static native void gluCylinder( - ByteBuffer target, - double baseRadius, - double topRadius, - double height, - int slices, - int stacks - ); - - /** - * destroys the quadrics object and frees any memory used by - * it. Once glu.deleteQuadric has been called, the object cannot be used again. - * - * @param qobj pecifies the quadrics object to be destroyed (created with - * glu.newQuadric). - */ - public static native void gluDeleteQuadric( - ByteBuffer qobj - ); - - - /** - * renders a disk on the z = 0 plane. The disk has a radius of - * outerRadius, and contains a concentric circular hole with a radius of - * innerRadius. If innerRadius is 0, then no hole is generated. The disk is - * subdivided around the z axis into slices (like pizza slices), and also - * about the z axis into rings (as specified by slices and loops, - * respectively). - * - * With respect to orientation, the +z side of the disk is considered to be - * "outside" (see glu.quadricOrientation). This means that if the orientation - * is set to GLU.OUTSIDE, then any normals generated point along the +z axis. - * Otherwise, they point along the -z axis. - * - * If texturing is turned on (with glu.quadricTexture), texture coordinates are - * generated linearly such that where r=outerRadius, the value at (r, 0, 0) is - * (1, 0.5), at (0, r, 0) it is (0.5, 1), at (-r, 0, 0) it is (0, 0.5), and at - * (0, -r, 0) it is (0.5, 0). - */ - public static native void gluDisk( - ByteBuffer target, - double innerRadius, - double outerRadius, - int slices, - int loops - ); - - /** - * renders a partial disk on the z=0 plane. A partial disk is - * similar to a full disk, except that only the subset of the disk from - * startAngle through startAngle + sweepAngle is included (where 0 degrees is - * along the +y axis, 90 degrees along the +x axis, 180 along the -y axis, and - * 270 along the -x axis). - * - * The partial disk has a radius of outerRadius, and contains a concentric - * circular hole with a radius of innerRadius. If innerRadius is zero, then - * no hole is generated. The partial disk is subdivided around the z axis - * into slices (like pizza slices), and also about the z axis into rings (as - * specified by slices and loops, respectively). - * - * With respect to orientation, the +z side of the partial disk is considered - * to be outside (see gluQuadricOrientation). This means that if the - * orientation is set to GLU_OUTSIDE, then any normals generated point along - * the +z axis. Otherwise, they point along the -z axis. - * - * If texturing is turned on (with gluQuadricTexture), texture coordinates are - * generated linearly such that where r=outerRadius, the value at (r, 0, 0) is - * (1, 0.5), at (0, r, 0) it is (0.5, 1), at (-r, 0, 0) it is (0, 0.5), and at - * (0, -r, 0) it is (0.5, 0). - */ - public static native void gluPartialDisk( - ByteBuffer target, - double innerRadius, - double outerRadius, - int slices, - int loops, - double startAngle, - double sweepAngle - ); - - /** - * specifies the draw style for quadrics rendered with - * qobj. The legal values are as follows: - * - * GLU.FILL: Quadrics are rendered with polygon primitives. The polygons - * are drawn in a counterclockwise fashion with respect to - * their normals (as defined with glu.quadricOrientation). - * - * GLU.LINE: Quadrics are rendered as a set of lines. - * - * GLU.SILHOUETTE: Quadrics are rendered as a set of lines, except that edges - * separating coplanar faces will not be drawn. - * - * GLU.POINT: Quadrics are rendered as a set of points. - */ - public static native void gluQuadricDrawStyle( - ByteBuffer target, - int drawStyle - ); - - /** - * specifies what kind of normals are desired for quadrics - * rendered with qobj. The legal values are as follows: - * - * GLU.NONE: No normals are generated. - * - * GLU.FLAT: One normal is generated for every facet of a quadric. - * - * GLU.SMOOTH: One normal is generated for every vertex of a quadric. This - * is the default. - */ - public static native void gluQuadricNormals( - ByteBuffer target, - int normals - ); - - /** - * specifies what kind of orientation is desired for - * quadrics rendered with qobj. The orientation values are as follows: - * - * GLU.OUTSIDE: Quadrics are drawn with normals pointing outward. - * - * GLU.INSIDE: Normals point inward. The default is GLU.OUTSIDE. - * - * Note that the interpretation of outward and inward depends on the quadric - * being drawn. - */ - public static native void gluQuadricOrientation( - ByteBuffer target, - int orientation - ); - - /** - * specifies if texture coordinates should be generated for - * quadrics rendered with qobj. If the value of textureCoords is true, - * then texture coordinates are generated, and if textureCoords is false, - * they are not.. The default is false. - * - * The manner in which texture coordinates are generated depends upon the - * specific quadric rendered. - */ - public static native void gluQuadricTexture( - ByteBuffer target, - boolean textureCoords - ); - - /** - * draws a sphere of the given radius centered around the origin. - * The sphere is subdivided around the z axis into slices and along the z axis - * into stacks (similar to lines of longitude and latitude). - * - * If the orientation is set to GLU.OUTSIDE (with glu.quadricOrientation), then - * any normals generated point away from the center of the sphere. Otherwise, - * they point toward the center of the sphere. - - * If texturing is turned on (with glu.quadricTexture), then texture - * coordinates are generated so that t ranges from 0.0 at z=-radius to 1.0 at - * z=radius (t increases linearly along longitudinal lines), and s ranges from - * 0.0 at the +y axis, to 0.25 at the +x axis, to 0.5 at the -y axis, to 0.75 - * at the -x axis, and back to 1.0 at the +y axis. - */ - public static native void gluSphere( - ByteBuffer target, - double radius, - int slices, - int stacks - ); - -/* public static native void gluQuadricCallback( - ByteBuffer target, - int type, - String method - ); -*/ - public static native void gluQuadricCallback( - ByteBuffer target, - int type, - Object obj, - String method - ); - } diff --git a/src/java/org/lwjgl/opengl/GLUConstants.java b/src/java/org/lwjgl/opengl/GLUConstants.java index 5301083e..44575f9a 100644 --- a/src/java/org/lwjgl/opengl/GLUConstants.java +++ b/src/java/org/lwjgl/opengl/GLUConstants.java @@ -56,165 +56,4 @@ public interface GLUConstants { public static final int GLU_FALSE = CoreGL11Constants.GL_FALSE; - /**** Quadric constants ****/ - - /* QuadricNormal */ - public static final int GLU_SMOOTH = 100000; - public static final int GLU_FLAT = 100001; - public static final int GLU_NONE = 100002; - - /* QuadricDrawStyle */ - public static final int GLU_POINT = 100010; - public static final int GLU_LINE = 100011; - public static final int GLU_FILL = 100012; - public static final int GLU_SILHOUETTE = 100013; - - /* QuadricOrientation */ - public static final int GLU_OUTSIDE = 100020; - public static final int GLU_INSIDE = 100021; - - /* Callback types: */ - /* GLU_ERROR = 100103 */ - - - /**** Tesselation constants ****/ - - public static final double GLU_TESS_MAX_COORD = 1.0e150; - - /* TessProperty */ - public static final int GLU_TESS_WINDING_RULE = 100140; - public static final int GLU_TESS_BOUNDARY_ONLY = 100141; - public static final int GLU_TESS_TOLERANCE = 100142; - - /* TessWinding */ - public static final int GLU_TESS_WINDING_ODD = 100130; - public static final int GLU_TESS_WINDING_NONZERO = 100131; - public static final int GLU_TESS_WINDING_POSITIVE = 100132; - public static final int GLU_TESS_WINDING_NEGATIVE = 100133; - public static final int GLU_TESS_WINDING_ABS_GEQ_TWO = 100134; - - /* TessCallback */ - public static final int GLU_TESS_BEGIN = 100100; /* void (CALLBACK*)(GLenum type) */ - public static final int GLU_TESS_VERTEX = 100101; /* void (CALLBACK*)(void *data) */ - public static final int GLU_TESS_END = 100102; /* void (CALLBACK*)(void) */ - public static final int GLU_TESS_ERROR = 100103; /* void (CALLBACK*)(GLenum errno) */ - public static final int GLU_TESS_EDGE_FLAG = 100104; /* void (CALLBACK*)(GLboolean boundaryEdge) */ - public static final int GLU_TESS_COMBINE = 100105; /* void (CALLBACK*)(GLdouble coords[3], - void *data[4], - GLfloat weight[4], - void **dataOut) */ - public static final int GLU_TESS_BEGIN_DATA = 100106; /* void (CALLBACK*)(GLenum type, - void *polygon_data) */ - public static final int GLU_TESS_VERTEX_DATA = 100107; /* void (CALLBACK*)(void *data, - void *polygon_data) */ - public static final int GLU_TESS_END_DATA = 100108; /* void (CALLBACK*)(void *polygon_data) */ - public static final int GLU_TESS_ERROR_DATA = 100109; /* void (CALLBACK*)(GLenum errno, - void *polygon_data) */ - public static final int GLU_TESS_EDGE_FLAG_DATA = 100110; /* void (CALLBACK*)(GLboolean boundaryEdge, - void *polygon_data) */ - public static final int GLU_TESS_COMBINE_DATA = 100111; /* void (CALLBACK*)(GLdouble coords[3], - void *data[4], - GLfloat weight[4], - void **dataOut, - void *polygon_data) */ - - /* TessError */ - public static final int GLU_TESS_ERROR1 = 100151; - public static final int GLU_TESS_ERROR2 = 100152; - public static final int GLU_TESS_ERROR3 = 100153; - public static final int GLU_TESS_ERROR4 = 100154; - public static final int GLU_TESS_ERROR5 = 100155; - public static final int GLU_TESS_ERROR6 = 100156; - public static final int GLU_TESS_ERROR7 = 100157; - public static final int GLU_TESS_ERROR8 = 100158; - - public static final int GLU_TESS_MISSING_BEGIN_POLYGON = GLU_TESS_ERROR1; - public static final int GLU_TESS_MISSING_BEGIN_CONTOUR = GLU_TESS_ERROR2; - public static final int GLU_TESS_MISSING_END_POLYGON = GLU_TESS_ERROR3; - public static final int GLU_TESS_MISSING_END_CONTOUR = GLU_TESS_ERROR4; - public static final int GLU_TESS_COORD_TOO_LARGE = GLU_TESS_ERROR5; - public static final int GLU_TESS_NEED_COMBINE_CALLBACK = GLU_TESS_ERROR6; - - /**** NURBS constants ****/ - - /* NurbsProperty */ - public static final int GLU_AUTO_LOAD_MATRIX = 100200; - public static final int GLU_CULLING = 100201; - public static final int GLU_SAMPLING_TOLERANCE = 100203; - public static final int GLU_DISPLAY_MODE = 100204; - public static final int GLU_PARAMETRIC_TOLERANCE = 100202; - public static final int GLU_SAMPLING_METHOD = 100205; - public static final int GLU_U_STEP = 100206; - public static final int GLU_V_STEP = 100207; - - /* NurbsSampling */ - public static final int GLU_PATH_LENGTH = 100215; - public static final int GLU_PARAMETRIC_ERROR = 100216; - public static final int GLU_DOMAIN_DISTANCE = 100217; - - - /* NurbsTrim */ - public static final int GLU_MAP1_TRIM_2 = 100210; - public static final int GLU_MAP1_TRIM_3 = 100211; - - /* NurbsDisplay */ - /* GLU_FILL = 100012 */ - public static final int GLU_OUTLINE_POLYGON = 100240; - public static final int GLU_OUTLINE_PATCH = 100241; - - /* NurbsCallback */ - /* GLU_ERROR = 100103 */ - - /* NurbsErrors */ - public static final int GLU_NURBS_ERROR1 = 100251; - public static final int GLU_NURBS_ERROR2 = 100252; - public static final int GLU_NURBS_ERROR3 = 100253; - public static final int GLU_NURBS_ERROR4 = 100254; - public static final int GLU_NURBS_ERROR5 = 100255; - public static final int GLU_NURBS_ERROR6 = 100256; - public static final int GLU_NURBS_ERROR7 = 100257; - public static final int GLU_NURBS_ERROR8 = 100258; - public static final int GLU_NURBS_ERROR9 = 100259; - public static final int GLU_NURBS_ERROR10 = 100260; - public static final int GLU_NURBS_ERROR11 = 100261; - public static final int GLU_NURBS_ERROR12 = 100262; - public static final int GLU_NURBS_ERROR13 = 100263; - public static final int GLU_NURBS_ERROR14 = 100264; - public static final int GLU_NURBS_ERROR15 = 100265; - public static final int GLU_NURBS_ERROR16 = 100266; - public static final int GLU_NURBS_ERROR17 = 100267; - public static final int GLU_NURBS_ERROR18 = 100268; - public static final int GLU_NURBS_ERROR19 = 100269; - public static final int GLU_NURBS_ERROR20 = 100270; - public static final int GLU_NURBS_ERROR21 = 100271; - public static final int GLU_NURBS_ERROR22 = 100272; - public static final int GLU_NURBS_ERROR23 = 100273; - public static final int GLU_NURBS_ERROR24 = 100274; - public static final int GLU_NURBS_ERROR25 = 100275; - public static final int GLU_NURBS_ERROR26 = 100276; - public static final int GLU_NURBS_ERROR27 = 100277; - public static final int GLU_NURBS_ERROR28 = 100278; - public static final int GLU_NURBS_ERROR29 = 100279; - public static final int GLU_NURBS_ERROR30 = 100280; - public static final int GLU_NURBS_ERROR31 = 100281; - public static final int GLU_NURBS_ERROR32 = 100282; - public static final int GLU_NURBS_ERROR33 = 100283; - public static final int GLU_NURBS_ERROR34 = 100284; - public static final int GLU_NURBS_ERROR35 = 100285; - public static final int GLU_NURBS_ERROR36 = 100286; - public static final int GLU_NURBS_ERROR37 = 100287; - - /* Contours types -- obsolete! */ - public static final int GLU_CW = 100120; - public static final int GLU_CCW = 100121; - public static final int GLU_INTERIOR = 100122; - public static final int GLU_EXTERIOR = 100123; - public static final int GLU_UNKNOWN = 100124; - - /* Names without "TESS_" prefix */ - public static final int GLU_BEGIN = GLU_TESS_BEGIN; - public static final int GLU_VERTEX = GLU_TESS_VERTEX; - public static final int GLU_END = GLU_TESS_END; - public static final int GLU_ERROR = GLU_TESS_ERROR; - public static final int GLU_EDGE_FLAG = GLU_TESS_EDGE_FLAG; }