summaryrefslogtreecommitdiffstats
path: root/src/net
diff options
context:
space:
mode:
Diffstat (limited to 'src/net')
-rw-r--r--src/net/java/joglutils/GLJFrame.java3
-rw-r--r--src/net/java/joglutils/jogltext/FontDrawer.java48
-rw-r--r--src/net/java/joglutils/jogltext/TextRenderer3D.java44
-rw-r--r--src/net/java/joglutils/lighting/Light.java182
-rw-r--r--src/net/java/joglutils/lighting/Material.java60
-rw-r--r--src/net/java/joglutils/model/examples/DisplayListRenderer.java106
-rw-r--r--src/net/java/joglutils/model/examples/ModelTest.java55
-rw-r--r--src/net/java/joglutils/model/loader/WaveFrontLoader.java2
-rw-r--r--src/net/java/joglutils/msg/actions/GLRenderAction.java24
-rw-r--r--src/net/java/joglutils/msg/elements/GLBlendElement.java56
-rw-r--r--src/net/java/joglutils/msg/elements/GLColorElement.java8
-rw-r--r--src/net/java/joglutils/msg/elements/GLCoordinateElement.java8
-rw-r--r--src/net/java/joglutils/msg/elements/GLModelMatrixElement.java8
-rw-r--r--src/net/java/joglutils/msg/elements/GLProjectionMatrixElement.java6
-rw-r--r--src/net/java/joglutils/msg/elements/GLTextureCoordinateElement.java8
-rw-r--r--src/net/java/joglutils/msg/elements/GLTextureElement.java12
-rw-r--r--src/net/java/joglutils/msg/elements/GLViewingMatrixElement.java2
-rw-r--r--src/net/java/joglutils/msg/math/Mat4f.java20
-rw-r--r--src/net/java/joglutils/msg/misc/Shader.java59
-rw-r--r--src/net/java/joglutils/msg/nodes/Texture2.java5
-rw-r--r--src/net/java/joglutils/msg/nodes/TriangleSet.java16
-rw-r--r--src/net/java/joglutils/msg/test/DisplayShelf.java3
-rw-r--r--src/net/java/joglutils/msg/test/DisplayShelfRenderer.java15
-rw-r--r--src/net/java/joglutils/msg/test/Test.java227
-rw-r--r--src/net/java/joglutils/test3ds/Main.java33
-rw-r--r--src/net/java/joglutils/test3ds/MyModel.java13
26 files changed, 517 insertions, 506 deletions
diff --git a/src/net/java/joglutils/GLJFrame.java b/src/net/java/joglutils/GLJFrame.java
index 59a1677..0746d5f 100644
--- a/src/net/java/joglutils/GLJFrame.java
+++ b/src/net/java/joglutils/GLJFrame.java
@@ -37,6 +37,7 @@
package net.java.joglutils;
import javax.media.opengl.*;
+import javax.media.opengl.awt.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
@@ -69,7 +70,7 @@ public class GLJFrame extends JFrame {
public GLJFrame(String title, GLEventListener listener) {
super(title);
this.listener = listener;
- this.caps = new GLCapabilities();
+ this.caps = new GLCapabilities(GLProfile.getDefault());
this.chooser = null; //can be null because that will choose the default
initComponents();
((GLCanvas)mainCanvas).addGLEventListener(listener);
diff --git a/src/net/java/joglutils/jogltext/FontDrawer.java b/src/net/java/joglutils/jogltext/FontDrawer.java
index faaac43..866ab0e 100644
--- a/src/net/java/joglutils/jogltext/FontDrawer.java
+++ b/src/net/java/joglutils/jogltext/FontDrawer.java
@@ -157,7 +157,7 @@ public class FontDrawer {
* @param str the string to render.
* @param gl the OpenGL context in which to render the text.
*/
- public void drawString(String str, GL gl) {
+ public void drawString(String str, GL2 gl) {
drawString(str,new GLU(),gl);
}
@@ -168,7 +168,7 @@ public class FontDrawer {
* @param glu a GLU instance to use for the text rendering (provided to prevent continuous re-instantiation of a GLU object)
* @param gl the OpenGL context in which to render the text.
*/
- public void drawString(String str, GLU glu, GL gl) {
+ public void drawString(String str, GLU glu, GL2 gl) {
GlyphVector gv = font.createGlyphVector(
new FontRenderContext(new AffineTransform(), true, true),
new StringCharacterIterator(str));
@@ -211,7 +211,7 @@ public class FontDrawer {
* @param str the string to render.
* @param gl the OpenGL context in which to render the text.
*/
- public void drawString(String str, GL gl, float xOff, float yOff, float zOff) {
+ public void drawString(String str, GL2 gl, float xOff, float yOff, float zOff) {
drawString(str,new GLU(),gl,xOff,yOff,zOff);
}
@@ -225,9 +225,9 @@ public class FontDrawer {
* @param glu a GLU instance to use for the text rendering (provided to prevent continuous re-instantiation of a GLU object)
* @param gl the OpenGL context in which to render the text.
*/
- public void drawString(String str, GLU glu, GL gl, float xOff, float yOff, float zOff) {
- gl.glPushAttrib(GL.GL_TRANSFORM_BIT);
- gl.glMatrixMode(GL.GL_MODELVIEW);
+ public void drawString(String str, GLU glu, GL2 gl, float xOff, float yOff, float zOff) {
+ gl.glPushAttrib(GL2.GL_TRANSFORM_BIT);
+ gl.glMatrixMode(GL2.GL_MODELVIEW);
gl.glPushMatrix();
gl.glTranslatef(xOff,yOff,zOff);
this.drawString(str,glu,gl);
@@ -235,11 +235,11 @@ public class FontDrawer {
gl.glPopAttrib();
}
- private void tesselateFace(GLU glu, GL gl, PathIterator pi, int windingRule, boolean justBoundary) {
+ private void tesselateFace(GLU glu, GL2 gl, PathIterator pi, int windingRule, boolean justBoundary) {
tesselateFace(glu,gl,pi,windingRule,justBoundary,0);
}
- private void tesselateFace(GLU glu, GL gl, PathIterator pi, int windingRule, boolean justBoundary,double tessZ) {
+ private void tesselateFace(GLU glu, GL2 gl, PathIterator pi, int windingRule, boolean justBoundary,double tessZ) {
GLUtessellatorCallback aCallback = new GLUtesselatorCallbackImpl(gl);
GLUtessellator tess = glu.gluNewTess();
@@ -261,9 +261,9 @@ public class FontDrawer {
}
if (justBoundary) {
- glu.gluTessProperty(tess, GLU.GLU_TESS_BOUNDARY_ONLY, GL.GL_TRUE);
+ glu.gluTessProperty(tess, GLU.GLU_TESS_BOUNDARY_ONLY, GL2.GL_TRUE);
} else {
- glu.gluTessProperty(tess, GLU.GLU_TESS_BOUNDARY_ONLY, GL.GL_FALSE);
+ glu.gluTessProperty(tess, GLU.GLU_TESS_BOUNDARY_ONLY, GL2.GL_FALSE);
}
glu.gluTessBeginPolygon(tess, (double[])null);
@@ -289,19 +289,19 @@ public class FontDrawer {
glu.gluDeleteTess(tess);
}
- private void drawSidesNoNorm(GL gl, PathIterator pi, boolean justBoundary,float tessZ) {
+ private void drawSidesNoNorm(GL2 gl, PathIterator pi, boolean justBoundary,float tessZ) {
//TODO: texture coords
if (justBoundary)
- gl.glPolygonMode(GL.GL_FRONT_AND_BACK,GL.GL_LINE);
+ gl.glPolygonMode(GL2.GL_FRONT_AND_BACK,GL2.GL_LINE);
else
- gl.glPolygonMode(GL.GL_FRONT_AND_BACK,GL.GL_FILL);
+ gl.glPolygonMode(GL2.GL_FRONT_AND_BACK,GL2.GL_FILL);
for(float[] coords = new float[6];!pi.isDone();pi.next()) {
float[] currRender = new float[3];
switch(pi.currentSegment(coords)) {
case PathIterator.SEG_MOVETO:
- gl.glBegin(GL.GL_QUAD_STRIP);
+ gl.glBegin(GL2.GL_QUAD_STRIP);
currRender[0] = coords[0];
currRender[1] = coords[1];
currRender[2] = 0;
@@ -332,20 +332,20 @@ public class FontDrawer {
}
}
- private void drawSidesFlatNorm(GL gl, PathIterator pi, boolean justBoundary,float tessZ) {
+ private void drawSidesFlatNorm(GL2 gl, PathIterator pi, boolean justBoundary,float tessZ) {
//TODO: texture coords
if (justBoundary)
- gl.glPolygonMode(GL.GL_FRONT_AND_BACK,GL.GL_LINE);
+ gl.glPolygonMode(GL2.GL_FRONT_AND_BACK,GL2.GL_LINE);
else
- gl.glPolygonMode(GL.GL_FRONT_AND_BACK,GL.GL_FILL);
+ gl.glPolygonMode(GL2.GL_FRONT_AND_BACK,GL2.GL_FILL);
float[] lastCoord = new float[3];
float[] firstCoord = new float[3];
for(float[] coords = new float[6];!pi.isDone();pi.next()) {
switch(pi.currentSegment(coords)) {
case PathIterator.SEG_MOVETO:
- gl.glBegin(GL.GL_QUADS);
+ gl.glBegin(GL2.GL_QUADS);
lastCoord[0] = coords[0];
lastCoord[1] = coords[1];
firstCoord[0] = coords[0];
@@ -386,15 +386,15 @@ public class FontDrawer {
}
- private void drawSidesAvgNorm(GL gl, PathIterator pi, boolean justBoundary,float tessZ) {
+ private void drawSidesAvgNorm(GL2 gl, PathIterator pi, boolean justBoundary,float tessZ) {
//TODO: improve performance with some form of caching?
//TODO: texture coords
//TODO: check last coord - might not quite be correct?
if (justBoundary)
- gl.glPolygonMode(GL.GL_FRONT_AND_BACK,GL.GL_LINE);
+ gl.glPolygonMode(GL2.GL_FRONT_AND_BACK,GL2.GL_LINE);
else
- gl.glPolygonMode(GL.GL_FRONT_AND_BACK,GL.GL_FILL);
+ gl.glPolygonMode(GL2.GL_FRONT_AND_BACK,GL2.GL_FILL);
float[] firstCoord = null;
@@ -408,7 +408,7 @@ public class FontDrawer {
firstCoord = new float[3];
firstCoord[0] = coords[0];
firstCoord[1] = coords[1];
- gl.glBegin(GL.GL_QUAD_STRIP);
+ gl.glBegin(GL2.GL_QUAD_STRIP);
break;
case PathIterator.SEG_LINETO:
if (secondCoord == null) {
@@ -478,9 +478,9 @@ public class FontDrawer {
}
private class GLUtesselatorCallbackImpl extends javax.media.opengl.glu.GLUtessellatorCallbackAdapter {
- private GL gl;
+ private GL2 gl;
- public GLUtesselatorCallbackImpl(GL gl) {
+ public GLUtesselatorCallbackImpl(GL2 gl) {
this.gl = gl;
}
diff --git a/src/net/java/joglutils/jogltext/TextRenderer3D.java b/src/net/java/joglutils/jogltext/TextRenderer3D.java
index 80f89d8..ec78ba9 100644
--- a/src/net/java/joglutils/jogltext/TextRenderer3D.java
+++ b/src/net/java/joglutils/jogltext/TextRenderer3D.java
@@ -55,10 +55,8 @@ import java.text.StringCharacterIterator;
import java.util.ArrayList;
import java.util.Iterator;
-import javax.media.opengl.GL;
-import javax.media.opengl.glu.GLU;
-import javax.media.opengl.glu.GLUtessellator;
-import javax.media.opengl.glu.GLUtessellatorCallback;
+import javax.media.opengl.*;
+import javax.media.opengl.glu.*;
import javax.vecmath.Vector3f;
/**
@@ -84,7 +82,7 @@ public class TextRenderer3D
private Vector3f normal = new Vector3f();
private GLU glu = new GLU();
- private GL gl = GLU.getCurrentGL();
+ private GL2 gl = GLU.getCurrentGL().getGL2();
private int lastIndex = -1;
private ArrayList<Integer> listIndex = new ArrayList<Integer>();
@@ -225,10 +223,10 @@ public class TextRenderer3D
public void draw( String str, float xOff, float yOff, float zOff, float scaleFactor )
{
- gl.glPushAttrib(GL.GL_TRANSFORM_BIT);
- gl.glMatrixMode(GL.GL_MODELVIEW);
+ gl.glPushAttrib(GL2.GL_TRANSFORM_BIT);
+ gl.glMatrixMode(GL2.GL_MODELVIEW);
gl.glPushMatrix();
- gl.glEnable( GL.GL_NORMALIZE);
+ gl.glEnable( GL2.GL_NORMALIZE);
gl.glScalef(scaleFactor, scaleFactor, scaleFactor);
gl.glTranslatef(xOff, yOff, zOff);
@@ -295,7 +293,7 @@ public class TextRenderer3D
public int compile( String str, float xOff, float yOff, float zOff, float scaleFactor )
{
int index = gl.glGenLists(1);
- gl.glNewList( index, GL.GL_COMPILE);
+ gl.glNewList( index, GL2.GL_COMPILE);
draw( str, xOff, yOff, zOff, scaleFactor);
gl.glEndList();
@@ -312,7 +310,7 @@ public class TextRenderer3D
public int compile( String str )
{
int index = gl.glGenLists(1);
- gl.glNewList( index, GL.GL_COMPILE);
+ gl.glNewList( index, GL2.GL_COMPILE);
draw( str );
gl.glEndList();
@@ -400,8 +398,8 @@ public class TextRenderer3D
*/
public Rectangle2D getBounds( String str, float scaleFactor )
{
- gl.glPushAttrib(GL.GL_TRANSFORM_BIT);
- gl.glMatrixMode(GL.GL_MODELVIEW);
+ gl.glPushAttrib(GL2.GL_TRANSFORM_BIT);
+ gl.glMatrixMode(GL2.GL_MODELVIEW);
gl.glPushMatrix();
gl.glScalef(scaleFactor, scaleFactor, scaleFactor);
@@ -420,12 +418,12 @@ public class TextRenderer3D
// construct the sides of each glyph by walking around and extending each vertex
// out to the depth of the extrusion
- private void drawSides(GL gl, PathIterator pi, boolean justBoundary, float depth)
+ private void drawSides(GL2 gl, PathIterator pi, boolean justBoundary, float depth)
{
if (justBoundary)
- gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_LINE);
+ gl.glPolygonMode(GL2.GL_FRONT_AND_BACK, GL2.GL_LINE);
else
- gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_FILL);
+ gl.glPolygonMode(GL2.GL_FRONT_AND_BACK, GL2.GL_FILL);
float[] lastCoord = new float[3];
float[] firstCoord = new float[3];
@@ -436,7 +434,7 @@ public class TextRenderer3D
switch (pi.currentSegment(coords))
{
case PathIterator.SEG_MOVETO:
- gl.glBegin(GL.GL_QUADS);
+ gl.glBegin(GL2.GL_QUADS);
lastCoord[0] = coords[0];
lastCoord[1] = coords[1];
firstCoord[0] = coords[0];
@@ -487,7 +485,7 @@ public class TextRenderer3D
}
// simple convenience for calculating and setting the normal
- private void setNormal ( GL gl, float x1, float y1, float z1, float x2, float y2, float z2 )
+ private void setNormal ( GL2 gl, float x1, float y1, float z1, float x2, float y2, float z2 )
{
vecA.set( x1, y1, z1);
vecB.set( x2, y2, z2);
@@ -497,7 +495,7 @@ public class TextRenderer3D
}
// routine that tesselates the current set of glyphs
- private void tesselateFace(GLU glu, GL gl, PathIterator pi, boolean justBoundary, double tessZ)
+ private void tesselateFace(GLU glu, GL2 gl, PathIterator pi, boolean justBoundary, double tessZ)
{
GLUtessellatorCallback aCallback = new GLUtesselatorCallbackImpl(gl);
GLUtessellator tess = glu.gluNewTess();
@@ -516,9 +514,9 @@ public class TextRenderer3D
glu.gluTessProperty(tess, GLU.GLU_TESS_WINDING_RULE, GLU.GLU_TESS_WINDING_NONZERO);
if (justBoundary)
- glu.gluTessProperty(tess, GLU.GLU_TESS_BOUNDARY_ONLY, GL.GL_TRUE);
+ glu.gluTessProperty(tess, GLU.GLU_TESS_BOUNDARY_ONLY, GL2.GL_TRUE);
else
- glu.gluTessProperty(tess, GLU.GLU_TESS_BOUNDARY_ONLY, GL.GL_FALSE);
+ glu.gluTessProperty(tess, GLU.GLU_TESS_BOUNDARY_ONLY, GL2.GL_FALSE);
glu.gluTessBeginPolygon(tess, (double[]) null);
@@ -550,9 +548,9 @@ public class TextRenderer3D
// Private class that implements the required callbacks for the tesselator
private class GLUtesselatorCallbackImpl extends javax.media.opengl.glu.GLUtessellatorCallbackAdapter
{
- private GL gl;
+ private GL2 gl;
- public GLUtesselatorCallbackImpl(GL gl)
+ public GLUtesselatorCallbackImpl(GL2 gl)
{
this.gl = gl;
}
@@ -578,7 +576,7 @@ public class TextRenderer3D
//--------------- diagnostic utilities -----------------------------------------
/*
- private void dumpShape(GL gl, GeneralPath path)
+ private void dumpShape(GL2 gl, GeneralPath path)
{
float[] coords = new float[6];
int count = 1;
diff --git a/src/net/java/joglutils/lighting/Light.java b/src/net/java/joglutils/lighting/Light.java
index 65b8690..07b780a 100644
--- a/src/net/java/joglutils/lighting/Light.java
+++ b/src/net/java/joglutils/lighting/Light.java
@@ -57,7 +57,7 @@ public class Light {
static HashMap<GL,Boolean> shaderBuiltin = new HashMap<GL,Boolean>();
static HashMap<GL,Integer> shaderProgNums = new HashMap<GL,Integer>();
- private GL attachedGL;
+ private GL2 attachedGL;
private int lightNumber;
//Light defaults are determined by constructor
@@ -111,7 +111,7 @@ public class Light {
* @param gl the OpenGL context to attach the light to
* @throws net.java.joglutils.lighting.LightingException if the light number is invalid or is already in use by another Light. Light is detached from any OpenGL Context.
*/
- public Light(GL gl) throws LightingException {
+ public Light(GL2 gl) throws LightingException {
this();
this.attachedGL = gl;
@@ -130,7 +130,7 @@ public class Light {
* @param lightNumber the light number to be used (must be on [0,7])
* @throws net.java.joglutils.lighting.LightingException if the light number is invalid or is already in use by another Light. Light is detached from any OpenGL Context.
*/
- public Light(GL gl, int lightNumber) throws LightingException {
+ public Light(GL2 gl, int lightNumber) throws LightingException {
this();
if (lightNumber < 0 || lightNumber > maxNumberOfLightsInGL(gl))
throw new LightingException("Requested light not availible in specified OpenGL context");
@@ -201,7 +201,7 @@ public class Light {
* @param gl the OpenGL context to attach this to
* @throws net.java.joglutils.lighting.LightingException if the specified context has no free lights. Light is detached from any OpenGL Context.
*/
- public void setAttachedGL(GL gl) throws LightingException {
+ public void setAttachedGL(GL2 gl) throws LightingException {
this.unassignLightNumber(this.attachedGL,this.lightNumber);
if(!this.hasFreeLights(gl)) {
this.attachedGL = null;
@@ -275,7 +275,7 @@ public class Light {
* @param gl the OpenGL context to use.
* @throws net.java.joglutils.lighting.LightingException if the light number stored in this Light is invalid on the specified context.
*/
- public void apply(GL gl) throws LightingException {
+ public void apply(GL2 gl) throws LightingException {
apply(gl,this.lightNumber);
}
/**
@@ -284,7 +284,7 @@ public class Light {
* @param gl the OpenGL context to use.
* @throws net.java.joglutils.lighting.LightingException if the light number stored in this Light is invalid on the specified context.
*/
- public void retrieve(GL gl) throws LightingException {
+ public void retrieve(GL2 gl) throws LightingException {
retrieve(gl,this.lightNumber);
}
@@ -293,7 +293,7 @@ public class Light {
* @param gl the OpenGL context to use.
* @throws net.java.joglutils.lighting.LightingException if the light number stored in this Light is invalid on the specified context.
*/
- public void enable(GL gl) throws LightingException {
+ public void enable(GL2 gl) throws LightingException {
enable(gl,this.lightNumber);
}
/**
@@ -301,7 +301,7 @@ public class Light {
* @param gl the OpenGL context to use.
* @throws net.java.joglutils.lighting.LightingException if the light number stored in this Light is invalid on the specified context.
*/
- public void disable(GL gl) throws LightingException {
+ public void disable(GL2 gl) throws LightingException {
disable(gl,this.lightNumber);
}
/**
@@ -311,30 +311,30 @@ public class Light {
* @param lightNumber the number of the light to use (should be on [0,7]).
* @throws net.java.joglutils.lighting.LightingException if the requested light is not valid on the specified context.
*/
- public void apply(GL gl, int lightNumber) throws LightingException {
+ public void apply(GL2 gl, int lightNumber) throws LightingException {
if(!this.isLightNumberValid(gl, lightNumber))
throw new LightingException("attempted to apply Light settings to invalid lightNumber for the requested OpenGL context");
int lightID = numToID(lightNumber);
//set color components
- gl.glLightfv(lightID,GL.GL_AMBIENT,ambient,0);
- gl.glLightfv(lightID,GL.GL_DIFFUSE,diffuse,0);
- gl.glLightfv(lightID,GL.GL_SPECULAR,specular,0);
+ gl.glLightfv(lightID,GL2.GL_AMBIENT,ambient,0);
+ gl.glLightfv(lightID,GL2.GL_DIFFUSE,diffuse,0);
+ gl.glLightfv(lightID,GL2.GL_SPECULAR,specular,0);
//OpenGL position information is contanied in Light lightPosition and light distance
float[] position = new float[4];
position[0] = lightPosition[0];
position[1] = lightPosition[1];
position[2] = lightPosition[2];
position[3] = lightW;
- gl.glLightfv(lightID,GL.GL_POSITION,position,0);
+ gl.glLightfv(lightID,GL2.GL_POSITION,position,0);
//set other parameters
- gl.glLightfv(lightID,GL.GL_SPOT_DIRECTION,spotDirection,0);
- gl.glLightf(lightID,GL.GL_SPOT_CUTOFF,spotCutoff);
- gl.glLightf(lightID,GL.GL_SPOT_EXPONENT,spotExponent);
- gl.glLightf(lightID,GL.GL_CONSTANT_ATTENUATION,constantAttenuation);
- gl.glLightf(lightID,GL.GL_LINEAR_ATTENUATION,linearAttenuation);
- gl.glLightf(lightID,GL.GL_QUADRATIC_ATTENUATION,quadraticAttenuation);
+ gl.glLightfv(lightID,GL2.GL_SPOT_DIRECTION,spotDirection,0);
+ gl.glLightf(lightID,GL2.GL_SPOT_CUTOFF,spotCutoff);
+ gl.glLightf(lightID,GL2.GL_SPOT_EXPONENT,spotExponent);
+ gl.glLightf(lightID,GL2.GL_CONSTANT_ATTENUATION,constantAttenuation);
+ gl.glLightf(lightID,GL2.GL_LINEAR_ATTENUATION,linearAttenuation);
+ gl.glLightf(lightID,GL2.GL_QUADRATIC_ATTENUATION,quadraticAttenuation);
this.lightNumber = lightNumber;
}
@@ -345,7 +345,7 @@ public class Light {
* @param lightNumber the number of the light to use (should be on [0,7]).
* @throws net.java.joglutils.lighting.LightingException if the requested light is not valid on the specified context.
*/
- public void retrieve(GL gl, int lightNumber) throws LightingException{
+ public void retrieve(GL2 gl, int lightNumber) throws LightingException{
if(!this.isLightNumberValid(gl, lightNumber))
throw new LightingException("attempted to retrieve Light settings to invalid lightNumber for the requested OpenGL context");
@@ -353,29 +353,29 @@ public class Light {
FloatBuffer buff = FloatBuffer.allocate(24);
//get color components - 4 each
- gl.glGetLightfv(lightID,GL.GL_AMBIENT,buff);
+ gl.glGetLightfv(lightID,GL2.GL_AMBIENT,buff);
buff.get(this.ambient);
- gl.glGetLightfv(lightID,GL.GL_DIFFUSE,buff);
+ gl.glGetLightfv(lightID,GL2.GL_DIFFUSE,buff);
buff.get(this.diffuse);
- gl.glGetLightfv(lightID,GL.GL_SPECULAR,buff);
+ gl.glGetLightfv(lightID,GL2.GL_SPECULAR,buff);
buff.get(this.specular);
//get light position - 4 (including distance)
- gl.glGetLightfv(lightID,GL.GL_POSITION,buff);
+ gl.glGetLightfv(lightID,GL2.GL_POSITION,buff);
buff.get(this.lightPosition);
this.lightW = buff.get();
//get spot direction- 3
- gl.glGetLightfv(lightID,GL.GL_SPOT_DIRECTION,buff);
+ gl.glGetLightfv(lightID,GL2.GL_SPOT_DIRECTION,buff);
buff.get(this.spotDirection);
//get individual floats - 1 each
- gl.glGetLightfv(lightID,GL.GL_SPOT_CUTOFF,buff);
+ gl.glGetLightfv(lightID,GL2.GL_SPOT_CUTOFF,buff);
this.spotCutoff = buff.get();
- gl.glGetLightfv(lightID,GL.GL_SPOT_EXPONENT,buff);
+ gl.glGetLightfv(lightID,GL2.GL_SPOT_EXPONENT,buff);
this.spotExponent = buff.get();
- gl.glGetLightfv(lightID,GL.GL_CONSTANT_ATTENUATION,buff);
+ gl.glGetLightfv(lightID,GL2.GL_CONSTANT_ATTENUATION,buff);
this.constantAttenuation = buff.get();
- gl.glGetLightfv(lightID,GL.GL_LINEAR_ATTENUATION,buff);
+ gl.glGetLightfv(lightID,GL2.GL_LINEAR_ATTENUATION,buff);
this.linearAttenuation = buff.get();
- gl.glGetLightfv(lightID,GL.GL_QUADRATIC_ATTENUATION,buff);
+ gl.glGetLightfv(lightID,GL2.GL_QUADRATIC_ATTENUATION,buff);
this.quadraticAttenuation = buff.get();
this.lightNumber = lightNumber;
@@ -386,7 +386,7 @@ public class Light {
* @param lightNumber the number of the light to use (should be on [0,7]).
* @throws net.java.joglutils.lighting.LightingException if the requested light is not valid on the specified context.
*/
- public void enable(GL gl, int lightNumber) throws LightingException {
+ public void enable(GL2 gl, int lightNumber) throws LightingException {
if(!this.isLightNumberValid(gl, lightNumber))
throw new LightingException("attempted to enable Light on with an invalid lightNumber for the requested OpenGL context");
gl.glEnable(numToID(lightNumber));
@@ -440,7 +440,7 @@ public class Light {
if (result != null) {
int lightID = result+lightNumber;
java.nio.IntBuffer buffer = java.nio.IntBuffer.allocate(1);
- gl.glGetIntegerv(GL.GL_CURRENT_PROGRAM,buffer);
+ gl.glGetIntegerv(GL2.GL_CURRENT_PROGRAM,buffer);
int currProgram = buffer.get();
if (currProgram == lightID)
@@ -455,7 +455,7 @@ public class Light {
* @param lightNumber the number of the light to use (should be on [0,7]).
* @throws net.java.joglutils.lighting.LightingException if the requested light is not valid on the specified context.
*/
- public void disable(GL gl, int lightNumber) throws LightingException {
+ public void disable(GL2 gl, int lightNumber) throws LightingException {
if(!this.isLightNumberValid(gl, lightNumber))
throw new LightingException("attempted to disable Light on with an invalid lightNumber for the requested OpenGL context");
gl.glDisable(numToID(lightNumber));
@@ -479,7 +479,7 @@ public class Light {
public void setAmbient(Color ambient) {
this.ambient = ambient.getRGBComponents(null);
if (this.attachedGL != null)
- this.attachedGL.glLightfv(numToID(lightNumber),GL.GL_AMBIENT,this.ambient,0);
+ this.attachedGL.glLightfv(numToID(lightNumber),GL2.GL_AMBIENT,this.ambient,0);
}
/**
@@ -497,7 +497,7 @@ public class Light {
public void setDiffuse(Color diffuse) {
this.diffuse = diffuse.getRGBComponents(null);
if (this.attachedGL != null)
- this.attachedGL.glLightfv(numToID(lightNumber),GL.GL_DIFFUSE,this.diffuse,0);
+ this.attachedGL.glLightfv(numToID(lightNumber),GL2.GL_DIFFUSE,this.diffuse,0);
}
@@ -516,7 +516,7 @@ public class Light {
public void setSpecular(Color specular) {
this.specular = specular.getRGBComponents(null);
if (this.attachedGL != null)
- this.attachedGL.glLightfv(numToID(lightNumber),GL.GL_SPECULAR,this.specular,0);
+ this.attachedGL.glLightfv(numToID(lightNumber),GL2.GL_SPECULAR,this.specular,0);
}
/**
@@ -540,7 +540,7 @@ public class Light {
position[1] = lightPosition[1];
position[2] = lightPosition[2];
position[3] = this.lightW;
- this.attachedGL.glLightfv(numToID(lightNumber),GL.GL_POSITION,position,0);
+ this.attachedGL.glLightfv(numToID(lightNumber),GL2.GL_POSITION,position,0);
}
this.lightPosition = lightPosition.clone();
}
@@ -572,7 +572,7 @@ public class Light {
*/
public void setSpotDirection(float[] spotDirection) {
if (this.attachedGL != null)
- this.attachedGL.glLightfv(numToID(lightNumber),GL.GL_SPOT_DIRECTION,spotDirection,0);
+ this.attachedGL.glLightfv(numToID(lightNumber),GL2.GL_SPOT_DIRECTION,spotDirection,0);
this.spotDirection = spotDirection.clone();
}
@@ -608,7 +608,7 @@ public class Light {
position[1] = this.lightPosition[1];
position[2] = this.lightPosition[2];
position[3] = lightW;
- this.attachedGL.glLightfv(numToID(lightNumber),GL.GL_POSITION,position,0);
+ this.attachedGL.glLightfv(numToID(lightNumber),GL2.GL_POSITION,position,0);
}
this.lightW = lightW;
}
@@ -633,7 +633,7 @@ public class Light {
*/
public void setSpotCutoff(float spotCutoff) {
if (this.attachedGL != null)
- this.attachedGL.glLightf(numToID(lightNumber),GL.GL_SPOT_CUTOFF,spotCutoff);
+ this.attachedGL.glLightf(numToID(lightNumber),GL2.GL_SPOT_CUTOFF,spotCutoff);
this.spotCutoff = spotCutoff;
}
@@ -651,7 +651,7 @@ public class Light {
*/
public void setSpotExponent(float spotExponent) {
if (this.attachedGL != null)
- this.attachedGL.glLightf(numToID(lightNumber),GL.GL_SPOT_EXPONENT,spotExponent);
+ this.attachedGL.glLightf(numToID(lightNumber),GL2.GL_SPOT_EXPONENT,spotExponent);
this.spotExponent = spotExponent;
}
@@ -670,7 +670,7 @@ public class Light {
*/
public void setConstantAttenuation(float constantAttenuation) {
if (this.attachedGL != null)
- this.attachedGL.glLightf(numToID(lightNumber),GL.GL_CONSTANT_ATTENUATION,constantAttenuation);
+ this.attachedGL.glLightf(numToID(lightNumber),GL2.GL_CONSTANT_ATTENUATION,constantAttenuation);
this.constantAttenuation = constantAttenuation;
}
@@ -689,7 +689,7 @@ public class Light {
*/
public void setLinearAttenuation(float linearAttenuation) {
if (this.attachedGL != null)
- this.attachedGL.glLightf(numToID(lightNumber),GL.GL_LINEAR_ATTENUATION,linearAttenuation);
+ this.attachedGL.glLightf(numToID(lightNumber),GL2.GL_LINEAR_ATTENUATION,linearAttenuation);
this.linearAttenuation = linearAttenuation;
}
@@ -708,7 +708,7 @@ public class Light {
*/
public void setQuadraticAttenuation(float quadraticAttenuation) {
if (this.attachedGL != null)
- this.attachedGL.glLightf(numToID(lightNumber),GL.GL_QUADRATIC_ATTENUATION,quadraticAttenuation);
+ this.attachedGL.glLightf(numToID(lightNumber),GL2.GL_QUADRATIC_ATTENUATION,quadraticAttenuation);
this.quadraticAttenuation = quadraticAttenuation;
}
@@ -728,7 +728,7 @@ public class Light {
* @param gl the OpenGL context to test
* @return the maximum number of lights (highest possible in OpenGL is 8)
*/
- public static int maxNumberOfLightsInGL(GL gl) {
+ public static int maxNumberOfLightsInGL(GL2 gl) {
java.nio.IntBuffer buff = java.nio.IntBuffer.allocate(1);
gl.glGetIntegerv(gl.GL_MAX_LIGHTS,buff);
return buff.get();
@@ -743,28 +743,28 @@ public class Light {
public static int idToNum(int lightID) throws LightingException {
int retNum = -1;
switch (lightID) {
- case GL.GL_LIGHT0:
+ case GL2.GL_LIGHT0:
retNum = 0;
break;
- case GL.GL_LIGHT1:
+ case GL2.GL_LIGHT1:
retNum = 1;
break;
- case GL.GL_LIGHT2:
+ case GL2.GL_LIGHT2:
retNum = 2;
break;
- case GL.GL_LIGHT3:
+ case GL2.GL_LIGHT3:
retNum = 3;
break;
- case GL.GL_LIGHT4:
+ case GL2.GL_LIGHT4:
retNum = 4;
break;
- case GL.GL_LIGHT5:
+ case GL2.GL_LIGHT5:
retNum = 5;
break;
- case GL.GL_LIGHT6:
+ case GL2.GL_LIGHT6:
retNum = 6;
break;
- case GL.GL_LIGHT7:
+ case GL2.GL_LIGHT7:
retNum = 7;
break;
default:
@@ -784,28 +784,28 @@ public class Light {
int retID = -1;
switch (lightNum) {
case 0:
- retID = GL.GL_LIGHT0;
+ retID = GL2.GL_LIGHT0;
break;
case 1:
- retID = GL.GL_LIGHT1;
+ retID = GL2.GL_LIGHT1;
break;
case 2:
- retID = GL.GL_LIGHT2;
+ retID = GL2.GL_LIGHT2;
break;
case 3:
- retID = GL.GL_LIGHT3;
+ retID = GL2.GL_LIGHT3;
break;
case 4:
- retID = GL.GL_LIGHT4;
+ retID = GL2.GL_LIGHT4;
break;
case 5:
- retID = GL.GL_LIGHT5;
+ retID = GL2.GL_LIGHT5;
break;
case 6:
- retID = GL.GL_LIGHT6;
+ retID = GL2.GL_LIGHT6;
break;
case 7:
- retID = GL.GL_LIGHT7;
+ retID = GL2.GL_LIGHT7;
break;
default:
throw new LightingException("tried to determine ID of a number not on [0,7]");
@@ -818,7 +818,7 @@ public class Light {
* @param gl the openGL context to test
* @return true if another Light object can be attached to this GL context
*/
- public static boolean hasFreeLights(GL gl) {
+ public static boolean hasFreeLights(GL2 gl) {
boolean[] lights = assignedLights.get(gl);
if (lights == null)
return true;
@@ -881,7 +881,7 @@ public class Light {
* @throws net.java.joglutils.lighting.LightingException if the OpenGL context does not support GLSL shaders or the shader did not sucessfully compile and link
*/
public static void initializePhongShader() throws LightingException {
- initializePhongShader(javax.media.opengl.glu.GLU.getCurrentGL());
+ initializePhongShader(javax.media.opengl.glu.GLU.getCurrentGL().getGL2());
}
/**
@@ -889,7 +889,7 @@ public class Light {
* @param gl the openGL context on which to initialize the shader
* @throws net.java.joglutils.lighting.LightingException if the OpenGL context does not support GLSL shaders or the shader did not sucessfully compile and link
*/
- public static void initializePhongShader(GL gl) throws LightingException {
+ public static void initializePhongShader(GL2 gl) throws LightingException {
/* Old way that only works for light zero
//program source
final String[] fragSource = {
@@ -943,8 +943,8 @@ public class Light {
if(builtin) {
progID = gl.glCreateProgram();
- int vertID = gl.glCreateShader(GL.GL_VERTEX_SHADER);
- int fragID = gl.glCreateShader(GL.GL_FRAGMENT_SHADER);
+ int vertID = gl.glCreateShader(GL2.GL_VERTEX_SHADER);
+ int fragID = gl.glCreateShader(GL2.GL_FRAGMENT_SHADER);
gl.glShaderSource(vertID,vertSource.length,vertSource,vertLengths,0);
gl.glShaderSource(fragID,fragSource.length,fragSource,fragLengths,0);
@@ -958,9 +958,9 @@ public class Light {
gl.glLinkProgram(progID);
int[] getProgArray = new int[1];
- gl.glGetProgramiv(progID,GL.GL_LINK_STATUS,getProgArray,0);
- if (getProgArray[0] == GL.GL_FALSE) {
- gl.glGetProgramiv(progID,GL.GL_INFO_LOG_LENGTH,getProgArray,0);
+ gl.glGetProgramiv(progID,GL2.GL_LINK_STATUS,getProgArray,0);
+ if (getProgArray[0] == GL2.GL_FALSE) {
+ gl.glGetProgramiv(progID,GL2.GL_INFO_LOG_LENGTH,getProgArray,0);
int logLength = getProgArray[0];
byte[] logArray = new byte[logLength];
gl.glGetProgramInfoLog(progID,logLength,getProgArray,0,logArray,0);
@@ -970,8 +970,8 @@ public class Light {
} else {
progID = gl.glCreateProgramObjectARB();
- int vertID = gl.glCreateShaderObjectARB(GL.GL_VERTEX_SHADER_ARB);
- int fragID = gl.glCreateShaderObjectARB(GL.GL_FRAGMENT_SHADER_ARB);
+ int vertID = gl.glCreateShaderObjectARB(GL2.GL_VERTEX_SHADER_ARB);
+ int fragID = gl.glCreateShaderObjectARB(GL2.GL_FRAGMENT_SHADER_ARB);
gl.glShaderSourceARB(vertID,vertSource.length,vertSource,vertLengths,0);
gl.glShaderSourceARB(fragID,fragSource.length,fragSource,fragLengths,0);
@@ -985,9 +985,9 @@ public class Light {
gl.glLinkProgramARB(progID);
int[] getProgArray = new int[1];
- gl.glGetObjectParameterivARB(progID,GL.GL_OBJECT_LINK_STATUS_ARB,getProgArray,0);
- if (getProgArray[0] == GL.GL_FALSE) {
- gl.glGetObjectParameterivARB(progID,GL.GL_OBJECT_INFO_LOG_LENGTH_ARB,getProgArray,0);
+ gl.glGetObjectParameterivARB(progID,GL2.GL_OBJECT_LINK_STATUS_ARB,getProgArray,0);
+ if (getProgArray[0] == GL2.GL_FALSE) {
+ gl.glGetObjectParameterivARB(progID,GL2.GL_OBJECT_INFO_LOG_LENGTH_ARB,getProgArray,0);
int logLength = getProgArray[0];
byte[] logArray = new byte[logLength];
gl.glGetInfoLogARB(progID,logLength,getProgArray,0,logArray,0);
@@ -1016,7 +1016,7 @@ public class Light {
throw new LightingException("Couldn't generate shader programs in numerical order - can't use Phong Shading");
}
- int vertID = gl.glCreateShader(GL.GL_VERTEX_SHADER);
+ int vertID = gl.glCreateShader(GL2.GL_VERTEX_SHADER);
String[] vertSource = generatePhongVertexShaderSource();
gl.glShaderSource(vertID,vertSource.length,vertSource,generateShaderLengths(vertSource),0);
@@ -1024,7 +1024,7 @@ public class Light {
//generate program for each light and compile and link
for (int currID = progID;currID < (8+progID);++currID) {
- int fragID = gl.glCreateShader(GL.GL_FRAGMENT_SHADER);
+ int fragID = gl.glCreateShader(GL2.GL_FRAGMENT_SHADER);
String[] fragSource = generatePhongFragmentShaderSource(currID-progID);
gl.glShaderSource(fragID,fragSource.length,fragSource,generateShaderLengths(fragSource),0);
@@ -1037,9 +1037,9 @@ public class Light {
gl.glLinkProgram(currID);
int[] getProgArray = new int[1];
- gl.glGetProgramiv(currID,GL.GL_LINK_STATUS,getProgArray,0);
- if (getProgArray[0] == GL.GL_FALSE) {
- gl.glGetProgramiv(currID,GL.GL_INFO_LOG_LENGTH,getProgArray,0);
+ gl.glGetProgramiv(currID,GL2.GL_LINK_STATUS,getProgArray,0);
+ if (getProgArray[0] == GL2.GL_FALSE) {
+ gl.glGetProgramiv(currID,GL2.GL_INFO_LOG_LENGTH,getProgArray,0);
int logLength = getProgArray[0];
byte[] logArray = new byte[logLength];
gl.glGetProgramInfoLog(currID,logLength,getProgArray,0,logArray,0);
@@ -1056,7 +1056,7 @@ public class Light {
throw new LightingException("Couldn't generate shader programs in numerical order - can't use Phong Shading");
}
- int vertID = gl.glCreateShaderObjectARB(GL.GL_VERTEX_SHADER_ARB);
+ int vertID = gl.glCreateShaderObjectARB(GL2.GL_VERTEX_SHADER);
String[] vertSource = generatePhongVertexShaderSource();
gl.glShaderSourceARB(vertID,vertSource.length,vertSource,generateShaderLengths(vertSource),0);
@@ -1064,7 +1064,7 @@ public class Light {
//generate program for each light and compile and link
for (int currID = progID;currID < (8+progID);++currID) {
- int fragID = gl.glCreateShaderObjectARB(GL.GL_FRAGMENT_SHADER_ARB);
+ int fragID = gl.glCreateShaderObjectARB(GL2.GL_FRAGMENT_SHADER);
String[] fragSource = generatePhongFragmentShaderSource(currID-progID);
gl.glShaderSourceARB(fragID,fragSource.length,fragSource,generateShaderLengths(fragSource),0);
@@ -1077,9 +1077,9 @@ public class Light {
gl.glLinkProgramARB(currID);
int[] getProgArray = new int[1];
- gl.glGetObjectParameterivARB(currID,GL.GL_OBJECT_LINK_STATUS_ARB,getProgArray,0);
- if (getProgArray[0] == GL.GL_FALSE) {
- gl.glGetObjectParameterivARB(currID,GL.GL_OBJECT_INFO_LOG_LENGTH_ARB,getProgArray,0);
+ gl.glGetObjectParameterivARB(currID,GL2.GL_OBJECT_LINK_STATUS_ARB,getProgArray,0);
+ if (getProgArray[0] == GL2.GL_FALSE) {
+ gl.glGetObjectParameterivARB(currID,GL2.GL_OBJECT_INFO_LOG_LENGTH_ARB,getProgArray,0);
int logLength = getProgArray[0];
byte[] logArray = new byte[logLength];
gl.glGetInfoLogARB(currID,logLength,getProgArray,0,logArray,0);
@@ -1100,7 +1100,7 @@ public class Light {
**/
public static void removePhongShader() throws LightingException {
- removePhongShader(javax.media.opengl.glu.GLU.getCurrentGL());
+ removePhongShader(javax.media.opengl.glu.GLU.getCurrentGL().getGL2());
}
/**
@@ -1109,7 +1109,7 @@ public class Light {
* @param gl the OpenGL context to remove the Phong shader program from
* @throws net.java.joglutils.lighting.LightingException if there is no Phong Shader initialized on this context
*/
- public static void removePhongShader(GL gl) throws LightingException {
+ public static void removePhongShader(GL2 gl) throws LightingException {
if (shaderBuiltin.containsKey(gl)) {
int progID = shaderProgNums.remove(gl);
if(shaderBuiltin.remove(gl)) {
@@ -1144,10 +1144,10 @@ public class Light {
}
//----------- Private internal functions/methods below this point------------
- private static boolean isLightNumberValid(GL gl ,int lightNumber) {
+ private static boolean isLightNumberValid(GL2 gl ,int lightNumber) {
return (lightNumber > -1 && lightNumber < maxNumberOfLightsInGL(gl));
}
- private static boolean isLightNumberFree(GL gl, int lightNumber) {
+ private static boolean isLightNumberFree(GL2 gl, int lightNumber) {
boolean[] lights = assignedLights.get(gl);
if (lights == null)
return true;
@@ -1157,7 +1157,7 @@ public class Light {
}
- private static int findAndAssignFreeLightNumber(GL gl) {
+ private static int findAndAssignFreeLightNumber(GL2 gl) {
boolean[] lights = assignedLights.get(gl);
if (lights == null) {
lights = new boolean[maxNumberOfLightsInGL(gl)];
@@ -1179,7 +1179,7 @@ public class Light {
return -1;
}
- private static void assignLightNumber(GL gl, int lightNumber) {
+ private static void assignLightNumber(GL2 gl, int lightNumber) {
//No range checking
boolean[] lights = assignedLights.get(gl);
if (lights == null) {
@@ -1191,7 +1191,7 @@ public class Light {
assignedLights.put(gl,lights);
}
- private static void unassignLightNumber(GL gl, int lightNumber) {
+ private static void unassignLightNumber(GL2 gl, int lightNumber) {
//No range checking
boolean[] lights = assignedLights.get(gl);
lights[lightNumber] = false;
diff --git a/src/net/java/joglutils/lighting/Material.java b/src/net/java/joglutils/lighting/Material.java
index a709423..f8500b4 100644
--- a/src/net/java/joglutils/lighting/Material.java
+++ b/src/net/java/joglutils/lighting/Material.java
@@ -52,7 +52,7 @@ import java.nio.*;
* @author Erik J. Tollerud
*/
public class Material {
- GL attachedGL;
+ GL2 attachedGL;
private int face;
private float[] ambient;
@@ -65,7 +65,7 @@ public class Material {
/** Creates a new instance of Material from the OpenGL default material settings */
public Material() {
attachedGL = null;
- face = GL.GL_FRONT_AND_BACK;
+ face = GL2.GL_FRONT_AND_BACK;
float[] localAmb = {0.2f,0.2f,0.2f,1.0f};
ambient = localAmb;
float[] localDiff = {0.8f,0.8f,0.8f,1.0f};
@@ -82,7 +82,7 @@ public class Material {
* @param gl the OpenGL context to attach
* @param face the face to use for configuring the material
*/
- public Material(GL gl, int face) {
+ public Material(GL2 gl, int face) {
this.attachedGL = gl;
this.face = face;
this.specular = new float[4];
@@ -95,14 +95,14 @@ public class Material {
* Creates a new instance of material, with the specified GL context attached. Settings are applied to front and back.
* @param gl the OpenGL context to attach
*/
- public Material(GL gl) {
- this(gl,GL.GL_FRONT_AND_BACK);
+ public Material(GL2 gl) {
+ this(gl,GL2.GL_FRONT_AND_BACK);
}
/**
* Attached the specified OpenGL context to this object
* @param gl the OpenGL context to attach this to
*/
- public void setAttachedGL(GL gl) {
+ public void setAttachedGL(GL2 gl) {
this.attachedGL = gl;
}
/**
@@ -132,21 +132,21 @@ public class Material {
* Sets the OpenGL State in the supplied context based on the settings in this Material.
* @param gl the OpenGL Context upon which to apply the settings from this Material.
*/
- public void apply(GL gl) {
- gl.glMaterialfv(face,GL.GL_SPECULAR,specular,0);
- gl.glMaterialfv(face,GL.GL_EMISSION,emissive,0);
- gl.glMaterialfv(face,GL.GL_AMBIENT,ambient,0);
- gl.glMaterialfv(face,GL.GL_DIFFUSE,diffuse,0);
- gl.glMaterialf(face,GL.GL_SHININESS,shininess);
+ public void apply(GL2 gl) {
+ gl.glMaterialfv(face,GL2.GL_SPECULAR,specular,0);
+ gl.glMaterialfv(face,GL2.GL_EMISSION,emissive,0);
+ gl.glMaterialfv(face,GL2.GL_AMBIENT,ambient,0);
+ gl.glMaterialfv(face,GL2.GL_DIFFUSE,diffuse,0);
+ gl.glMaterialf(face,GL2.GL_SHININESS,shininess);
}
/**
* Sets the settings in this Material from the specified OpenGL context's state.
* @param gl the OpenGL Context to use in setting this Material's settings.
*/
- public void retrieve(GL gl) {
+ public void retrieve(GL2 gl) {
int retrievalFace = face;
- if (face == GL.GL_FRONT_AND_BACK)
- retrievalFace = GL.GL_FRONT;
+ if (face == GL2.GL_FRONT_AND_BACK)
+ retrievalFace = GL2.GL_FRONT;
FloatBuffer buff = FloatBuffer.allocate(17);
@@ -182,23 +182,23 @@ public class Material {
/**
* Specifies the face for subsequent apply method calls to apply and retrieve the material settings. If
* GL_FRONT_AND_BACK, will retrieve from GL_FRONT.
- * @param face the face to apply material settings upon. Must be GL.GL_FRONT_AND_BACK, GL.GL_FRONT, or GL.GL_BACK
+ * @param face the face to apply material settings upon. Must be GL2.GL_FRONT_AND_BACK, GL2.GL_FRONT, or GL2.GL_BACK
* @throws sddm.lighting.LightingException if an invalid input is provided
*/
public void setFace(int face) throws LightingException {
- if(face==GL.GL_FRONT_AND_BACK)
- this.face = GL.GL_FRONT_AND_BACK;
- else if(face == GL.GL_FRONT)
- this.face = GL.GL_FRONT;
- else if(face == GL.GL_BACK)
- this.face = GL.GL_BACK;
+ if(face==GL2.GL_FRONT_AND_BACK)
+ this.face = GL2.GL_FRONT_AND_BACK;
+ else if(face == GL2.GL_FRONT)
+ this.face = GL2.GL_FRONT;
+ else if(face == GL2.GL_BACK)
+ this.face = GL2.GL_BACK;
else
throw new LightingException("Attempted to set face to an invalid value");
}
/**
* Determines what face the material settings are applied to or retrieved from.
- * @return the face used - can be GL.GL_FRONT_AND_BACK, GL.GL_FRONT, or GL.GL_BACK
+ * @return the face used - can be GL2.GL_FRONT_AND_BACK, GL2.GL_FRONT, or GL2.GL_BACK
*/
public int getFace() {
return face;
@@ -210,7 +210,7 @@ public class Material {
*/
public void setSpecular(Color specular) {
if (this.attachedGL != null)
- attachedGL.glMaterialfv(face,GL.GL_SPECULAR,specular.getRGBComponents(null),0);
+ attachedGL.glMaterialfv(face,GL2.GL_SPECULAR,specular.getRGBComponents(null),0);
this.specular = specular.getRGBComponents(null);
}
@@ -228,7 +228,7 @@ public class Material {
*/
public void setShininess(float shininess) {
if (this.attachedGL != null)
- attachedGL.glMaterialf(face,GL.GL_SHININESS,shininess);
+ attachedGL.glMaterialf(face,GL2.GL_SHININESS,shininess);
this.shininess = shininess;
}
@@ -246,7 +246,7 @@ public class Material {
*/
public void setEmissive(Color emissive) {
if (this.attachedGL != null)
- attachedGL.glMaterialfv(face,GL.GL_EMISSION,emissive.getRGBComponents(null),0);
+ attachedGL.glMaterialfv(face,GL2.GL_EMISSION,emissive.getRGBComponents(null),0);
this.emissive = emissive.getRGBComponents(null);
}
@@ -264,7 +264,7 @@ public class Material {
*/
public void setAmbient(Color ambient) {
if (this.attachedGL != null)
- attachedGL.glMaterialfv(face,GL.GL_AMBIENT,ambient.getRGBComponents(null),0);
+ attachedGL.glMaterialfv(face,GL2.GL_AMBIENT,ambient.getRGBComponents(null),0);
this.ambient = ambient.getRGBComponents(null);
}
@@ -282,7 +282,7 @@ public class Material {
*/
public void setDiffuse(Color diffuse) {
if (this.attachedGL != null)
- attachedGL.glMaterialfv(face,GL.GL_DIFFUSE,diffuse.getRGBComponents(null),0);
+ attachedGL.glMaterialfv(face,GL2.GL_DIFFUSE,diffuse.getRGBComponents(null),0);
this.diffuse = diffuse.getRGBComponents(null);
}
@@ -319,7 +319,7 @@ public class Material {
* @param gl the OpenGL context to apply this color to.
* @param ambient the ambient color to be applied.
*/
- public static void applyGlobalAmbient(GL gl, Color ambient) {
+ public static void applyGlobalAmbient(GL2 gl, Color ambient) {
gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT,ambient.getRGBComponents(null),0);
}
/**
@@ -327,7 +327,7 @@ public class Material {
* @param gl the OpenGL Context from which to get the color.
* @return the ambient color in the specified OpenGL Context.
*/
- public static Color getGlobalAmbient(GL gl) {
+ public static Color getGlobalAmbient(GL2 gl) {
FloatBuffer buff = FloatBuffer.allocate(4);
gl.glGetFloatv(gl.GL_LIGHT_MODEL_AMBIENT, buff);
return new Color(buff.get(),buff.get(),buff.get(),buff.get());
diff --git a/src/net/java/joglutils/model/examples/DisplayListRenderer.java b/src/net/java/joglutils/model/examples/DisplayListRenderer.java
index 50f7d99..4989356 100644
--- a/src/net/java/joglutils/model/examples/DisplayListRenderer.java
+++ b/src/net/java/joglutils/model/examples/DisplayListRenderer.java
@@ -10,16 +10,14 @@
package net.java.joglutils.model.examples;
import net.java.joglutils.model.*;
-import com.sun.opengl.util.texture.Texture;
-import com.sun.opengl.util.texture.TextureCoords;
-import com.sun.opengl.util.texture.TextureIO;
+import com.sun.opengl.util.texture.*;
+import com.sun.opengl.util.texture.awt.*;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.net.URL;
import java.util.HashMap;
import javax.imageio.ImageIO;
-import javax.media.opengl.GL;
-import javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.*;
import net.java.joglutils.model.ResourceRetriever;
import net.java.joglutils.model.geometry.Bounds;
import net.java.joglutils.model.geometry.Material;
@@ -56,13 +54,13 @@ public class DisplayListRenderer implements iModel3DRenderer {
public void render(Object context, Model model)
{
- GL gl = null;
+ GL2 gl = null;
- if (context instanceof GL)
- gl = (GL) context;
+ if (context instanceof GL2)
+ gl = (GL2) context;
else if (context instanceof GLAutoDrawable)
- gl = ((GLAutoDrawable) context).getGL();
+ gl = ((GLAutoDrawable) context).getGL().getGL2();
if (gl == null) {
return;
@@ -81,22 +79,22 @@ public class DisplayListRenderer implements iModel3DRenderer {
}
// save some current state variables
- boolean isTextureEnabled = gl.glIsEnabled(GL.GL_TEXTURE_2D);
- boolean isLightingEnabled = gl.glIsEnabled(GL.GL_LIGHTING);
- boolean isMaterialEnabled = gl.glIsEnabled(GL.GL_COLOR_MATERIAL);
+ boolean isTextureEnabled = gl.glIsEnabled(GL2.GL_TEXTURE_2D);
+ boolean isLightingEnabled = gl.glIsEnabled(GL2.GL_LIGHTING);
+ boolean isMaterialEnabled = gl.glIsEnabled(GL2.GL_COLOR_MATERIAL);
// check lighting
- if (!model.isUsingLighting()) { gl.glDisable(GL.GL_LIGHTING); }
+ if (!model.isUsingLighting()) { gl.glDisable(GL2.GL_LIGHTING); }
// check texture
- if (model.isUsingTexture()) { gl.glEnable(GL.GL_TEXTURE_2D); }
- else { gl.glDisable(GL.GL_TEXTURE_2D); }
+ if (model.isUsingTexture()) { gl.glEnable(GL2.GL_TEXTURE_2D); }
+ else { gl.glDisable(GL2.GL_TEXTURE_2D); }
// check wireframe
- if (model.isRenderingAsWireframe()) { gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_LINE); }
- else { gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_FILL); }
+ if (model.isRenderingAsWireframe()) { gl.glPolygonMode(GL2.GL_FRONT_AND_BACK, GL2.GL_LINE); }
+ else { gl.glPolygonMode(GL2.GL_FRONT_AND_BACK, GL2.GL_FILL); }
- gl.glDisable(GL.GL_COLOR_MATERIAL);
+ gl.glDisable(GL2.GL_COLOR_MATERIAL);
gl.glPushMatrix();
@@ -115,7 +113,7 @@ public class DisplayListRenderer implements iModel3DRenderer {
gl.glCallList(displayList);
// Disabled lighting for drawing the boundary lines so they are all white (or whatever I chose)
- gl.glDisable(GL.GL_LIGHTING);
+ gl.glDisable(GL2.GL_LIGHTING);
if (model.isRenderModelBounds())
gl.glCallList(modelBoundsList);
if (model.isRenderObjectBounds())
@@ -125,21 +123,21 @@ public class DisplayListRenderer implements iModel3DRenderer {
// Reset the flags back for lighting and texture
if (isTextureEnabled) {
- gl.glEnable(GL.GL_TEXTURE_2D);
+ gl.glEnable(GL2.GL_TEXTURE_2D);
} else {
- gl.glDisable(GL.GL_TEXTURE_2D);
+ gl.glDisable(GL2.GL_TEXTURE_2D);
}
if (isLightingEnabled) {
- gl.glEnable(GL.GL_LIGHTING);
+ gl.glEnable(GL2.GL_LIGHTING);
} else {
- gl.glDisable(GL.GL_LIGHTING);
+ gl.glDisable(GL2.GL_LIGHTING);
}
if (isMaterialEnabled) {
- gl.glEnable(GL.GL_COLOR_MATERIAL);
+ gl.glEnable(GL2.GL_COLOR_MATERIAL);
} else {
- gl.glDisable(GL.GL_COLOR_MATERIAL);
+ gl.glDisable(GL2.GL_COLOR_MATERIAL);
}
}
@@ -150,7 +148,7 @@ public class DisplayListRenderer implements iModel3DRenderer {
* @param file
* @return
*/
- private int initialize(GL gl, Model model)
+ private int initialize(GL2 gl, Model model)
{
if (this.isDebugging)
System.out.println("Initialize Model: " + model.getSource());
@@ -217,7 +215,7 @@ public class DisplayListRenderer implements iModel3DRenderer {
if (this.isDebugging)
System.out.println(" Model List");
- gl.glNewList(compiledList, GL.GL_COMPILE);
+ gl.glNewList(compiledList, GL2.GL_COMPILE);
genList(gl, model);
gl.glEndList();
@@ -225,7 +223,7 @@ public class DisplayListRenderer implements iModel3DRenderer {
if (this.isDebugging)
System.out.println(" Boundary List");
- gl.glNewList(modelBoundsList, GL.GL_COMPILE);
+ gl.glNewList(modelBoundsList, GL2.GL_COMPILE);
genModelBoundsList(gl, model);
gl.glEndList();
@@ -233,7 +231,7 @@ public class DisplayListRenderer implements iModel3DRenderer {
if (this.isDebugging)
System.out.println(" Object Boundary List");
- gl.glNewList(objectBoundsList, GL.GL_COMPILE);
+ gl.glNewList(objectBoundsList, GL2.GL_COMPILE);
genObjectBoundsList(gl, model);
gl.glEndList();
@@ -264,7 +262,7 @@ public class DisplayListRenderer implements iModel3DRenderer {
return;
}
- texture.put(id, TextureIO.newTexture(bufferedImage, true));
+ texture.put(id, AWTTextureIO.newTexture(bufferedImage, true));
}
}
@@ -273,7 +271,7 @@ public class DisplayListRenderer implements iModel3DRenderer {
*
* @param gl
*/
- private void genList(GL gl, Model model) {
+ private void genList(GL2 gl, Model model) {
TextureCoords coords;
for (int i=0; i<model.getNumberOfMeshes(); i++) {
@@ -288,7 +286,7 @@ public class DisplayListRenderer implements iModel3DRenderer {
Texture t = texture.get(tempObj.materialID);
// switch to texture mode and push a new matrix on the stack
- gl.glMatrixMode(GL.GL_TEXTURE);
+ gl.glMatrixMode(GL2.GL_TEXTURE);
gl.glPushMatrix();
// check to see if the texture needs flipping
@@ -298,14 +296,14 @@ public class DisplayListRenderer implements iModel3DRenderer {
}
// switch to modelview matrix and push a new matrix on the stack
- gl.glMatrixMode(GL.GL_MODELVIEW);
+ gl.glMatrixMode(GL2.GL_MODELVIEW);
gl.glPushMatrix();
// This is required to repeat textures...because some are not and so only
// part of the model gets filled in....Might be a way to check if this is
// required per object but I'm not sure...would need to research this.
- gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_S, GL.GL_REPEAT);
- gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_T, GL.GL_REPEAT);
+ gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_WRAP_S, GL2.GL_REPEAT);
+ gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_WRAP_T, GL2.GL_REPEAT);
// enable, bind and get texture coordinates
t.enable();
@@ -329,11 +327,11 @@ public class DisplayListRenderer implements iModel3DRenderer {
float[] rgba = new float[4];
Material material = model.getMaterial(tempObj.faces[j].materialID);
- gl.glMaterialfv(GL.GL_FRONT, GL.GL_DIFFUSE, material.diffuseColor.getRGBComponents(rgba), 0);
- gl.glMaterialfv(GL.GL_FRONT, GL.GL_AMBIENT, material.ambientColor.getRGBComponents(rgba), 0);
- gl.glMaterialfv(GL.GL_FRONT, GL.GL_SPECULAR, material.specularColor.getRGBComponents(rgba), 0);
- gl.glMaterialf(GL.GL_FRONT, GL.GL_SHININESS, material.shininess);
- gl.glMaterialfv(GL.GL_FRONT, GL.GL_EMISSION, material.emissive.getRGBComponents(rgba), 0);
+ gl.glMaterialfv(GL2.GL_FRONT, GL2.GL_DIFFUSE, material.diffuseColor.getRGBComponents(rgba), 0);
+ gl.glMaterialfv(GL2.GL_FRONT, GL2.GL_AMBIENT, material.ambientColor.getRGBComponents(rgba), 0);
+ gl.glMaterialfv(GL2.GL_FRONT, GL2.GL_SPECULAR, material.specularColor.getRGBComponents(rgba), 0);
+ gl.glMaterialf(GL2.GL_FRONT, GL2.GL_SHININESS, material.shininess);
+ gl.glMaterialfv(GL2.GL_FRONT, GL2.GL_EMISSION, material.emissive.getRGBComponents(rgba), 0);
}
}
@@ -341,7 +339,7 @@ public class DisplayListRenderer implements iModel3DRenderer {
int vertexIndex = 0;
int normalIndex = 0;
int textureIndex = 0;
- gl.glBegin(GL.GL_POLYGON);
+ gl.glBegin(GL2.GL_POLYGON);
//TODO: the number of vertices for a face is not always 3
for (int whichVertex=0; whichVertex<tempObj.faces[j].vertIndex.length; whichVertex++) {
vertexIndex = tempObj.faces[j].vertIndex[whichVertex];
@@ -387,10 +385,10 @@ public class DisplayListRenderer implements iModel3DRenderer {
if (t != null)
t.disable();
- gl.glMatrixMode(GL.GL_TEXTURE);
+ gl.glMatrixMode(GL2.GL_TEXTURE);
gl.glPopMatrix();
- gl.glMatrixMode(GL.GL_MODELVIEW);
+ gl.glMatrixMode(GL2.GL_MODELVIEW);
gl.glPopMatrix();
}
}
@@ -406,7 +404,7 @@ public class DisplayListRenderer implements iModel3DRenderer {
* @param gl
* @param id
*/
- public void renderBoundsOfObject(GL gl, int id, Model model) {
+ public void renderBoundsOfObject(GL2 gl, int id, Model model) {
if (id >=0 && id <= model.getNumberOfMeshes()) {
if (model.getMesh(id).bounds != null) {
drawBounds(gl, model.getMesh(id).bounds);
@@ -422,7 +420,7 @@ public class DisplayListRenderer implements iModel3DRenderer {
* @param gLDrawable
*/
private void genModelBoundsList(GLAutoDrawable gLDrawable, Model model) {
- GL gl = gLDrawable.getGL();
+ GL2 gl = gLDrawable.getGL().getGL2();
drawBounds(gl, model.getBounds());
}
@@ -432,7 +430,7 @@ public class DisplayListRenderer implements iModel3DRenderer {
*
* @param gl
*/
- private void genModelBoundsList(GL gl, Model model) {
+ private void genModelBoundsList(GL2 gl, Model model) {
drawBounds(gl, model.getBounds());
}
@@ -442,7 +440,7 @@ public class DisplayListRenderer implements iModel3DRenderer {
* @param gLDrawable
*/
private void genObjectBoundsList(GLAutoDrawable gLDrawable, Model model) {
- GL gl = gLDrawable.getGL();
+ GL2 gl = gLDrawable.getGL().getGL2();
genObjectBoundsList(gl, model);
}
@@ -451,7 +449,7 @@ public class DisplayListRenderer implements iModel3DRenderer {
*
* @param gl
*/
- private void genObjectBoundsList(GL gl, Model model) {
+ private void genObjectBoundsList(GL2 gl, Model model) {
for (int i=0; i<model.getNumberOfMeshes(); i++) {
if (model.getMesh(i).bounds != null) {
drawBounds(gl, model.getMesh(i).bounds);
@@ -466,9 +464,9 @@ public class DisplayListRenderer implements iModel3DRenderer {
* @param gl
* @param bounds
*/
- private void drawBounds(GL gl, Bounds bounds) {
+ private void drawBounds(GL2 gl, Bounds bounds) {
// Front Face
- gl.glBegin(GL.GL_LINE_LOOP);
+ gl.glBegin(GL2.GL_LINE_LOOP);
gl.glVertex3f(bounds.min.x, bounds.min.y, bounds.min.z);
gl.glVertex3f(bounds.max.x, bounds.min.y, bounds.min.z);
gl.glVertex3f(bounds.max.x, bounds.max.y, bounds.min.z);
@@ -476,7 +474,7 @@ public class DisplayListRenderer implements iModel3DRenderer {
gl.glEnd();
// Back Face
- gl.glBegin(GL.GL_LINE_LOOP);
+ gl.glBegin(GL2.GL_LINE_LOOP);
gl.glVertex3f(bounds.min.x, bounds.min.y, bounds.max.z);
gl.glVertex3f(bounds.max.x, bounds.min.y, bounds.max.z);
gl.glVertex3f(bounds.max.x, bounds.max.y, bounds.max.z);
@@ -484,7 +482,7 @@ public class DisplayListRenderer implements iModel3DRenderer {
gl.glEnd();
// Connect the corners between the front and back face.
- gl.glBegin(GL.GL_LINES);
+ gl.glBegin(GL2.GL_LINES);
gl.glVertex3f(bounds.min.x, bounds.min.y, bounds.min.z);
gl.glVertex3f(bounds.min.x, bounds.min.y, bounds.max.z);
@@ -538,7 +536,7 @@ public class DisplayListRenderer implements iModel3DRenderer {
return -1;
}
- public void remove(Object objID, GL gl, int howMany) {
+ public void remove(Object objID, GL2 gl, int howMany) {
Integer list = listCache.get(objID);
if(list != null)
@@ -552,7 +550,7 @@ public class DisplayListRenderer implements iModel3DRenderer {
* object being passed in. If the object already has a display list
* allocated, the existing ID is returned.
*/
- public int generateList(Object objID, GL gl, int howMany) {
+ public int generateList(Object objID, GL2 gl, int howMany) {
Integer list = null;
list = listCache.get(objID);
diff --git a/src/net/java/joglutils/model/examples/ModelTest.java b/src/net/java/joglutils/model/examples/ModelTest.java
index d4f1f16..f92ebd8 100644
--- a/src/net/java/joglutils/model/examples/ModelTest.java
+++ b/src/net/java/joglutils/model/examples/ModelTest.java
@@ -45,13 +45,11 @@ import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
-import javax.media.opengl.GLCanvas;
+import javax.media.opengl.awt.GLCanvas;
import javax.swing.*;
import javax.swing.event.MouseInputAdapter;
import java.awt.event.MouseEvent;
-import javax.media.opengl.GL;
-import javax.media.opengl.GLAutoDrawable;
-import javax.media.opengl.GLEventListener;
+import javax.media.opengl.*;
import java.awt.*;
import javax.media.opengl.glu.GLU;
import net.java.joglutils.model.ModelFactory;
@@ -163,8 +161,8 @@ public class ModelTest {
*/
public void display(GLAutoDrawable gLDrawable)
{
- final GL gl = gLDrawable.getGL();
- gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
+ final GL2 gl = gLDrawable.getGL().getGL2();
+ gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT);
gl.glLoadIdentity();
glu.gluLookAt(0,0,10, 0,0,0, 0,1,0);
@@ -205,7 +203,7 @@ public class ModelTest {
*/
public void init(GLAutoDrawable gLDrawable)
{
- final GL gl = gLDrawable.getGL();
+ final GL2 gl = gLDrawable.getGL().getGL2();
try
{
@@ -249,26 +247,26 @@ public class ModelTest {
float lightPosition[] = { 0, 50000000, 0, 1.0f };
float[] model_ambient = {0.5f, 0.5f, 0.5f, 1.0f};
- gl.glLightModelfv(GL.GL_LIGHT_MODEL_AMBIENT, model_ambient, 0);
- gl.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, lightPosition, 0);
- gl.glLightfv(GL.GL_LIGHT0, GL.GL_DIFFUSE, lightDiffuse, 0);
- gl.glLightfv(GL.GL_LIGHT0, GL.GL_AMBIENT, lightAmbient, 0);
- gl.glLightfv(GL.GL_LIGHT0, GL.GL_SPECULAR, lightSpecular, 0);
-
- gl.glEnable(GL.GL_LIGHT0);
- gl.glEnable(GL.GL_LIGHTING);
- gl.glEnable(GL.GL_NORMALIZE);
-
- gl.glEnable(GL.GL_CULL_FACE);
- gl.glShadeModel(GL.GL_SMOOTH);
+ gl.glLightModelfv(GL2.GL_LIGHT_MODEL_AMBIENT, model_ambient, 0);
+ gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_POSITION, lightPosition, 0);
+ gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_DIFFUSE, lightDiffuse, 0);
+ gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_AMBIENT, lightAmbient, 0);
+ gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_SPECULAR, lightSpecular, 0);
+
+ gl.glEnable(GL2.GL_LIGHT0);
+ gl.glEnable(GL2.GL_LIGHTING);
+ gl.glEnable(GL2.GL_NORMALIZE);
+
+ gl.glEnable(GL2.GL_CULL_FACE);
+ gl.glShadeModel(GL2.GL_SMOOTH);
gl.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
gl.glClearDepth(1.0f);
- gl.glEnable(GL.GL_DEPTH_TEST);
- gl.glDepthFunc(GL.GL_LEQUAL);
- gl.glHint(GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST);
- //gl.glLightModeli(GL.GL_LIGHT_MODEL_TWO_SIDE, 0);
+ gl.glEnable(GL2.GL_DEPTH_TEST);
+ gl.glDepthFunc(GL2.GL_LEQUAL);
+ gl.glHint(GL2.GL_PERSPECTIVE_CORRECTION_HINT, GL2.GL_NICEST);
+ //gl.glLightModeli(GL2.GL_LIGHT_MODEL_TWO_SIDE, 0);
- gl.glMatrixMode(GL.GL_MODELVIEW);
+ gl.glMatrixMode(GL2.GL_MODELVIEW);
gl.glPushMatrix();
}
@@ -288,19 +286,22 @@ public class ModelTest {
*/
public void reshape(GLAutoDrawable gLDrawable, int x, int y, int width, int height)
{
- final GL gl = gLDrawable.getGL();
+ final GL2 gl = gLDrawable.getGL().getGL2();
if (height <= 0) // avoid a divide by zero error!
height = 1;
final float h = (float)width / (float)height;
gl.glViewport(0, 0, width, height);
- gl.glMatrixMode(GL.GL_PROJECTION);
+ gl.glMatrixMode(GL2.GL_PROJECTION);
gl.glLoadIdentity();
gl.glOrtho(-1, 1, -1, 1, -50, 50);
- gl.glMatrixMode(GL.GL_MODELVIEW);
+ gl.glMatrixMode(GL2.GL_MODELVIEW);
gl.glLoadIdentity();
}
+ public void dispose(GLAutoDrawable drawable) {
+ }
+
/**
* Get the point at the start of the mouse drag
*
diff --git a/src/net/java/joglutils/model/loader/WaveFrontLoader.java b/src/net/java/joglutils/model/loader/WaveFrontLoader.java
index f3eeb6b..2f9c1b1 100644
--- a/src/net/java/joglutils/model/loader/WaveFrontLoader.java
+++ b/src/net/java/joglutils/model/loader/WaveFrontLoader.java
@@ -92,7 +92,7 @@ public class WaveFrontLoader implements iLoader {
continue;
}
- if (line.isEmpty()) {
+ if (line.length() == 0) {
// igonore empty lines
continue;
}
diff --git a/src/net/java/joglutils/msg/actions/GLRenderAction.java b/src/net/java/joglutils/msg/actions/GLRenderAction.java
index e17d97b..b65c515 100644
--- a/src/net/java/joglutils/msg/actions/GLRenderAction.java
+++ b/src/net/java/joglutils/msg/actions/GLRenderAction.java
@@ -96,31 +96,31 @@ public class GLRenderAction extends Action {
private float curAspectRatio = 1.0f;
private int applyDepth = 0;
- private GL gl;
+ private GL2 gl;
public void apply(Node node) {
int depth = applyDepth++;
try {
if (depth == 0) {
- gl = GLU.getCurrentGL();
+ gl = GLU.getCurrentGL().getGL2();
// Applying to the root of the scene graph
// Push necessary GL state
// FIXME: add in additional bits as we add more capabilities
- gl.glPushAttrib(GL.GL_ENABLE_BIT | GL.GL_CURRENT_BIT | GL.GL_DEPTH_BUFFER_BIT | GL.GL_TRANSFORM_BIT);
- gl.glDisable(GL.GL_LIGHTING);
- gl.glEnable(GL.GL_DEPTH_TEST);
+ gl.glPushAttrib(GL2.GL_ENABLE_BIT | GL2.GL_CURRENT_BIT | GL2.GL_DEPTH_BUFFER_BIT | GL2.GL_TRANSFORM_BIT);
+ gl.glDisable(GL2.GL_LIGHTING);
+ gl.glEnable(GL2.GL_DEPTH_TEST);
gl.glColor4f(1, 1, 1, 1);
- gl.glMatrixMode(GL.GL_TEXTURE);
+ gl.glMatrixMode(GL2.GL_TEXTURE);
gl.glLoadIdentity();
- gl.glMatrixMode(GL.GL_MODELVIEW);
+ gl.glMatrixMode(GL2.GL_MODELVIEW);
gl.glLoadIdentity();
- gl.glPushClientAttrib(GL.GL_CLIENT_VERTEX_ARRAY_BIT);
- gl.glDisableClientState(GL.GL_VERTEX_ARRAY);
- gl.glDisableClientState(GL.GL_TEXTURE_COORD_ARRAY);
+ gl.glPushClientAttrib(GL2.GL_CLIENT_VERTEX_ARRAY_BIT);
+ gl.glDisableClientState(GL2.GL_VERTEX_ARRAY);
+ gl.glDisableClientState(GL2.GL_TEXTURE_COORD_ARRAY);
// FIXME: should add in disabling of normal array
// Figure out the aspect ratio of the current viewport
int[] viewport = new int[4];
- gl.glGetIntegerv(GL.GL_VIEWPORT, viewport, 0);
+ gl.glGetIntegerv(GL2.GL_VIEWPORT, viewport, 0);
curAspectRatio = (float) viewport[2] / (float) viewport[3];
}
apply(table, node);
@@ -135,7 +135,7 @@ public class GLRenderAction extends Action {
}
/** Returns the GL instance being used for rendering. */
- public GL getGL() {
+ public GL2 getGL() {
return gl;
}
diff --git a/src/net/java/joglutils/msg/elements/GLBlendElement.java b/src/net/java/joglutils/msg/elements/GLBlendElement.java
index 7955533..16e2266 100644
--- a/src/net/java/joglutils/msg/elements/GLBlendElement.java
+++ b/src/net/java/joglutils/msg/elements/GLBlendElement.java
@@ -76,41 +76,41 @@ public class GLBlendElement extends BlendElement {
private static int oglBlendFunc(int func) {
switch (func) {
- case Blend.ZERO: return GL.GL_ZERO;
- case Blend.ONE: return GL.GL_ONE;
- case Blend.SRC_COLOR: return GL.GL_SRC_COLOR;
- case Blend.ONE_MINUS_SRC_COLOR: return GL.GL_ONE_MINUS_SRC_COLOR;
- case Blend.DST_COLOR: return GL.GL_DST_COLOR;
- case Blend.ONE_MINUS_DST_COLOR: return GL.GL_ONE_MINUS_DST_COLOR;
- case Blend.SRC_ALPHA: return GL.GL_SRC_ALPHA;
- case Blend.ONE_MINUS_SRC_ALPHA: return GL.GL_ONE_MINUS_SRC_ALPHA;
- case Blend.DST_ALPHA: return GL.GL_DST_ALPHA;
- case Blend.ONE_MINUS_DST_ALPHA: return GL.GL_ONE_MINUS_DST_ALPHA;
- case Blend.SRC_ALPHA_SATURATE: return GL.GL_SRC_ALPHA_SATURATE;
- case Blend.CONSTANT_COLOR: return GL.GL_CONSTANT_COLOR;
- case Blend.ONE_MINUS_CONSTANT_COLOR: return GL.GL_ONE_MINUS_CONSTANT_COLOR;
- case Blend.CONSTANT_ALPHA: return GL.GL_CONSTANT_ALPHA;
- case Blend.ONE_MINUS_CONSTANT_ALPHA: return GL.GL_ONE_MINUS_CONSTANT_ALPHA;
+ case Blend.ZERO: return GL2.GL_ZERO;
+ case Blend.ONE: return GL2.GL_ONE;
+ case Blend.SRC_COLOR: return GL2.GL_SRC_COLOR;
+ case Blend.ONE_MINUS_SRC_COLOR: return GL2.GL_ONE_MINUS_SRC_COLOR;
+ case Blend.DST_COLOR: return GL2.GL_DST_COLOR;
+ case Blend.ONE_MINUS_DST_COLOR: return GL2.GL_ONE_MINUS_DST_COLOR;
+ case Blend.SRC_ALPHA: return GL2.GL_SRC_ALPHA;
+ case Blend.ONE_MINUS_SRC_ALPHA: return GL2.GL_ONE_MINUS_SRC_ALPHA;
+ case Blend.DST_ALPHA: return GL2.GL_DST_ALPHA;
+ case Blend.ONE_MINUS_DST_ALPHA: return GL2.GL_ONE_MINUS_DST_ALPHA;
+ case Blend.SRC_ALPHA_SATURATE: return GL2.GL_SRC_ALPHA_SATURATE;
+ case Blend.CONSTANT_COLOR: return GL2.GL_CONSTANT_COLOR;
+ case Blend.ONE_MINUS_CONSTANT_COLOR: return GL2.GL_ONE_MINUS_CONSTANT_COLOR;
+ case Blend.CONSTANT_ALPHA: return GL2.GL_CONSTANT_ALPHA;
+ case Blend.ONE_MINUS_CONSTANT_ALPHA: return GL2.GL_ONE_MINUS_CONSTANT_ALPHA;
}
throw new InternalError("Illegal blend function " + func);
}
private int oglBlendEquation(int equation) {
switch (equation) {
- case Blend.FUNC_ADD: return GL.GL_FUNC_ADD;
- case Blend.FUNC_SUBTRACT: return GL.GL_FUNC_SUBTRACT;
- case Blend.FUNC_REVERSE_SUBTRACT: return GL.GL_FUNC_REVERSE_SUBTRACT;
- case Blend.MIN: return GL.GL_MIN;
- case Blend.MAX: return GL.GL_MAX;
+ case Blend.FUNC_ADD: return GL2.GL_FUNC_ADD;
+ case Blend.FUNC_SUBTRACT: return GL2.GL_FUNC_SUBTRACT;
+ case Blend.FUNC_REVERSE_SUBTRACT: return GL2.GL_FUNC_REVERSE_SUBTRACT;
+ case Blend.MIN: return GL2.GL_MIN;
+ case Blend.MAX: return GL2.GL_MAX;
}
throw new InternalError("Illegal blend equation " + equation);
}
- private static void validateFunc(GL gl, int func) {
- if (func == GL.GL_CONSTANT_COLOR ||
- func == GL.GL_ONE_MINUS_CONSTANT_COLOR ||
- func == GL.GL_CONSTANT_ALPHA ||
- func == GL.GL_ONE_MINUS_CONSTANT_ALPHA) {
+ private static void validateFunc(GL2 gl, int func) {
+ if (func == GL2.GL_CONSTANT_COLOR ||
+ func == GL2.GL_ONE_MINUS_CONSTANT_COLOR ||
+ func == GL2.GL_CONSTANT_ALPHA ||
+ func == GL2.GL_ONE_MINUS_CONSTANT_ALPHA) {
if (!gl.isExtensionAvailable("GL_ARB_imaging")) {
throw new RuntimeException("Blend function requires GL_ARB_imaging extension");
}
@@ -118,10 +118,10 @@ public class GLBlendElement extends BlendElement {
}
private void send() {
- GL gl = GLU.getCurrentGL();
+ GL2 gl = GLU.getCurrentGL().getGL2();
// Don't try to optimize what we send to OpenGL at this point -- too complicated
if (enabled) {
- gl.glEnable(GL.GL_BLEND);
+ gl.glEnable(GL2.GL_BLEND);
int oglSrcFunc = oglBlendFunc(srcFunc);
int oglDestFunc = oglBlendFunc(destFunc);
validateFunc(gl, oglSrcFunc);
@@ -132,7 +132,7 @@ public class GLBlendElement extends BlendElement {
gl.glBlendColor(blendColor.x(), blendColor.y(), blendColor.z(), blendColor.w());
}
} else {
- gl.glDisable(GL.GL_BLEND);
+ gl.glDisable(GL2.GL_BLEND);
}
}
}
diff --git a/src/net/java/joglutils/msg/elements/GLColorElement.java b/src/net/java/joglutils/msg/elements/GLColorElement.java
index 732ee98..0503e9a 100644
--- a/src/net/java/joglutils/msg/elements/GLColorElement.java
+++ b/src/net/java/joglutils/msg/elements/GLColorElement.java
@@ -89,12 +89,12 @@ public class GLColorElement extends ColorElement {
if (this.enabled == enabled)
return; // No OpenGL work to do
this.enabled = enabled;
- GL gl = GLU.getCurrentGL();
+ GL2 gl = GLU.getCurrentGL().getGL2();
if (enabled) {
- gl.glColorPointer(4, GL.GL_FLOAT, 0, colors);
- gl.glEnableClientState(GL.GL_COLOR_ARRAY);
+ gl.glColorPointer(4, GL2.GL_FLOAT, 0, colors);
+ gl.glEnableClientState(GL2.GL_COLOR_ARRAY);
} else {
- gl.glDisableClientState(GL.GL_COLOR_ARRAY);
+ gl.glDisableClientState(GL2.GL_COLOR_ARRAY);
// Assume we have to reset the current color to the default
gl.glColor4f(1, 1, 1, 1);
}
diff --git a/src/net/java/joglutils/msg/elements/GLCoordinateElement.java b/src/net/java/joglutils/msg/elements/GLCoordinateElement.java
index d33e4ec..aa59690 100644
--- a/src/net/java/joglutils/msg/elements/GLCoordinateElement.java
+++ b/src/net/java/joglutils/msg/elements/GLCoordinateElement.java
@@ -88,12 +88,12 @@ public class GLCoordinateElement extends CoordinateElement {
if (this.enabled == enabled)
return; // No OpenGL work to do
this.enabled = enabled;
- GL gl = GLU.getCurrentGL();
+ GL2 gl = GLU.getCurrentGL().getGL2();
if (enabled) {
- gl.glVertexPointer(3, GL.GL_FLOAT, 0, coords);
- gl.glEnableClientState(GL.GL_VERTEX_ARRAY);
+ gl.glVertexPointer(3, GL2.GL_FLOAT, 0, coords);
+ gl.glEnableClientState(GL2.GL_VERTEX_ARRAY);
} else {
- gl.glDisableClientState(GL.GL_VERTEX_ARRAY);
+ gl.glDisableClientState(GL2.GL_VERTEX_ARRAY);
}
}
}
diff --git a/src/net/java/joglutils/msg/elements/GLModelMatrixElement.java b/src/net/java/joglutils/msg/elements/GLModelMatrixElement.java
index a63f8ae..c10e436 100644
--- a/src/net/java/joglutils/msg/elements/GLModelMatrixElement.java
+++ b/src/net/java/joglutils/msg/elements/GLModelMatrixElement.java
@@ -68,7 +68,7 @@ public class GLModelMatrixElement extends ModelMatrixElement {
this.state = state;
// Cause side-effects in OpenGL
- GL gl = GLU.getCurrentGL();
+ GL2 gl = GLU.getCurrentGL().getGL2();
gl.glPushMatrix();
}
@@ -76,7 +76,7 @@ public class GLModelMatrixElement extends ModelMatrixElement {
super.pop(state, previousTopElement);
// Cause side-effects in OpenGL
- GL gl = GLU.getCurrentGL();
+ GL2 gl = GLU.getCurrentGL().getGL2();
gl.glPopMatrix();
}
@@ -85,7 +85,7 @@ public class GLModelMatrixElement extends ModelMatrixElement {
// Cause side-effects in OpenGL
// Recompute the complete modelview matrix
Mat4f mat = ViewingMatrixElement.getInstance(state).getMatrix();
- GL gl = GLU.getCurrentGL();
+ GL2 gl = GLU.getCurrentGL().getGL2();
if (gl.isExtensionAvailable("GL_VERSION_1_3")) {
gl.glLoadTransposeMatrixf(mat.getRowMajorData(), 0);
} else {
@@ -97,7 +97,7 @@ public class GLModelMatrixElement extends ModelMatrixElement {
public void multElt(Mat4f matrix) {
super.multElt(matrix);
- GL gl = GLU.getCurrentGL();
+ GL2 gl = GLU.getCurrentGL().getGL2();
if (gl.isExtensionAvailable("GL_VERSION_1_3")) {
gl.glMultTransposeMatrixf(matrix.getRowMajorData(), 0);
} else {
diff --git a/src/net/java/joglutils/msg/elements/GLProjectionMatrixElement.java b/src/net/java/joglutils/msg/elements/GLProjectionMatrixElement.java
index 3dfad8f..c811ba4 100644
--- a/src/net/java/joglutils/msg/elements/GLProjectionMatrixElement.java
+++ b/src/net/java/joglutils/msg/elements/GLProjectionMatrixElement.java
@@ -67,8 +67,8 @@ public class GLProjectionMatrixElement extends ProjectionMatrixElement {
public void setElt(Mat4f matrix) {
super.setElt(matrix);
- GL gl = GLU.getCurrentGL();
- gl.glMatrixMode(GL.GL_PROJECTION);
+ GL2 gl = GLU.getCurrentGL().getGL2();
+ gl.glMatrixMode(GL2.GL_PROJECTION);
if (gl.isExtensionAvailable("GL_VERSION_1_3")) {
gl.glLoadTransposeMatrixf(matrix.getRowMajorData(), 0);
} else {
@@ -76,6 +76,6 @@ public class GLProjectionMatrixElement extends ProjectionMatrixElement {
matrix.getColumnMajorData(tmp);
gl.glLoadMatrixf(tmp, 0);
}
- gl.glMatrixMode(GL.GL_MODELVIEW);
+ gl.glMatrixMode(GL2.GL_MODELVIEW);
}
}
diff --git a/src/net/java/joglutils/msg/elements/GLTextureCoordinateElement.java b/src/net/java/joglutils/msg/elements/GLTextureCoordinateElement.java
index 111d0a9..50a871c 100644
--- a/src/net/java/joglutils/msg/elements/GLTextureCoordinateElement.java
+++ b/src/net/java/joglutils/msg/elements/GLTextureCoordinateElement.java
@@ -89,16 +89,16 @@ public class GLTextureCoordinateElement extends TextureCoordinateElement {
if (this.enabled == enabled)
return; // No OpenGL work to do
this.enabled = enabled;
- GL gl = GLU.getCurrentGL();
+ GL2 gl = GLU.getCurrentGL().getGL2();
if (enabled) {
// FIXME: may want to link this up with the GLTextureElement so
// that we only enable the texture coordinate array if we both
// have a TextureCoordinateElement and a TextureElement active
// (a little error checking for the application)
- gl.glTexCoordPointer(2, GL.GL_FLOAT, 0, coords);
- gl.glEnableClientState(GL.GL_TEXTURE_COORD_ARRAY);
+ gl.glTexCoordPointer(2, GL2.GL_FLOAT, 0, coords);
+ gl.glEnableClientState(GL2.GL_TEXTURE_COORD_ARRAY);
} else {
- gl.glDisableClientState(GL.GL_TEXTURE_COORD_ARRAY);
+ gl.glDisableClientState(GL2.GL_TEXTURE_COORD_ARRAY);
}
}
}
diff --git a/src/net/java/joglutils/msg/elements/GLTextureElement.java b/src/net/java/joglutils/msg/elements/GLTextureElement.java
index b5a196d..7f903c3 100644
--- a/src/net/java/joglutils/msg/elements/GLTextureElement.java
+++ b/src/net/java/joglutils/msg/elements/GLTextureElement.java
@@ -74,7 +74,7 @@ public class GLTextureElement extends TextureElement {
}
private void switchTextures(Texture2 prev, Texture2 texture) {
- GL gl = GLU.getCurrentGL();
+ GL2 gl = GLU.getCurrentGL().getGL2();
Texture prevTexture = null;
Texture curTexture = null;
int texEnvMode = 0;
@@ -96,12 +96,12 @@ public class GLTextureElement extends TextureElement {
curTexture.bind();
int glEnvMode = 0;
switch (texEnvMode) {
- case Texture2.MODULATE: glEnvMode = GL.GL_MODULATE; break;
- case Texture2.DECAL: glEnvMode = GL.GL_DECAL; break;
- case Texture2.BLEND: glEnvMode = GL.GL_BLEND; break;
- case Texture2.REPLACE: glEnvMode = GL.GL_REPLACE; break;
+ case Texture2.MODULATE: glEnvMode = GL2.GL_MODULATE; break;
+ case Texture2.DECAL: glEnvMode = GL2.GL_DECAL; break;
+ case Texture2.BLEND: glEnvMode = GL2.GL_BLEND; break;
+ case Texture2.REPLACE: glEnvMode = GL2.GL_REPLACE; break;
}
- gl.glTexEnvi(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_MODE, glEnvMode);
+ gl.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, glEnvMode);
}
}
}
diff --git a/src/net/java/joglutils/msg/elements/GLViewingMatrixElement.java b/src/net/java/joglutils/msg/elements/GLViewingMatrixElement.java
index a24f53f..cff9fe3 100644
--- a/src/net/java/joglutils/msg/elements/GLViewingMatrixElement.java
+++ b/src/net/java/joglutils/msg/elements/GLViewingMatrixElement.java
@@ -75,7 +75,7 @@ public class GLViewingMatrixElement extends ViewingMatrixElement {
// Must push the combined viewing and modelview matrices down to OpenGL
Mat4f mdl = ModelMatrixElement.getInstance(state).getMatrix();
temp.mul(matrix, mdl);
- GL gl = GLU.getCurrentGL();
+ GL2 gl = GLU.getCurrentGL().getGL2();
if (gl.isExtensionAvailable("GL_VERSION_1_3")) {
gl.glLoadTransposeMatrixf(temp.getRowMajorData(), 0);
} else {
diff --git a/src/net/java/joglutils/msg/math/Mat4f.java b/src/net/java/joglutils/msg/math/Mat4f.java
index fc4d955..bc7cee0 100644
--- a/src/net/java/joglutils/msg/math/Mat4f.java
+++ b/src/net/java/joglutils/msg/math/Mat4f.java
@@ -37,6 +37,8 @@
package net.java.joglutils.msg.math;
+import java.nio.*;
+
/** A (very incomplete) 4x4 matrix class. Representation assumes
row-major order and multiplication by column vectors on the
right. */
@@ -260,12 +262,30 @@ public class Mat4f {
}
}
+ /** Copies data in column-major (OpenGL format) order into passed
+ float buffer, which must have 16 or more remaining elements. */
+ public void getColumnMajorData(FloatBuffer out) {
+ for (int i = 0; i < 4; i++) {
+ for (int j = 0; j < 4; j++) {
+ out.put(4 * j + i, get(i, j));
+ }
+ }
+ }
+
/** Returns the matrix data in row-major format, which is the
opposite of OpenGL's convention. */
public float[] getRowMajorData() {
return data;
}
+ /** Stores the matrix data into the passed FloatBuffer in row-major
+ format, which is the opposite of OpenGL's convention. */
+ public void getRowMajorData(FloatBuffer out) {
+ for (int i = 0; i < 16; i++) {
+ out.put(i, data[i]);
+ }
+ }
+
public Matf toMatf() {
Matf out = new Matf(4, 4);
for (int i = 0; i < 4; i++) {
diff --git a/src/net/java/joglutils/msg/misc/Shader.java b/src/net/java/joglutils/msg/misc/Shader.java
index ab25f78..cf32fc6 100644
--- a/src/net/java/joglutils/msg/misc/Shader.java
+++ b/src/net/java/joglutils/msg/misc/Shader.java
@@ -36,10 +36,9 @@
package net.java.joglutils.msg.misc;
-import javax.media.opengl.GL;
-import javax.media.opengl.GLException;
+import javax.media.opengl.*;
import javax.media.opengl.glu.GLU;
-import static javax.media.opengl.GL.*;
+import static javax.media.opengl.GL2.*;
/**
* Represents an OpenGL shader program object, which can be constructed from
@@ -89,7 +88,7 @@ public class Shader {
public Shader(String fragmentCode)
throws GLException
{
- GL gl = GLU.getCurrentGL();
+ GL2 gl = GLU.getCurrentGL().getGL2();
id = createProgram(gl, null, fragmentCode);
}
@@ -110,7 +109,7 @@ public class Shader {
public Shader(String vertexCode, String fragmentCode)
throws GLException
{
- GL gl = GLU.getCurrentGL();
+ GL2 gl = GLU.getCurrentGL().getGL2();
id = createProgram(gl, vertexCode, fragmentCode);
}
@@ -122,7 +121,7 @@ public class Shader {
* @throws GLException if no OpenGL context was current or if any
* OpenGL-related errors occurred
*/
- private static int createProgram(GL gl,
+ private static int createProgram(GL2 gl,
String vertexShaderSource,
String fragmentShaderSource)
throws GLException
@@ -201,10 +200,10 @@ public class Shader {
* @throws GLException if no OpenGL context was current or if any
* OpenGL-related errors occurred
*/
- private static int compileShader(GL gl, String shaderSource, boolean vertex)
+ private static int compileShader(GL2 gl, String shaderSource, boolean vertex)
throws GLException
{
- int kind = vertex ? GL_VERTEX_SHADER_ARB : GL_FRAGMENT_SHADER_ARB;
+ int kind = vertex ? GL_VERTEX_SHADER : GL_FRAGMENT_SHADER;
int shader;
int[] success = new int[1];
int[] infoLogLength = new int[1];
@@ -255,7 +254,7 @@ public class Shader {
* OpenGL-related errors occurred
*/
public void enable() throws GLException {
- GL gl = GLU.getCurrentGL();
+ GL2 gl = GLU.getCurrentGL().getGL2();
gl.glUseProgramObjectARB(id);
}
@@ -266,7 +265,7 @@ public class Shader {
* OpenGL-related errors occurred
*/
public void disable() throws GLException {
- GL gl = GLU.getCurrentGL();
+ GL2 gl = GLU.getCurrentGL().getGL2();
gl.glUseProgramObjectARB(0);
}
@@ -277,7 +276,7 @@ public class Shader {
* OpenGL-related errors occurred
*/
public void dispose() throws GLException {
- GL gl = GLU.getCurrentGL();
+ GL2 gl = GLU.getCurrentGL().getGL2();
gl.glDeleteObjectARB(id);
id = 0;
}
@@ -294,7 +293,7 @@ public class Shader {
public void setUniform(String name, int i0)
throws GLException
{
- GL gl = GLU.getCurrentGL();
+ GL2 gl = GLU.getCurrentGL().getGL2();
int loc = gl.glGetUniformLocationARB(id, name);
gl.glUniform1iARB(loc, i0);
}
@@ -312,7 +311,7 @@ public class Shader {
public void setUniform(String name, int i0, int i1)
throws GLException
{
- GL gl = GLU.getCurrentGL();
+ GL2 gl = GLU.getCurrentGL().getGL2();
int loc = gl.glGetUniformLocationARB(id, name);
gl.glUniform2iARB(loc, i0, i1);
}
@@ -331,7 +330,7 @@ public class Shader {
public void setUniform(String name, int i0, int i1, int i2)
throws GLException
{
- GL gl = GLU.getCurrentGL();
+ GL2 gl = GLU.getCurrentGL().getGL2();
int loc = gl.glGetUniformLocationARB(id, name);
gl.glUniform3iARB(loc, i0, i1, i2);
}
@@ -351,7 +350,7 @@ public class Shader {
public void setUniform(String name, int i0, int i1, int i2, int i3)
throws GLException
{
- GL gl = GLU.getCurrentGL();
+ GL2 gl = GLU.getCurrentGL().getGL2();
int loc = gl.glGetUniformLocationARB(id, name);
gl.glUniform4iARB(loc, i0, i1, i2, i3);
}
@@ -368,7 +367,7 @@ public class Shader {
public void setUniform(String name, float f0)
throws GLException
{
- GL gl = GLU.getCurrentGL();
+ GL2 gl = GLU.getCurrentGL().getGL2();
int loc = gl.glGetUniformLocationARB(id, name);
gl.glUniform1fARB(loc, f0);
}
@@ -386,7 +385,7 @@ public class Shader {
public void setUniform(String name, float f0, float f1)
throws GLException
{
- GL gl = GLU.getCurrentGL();
+ GL2 gl = GLU.getCurrentGL().getGL2();
int loc = gl.glGetUniformLocationARB(id, name);
gl.glUniform2fARB(loc, f0, f1);
}
@@ -405,7 +404,7 @@ public class Shader {
public void setUniform(String name, float f0, float f1, float f2)
throws GLException
{
- GL gl = GLU.getCurrentGL();
+ GL2 gl = GLU.getCurrentGL().getGL2();
int loc = gl.glGetUniformLocationARB(id, name);
gl.glUniform3fARB(loc, f0, f1, f2);
}
@@ -425,7 +424,7 @@ public class Shader {
public void setUniform(String name, float f0, float f1, float f2, float f3)
throws GLException
{
- GL gl = GLU.getCurrentGL();
+ GL2 gl = GLU.getCurrentGL().getGL2();
int loc = gl.glGetUniformLocationARB(id, name);
gl.glUniform4fARB(loc, f0, f1, f2, f3);
}
@@ -444,7 +443,7 @@ public class Shader {
public void setUniformArray1i(String name, int count, int[] vals, int off)
throws GLException
{
- GL gl = GLU.getCurrentGL();
+ GL2 gl = GLU.getCurrentGL().getGL2();
int loc = gl.glGetUniformLocationARB(id, name);
gl.glUniform1ivARB(loc, count, vals, off);
}
@@ -463,7 +462,7 @@ public class Shader {
public void setUniformArray2i(String name, int count, int[] vals, int off)
throws GLException
{
- GL gl = GLU.getCurrentGL();
+ GL2 gl = GLU.getCurrentGL().getGL2();
int loc = gl.glGetUniformLocationARB(id, name);
gl.glUniform2ivARB(loc, count, vals, off);
}
@@ -482,7 +481,7 @@ public class Shader {
public void setUniformArray3i(String name, int count, int[] vals, int off)
throws GLException
{
- GL gl = GLU.getCurrentGL();
+ GL2 gl = GLU.getCurrentGL().getGL2();
int loc = gl.glGetUniformLocationARB(id, name);
gl.glUniform3ivARB(loc, count, vals, off);
}
@@ -501,7 +500,7 @@ public class Shader {
public void setUniformArray4i(String name, int count, int[] vals, int off)
throws GLException
{
- GL gl = GLU.getCurrentGL();
+ GL2 gl = GLU.getCurrentGL().getGL2();
int loc = gl.glGetUniformLocationARB(id, name);
gl.glUniform4ivARB(loc, count, vals, off);
}
@@ -521,7 +520,7 @@ public class Shader {
int count, float[] vals, int off)
throws GLException
{
- GL gl = GLU.getCurrentGL();
+ GL2 gl = GLU.getCurrentGL().getGL2();
int loc = gl.glGetUniformLocationARB(id, name);
gl.glUniform1fvARB(loc, count, vals, off);
}
@@ -541,7 +540,7 @@ public class Shader {
int count, float[] vals, int off)
throws GLException
{
- GL gl = GLU.getCurrentGL();
+ GL2 gl = GLU.getCurrentGL().getGL2();
int loc = gl.glGetUniformLocationARB(id, name);
gl.glUniform2fvARB(loc, count, vals, off);
}
@@ -561,7 +560,7 @@ public class Shader {
int count, float[] vals, int off)
throws GLException
{
- GL gl = GLU.getCurrentGL();
+ GL2 gl = GLU.getCurrentGL().getGL2();
int loc = gl.glGetUniformLocationARB(id, name);
gl.glUniform3fvARB(loc, count, vals, off);
}
@@ -581,7 +580,7 @@ public class Shader {
int count, float[] vals, int off)
throws GLException
{
- GL gl = GLU.getCurrentGL();
+ GL2 gl = GLU.getCurrentGL().getGL2();
int loc = gl.glGetUniformLocationARB(id, name);
gl.glUniform4fvARB(loc, count, vals, off);
}
@@ -604,7 +603,7 @@ public class Shader {
float[] vals, int off)
throws GLException
{
- GL gl = GLU.getCurrentGL();
+ GL2 gl = GLU.getCurrentGL().getGL2();
int loc = gl.glGetUniformLocationARB(id, name);
gl.glUniformMatrix2fvARB(loc, count, transpose, vals, off);
}
@@ -627,7 +626,7 @@ public class Shader {
float[] vals, int off)
throws GLException
{
- GL gl = GLU.getCurrentGL();
+ GL2 gl = GLU.getCurrentGL().getGL2();
int loc = gl.glGetUniformLocationARB(id, name);
gl.glUniformMatrix3fvARB(loc, count, transpose, vals, off);
}
@@ -650,7 +649,7 @@ public class Shader {
float[] vals, int off)
throws GLException
{
- GL gl = GLU.getCurrentGL();
+ GL2 gl = GLU.getCurrentGL().getGL2();
int loc = gl.glGetUniformLocationARB(id, name);
gl.glUniformMatrix4fvARB(loc, count, transpose, vals, off);
}
diff --git a/src/net/java/joglutils/msg/nodes/Texture2.java b/src/net/java/joglutils/msg/nodes/Texture2.java
index 7844790..9c4cb60 100644
--- a/src/net/java/joglutils/msg/nodes/Texture2.java
+++ b/src/net/java/joglutils/msg/nodes/Texture2.java
@@ -43,8 +43,9 @@ import java.net.*;
import java.util.*;
import javax.media.opengl.*;
-import com.sun.opengl.util.j2d.*;
+import com.sun.opengl.util.awt.*;
import com.sun.opengl.util.texture.*;
+import com.sun.opengl.util.texture.awt.*;
import net.java.joglutils.msg.actions.*;
import net.java.joglutils.msg.elements.*;
@@ -127,7 +128,7 @@ public class Texture2 extends Node {
Texture is fetched. */
public void setTexture(BufferedImage image, boolean mipmap) {
disposeTextureRenderer();
- data = TextureIO.newTextureData(image, mipmap);
+ data = AWTTextureIO.newTextureData(image, mipmap);
dirty = true;
}
diff --git a/src/net/java/joglutils/msg/nodes/TriangleSet.java b/src/net/java/joglutils/msg/nodes/TriangleSet.java
index ffa0ea3..4659a19 100644
--- a/src/net/java/joglutils/msg/nodes/TriangleSet.java
+++ b/src/net/java/joglutils/msg/nodes/TriangleSet.java
@@ -73,7 +73,7 @@ public class TriangleSet extends TriangleBasedShape {
if (CoordinateElement.get(state) != null) {
// OK, we have coordinates to send down, at least
- GL gl = action.getGL();
+ GL2 gl = action.getGL();
Texture tex = null;
boolean haveTexCoords = false;
@@ -90,7 +90,7 @@ public class TriangleSet extends TriangleBasedShape {
if (tex != null) {
// Set up the texture matrix to uniformly map [0..1] to the used
// portion of the texture image
- gl.glMatrixMode(GL.GL_TEXTURE);
+ gl.glMatrixMode(GL2.GL_TEXTURE);
gl.glPushMatrix();
if (gl.isExtensionAvailable("GL_VERSION_1_3")) {
gl.glLoadTransposeMatrixf(getTextureMatrix(tex).getRowMajorData(), 0);
@@ -99,25 +99,25 @@ public class TriangleSet extends TriangleBasedShape {
getTextureMatrix(tex).getColumnMajorData(tmp);
gl.glLoadMatrixf(tmp, 0);
}
- gl.glMatrixMode(GL.GL_MODELVIEW);
+ gl.glMatrixMode(GL2.GL_MODELVIEW);
} else if (haveTexCoords) {
// Want to turn off the use of texture coordinates to avoid errors
// FIXME: not 100% sure whether we need to do this, but think we should
- gl.glDisableClientState(GL.GL_TEXTURE_COORD_ARRAY);
+ gl.glDisableClientState(GL2.GL_TEXTURE_COORD_ARRAY);
}
// For now, assume the triangle set and the number of available
// coordinates match -- may want to add debugging information
// for this later
- gl.glDrawArrays(GL.GL_TRIANGLES, 0, 3 * getNumTriangles());
+ gl.glDrawArrays(GL2.GL_TRIANGLES, 0, 3 * getNumTriangles());
if (tex != null) {
- gl.glMatrixMode(GL.GL_TEXTURE);
+ gl.glMatrixMode(GL2.GL_TEXTURE);
gl.glPopMatrix();
- gl.glMatrixMode(GL.GL_MODELVIEW);
+ gl.glMatrixMode(GL2.GL_MODELVIEW);
} else if (haveTexCoords) {
// Might want this the next time we render a shape
- gl.glEnableClientState(GL.GL_TEXTURE_COORD_ARRAY);
+ gl.glEnableClientState(GL2.GL_TEXTURE_COORD_ARRAY);
}
}
}
diff --git a/src/net/java/joglutils/msg/test/DisplayShelf.java b/src/net/java/joglutils/msg/test/DisplayShelf.java
index de08225..1e3bab7 100644
--- a/src/net/java/joglutils/msg/test/DisplayShelf.java
+++ b/src/net/java/joglutils/msg/test/DisplayShelf.java
@@ -48,6 +48,7 @@ import java.net.*;
import javax.swing.*;
import javax.media.opengl.*;
+import javax.media.opengl.awt.*;
/**
* A test implementing a 3D display shelf component.
@@ -134,7 +135,7 @@ public class DisplayShelf {
}
DisplayShelfRenderer renderer = new DisplayShelfRenderer(model);
- GLCanvas canvas = new GLCanvas(new GLCapabilities(), null, renderer.getSharedContext(), null);
+ GLCanvas canvas = new GLCanvas(new GLCapabilities(GLProfile.getDefault()), null, renderer.getSharedContext(), null);
canvas.setFocusable(true);
canvas.addGLEventListener(renderer);
f.add(canvas);
diff --git a/src/net/java/joglutils/msg/test/DisplayShelfRenderer.java b/src/net/java/joglutils/msg/test/DisplayShelfRenderer.java
index adf1263..5cdffc1 100644
--- a/src/net/java/joglutils/msg/test/DisplayShelfRenderer.java
+++ b/src/net/java/joglutils/msg/test/DisplayShelfRenderer.java
@@ -49,7 +49,8 @@ import javax.swing.*;
import javax.swing.event.*;
import javax.media.opengl.*;
-import com.sun.opengl.util.j2d.*;
+import javax.media.opengl.awt.*;
+import com.sun.opengl.util.awt.*;
import net.java.joglutils.msg.actions.*;
import net.java.joglutils.msg.collections.*;
@@ -99,7 +100,7 @@ public class DisplayShelfRenderer implements GLEventListener {
private GLPbuffer sharedPbuffer;
private boolean firstInit = true;
- private GLAutoDrawable drawable;
+ private AWTGLAutoDrawable drawable;
private Separator root;
private Separator imageRoot;
@@ -154,7 +155,7 @@ public class DisplayShelfRenderer implements GLEventListener {
// Create a small pbuffer with which we share textures and display
// lists to avoid having to reload textures during repeated calls
// to init()
- sharedPbuffer = GLDrawableFactory.getFactory().createGLPbuffer(new GLCapabilities(), null, 1, 1, null);
+ sharedPbuffer = GLDrawableFactory.getFactory(GLProfile.getDefault()).createGLPbuffer(new GLCapabilities(GLProfile.getDefault()), null, 1, 1, null);
sharedPbuffer.display();
this.fetcher = new BasicFetcher<Integer>();
@@ -221,8 +222,8 @@ public class DisplayShelfRenderer implements GLEventListener {
return targetIndex;
}
- public void init(GLAutoDrawable drawable) {
- this.drawable = drawable;
+ public void init(GLAutoDrawable d) {
+ this.drawable = (AWTGLAutoDrawable) d;
GL gl = drawable.getGL();
if (firstInit) {
@@ -407,7 +408,7 @@ public class DisplayShelfRenderer implements GLEventListener {
if (repaintAgain) {
animating = true;
- drawable.repaint();
+ ((AWTGLAutoDrawable) drawable).repaint();
} else {
animating = false;
}
@@ -416,7 +417,7 @@ public class DisplayShelfRenderer implements GLEventListener {
public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
}
- public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) {}
+ public void dispose(GLAutoDrawable drawable) {}
//----------------------------------------------------------------------
// Internals only below this point
diff --git a/src/net/java/joglutils/msg/test/Test.java b/src/net/java/joglutils/msg/test/Test.java
index a782e3e..d54d31b 100644
--- a/src/net/java/joglutils/msg/test/Test.java
+++ b/src/net/java/joglutils/msg/test/Test.java
@@ -35,116 +35,117 @@
*
*/
-package net.java.joglutils.msg.test;
-
-import java.awt.Frame;
-import java.awt.event.*;
-import java.io.*;
-
-import javax.media.opengl.*;
-import com.sun.opengl.util.texture.*;
-
-import net.java.joglutils.msg.actions.*;
-import net.java.joglutils.msg.collections.*;
-import net.java.joglutils.msg.math.*;
-import net.java.joglutils.msg.nodes.*;
-
-/** A very basic test of the Minimal Scene Graph library. */
-
-public class Test {
- public static void main(String[] args) {
- Frame frame = new Frame("Minimal Scene Graph (MSG) Test");
- GLCanvas canvas = new GLCanvas();
- canvas.addGLEventListener(new Listener());
- frame.add(canvas);
- frame.setSize(512, 512);
- frame.setVisible(true);
- frame.addWindowListener(new WindowAdapter() {
- public void windowClosing(WindowEvent e) {
- new Thread(new Runnable() {
- public void run() {
- System.exit(0);
- }
- }).start();
- }
- });
- }
-
- static class Listener implements GLEventListener {
- private Separator root;
- private GLRenderAction renderAction;
-
- public void init(GLAutoDrawable drawable) {
- root = new Separator();
- PerspectiveCamera cam = new PerspectiveCamera();
- cam.setPosition(new Vec3f(0, 0, 2));
- root.addChild(cam);
- Coordinate3 coordNode = new Coordinate3();
- Vec3fCollection coords = new Vec3fCollection();
- // First triangle
- coords.add(new Vec3f( 1, 1, 0));
- coords.add(new Vec3f(-1, 1, 0));
- coords.add(new Vec3f(-1, -1, 0));
- // Second triangle
- coords.add(new Vec3f( 1, 1, 0));
- coords.add(new Vec3f(-1, -1, 0));
- coords.add(new Vec3f( 1, -1, 0));
- coordNode.setData(coords);
- root.addChild(coordNode);
-
- // Texture coordinates
- TextureCoordinate2 texCoordNode = new TextureCoordinate2();
- Vec2fCollection texCoords = new Vec2fCollection();
- // First triangle
- texCoords.add(new Vec2f( 1, 1));
- texCoords.add(new Vec2f( 0, 1));
- texCoords.add(new Vec2f( 0, 0));
- // Second triangle
- texCoords.add(new Vec2f( 1, 1));
- texCoords.add(new Vec2f( 0, 0));
- texCoords.add(new Vec2f( 1, 0));
- texCoordNode.setData(texCoords);
- root.addChild(texCoordNode);
-
- // Colors
- Color4 colorNode = new Color4();
- Vec4fCollection colors = new Vec4fCollection();
- // First triangle
- colors.add(new Vec4f(1.0f, 1.0f, 1.0f, 1.0f));
- colors.add(new Vec4f(1.0f, 1.0f, 1.0f, 1.0f));
- colors.add(new Vec4f(0.0f, 0.0f, 0.0f, 0.0f));
- // Second triangle
- colors.add(new Vec4f(1.0f, 1.0f, 1.0f, 1.0f));
- colors.add(new Vec4f(0.0f, 0.0f, 0.0f, 0.0f));
- colors.add(new Vec4f(0.0f, 0.0f, 0.0f, 0.0f));
- colorNode.setData(colors);
- root.addChild(colorNode);
-
- TriangleSet tris = new TriangleSet();
- tris.setNumTriangles(2);
- root.addChild(tris);
-
- // Testing transforms
- Transform xform = new Transform();
- xform.getTransform().setTranslation(new Vec3f(2, -2, 0));
- // xform.getTransform().setRotation(new Rotf(new Vec3f(0, 1, 0), (float) (-Math.PI / 4)));
- root.addChild(xform);
-
- root.addChild(tris);
-
- GL gl = drawable.getGL();
- gl.glEnable(GL.GL_DEPTH_TEST);
-
- renderAction = new GLRenderAction();
- }
-
- public void display(GLAutoDrawable drawable) {
- GL gl = drawable.getGL();
- gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
- renderAction.apply(root);
- }
-
- public void reshape(GLAutoDrawable drawable, int x, int y, int w, int h) {}
- public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) {}
- }
-}
+package net.java.joglutils.msg.test;
+
+import java.awt.Frame;
+import java.awt.event.*;
+import java.io.*;
+
+import javax.media.opengl.*;
+import javax.media.opengl.awt.*;
+import com.sun.opengl.util.texture.*;
+
+import net.java.joglutils.msg.actions.*;
+import net.java.joglutils.msg.collections.*;
+import net.java.joglutils.msg.math.*;
+import net.java.joglutils.msg.nodes.*;
+
+/** A very basic test of the Minimal Scene Graph library. */
+
+public class Test {
+ public static void main(String[] args) {
+ Frame frame = new Frame("Minimal Scene Graph (MSG) Test");
+ GLCanvas canvas = new GLCanvas();
+ canvas.addGLEventListener(new Listener());
+ frame.add(canvas);
+ frame.setSize(512, 512);
+ frame.setVisible(true);
+ frame.addWindowListener(new WindowAdapter() {
+ public void windowClosing(WindowEvent e) {
+ new Thread(new Runnable() {
+ public void run() {
+ System.exit(0);
+ }
+ }).start();
+ }
+ });
+ }
+
+ static class Listener implements GLEventListener {
+ private Separator root;
+ private GLRenderAction renderAction;
+
+ public void init(GLAutoDrawable drawable) {
+ root = new Separator();
+ PerspectiveCamera cam = new PerspectiveCamera();
+ cam.setPosition(new Vec3f(0, 0, 2));
+ root.addChild(cam);
+ Coordinate3 coordNode = new Coordinate3();
+ Vec3fCollection coords = new Vec3fCollection();
+ // First triangle
+ coords.add(new Vec3f( 1, 1, 0));
+ coords.add(new Vec3f(-1, 1, 0));
+ coords.add(new Vec3f(-1, -1, 0));
+ // Second triangle
+ coords.add(new Vec3f( 1, 1, 0));
+ coords.add(new Vec3f(-1, -1, 0));
+ coords.add(new Vec3f( 1, -1, 0));
+ coordNode.setData(coords);
+ root.addChild(coordNode);
+
+ // Texture coordinates
+ TextureCoordinate2 texCoordNode = new TextureCoordinate2();
+ Vec2fCollection texCoords = new Vec2fCollection();
+ // First triangle
+ texCoords.add(new Vec2f( 1, 1));
+ texCoords.add(new Vec2f( 0, 1));
+ texCoords.add(new Vec2f( 0, 0));
+ // Second triangle
+ texCoords.add(new Vec2f( 1, 1));
+ texCoords.add(new Vec2f( 0, 0));
+ texCoords.add(new Vec2f( 1, 0));
+ texCoordNode.setData(texCoords);
+ root.addChild(texCoordNode);
+
+ // Colors
+ Color4 colorNode = new Color4();
+ Vec4fCollection colors = new Vec4fCollection();
+ // First triangle
+ colors.add(new Vec4f(1.0f, 1.0f, 1.0f, 1.0f));
+ colors.add(new Vec4f(1.0f, 1.0f, 1.0f, 1.0f));
+ colors.add(new Vec4f(0.0f, 0.0f, 0.0f, 0.0f));
+ // Second triangle
+ colors.add(new Vec4f(1.0f, 1.0f, 1.0f, 1.0f));
+ colors.add(new Vec4f(0.0f, 0.0f, 0.0f, 0.0f));
+ colors.add(new Vec4f(0.0f, 0.0f, 0.0f, 0.0f));
+ colorNode.setData(colors);
+ root.addChild(colorNode);
+
+ TriangleSet tris = new TriangleSet();
+ tris.setNumTriangles(2);
+ root.addChild(tris);
+
+ // Testing transforms
+ Transform xform = new Transform();
+ xform.getTransform().setTranslation(new Vec3f(2, -2, 0));
+ // xform.getTransform().setRotation(new Rotf(new Vec3f(0, 1, 0), (float) (-Math.PI / 4)));
+ root.addChild(xform);
+
+ root.addChild(tris);
+
+ GL gl = drawable.getGL();
+ gl.glEnable(GL.GL_DEPTH_TEST);
+
+ renderAction = new GLRenderAction();
+ }
+
+ public void display(GLAutoDrawable drawable) {
+ GL gl = drawable.getGL();
+ gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
+ renderAction.apply(root);
+ }
+
+ public void reshape(GLAutoDrawable drawable, int x, int y, int w, int h) {}
+ public void dispose(GLAutoDrawable drawable) {}
+ }
+}
diff --git a/src/net/java/joglutils/test3ds/Main.java b/src/net/java/joglutils/test3ds/Main.java
index d2b6c09..593c1a4 100644
--- a/src/net/java/joglutils/test3ds/Main.java
+++ b/src/net/java/joglutils/test3ds/Main.java
@@ -40,12 +40,8 @@ import com.sun.opengl.util.Animator;
import java.awt.Frame;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
-import javax.media.opengl.GL;
-import javax.media.opengl.GLAutoDrawable;
-import javax.media.opengl.GLCanvas;
-import javax.media.opengl.GLCapabilities;
-import javax.media.opengl.GLDrawableFactory;
-import javax.media.opengl.GLEventListener;
+import javax.media.opengl.*;
+import javax.media.opengl.awt.*;
import javax.media.opengl.glu.GLU;
public class Main {
@@ -84,8 +80,8 @@ public class Main {
public void display(GLAutoDrawable gLDrawable)
{
- final GL gl = gLDrawable.getGL();
- gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
+ final GL2 gl = gLDrawable.getGL().getGL2();
+ gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT);
gl.glLoadIdentity();
gl.glPushMatrix();
@@ -97,12 +93,7 @@ public class Main {
}
- /** Called when the display mode has been changed. <B>!! CURRENTLY UNIMPLEMENTED IN JOGL !!</B>
- * @param gLDrawable The GLDrawable object.
- * @param modeChanged Indicates if the video mode has changed.
- * @param deviceChanged Indicates if the video device has changed.
- */
- public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) {}
+ public void dispose(GLAutoDrawable drawable) {}
/** Called by the drawable immediately after the OpenGL context is
* initialized for the first time. Can be used to perform one-time OpenGL
@@ -111,13 +102,13 @@ public class Main {
*/
public void init(GLAutoDrawable gLDrawable)
{
- final GL gl = gLDrawable.getGL();
+ final GL2 gl = gLDrawable.getGL().getGL2();
gl.glClearColor(0.0f, 0.0f, 0.0f, 0.3f);
gl.glClearDepth(1.0f);
- gl.glEnable(GL.GL_DEPTH_TEST);
- gl.glDepthFunc(GL.GL_LEQUAL);
- gl.glHint(GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST);
+ gl.glEnable(GL2.GL_DEPTH_TEST);
+ gl.glDepthFunc(GL2.GL_LEQUAL);
+ gl.glHint(GL2.GL_PERSPECTIVE_CORRECTION_HINT, GL2.GL_NICEST);
if (!model.isLoaded())
model.load(gLDrawable, "globe.3ds");
@@ -139,17 +130,17 @@ public class Main {
*/
public void reshape(GLAutoDrawable gLDrawable, int x, int y, int width, int height)
{
- final GL gl = gLDrawable.getGL();
+ final GL2 gl = gLDrawable.getGL().getGL2();
final GLU glu = new GLU();
if (height <= 0) // avoid a divide by zero error!
height = 1;
final float h = (float)width / (float)height;
gl.glViewport(0, 0, width, height);
- gl.glMatrixMode(GL.GL_PROJECTION);
+ gl.glMatrixMode(GL2.GL_PROJECTION);
gl.glLoadIdentity();
gl.glOrtho(-1000, 1000, -1000, 1000, -10000, 10000);
- gl.glMatrixMode(GL.GL_MODELVIEW);
+ gl.glMatrixMode(GL2.GL_MODELVIEW);
gl.glLoadIdentity();
}
}
diff --git a/src/net/java/joglutils/test3ds/MyModel.java b/src/net/java/joglutils/test3ds/MyModel.java
index 1d8ec95..fbdca36 100644
--- a/src/net/java/joglutils/test3ds/MyModel.java
+++ b/src/net/java/joglutils/test3ds/MyModel.java
@@ -42,8 +42,7 @@ import com.sun.opengl.util.texture.TextureCoords;
import com.sun.opengl.util.texture.TextureIO;
import java.io.File;
import java.io.IOException;
-import javax.media.opengl.GL;
-import javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.*;
public class MyModel extends Model3DS
{
@@ -67,7 +66,7 @@ public class MyModel extends Model3DS
if (!super.load(file))
return false;
- GL gl = gLDrawable.getGL();
+ GL2 gl = gLDrawable.getGL().getGL2();
int numMaterials = materials.size();
texture = new Texture[numMaterials];
@@ -77,7 +76,7 @@ public class MyModel extends Model3DS
}
compiledList = gl.glGenLists(1);
- gl.glNewList(compiledList, GL.GL_COMPILE);
+ gl.glNewList(compiledList, GL2.GL_COMPILE);
genList(gLDrawable);
gl.glEndList();
@@ -88,7 +87,7 @@ public class MyModel extends Model3DS
public void render(GLAutoDrawable gLDrawable)
{
- GL gl = gLDrawable.getGL();
+ GL2 gl = gLDrawable.getGL().getGL2();
gl.glCallList(compiledList);
}
@@ -106,7 +105,7 @@ public class MyModel extends Model3DS
private void genList(GLAutoDrawable gLDrawable)
{
- GL gl = gLDrawable.getGL();
+ GL2 gl = gLDrawable.getGL().getGL2();
TextureCoords coords;
for (int i=0; i<objects.size(); i++) {
@@ -117,7 +116,7 @@ public class MyModel extends Model3DS
coords = texture[tempObj.materialID].getImageTexCoords();
}
- gl.glBegin(GL.GL_TRIANGLES);
+ gl.glBegin(GL2.GL_TRIANGLES);
for (int j=0; j<tempObj.numOfFaces; j++) {
for (int whichVertex=0; whichVertex<3; whichVertex++) {
int index = tempObj.faces[j].vertIndex[whichVertex];