aboutsummaryrefslogtreecommitdiffstats
path: root/demos/glStencilTest.java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2000-11-18 06:43:49 +0000
committerSven Gothel <[email protected]>2000-11-18 06:43:49 +0000
commit880653d31a8f1ff8384fdbc75b84934bceecfdb8 (patch)
treebdafb71416f176d2a4b73bf716c9dc3f13685a8b /demos/glStencilTest.java
Initial revision
Diffstat (limited to 'demos/glStencilTest.java')
-rwxr-xr-xdemos/glStencilTest.java95
1 files changed, 95 insertions, 0 deletions
diff --git a/demos/glStencilTest.java b/demos/glStencilTest.java
new file mode 100755
index 0000000..79a2e4b
--- /dev/null
+++ b/demos/glStencilTest.java
@@ -0,0 +1,95 @@
+import gl4java.awt.*;
+import java.awt.*;
+import java.awt.Dimension;
+import gl4java.GLContext;
+import gl4java.GLFunc;
+
+public class glStencilTest {
+
+ protected class MyCanvas extends GLCanvas {
+
+ public MyCanvas(int w, int h) {
+ super(w,h);
+ GLContext.gljNativeDebug = false;
+ GLContext.gljClassDebug = false;
+ }
+
+ public void preInit() {
+ stencilBits = 8;
+ }
+
+ public void init() {
+ gl.glMatrixMode(GL_PROJECTION);
+ gl.glOrtho(-1,1,-1,1,-50.0,50.0);
+ gl.glMatrixMode(GL_MODELVIEW);
+ glj.gljCheckGL();
+ }
+
+ public void reshape(int w, int h) {
+ Dimension d=new Dimension(w,h);
+ if (!cvsIsInit()) return;
+ if( glj.gljMakeCurrent() == false ) {
+ System.out.println("problem in use() method");
+ return;
+ }
+ setSize(d);
+ gl.glViewport(0,0,w,h);
+ glj.gljCheckGL();
+ glj.gljFree();
+ }
+
+ public void display() {
+ int i;
+
+ if( glj.gljMakeCurrent() == false ) {
+ System.out.println("problem in use() method");
+ return;
+ }
+
+ gl.glPushMatrix();
+ gl.glClear(GL_COLOR_BUFFER_BIT);
+ glu.gluLookAt(0, 0, 20, 0, 0, 0, 0, 1, 0);
+
+ gl.glBegin(GL_POLYGON);
+ gl.glVertex2d(0,-0.5);
+ gl.glVertex2d(0.5,0.5);
+ gl.glVertex2d(-0.5,0.5);
+ gl.glEnd();
+
+
+ // Examine some OpenGL properties
+ int [] res=new int[6];
+
+ gl.glGetIntegerv(GL_STENCIL_BITS,res);
+ System.out.println("Stencil bits are "+res[0]);
+
+ gl.glGetIntegerv(GL_RED_BITS,res);
+ System.out.println("Color bits are "+res[0]);
+
+ gl.glPopMatrix();
+ glj.gljSwap();
+ glj.gljCheckGL();
+ glj.gljFree();
+ }
+ }
+
+ protected MyCanvas cvs;
+ protected Frame frame;
+
+ public glStencilTest() {
+ frame = new Frame( "OpenGL" );
+ cvs= new MyCanvas(640,480);
+ frame.setSize(640,480);
+ frame.add("Center", cvs);
+ frame.setVisible(true);
+ }
+
+ public static void main(java.lang.String[] args) {
+ try {
+ glStencilTest g=new glStencilTest();
+ } catch (Throwable exception) {
+ System.err.println("Exception occurred in main()");
+ exception.printStackTrace(System.out);
+ }
+ }
+}