Made gluProject to use one result FloatBuffer, javadoc corrections

This commit is contained in:
Ioannis Tsakpinis 2004-02-29 23:42:51 +00:00
parent e1e6ea2093
commit 7dc7337396
7 changed files with 91 additions and 98 deletions

View File

@ -8,8 +8,8 @@ import org.lwjgl.opengl.GL11;
/**
* GLU.java
*
*
*
*
* Created 23-dec-2003
* @author Erik Duijs
*/
@ -53,7 +53,7 @@ public class GLU implements GLUConstants {
float right,
float bottom,
float top) {
GL11.glOrtho(left, right, bottom, top, -1.0, 1.0);
}
@ -81,18 +81,16 @@ public class GLU implements GLUConstants {
* @param modelMatrix
* @param projMatrix
* @param viewport
* @param winx
* @param winy
* @param winz
* @param win_pos
* @return
*/
public static boolean gluProject(float objx, float objy, float objz,
FloatBuffer modelMatrix,
public static boolean gluProject(float objx, float objy, float objz,
FloatBuffer modelMatrix,
FloatBuffer projMatrix,
IntBuffer viewport,
FloatBuffer winx, FloatBuffer winy, FloatBuffer winz)
FloatBuffer win_pos)
{
return Project.gluProject(objx, objy, objz, modelMatrix, projMatrix, viewport, winx, winy, winz);
return Project.gluProject(objx, objy, objz, modelMatrix, projMatrix, viewport, win_pos);
}
/**
@ -107,7 +105,7 @@ public class GLU implements GLUConstants {
* @return
*/
public static boolean gluUnProject(float winx, float winy, float winz,
FloatBuffer modelMatrix,
FloatBuffer modelMatrix,
FloatBuffer projMatrix,
IntBuffer viewport,
FloatBuffer obj_pos)
@ -129,7 +127,7 @@ public class GLU implements GLUConstants {
float width,
float height,
IntBuffer viewport) {
Project.gluPickMatrix(x, y, width, height, viewport);
}
@ -141,11 +139,11 @@ public class GLU implements GLUConstants {
public static String gluGetString(int name) {
return Registry.gluGetString(name);
}
/**
* Method gluCheckExtension.
* @param string
* @param string1
* @param extName
* @param extString
* @return boolean
*/
public static boolean gluCheckExtension(String extName, String extString) {
@ -171,21 +169,21 @@ public class GLU implements GLUConstants {
int format,
int type,
ByteBuffer data) {
return MipMap.gluBuild2DMipmaps(target, components, width, height, format, type, data);
}
/**
* Method gluScaleImage.
* @param format
* @param width
* @param height
* @param type
* @param data
* @param w
* @param h
* @param type1
* @param image
* @param widthIn
* @param heightIn
* @param typeIn
* @param dataIn
* @param widthOut
* @param heightOut
* @param typeOut
* @param dataOut
* @return int
*/
public static int gluScaleImage(
@ -198,7 +196,7 @@ public class GLU implements GLUConstants {
int heightOut,
int typeOut,
ByteBuffer dataOut) {
return MipMap.gluScaleImage(format, widthIn, heightIn, typeIn, dataIn, widthOut, heightOut, typeOut, dataOut);
}

View File

@ -6,8 +6,8 @@ import org.lwjgl.opengl.GL11;
/**
* MipMap.java
*
*
*
*
* Created 11-jan-2004
* @author Erik Duijs
*/
@ -15,7 +15,7 @@ public class MipMap extends Util implements GLUConstants {
/**
* Method gluBuild2DMipmaps
*
*
* @param target
* @param components
* @param width
@ -123,14 +123,14 @@ public class MipMap extends Util implements GLUConstants {
/**
* Method gluScaleImage.
* @param format
* @param width
* @param height
* @param type
* @param data
* @param w
* @param h
* @param type1
* @param image
* @param widthIn
* @param heightIn
* @param typein
* @param dataIn
* @param widthOut
* @param heightOut
* @param typeOut
* @param dataOut
* @return int
*/
public static int gluScaleImage(
@ -149,7 +149,7 @@ public class MipMap extends Util implements GLUConstants {
float sx, sy;
int sizein, sizeout;
int rowstride, rowlen;
components = compPerPix(format);
if (components == -1) {
return GLU_INVALID_ENUM;
@ -253,7 +253,7 @@ public class MipMap extends Util implements GLUConstants {
}
}
// Convert temp output
if (pss.packRowLength > 0) {
rowlen = pss.packRowLength;

View File

@ -4,8 +4,8 @@ import org.lwjgl.opengl.GL11;
/**
* PixelStoreState.java
*
*
*
*
* Created 11-jan-2004
* @author Erik Duijs
*/
@ -19,15 +19,15 @@ class PixelStoreState extends Util implements GLUConstants {
public int packAlignment = glGetIntegerv(GL11.GL_PACK_ALIGNMENT);
public int packSkipRows = glGetIntegerv(GL11.GL_PACK_SKIP_ROWS);
public int packSkipPixels = glGetIntegerv(GL11.GL_PACK_SKIP_PIXELS);
/**
* Constructor for PixelStoreState.
*/
public PixelStoreState() {
PixelStoreState() {
super();
load();
}
public void load() {
unpackRowLength = glGetIntegerv(GL11.GL_UNPACK_ROW_LENGTH);
unpackAlignment = glGetIntegerv(GL11.GL_UNPACK_ALIGNMENT);

View File

@ -7,8 +7,8 @@ import org.lwjgl.opengl.GL11;
/**
* Project.java
*
*
*
*
* Created 11-jan-2004
* @author Erik Duijs
*/
@ -48,7 +48,7 @@ public class Project extends Util implements GLUConstants {
private static void __gluMultMatrixVecf(FloatBuffer finalMatrix, float[] in, float[] out) {
for (int i=0; i<4; i++) {
out[i] =
out[i] =
in[0] * finalMatrix.get(0*4+i) +
in[1] * finalMatrix.get(1*4+i) +
in[2] * finalMatrix.get(2*4+i) +
@ -57,8 +57,8 @@ public class Project extends Util implements GLUConstants {
}
/**
* @param finalMatrix
* @param finalMatrix2
* @param src
* @param inverse
* @return
*/
private static boolean __gluInvertMatrixf(FloatBuffer src, FloatBuffer inverse) {
@ -129,23 +129,23 @@ public class Project extends Util implements GLUConstants {
}
/**
* @param modelMatrix
* @param projMatrix
* @param finalMatrix
* @param a
* @param b
* @param r
*/
private static void __gluMultMatricesf(FloatBuffer a, FloatBuffer b, FloatBuffer r) {
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
r.put(i*4+j,
r.put(i*4+j,
a.get(i*4+0)*b.get(0*4+j) +
a.get(i*4+1)*b.get(1*4+j) +
a.get(i*4+2)*b.get(2*4+j) +
a.get(i*4+3)*b.get(3*4+j));
}
}
}
}
/**
* Method gluPerspective.
* @param fovy
@ -199,7 +199,6 @@ public class Project extends Util implements GLUConstants {
float upy,
float upz) {
int i;
float[] forward = new float[3];
float[] side = new float[3];
float[] up = new float[3];
@ -246,16 +245,14 @@ public class Project extends Util implements GLUConstants {
* @param modelMatrix
* @param projMatrix
* @param viewport
* @param winx
* @param winy
* @param winz
* @param win_pos
* @return
*/
public static boolean gluProject(float objx, float objy, float objz,
FloatBuffer modelMatrix,
public static boolean gluProject(float objx, float objy, float objz,
FloatBuffer modelMatrix,
FloatBuffer projMatrix,
IntBuffer viewport,
FloatBuffer winx, FloatBuffer winy, FloatBuffer winz)
FloatBuffer win_pos)
{
float[] in = new float[4];
float[] out = new float[4];
@ -279,9 +276,12 @@ public class Project extends Util implements GLUConstants {
in[0] = in[0] * viewport.get(2) + viewport.get(0);
in[1] = in[1] * viewport.get(3) + viewport.get(1);
winx.put(0, in[0]);
winy.put(0, in[1]);
winz.put(0, in[2]);
int pos = win_pos.position();
win_pos.put(pos++, in[0]);
win_pos.put(pos++, in[1]);
win_pos.put(pos, in[2]);
return true;
}
@ -293,13 +293,11 @@ public class Project extends Util implements GLUConstants {
* @param modelMatrix
* @param projMatrix
* @param viewport
* @param objx
* @param objy
* @param objz
* @param obj_pos
* @return
*/
public static boolean gluUnProject(float winx, float winy, float winz,
FloatBuffer modelMatrix,
FloatBuffer modelMatrix,
FloatBuffer projMatrix,
IntBuffer viewport,
FloatBuffer obj_pos)
@ -329,9 +327,13 @@ public class Project extends Util implements GLUConstants {
out[0] /= out[3];
out[1] /= out[3];
out[2] /= out[3];
obj_pos.put(0, out[0]);
obj_pos.put(1, out[1]);
obj_pos.put(2, out[2]);
int pos = obj_pos.position();
obj_pos.put(pos++, out[0]);
obj_pos.put(pos++, out[1]);
obj_pos.put(pos, out[2]);
return true;
}

View File

@ -2,8 +2,8 @@ package org.lwjgl.opengl.glu;
/**
* Registry.java
*
*
*
*
* Created 11-jan-2004
* @author Erik Duijs
*/
@ -30,17 +30,15 @@ public class Registry extends Util implements GLUConstants {
/**
* Method gluCheckExtension
*
*
* @param extName is an extension name.
* @param extString is a string of extensions separated by blank(s). There may or
* @param extString is a string of extensions separated by blank(s). There may or
* may not be leading or trailing blank(s) in extString.
* This works in cases of extensions being prefixes of another like
* GL_EXT_texture and GL_EXT_texture3D.
* @return boolean true if extName is found otherwise it returns false.
*/
public static boolean gluCheckExtension(String extName, String extString) {
boolean flag = false;
if (extString == null || extName == null)
return false;

View File

@ -5,8 +5,8 @@ import org.lwjgl.opengl.GL11;
/**
* Sphere.java
*
*
*
*
* Created 23-dec-2003
* @author Erik Duijs
*/
@ -27,7 +27,7 @@ public class Sphere extends Quadric implements GLUConstants {
* 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
@ -44,11 +44,7 @@ public class Sphere extends Quadric implements GLUConstants {
boolean normals;
float nsign;
if (super.normals == GLU_NONE) {
normals = false;
} else {
normals = true;
}
normals = super.normals != GLU_NONE;
if (super.orientation == GLU_INSIDE) {
nsign = -1.0f;
@ -125,7 +121,6 @@ public class Sphere extends Quadric implements GLUConstants {
GL11.glVertex3f(0.0f, 0.0f, -radius * nsign);
rho = PI - drho;
s = 1.0f;
t = dt;
for (j = slices; j >= 0; j--) {
theta = (j == slices) ? 0.0f : j * dtheta;
x = -sin(theta) * sin(rho);
@ -141,7 +136,7 @@ public class Sphere extends Quadric implements GLUConstants {
} else if (
super.drawStyle == GLU_LINE
|| super.drawStyle == GLU_SILHOUETTE) {
// draw stack lines
// draw stack lines
for (i = 1;
i < stacks;
i++) { // stack line at i==stacks-1 was missing here

View File

@ -10,8 +10,8 @@ import org.lwjgl.opengl.GL12;
/**
* Util.java
*
*
*
*
* Created 7-jan-2004
* @author Erik Duijs
*/
@ -60,7 +60,7 @@ public class Util {
result[1] = v1[2] * v2[0] - v1[0] * v2[2];
result[2] = v1[0] * v2[1] - v1[1] * v2[0];
}
/**
* Method compPerPix.
* @param format
@ -93,11 +93,11 @@ public class Util {
/**
* Method nearestPower.
*
* Compute the nearest power of 2 number. This algorithm is a little
*
* Compute the nearest power of 2 number. This algorithm is a little
* strange, but it works quite well.
*
* @param width
*
* @param value
* @return int
*/
protected static int nearestPower(int value) {
@ -115,8 +115,8 @@ public class Util {
} else if (value == 3) {
return i * 4;
}
value = value >> 1;
i *= 2;
value >>= 1;
i <<= 1;
}
}
@ -186,7 +186,7 @@ public class Util {
return n * m;
}
/**
* Create a FloatBuffer of specified size.
* @param size
@ -214,7 +214,7 @@ public class Util {
/**
* Convenience method for returning an int,
* rather than getting it out of a buffer yourself.
*
*
* @param what
* @return int
*/