summaryrefslogtreecommitdiffstats
path: root/src/demos/cg
diff options
context:
space:
mode:
Diffstat (limited to 'src/demos/cg')
-rw-r--r--src/demos/cg/runtime_ogl/cgGL_vertex_example.java20
-rw-r--r--src/demos/cg/runtime_ogl_vertex_fragment/runtime_ogl_vertex_fragment.java30
2 files changed, 27 insertions, 23 deletions
diff --git a/src/demos/cg/runtime_ogl/cgGL_vertex_example.java b/src/demos/cg/runtime_ogl/cgGL_vertex_example.java
index f1f41dd..e8ca280 100644
--- a/src/demos/cg/runtime_ogl/cgGL_vertex_example.java
+++ b/src/demos/cg/runtime_ogl/cgGL_vertex_example.java
@@ -33,8 +33,10 @@
package demos.cg.runtime_ogl;
-import net.java.games.cg.*;
-import net.java.games.jogl.*;
+import com.sun.opengl.cg.*;
+import javax.media.opengl.*;
+import javax.media.opengl.glu.*;
+import com.sun.opengl.utils.*;
import java.awt.*;
import java.awt.event.*;
@@ -54,6 +56,7 @@ public class cgGL_vertex_example implements GLEventListener
private final int TextureRes = 512;
+ private GLU glu = new GLU();
private static CGcontext Context = null;
private static CGprogram Program = null;
private static CGparameter KdParam = null;
@@ -154,7 +157,7 @@ public class cgGL_vertex_example implements GLEventListener
CgGL.cgGLDisableProfile(profile);
}
- public void display(GLDrawable drawable)
+ public void display(GLAutoDrawable drawable)
{
GL gl = drawable.getGL();
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
@@ -173,12 +176,12 @@ public class cgGL_vertex_example implements GLEventListener
v[1][2] = v[2][2] = v[5][2] = v[6][2] = -1;
}
- public void displayChanged(GLDrawable drawable, boolean modeChanged, boolean deviceChanged)
+ public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged)
{
// nothing
}
- public void init(GLDrawable drawable)
+ public void init(GLAutoDrawable drawable)
{
// Note: we initialize Cg in this init() method instead of main()
// because Cg (apparently) requires an active OpenGL context in order to
@@ -223,13 +226,12 @@ public class cgGL_vertex_example implements GLEventListener
CheckCgError();
}
GL gl = drawable.getGL();
- GLU glu = drawable.getGLU();
InitializeCube(CubeVertices);
/* Enable a single OpenGL light. */
- gl.glLightfv(GL.GL_LIGHT0, GL.GL_DIFFUSE, LightDiffuse);
- gl.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, LightPosition);
+ gl.glLightfv(GL.GL_LIGHT0, GL.GL_DIFFUSE, LightDiffuse, 0);
+ gl.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, LightPosition, 0);
gl.glEnable(GL.GL_LIGHT0);
if (false) { // #if 0
gl.glEnable(GL.GL_LIGHTING);
@@ -259,7 +261,7 @@ public class cgGL_vertex_example implements GLEventListener
}
- public void reshape(GLDrawable drawable, int x, int y, int width, int height)
+ public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height)
{
// do nothing
}
diff --git a/src/demos/cg/runtime_ogl_vertex_fragment/runtime_ogl_vertex_fragment.java b/src/demos/cg/runtime_ogl_vertex_fragment/runtime_ogl_vertex_fragment.java
index 0c389e1..51fe8d5 100644
--- a/src/demos/cg/runtime_ogl_vertex_fragment/runtime_ogl_vertex_fragment.java
+++ b/src/demos/cg/runtime_ogl_vertex_fragment/runtime_ogl_vertex_fragment.java
@@ -33,9 +33,11 @@
package demos.cg.runtime_ogl_vertex_fragment;
-import net.java.games.cg.*;
-import net.java.games.jogl.*;
-import net.java.games.jogl.util.*;
+import com.sun.opengl.cg.*;
+import javax.media.opengl.*;
+import javax.media.opengl.glu.*;
+import com.sun.opengl.utils.*;
+import com.sun.opengl.utils.*;
import java.awt.*;
import java.awt.event.*;
@@ -55,6 +57,7 @@ public class runtime_ogl_vertex_fragment implements GLEventListener
// in as well as handles to the vertex and fragment program used in this
// demo.
+ private GLU glu = new GLU();
CGcontext context;
CGprogram vertexProgram, fragmentProgram;
@@ -91,7 +94,7 @@ public class runtime_ogl_vertex_fragment implements GLEventListener
// and all the rest happens in the display function...
}
- public void init(GLDrawable drawable)
+ public void init(GLAutoDrawable drawable)
{
// Use debug pipeline
// drawable.setGL(new DebugGL(drawable.getGL()));
@@ -125,11 +128,10 @@ public class runtime_ogl_vertex_fragment implements GLEventListener
private static int curTime = 0;
// display callback function
- public void display(GLDrawable drawable)
+ public void display(GLAutoDrawable drawable)
{
GL gl = drawable.getGL();
- GLU glu = drawable.getGLU();
// The usual OpenGL stuff to clear the screen and set up viewing.
gl.glClearColor(.25f, .25f, .25f, 1.0f);
@@ -168,15 +170,15 @@ public class runtime_ogl_vertex_fragment implements GLEventListener
// vertex shader could be modified so that these were uniform for
// better efficiency, but this gives us flexibility for the future.
float Kd[] = { .7f, .2f, .2f }, Ks[] = { .9f, .9f, .9f };
- CgGL.cgGLSetParameter3fv(CgGL.cgGetNamedParameter(vertexProgram, "diffuse"), Kd);
- CgGL.cgGLSetParameter3fv(CgGL.cgGetNamedParameter(vertexProgram, "specular"), Ks);
+ CgGL.cgGLSetParameter3fv(CgGL.cgGetNamedParameter(vertexProgram, "diffuse"), Kd, 0);
+ CgGL.cgGLSetParameter3fv(CgGL.cgGetNamedParameter(vertexProgram, "specular"), Ks, 0);
// Now bind uniform parameters to fragment shader
float lightPos[] = { 3, 2, -3 };
- CgGL.cgGLSetParameter3fv(CgGL.cgGetNamedParameter(fragmentProgram, "Plight"), lightPos);
+ CgGL.cgGLSetParameter3fv(CgGL.cgGetNamedParameter(fragmentProgram, "Plight"), lightPos, 0);
float lightColor[] = { 1, 1, 1 };
CgGL.cgGLSetParameter3fv(CgGL.cgGetNamedParameter(fragmentProgram, "lightColor"),
- lightColor);
+ lightColor, 0);
CgGL.cgGLSetParameter1f(CgGL.cgGetNamedParameter(fragmentProgram, "shininess"), 40);
// And finally, enable the approprate texture for fragment shader; the
@@ -273,7 +275,7 @@ public class runtime_ogl_vertex_fragment implements GLEventListener
// checkerboard--which is used to modulate the diffuse channel in the
// fragment shader.
int[] handle = new int[1];
- gl.glGenTextures(1, handle);
+ gl.glGenTextures(1, handle, 0);
// Basic OpenGL texture state setup
gl.glBindTexture(GL.GL_TEXTURE_2D, handle[0]);
@@ -303,7 +305,7 @@ public class runtime_ogl_vertex_fragment implements GLEventListener
}
}
- gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_RGBA, RES, RES, 0, GL.GL_RGBA, GL.GL_FLOAT, data);
+ gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_RGBA, RES, RES, 0, GL.GL_RGBA, GL.GL_FLOAT, FloatBuffer.wrap(data));
// Tell Cg which texture handle should be associated with the sampler2D
// parameter to the fragment shader.
@@ -417,12 +419,12 @@ public class runtime_ogl_vertex_fragment implements GLEventListener
N.put(offsetN + 2, P.get(offsetP + 2));
}
- public void displayChanged(GLDrawable drawable, boolean modeChanged, boolean deviceChanged)
+ public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged)
{
// nothing
}
- public void reshape(GLDrawable drawable, int x, int y, int width, int height)
+ public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height)
{
// do nothing
}