summaryrefslogtreecommitdiffstats
path: root/src/demos/cg
diff options
context:
space:
mode:
authorKenneth Russel <[email protected]>2005-07-07 22:50:13 +0000
committerKenneth Russel <[email protected]>2005-07-07 22:50:13 +0000
commit3cce9fefe99b2a9fe7372c5be21ba7a49f98bf66 (patch)
treef1c260f62b6659b9fb5fa6d96e4c8723e4fc55d7 /src/demos/cg
parent9d278dff86c07218ff2616745381ccc2689f8ea5 (diff)
Merged with main trunk (tag JOGL_PRE_1_1_1)
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/../svn-server-sync/jogl-demos/branches/JSR-231@98 3298f667-5e0e-4b4a-8ed4-a3559d26a5f4
Diffstat (limited to 'src/demos/cg')
-rw-r--r--src/demos/cg/runtime_ogl/cgGL_vertex_example.java14
-rw-r--r--src/demos/cg/runtime_ogl_vertex_fragment/runtime_ogl_vertex_fragment.java26
2 files changed, 30 insertions, 10 deletions
diff --git a/src/demos/cg/runtime_ogl/cgGL_vertex_example.java b/src/demos/cg/runtime_ogl/cgGL_vertex_example.java
index ec2cb9a..f1f41dd 100644
--- a/src/demos/cg/runtime_ogl/cgGL_vertex_example.java
+++ b/src/demos/cg/runtime_ogl/cgGL_vertex_example.java
@@ -31,11 +31,14 @@
*
*/
+package demos.cg.runtime_ogl;
+
import net.java.games.cg.*;
import net.java.games.jogl.*;
import java.awt.*;
import java.awt.event.*;
+import java.io.*;
/**
* cgGL_vertex_example: simple demo of Nvidia CgGL API. Based upon C version
@@ -187,9 +190,14 @@ public class cgGL_vertex_example implements GLEventListener
CheckCgError();
/* Test adding source text to context */
- Program = CgGL.cgCreateProgramFromFile(
- Context, CgGL.CG_SOURCE, "cgGL_vertex_example.cg",
- profile, null, null);
+ try {
+ Program = CgGL.cgCreateProgramFromStream(
+ Context, CgGL.CG_SOURCE,
+ getClass().getClassLoader().getResourceAsStream("demos/cg/runtime_ogl/cgGL_vertex_example.cg"),
+ profile, null, null);
+ } catch (IOException e) {
+ throw new RuntimeException("Error loading Cg vertex program", e);
+ }
CheckCgError();
System.err.println(
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 3ceabc0..0c389e1 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
@@ -31,6 +31,8 @@
*
*/
+package demos.cg.runtime_ogl_vertex_fragment;
+
import net.java.games.cg.*;
import net.java.games.jogl.*;
import net.java.games.jogl.util.*;
@@ -67,9 +69,6 @@ public class runtime_ogl_vertex_fragment implements GLEventListener
GLCanvas canvas = GLDrawableFactory.getFactory().createGLCanvas(new GLCapabilities());
canvas.addGLEventListener(new runtime_ogl_vertex_fragment());
- // Use debug pipeline
- canvas.setGL(new DebugGL(canvas.getGL()));
-
frame.add(canvas);
frame.setSize(512, 512);
final Animator animator = new Animator(canvas);
@@ -94,6 +93,9 @@ public class runtime_ogl_vertex_fragment implements GLEventListener
public void init(GLDrawable drawable)
{
+ // Use debug pipeline
+ // drawable.setGL(new DebugGL(drawable.getGL()));
+
GL gl = drawable.getGL();
// Basic Cg setup; register a callback function for any errors
@@ -235,8 +237,13 @@ public class runtime_ogl_vertex_fragment implements GLEventListener
// Load and compile the vertex program from demo_vert.cg; hold on to the
// handle to it that is returned.
- vertexProgram = CgGL.cgCreateProgramFromFile(context, CgGL.CG_SOURCE, "demo_vert.cg",
- vertexProfile, null, null);
+ try {
+ vertexProgram = CgGL.cgCreateProgramFromStream(context, CgGL.CG_SOURCE,
+ getClass().getClassLoader().getResourceAsStream("demos/cg/runtime_ogl_vertex_fragment/demo_vert.cg"),
+ vertexProfile, null, null);
+ } catch (IOException e) {
+ throw new RuntimeException("Error loading Cg vertex program", e);
+ }
if (!CgGL.cgIsProgramCompiled(vertexProgram))
CgGL.cgCompileProgram(vertexProgram);
@@ -245,8 +252,13 @@ public class runtime_ogl_vertex_fragment implements GLEventListener
CgGL.cgGLLoadProgram(vertexProgram);
// And similarly set things up for the fragment program.
- fragmentProgram = CgGL.cgCreateProgramFromFile(context, CgGL.CG_SOURCE, "demo_frag.cg",
- fragmentProfile, null, null);
+ try {
+ fragmentProgram = CgGL.cgCreateProgramFromStream(context, CgGL.CG_SOURCE,
+ getClass().getClassLoader().getResourceAsStream("demos/cg/runtime_ogl_vertex_fragment/demo_frag.cg"),
+ fragmentProfile, null, null);
+ } catch (IOException e) {
+ throw new RuntimeException("Error loading Cg fragment program", e);
+ }
if (!CgGL.cgIsProgramCompiled(fragmentProgram)) {
CgGL.cgCompileProgram(fragmentProgram);
}