diff options
author | Sven Gothel <[email protected]> | 2000-11-18 06:43:49 +0000 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2000-11-18 06:43:49 +0000 |
commit | 880653d31a8f1ff8384fdbc75b84934bceecfdb8 (patch) | |
tree | bdafb71416f176d2a4b73bf716c9dc3f13685a8b /demos |
Initial revision
Diffstat (limited to 'demos')
338 files changed, 56050 insertions, 0 deletions
diff --git a/demos/GLLandScape/GLLandScape-readme.txt b/demos/GLLandScape/GLLandScape-readme.txt new file mode 100644 index 0000000..7ceb26f --- /dev/null +++ b/demos/GLLandScape/GLLandScape-readme.txt @@ -0,0 +1,58 @@ +GLLandScape V 1.1 (for JDK 1.1.X + GL4Java) +=========================================== + +you need to have: +================= + + o jdk 1.1.X or java2 + o GL4Java V 2.X.X (http://www.jausoft.com/gl4java.html) + +ABOUT +===== + +GLLandScape is another demonstration and test for GL4Java. + +The landscape algorythms are taken from +Nicholas Anderson's Landscape V1.0 ! + http://www.fortunecity.com/skyscraper/online/263 + mailto:[email protected] + +A landscape will be generated, where you can walk through :-) + +FUTURE +====== + +I ported Nicholas Anderson's Landscape V1.0, +because i am thinking that this is a fine virtual-world, +to create a game :-) + +CHANGES +======= + +Now using display lists for the world -> faster ! + +INSTALL +======= + +be sure to have GL4Java correctly installed +(check the manuals at http://www.jausoft.com/gl4java.html ! + +extract the GLLandScape.zip file ! + +generate the classes with: �javac *.java� + +run GLLandScape with: 'java GLLandScapeFrame' + +thats it :-) + +THANXS +====== + +Thanxs to Nicholas Anderson for his source code of +Landscape V1.0, which was written in ANSI-C and uses +OpenGL GLU and GLUT ! + +Sven Goethel + + + diff --git a/demos/GLLandScape/GLLandScape1-big.html b/demos/GLLandScape/GLLandScape1-big.html new file mode 100644 index 0000000..06dcdf4 --- /dev/null +++ b/demos/GLLandScape/GLLandScape1-big.html @@ -0,0 +1,14 @@ +<HTML>
+<HEAD>
+<TITLE>Göthel Hard- und Software Entwicklungen</TITLE>
+</HEAD>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+<hr>
+<applet code="GLLandScape1Applet.class" width=800 height=600>
+<param name=frames value="55">
+</applet>
+<hr>
+</BODY>
+</HTML>
+
+
diff --git a/demos/GLLandScape/GLLandScape1-big_plugin13.html b/demos/GLLandScape/GLLandScape1-big_plugin13.html new file mode 100644 index 0000000..1cb8f63 --- /dev/null +++ b/demos/GLLandScape/GLLandScape1-big_plugin13.html @@ -0,0 +1,46 @@ +<HTML>
+<HEAD>
+<TITLE>Göthel Hard- und Software Entwicklungen</TITLE>
+</HEAD>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+<hr>
+<!--"CONVERTED_APPLET"-->
+<!-- CONVERTER VERSION 1.3 --> +<SCRIPT LANGUAGE="JavaScript"><!-- + var _info = navigator.userAgent; var _ns = false; + var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0); +//--></SCRIPT> +<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!-- + var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0))); +//--></SCRIPT></COMMENT> + +<SCRIPT LANGUAGE="JavaScript"><!-- + if (_ie == true) document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = 800 HEIGHT = 600 codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0"><NOEMBED><XMP>'); + else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.3" CODE = "GLLandScape1Applet.class" WIDTH = 800 HEIGHT = 600 frames = "55" scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html"><NOEMBED><XMP>'); +//--></SCRIPT> +<APPLET CODE = "GLLandScape1Applet.class" WIDTH = 800 HEIGHT = 600></XMP> +<PARAM NAME = CODE VALUE = "GLLandScape1Applet.class" >
+ +<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3"> +<PARAM NAME="scriptable" VALUE="false"> +<PARAM NAME = frames VALUE ="55">
+ +</APPLET> + +</NOEMBED></EMBED></OBJECT> + + +<!-- +<APPLET CODE = "GLLandScape1Applet.class" WIDTH = 800 HEIGHT = 600>
+<PARAM NAME = frames VALUE ="55">
+
+
+</APPLET> +--> +<!--"END_CONVERTED_APPLET"-->
+
+<hr>
+</BODY>
+</HTML>
+
+
diff --git a/demos/GLLandScape/GLLandScape1.html b/demos/GLLandScape/GLLandScape1.html new file mode 100644 index 0000000..5521afd --- /dev/null +++ b/demos/GLLandScape/GLLandScape1.html @@ -0,0 +1,14 @@ +<HTML>
+<HEAD>
+<TITLE>Göthel Hard- und Software Entwicklungen</TITLE>
+</HEAD>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+<hr>
+<applet code="GLLandScape1Applet.class" width=500 height=300>
+<param name=frames value="55">
+</applet>
+<hr>
+</BODY>
+</HTML>
+
+
diff --git a/demos/GLLandScape/GLLandScape1.java b/demos/GLLandScape/GLLandScape1.java new file mode 100644 index 0000000..209f6db --- /dev/null +++ b/demos/GLLandScape/GLLandScape1.java @@ -0,0 +1,714 @@ +/** + * @(#) GLLandScape1.java + */ +import gl4java.GLContext; +import gl4java.awt.GLAnimCanvas; +import java.awt.*; +import java.awt.event.*; +import java.lang.*; +import java.util.*; + +/** + * This is meant as an skellekton for porting/writing + * OpenGL to gl4java + * + * If you are interessting in further Documentation and/or + * the history of gl4java follow the following link. + * + * <pre> + <a href="gl4java.html#_top_">The gl4java Documentation</a> + * </pre> + * <p> + * + * This NEW dummy code uses repaint(), + * the std. java thread, and sleep to suspend with a given + * Frames per secounds value !! + * (of course - sDisplay is still avaiable, + * but i guess it is not that reliable ... comments welcome ) + * + * + * @see WinDataAccess + * @version 1.1, 3. MAI 1999 + * @author Sven Goethel + * + */ +class GLLandScape1 extends GLAnimCanvas +{ + /** + * Variables for the LandScape + */ + class COLOUR + { + public float r, g, b; + + public COLOUR() + { + r = 0.0f; + g = 0.0f; + b = 0.0f; + } + + } + + /* The constant MAP is used throughout the program and represents the MAP of + the matrix/landscape. */ + static final int MAP = 256; + + /* This is the holding space for the landscape. */ + float y[/*MAP+2*/][/*MAP+2*/]; + + char object[/*MAP+1*/][/*MAP+1*/]; + + /* This is the holding space for the landscape colours. */ + COLOUR c[/*MAP+1*/][/*MAP+1*/]; + + public static final int FORWARD = 1; + + public static final int UP = 2; + + public static final int TURNLEFT = 3; + + public static final int STRAFELEFT = 4; + + public static final int LOOKUP = 5; + + public static final int LOOKSET = 6; + + static final int TRUE = 1; + + static final int FALSE = 0; + + static final int WIDTH = 32; + + /* The width of the texture map. */ + byte texImg[/*WIDTH * WIDTH * 4*/]; + + int texName[/*1*/] = {0}; + + short comp = 32; + + /* Scale modifier. */ + short temp, texture_mapping = FALSE, land_fogging = TRUE, + flat_shading = FALSE; + + /* Initial eye position and vector of sight. */ + float posx, posy, posz; + + float lookx, looky, lookz; + + float mySpeed = 0; + + int myDir = FORWARD; + + // the display list for the land .. + int theLand; + + + public GLLandScape1(int w, int h) + { + super(w,h); + } + + public void init_pos() + { + posx = 4500.0f; + posy = 256.0f; + posz = 4500.0f; + lookx = 4096.0f; + looky = 0.0f; + lookz = 4096.0f; + mySpeed = 0; + System.out.println("init_pos"); + } + + public void init() + { + int i, j; + /* here we should add and initialize our JAVA components */ + texImg = new byte[WIDTH * WIDTH * 4]; + y = new float[MAP + 2][MAP + 2]; + object = new char[MAP + 1][MAP + 1]; + c = new COLOUR[MAP + 1][MAP + 1]; + for(i = 0;i <= MAP;i++) + { + for(j = 0;j <= MAP;j++) + { + c[i][j] = new COLOUR(); + } + } + float fogColor[] = {0.75f, 0.75f, 1.0f, 1.0f}; + init_pos(); + // srand(224); + + create_fractal(); + genLand(); + + // srand((unsigned)time(NULL)); + makeTexture(); + /* ... and furthet OpenGL init's - like you want to */ + gl.glPixelStorei(GL_UNPACK_ALIGNMENT,1); + if(texture_mapping == TRUE) + gl.glEnable(GL_TEXTURE_2D); + gl.glGenTextures(1,texName); + gl.glBindTexture(GL_TEXTURE_2D,texName[0]); + gl.glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT); + gl.glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT); + gl.glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST); + gl.glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST); + gl.glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA,WIDTH,WIDTH,0,GL_RGBA,GL_UNSIGNED_BYTE,texImg); + gl.glEnable(GL_DEPTH_TEST); + if(flat_shading == FALSE) + gl.glShadeModel(GL_SMOOTH); + else + gl.glShadeModel(GL_FLAT); + if(land_fogging == TRUE) + gl.glEnable(GL_FOG); + else + gl.glDisable(GL_FOG); + gl.glFogi(GL_FOG_MODE,GL_LINEAR); + gl.glFogfv(GL_FOG_COLOR,fogColor); + gl.glFogf(GL_FOG_DENSITY,0.4f); + gl.glFogf(GL_FOG_START,800.0f); + gl.glFogf(GL_FOG_END,1000.0f); + gl.glClearColor(0.75f,0.75f,1.0f,1.0f); + // FreeConsole(); + glj.gljCheckGL(); + + + Dimension dim = getSize(); + reshape(dim.width,dim.height); + myMove(FORWARD,mySpeed,true); + check_height(); + repaint(); + /* and start our working thread ... */ + start(); + } + + public void display() + { + int i; + /* Standard gl4java Init */ + if(!cvsIsInit() || glj.gljMakeCurrent() == false) + { + System.out.println("problem in use() method"); + return; + } + // ... just render it + + gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + gl.glCallList(theLand); + + myMove(FORWARD,mySpeed,true); + check_height(); + + setSuspended(mySpeed==0); + + /* For your animation dutys ;-) */ + glj.gljSwap(); + glj.gljCheckGL(); + glj.gljFree(); + } + + /*************************************************************/ + /*************************************************************/ + /*************************************************************/ + /*************************************************************/ + /*************************************************************/ + /*************************************************************/ + void create_fractal() + { + int bsize, csize; + int x, z, i; + int r = 256; + /* The maximum random value. */ + float gradient, shadow = 0.5f, n; + /* Make the matrix flat. */ + for(x = 0;x < MAP + 2;x++) + for(z = 0;z < MAP + 2;z++) + y[x][z] = 0L; + bsize = MAP; + for(i = 0;i < 8;i++) + { + for(x = 0;x < MAP;x += bsize) + for(z = 0;z < MAP;z += bsize) + y[x][z] += (Math.random() * r - r / 2); + if(i > 4) + r = r / 2; + csize = bsize / 2; + if(csize > 0) + { + for(x = 0;x < MAP;x += bsize) + for(z = 0;z < MAP;z += bsize) + { + if(x < MAP) + y[x + csize][z] = (y[x + bsize][z] + y[x][z]) / 2; + if(z < MAP) + y[x][z + csize] = (y[x][z + bsize] + y[x][z]) / 2; + if(x < MAP && z < MAP) + y[x + csize][z + csize] = (y[x][z] + y[x + bsize][z] + y[x][z + bsize] + y[x + bsize][z + bsize]) / 4; + } + } + bsize = csize; + } + for(x = 0;x < MAP;x++) + { + for(z = 0;z < MAP;z++) + { + y[x][z] = y[x][z] + y[x + 1][z] + y[x + 1][z + 1] + y[x][z + 1]; + y[x][z] /= 4.0f; + } + } + for(x = MAP;x > 0;x--) + { + for(z = 0;z < MAP;z++) + { + y[x][z] = y[x][z] + y[x - 1][z] + y[x - 1][z + 1] + y[x][z + 1]; + y[x][z] /= 4.0f; + } + } + /* put trees in various places on grassland. */ + for(x = 0;x < MAP;x++) + { + for(z = 0;z < MAP;z++) + { + if(((int)(Math.random() * 256.0f)) % 8 == 0 && y[x][z] > 0 && y[x][z] < 64) + { + object[x][z] = 't'; + } + else + { + object[x][z] = 'n'; + } + } + } + for(x = 0;x < MAP;x++) + for(z = 0;z < MAP;z++) + if(y[x][z] > 8) + { + n = y[x][z]; + y[x][z] *= n; + y[x][z] /= 256.0f; + } + for(x = 0;x <= MAP;x++) + { + for(z = 0;z <= MAP;z++) + { + gradient = ((float)(y[x][z] - y[x + 1][z])) / 100.0f; + if(y[x][z] > 64) + { + if((y[x][z] - y[x][z + 1]) < 8 && (y[x][z] - y[x][z + 1]) > -8 && (y[x][z] - y[x + 1][z]) < 8 && (y[x][z] - y[x + 1][z]) > -8) + { + c[x][z].g = gradient + 0.75f; + c[x][z].r = c[x][z].g; + c[x][z].b = c[x][z].g; + } + else + { + c[x][z].r = gradient + 0.75f; + c[x][z].g = c[x][z].r * 0.8f; + c[x][z].b = c[x][z].r * 0.5f; + } + } + else + if(y[x][z] > 0) + { + c[x][z].g = gradient + 0.75f; + c[x][z].r = c[x][z].g * 0.6f; + c[x][z].b = 0.0f; + } + else + { + c[x][z].r = gradient + 1.0f; + c[x][z].g = c[x][z].r * 0.75f; + c[x][z].b = c[x][z].r * 0.5f; + } + } + } + for(x = 0;x <= MAP;x++) + for(z = 0;z <= MAP;z++) + { + if(y[x][z] < 0) + y[x][z] /= 4.0f; + } + + } + + void makeTexture() + { + int i, j, h, c; + for(i = 0;i < WIDTH;i++) + { + for(j = 0;j < WIDTH;j++) + { + c = (int)(Math.random() * 15 + 240); + h = i * WIDTH * 4 + j * 4; + texImg[h + 0] = (byte)c; + texImg[h + 1] = (byte)c; + texImg[h + 2] = (byte)c; + texImg[h + 3] = (byte)255; + } + } + } + + void check_height() + { + float x0, x1, lx, lz, x, z, midpoint; + int fx, fz; + x = (posx / (comp * 1.0f)); + z = (posz / (comp * 1.0f)); + fx = (int)(x); + fz = (int)(z); + lx = x - fx; + lz = z - fz; + if(fx >= MAP + 2 || fz >= MAP + 2 || fx < 0 || fz < 0) + { + init_pos(); + return; + } + x0 = y[fx][fz] + (y[fx][fz + 1] - y[fx][fz]) * lz; + x1 = y[fx + 1][fz] + (y[fx + 1][fz + 1] - y[fx + 1][fz]) * lz; + midpoint = x0 + (x1 - x0) * lx; + posy = midpoint + 16.0f; + } + + /* Function that moves the eye / turns the angle of sight. */ + /* Updates scene if update. */ + void myMove(int dir, float amount, boolean update) + { + float diff = (float)Math.sqrt(lookx * lookx + lookz * lookz); + /* + float alpha = (float) + Math.atan(Math.abs(lookz)/Math.abs(lookx)); + if(lookx<0&&lookz>=0) + alpha+=(float)(Math.PI/2.0); + else if(lookx>=0&&lookz>=0) + alpha+=0; + else if(lookx<0&&lookz<0) + alpha+=(float)Math.PI; + else if(lookx>=0&&lookz<0) + alpha+=(float)((3.0*Math.PI)/2.0); + float _alpha = (float) (alpha*180f/Math.PI ); + */ + boolean do_repaint = false; + lookx /= diff; + lookz /= diff; + //myDir=dir; + switch(dir) + { + case FORWARD: + posx += lookx * amount; + posz += lookz * amount; + break; + case TURNLEFT: + lookx = lookx * (float)Math.cos(amount) + lookz * (float)Math.sin(amount); + lookz = lookz * (float)Math.cos(amount) - lookx * (float)Math.sin(amount); + // lookx^2 + lookz^2 != 1 for some reason. Fix. + lookx /= diff; + lookz /= diff; + do_repaint = true; + break; + case STRAFELEFT: + posx += lookz * amount; + posz -= lookx * amount; + break; + case UP: + posy += amount; + do_repaint = true; + break; + case LOOKUP: + looky += amount; + do_repaint = true; + break; + case LOOKSET: + looky = amount; + do_repaint = true; + break; + } + int x = (int)(posx / (comp * 1.0f)); + int z = (int)(posz / (comp * 1.0f)); + if(x > MAP) + posx = 0; + if(z > MAP) + posz = 0; + if(posx < 0) + posx = MAP * comp; + if(posz < 0) + posz = MAP * comp; + if (update) + { + gl.glMatrixMode(GL_MODELVIEW); gl.glLoadIdentity(); + glu.gluLookAt(posx, posy, posz, + posx+lookx, posy+looky, + posz+lookz, 0.0f,1.0f,0.0f); + if( do_repaint ) + repaint(); + } + } + + void draw_tree(int x, int z) + { + int x1, y1, z1; + y1 = (int)y[x][z]; + x1 = x * comp; + z1 = z * comp; + gl.glBegin(GL_POLYGON); + gl.glColor3f(0.6f,0.4f,0.0f); + gl.glVertex3f(x1 - 2,y1 + 5,z1); + gl.glVertex3f(x1 + 2,y1 + 5,z1); + gl.glVertex3f(x1 + 2,y1,z1); + gl.glVertex3f(x1 - 2,y1,z1); + gl.glEnd(); + gl.glBegin(GL_POLYGON); + gl.glVertex3f(x1,y1 + 5,z1 - 2); + gl.glVertex3f(x1,y1 + 5,z1 + 2); + gl.glVertex3f(x1,y1,z1 + 2); + gl.glVertex3f(x1,y1,z1 - 2); + gl.glEnd(); + gl.glBegin(GL_POLYGON); + gl.glColor3f(0.35f,0.7f,0.0f); + gl.glTexCoord2f(0.0f,0.0f); + gl.glVertex3f(x1 - 10,y1 + 5,z1); + gl.glTexCoord2f(0.5f,1.0f); + gl.glVertex3f(x1,y1 + 25,z1); + gl.glTexCoord2f(1.0f,0.0f); + gl.glVertex3f(x1 + 10,y1 + 5,z1); + gl.glEnd(); + gl.glBegin(GL_POLYGON); + gl.glColor3f(0.4f,0.8f,0.0f); + gl.glTexCoord2f(0.0f,0.0f); + gl.glVertex3f(x1,y1 + 5,z1 - 10); + gl.glTexCoord2f(0.5f,1.0f); + gl.glVertex3f(x1,y1 + 25,z1); + gl.glTexCoord2f(1.0f,0.0f); + gl.glVertex3f(x1,y1 + 5,z1 + 10); + gl.glEnd(); + } + + void genLand() + { + int x, z, position_x, position_z; + float x1, x2, z1, z2; + + theLand = gl.glGenLists(1); + gl.glNewList(theLand, GL_COMPILE); + + position_x = (int)(posx / comp); + position_z = (int)(posz / comp); + for(x = position_x - 16;x < position_x + 17;x++) + for(z = position_z - 16;z < position_z + 17;z++) + { + if(x > 0 && x < MAP && z > 0 && z < MAP) + { + x1 = x * comp; + x2 = x * comp + comp; + z1 = z * comp; + z2 = z * comp + comp; + gl.glBegin(GL_POLYGON); + gl.glColor3f(c[x][z].r,c[x][z].g,c[x][z].b); + gl.glTexCoord2f(0.0f,0.0f); + gl.glVertex3f(x1,y[x][z],z1); + gl.glColor3f(c[x + 1][z].r,c[x + 1][z].g,c[x + 1][z].b); + gl.glTexCoord2f(1.0f,0.0f); + gl.glVertex3f(x2,y[x + 1][z],z1); + gl.glColor3f(c[x][z + 1].r,c[x][z + 1].g,c[x][z + 1].b); + gl.glTexCoord2f(0.0f,1.0f); + gl.glVertex3f(x1,y[x][z + 1],z2); + gl.glEnd(); + gl.glBegin(GL_POLYGON); + gl.glColor3f(c[x + 1][z + 1].r,c[x + 1][z + 1].g,c[x + 1][z + 1].b); + gl.glTexCoord2f(1.0f,1.0f); + gl.glVertex3f(x2,y[x + 1][z + 1],z2); + gl.glColor3f(c[x][z + 1].r,c[x][z + 1].g,c[x][z + 1].b); + gl.glTexCoord2f(0.0f,1.0f); + gl.glVertex3f(x1,y[x][z + 1],z2); + gl.glColor3f(c[x + 1][z].r,c[x + 1][z].g,c[x + 1][z].b); + gl.glTexCoord2f(1.0f,0.0f); + gl.glVertex3f(x2,y[x + 1][z],z1); + gl.glEnd(); + if(object[x][z] == 't') + draw_tree(x,z); + } + } + gl.glEndList(); + glj.gljCheckGL(); + } + + public void reshape(int w, int h) + { + glj.gljResize(w,h); + gl.glViewport(0,0,w,h); + gl.glMatrixMode(GL_PROJECTION); + gl.glLoadIdentity(); + glu.gluPerspective(60.0,(double)w / (double)h,1.0,1000.0); + gl.glMatrixMode(GL_MODELVIEW); + gl.glLoadIdentity(); + glu.gluLookAt(posx,posy,posz,posx + lookx,posy + looky,posz + lookz,0.0,1.0,0.0); + } + + public float getMySpeed() + { + return mySpeed; + } + + public void setMySpeed(float s) + { + mySpeed = s; + setSuspended(false); + } + + public boolean getTextureState() + { + return texture_mapping == TRUE; + } + + public void setTexture(boolean t) + { + if(t) + { + if(texture_mapping == FALSE) + { + if(glj!=null) + { + if(glj.gljMakeCurrent() == false) + { + System.out.println("problem in use() method"); + return; + } + gl.glEnable(GL_TEXTURE_2D); + texture_mapping = TRUE; + glj.gljCheckGL(); + repaint(); + } + } + } + else + { + if(texture_mapping == TRUE) + { + if(glj!=null) + { + if(glj.gljMakeCurrent() == false) + { + System.out.println("problem in use() method"); + return; + } + gl.glDisable(GL_TEXTURE_2D); + texture_mapping = FALSE; + glj.gljCheckGL(); + repaint(); + } + } + } + setSuspended(false); + } + + public boolean getFogState() + { + return land_fogging == TRUE; + } + + public void setFog(boolean t) + { + if(t) + { + if(land_fogging == FALSE) + { + if(glj!=null) + { + if(glj.gljMakeCurrent() == false) + { + System.out.println("problem in use() method"); + return; + } + gl.glEnable(GL_FOG); + land_fogging = TRUE; + glj.gljCheckGL(); + repaint(); + } + } + } + else + { + if(land_fogging == TRUE) + { + if(glj!=null) + { + if(glj.gljMakeCurrent() == false) + { + System.out.println("problem in use() method"); + return; + } + gl.glDisable(GL_FOG); + land_fogging = FALSE; + glj.gljCheckGL(); + repaint(); + } + } + } + setSuspended(false); + } + + public boolean getFlatShadeState() + { + return flat_shading == TRUE; + } + + public void setFlatShading(boolean t) + { + if(t) + { + if(flat_shading == FALSE) + { + if(glj!=null) + { + if(glj.gljMakeCurrent() == false) + { + System.out.println("problem in use() method"); + return; + } + gl.glShadeModel(GL_FLAT); + flat_shading = TRUE; + glj.gljCheckGL(); + repaint(); + } + } + } + else + { + if(flat_shading == TRUE) + { + if(glj!=null) + { + if(glj.gljMakeCurrent() == false) + { + System.out.println("problem in use() method"); + return; + } + gl.glShadeModel(GL_SMOOTH); + flat_shading = FALSE; + glj.gljCheckGL(); + repaint(); + } + } + } + setSuspended(false); + } + + public void newFractal() + { + create_fractal(); + if(!cvsIsInit() || glj.gljMakeCurrent() == false) + { + System.out.println("problem in use() method"); + return; + } + gl.glFinish(); + gl.glDeleteLists(theLand, 1); + genLand(); + check_height(); + repaint(); + setSuspended(false); + } + +} + diff --git a/demos/GLLandScape/GLLandScape1Applet.java b/demos/GLLandScape/GLLandScape1Applet.java new file mode 100644 index 0000000..155f934 --- /dev/null +++ b/demos/GLLandScape/GLLandScape1Applet.java @@ -0,0 +1,399 @@ + +import gl4java.GLContext; +import java.awt.*; +import java.applet.*; +import java.awt.event.*; + +public class GLLandScape1Applet extends Applet + implements MouseListener, KeyListener, ActionListener +{ + GLLandScape1 landScape = null; + + Button bTexture = null; + Button bShading = null; + Button bFog = null; + Button bNewFractal = null; + Button bInfo = null; + + Button bFps; TextField tFps; + + boolean gameOn = true; + + SpeedTimer tMySpeed = null; + + public void init() + { + init(0,0); + } + + public void init(int w, int h) + { + super.init(); + + setLayout(new BorderLayout()); + + Panel glFeatures = new Panel(); + glFeatures.setLayout(new GridLayout(6,1)); + glFeatures.add(bTexture =new Button("Texture")); + glFeatures.add(bShading =new Button("Shading")); + glFeatures.add(bFog =new Button("Fogging")); + glFeatures.add(bNewFractal =new Button("Fractal")); + bTexture.addMouseListener(this); + bShading.addMouseListener(this); + bFog.addMouseListener(this); + bNewFractal.addMouseListener(this); + add("East", glFeatures); + + Panel pFps = new Panel(); + pFps.setLayout(new GridLayout(1,3)); + pFps.add(bInfo =new Button("info")); + pFps.add(bFps =new Button("get fps")); + pFps.add(tFps =new TextField()); + bInfo.addMouseListener(this); + bFps.addMouseListener(this); + tFps.addActionListener(this); + add("South", pFps); + + if(w==0 && h==0) + { + Dimension d = getSize(); + landScape= new GLLandScape1(d.width, d.height); + } else { + landScape= new GLLandScape1(w, h); + } + landScape.setAnimateFps(30.0); + landScape.addMouseListener(this); + landScape.addKeyListener(this); + + tMySpeed = new SpeedTimer(landScape, 200); + + landScape.requestFocus(); + landScape.setMySpeed(0); + + add("Center", landScape); + } + + public void destroy() + { + landScape.stop(); + landScape.cvsDispose(); + landScape.removeMouseListener(this); + landScape.removeKeyListener(this); + } + + public void start() + { + landScape.start(); + } + + public void stop() + { + landScape.stop(); + } + + public static void main( String args[] ) { + String gljLib=null; + String glLib=null; + String gluLib=null; + + if(args.length>0) + gljLib = args[0]; + if(args.length>1) + glLib = args[1]; + if(args.length>2) + gluLib = args[2]; + + if(GLContext.loadNativeLibraries(gljLib, glLib, gluLib)==false) + System.out.println("GLCanvasV2 could not load native libs:"+ + gljLib + ", " + glLib + ", " + gluLib); + + GLContext.gljNativeDebug = false; + GLContext.gljClassDebug = false; + + GLLandScape1Applet window = + new GLLandScape1Applet(); + + Frame f = new Frame(); + f.add(window); + window.init(500,300); + f.pack(); + f.setVisible(true); + + f.addWindowListener( new WindowAdapter() + { + public void windowClosed(WindowEvent e) + { + System.exit(0); + } + public void windowClosing(WindowEvent e) + { + System.exit(0); + } + } + ); + + + window.start(); + } + + // Methods required for the implementation of MouseListener + public void mouseEntered( MouseEvent evt ) + { + Component comp = evt.getComponent(); + if( comp.equals(landScape ) ) + { + landScape.requestFocus(); + } + } + + public void mouseExited( MouseEvent evt ) + { + } + + public void mousePressed( MouseEvent evt ) + { + } + public void mouseReleased( MouseEvent evt ) { + } + + public void mouseClicked( MouseEvent evt ) + { + Component comp = evt.getComponent(); + + if( comp.equals(bTexture ) ) + landScape.setTexture( ! landScape.getTextureState()); + else if( comp.equals(bNewFractal ) ) + landScape.newFractal(); + else if( comp.equals(bShading ) ) + landScape.setFlatShading(!landScape.getFlatShadeState()); + else if( comp.equals(bFog ) ) + landScape.setFog( ! landScape.getFogState()); + else if( comp.equals(landScape) ) + landScape.setSuspended(false); + else if( comp.equals(bFps) ) + { + double fps = 0; + + landScape.stopFpsCounter(); + fps=landScape.getFps(); + tFps.setText(String.valueOf(fps)); + landScape.resetFpsCounter(); + } + else if( comp.equals(bInfo) ) + { + InfoWin iw = new InfoWin(); + } + } + + + public void keyTyped(KeyEvent e) + { + } + + public void keyPressed(KeyEvent e) + { + int key = e.getKeyCode(); + + if( gameOn==true ) + { + if ( key==KeyEvent.VK_LEFT ) + { + landScape.myMove(landScape.TURNLEFT, 0.1f, true); + tMySpeed.start(); + } + else if ( key==KeyEvent.VK_RIGHT ) + { + landScape.myMove(landScape.TURNLEFT, -0.1f, true); + tMySpeed.start(); + } + else if ( key==KeyEvent.VK_UP ) + { + float v = tMySpeed.getSpeed(); + + if ( e.isShiftDown() ) + { + tMySpeed.setSpeed(v+2.0f); + } + else { + tMySpeed.setSpeed(v+1.0f); + } + tMySpeed.start(); + } + else if ( key==KeyEvent.VK_DOWN ) + { + float v = tMySpeed.getSpeed(); + + if ( e.isShiftDown() ) + tMySpeed.setSpeed(v/2.0f); + else + tMySpeed.setSpeed(v-1.0f); + tMySpeed.start(); + } + else if ( key==KeyEvent.VK_PAGE_UP ) + { + landScape.myMove(landScape.LOOKUP, 0.1f, true); + tMySpeed.start(); + } + else if ( key==KeyEvent.VK_PAGE_DOWN ) + { + landScape.myMove(landScape.LOOKUP, -0.1f, true); + tMySpeed.start(); + } + else if ( key==KeyEvent.VK_END ) + { + landScape.myMove(landScape.LOOKSET, 0f, true); + tMySpeed.start(); + } + } + } + + public void keyReleased(KeyEvent e) + { + int key = e.getKeyCode(); + + if( gameOn==true && + ( key==KeyEvent.VK_UP || + key==KeyEvent.VK_DOWN + ) + ) + { + //ts.start(); + } + else if( gameOn==true && + ( key==KeyEvent.VK_LEFT || + key==KeyEvent.VK_RIGHT + ) + ) + { + //landScape.noMySpeed(); + } + } + + public void actionPerformed(ActionEvent event) + { + Object source = event.getSource(); + + if ( source == tFps ) + { + try { + double FramesPerSec= + Double.valueOf(tFps.getText()).doubleValue(); + landScape.setAnimateFps(FramesPerSec); + landScape.setSuspended(false); + } catch (NumberFormatException s) { + System.out.println("wrong fps format, use float .."); + } + + } + } + + class SpeedTimer implements Runnable { + protected Thread me = null; + protected boolean to=false, started=false; + protected int _t; + + protected float speed = 0.0f; + protected GLLandScape1 _ls; + + public SpeedTimer(GLLandScape1 ls, int t) + { _ls=ls; _t=t; } + + public void start() + { + if(me!=null) stop(); + to=false; + started=true; + + me = new Thread(this); + me.start(); + } + + public void stop() { + if(me!=null) + { + me.stop(); + me=null; + started=false; + to=false; + } + } + + public void run() { + if(me!=null) + { + try {me.sleep(_t,0);} catch (InterruptedException e){} + to=true; + while(speed>1.0f) + { + speed/=2.0f; + _ls.setMySpeed(speed); + try {me.sleep(_t,0);} catch (InterruptedException e){} + } + speed = 0.0f; + _ls.setMySpeed(0f); + } + } + + public boolean isActive() { return to; } + public boolean isStarted() { return started; } + + public float getSpeed() { return speed; } + public void setSpeed(float v) + { speed=v; + _ls.setMySpeed(speed); + } + + } + + class InfoWin extends Frame + implements ActionListener + { + protected Button DismissButton; + + String text = + "GLLandScape1 V 1.2\n"+ + "by Sven Goethel\n"+ + "\thttp://www.jausoft.com/gl4java.html\n"+ + "\tmailto:[email protected]\n\n"+ + "The original sources for the lanscape algorythms,\n"+ + "are taken from Nicholas Anderson's Landscape V1.0 !\n"+ + "\thttp://www.fortunecity.com/skyscraper/online/263\n"+ + "\tmailto:[email protected]\n\n"+ + "usage:\n"+ + "\t ARROW-UP : accelerate\n"+ + "\t ARROW-UP + SHIFT : accelerate fast \n"+ + "\t ARROW-DOWN : de-accelerate\n"+ + "\t ARROW-DOWN + SHIFT : de-accelerate fast\n"+ + "\t ARROW-LEFT : turn left\n"+ + "\t ARROW-right : turn right\n"+ + "\t PAGE-UP : look-up\n"+ + "\t PAGE-DOWN : look-down\n"+ + "\t END : look normal\n\n"+ + "Have a lot of fun - Sven Goethel\n"; + + public InfoWin() + { + setTitle("INFO"); + setName("INFO"); + + setLayout(new BorderLayout()); + add("Center", new TextArea(text, 25, 50)); + + add("South", DismissButton = new Button("dismiss")); + DismissButton.addActionListener(this); + + pack(); + setVisible(true); + + toFront(); + } + + public void actionPerformed(ActionEvent event) { + if ( event.getSource() == DismissButton) + { + setVisible(false); + dispose(); + } + } + } +} diff --git a/demos/GLLandScape/GLLandScape1_plugin13.html b/demos/GLLandScape/GLLandScape1_plugin13.html new file mode 100644 index 0000000..a3f188b --- /dev/null +++ b/demos/GLLandScape/GLLandScape1_plugin13.html @@ -0,0 +1,46 @@ +<HTML>
+<HEAD>
+<TITLE>Göthel Hard- und Software Entwicklungen</TITLE>
+</HEAD>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+<hr>
+<!--"CONVERTED_APPLET"-->
+<!-- CONVERTER VERSION 1.3 --> +<SCRIPT LANGUAGE="JavaScript"><!-- + var _info = navigator.userAgent; var _ns = false; + var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0); +//--></SCRIPT> +<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!-- + var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0))); +//--></SCRIPT></COMMENT> + +<SCRIPT LANGUAGE="JavaScript"><!-- + if (_ie == true) document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = 500 HEIGHT = 300 codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0"><NOEMBED><XMP>'); + else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.3" CODE = "GLLandScape1Applet.class" WIDTH = 500 HEIGHT = 300 frames = "55" scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html"><NOEMBED><XMP>'); +//--></SCRIPT> +<APPLET CODE = "GLLandScape1Applet.class" WIDTH = 500 HEIGHT = 300></XMP> +<PARAM NAME = CODE VALUE = "GLLandScape1Applet.class" >
+ +<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3"> +<PARAM NAME="scriptable" VALUE="false"> +<PARAM NAME = frames VALUE ="55">
+ +</APPLET> + +</NOEMBED></EMBED></OBJECT> + + +<!-- +<APPLET CODE = "GLLandScape1Applet.class" WIDTH = 500 HEIGHT = 300>
+<PARAM NAME = frames VALUE ="55">
+
+
+</APPLET> +--> +<!--"END_CONVERTED_APPLET"-->
+
+<hr>
+</BODY>
+</HTML>
+
+
diff --git a/demos/GLLandScape/GLLandScape1w1-big.html b/demos/GLLandScape/GLLandScape1w1-big.html new file mode 100644 index 0000000..7e5eae0 --- /dev/null +++ b/demos/GLLandScape/GLLandScape1w1-big.html @@ -0,0 +1,14 @@ +<HTML>
+<HEAD>
+<TITLE>Göthel Hard- und Software Entwicklungen</TITLE>
+</HEAD>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+<hr>
+<applet code="GLLandScape1w1Applet.class" width=800 height=600>
+<param name=frames value="55">
+</applet>
+<hr>
+</BODY>
+</HTML>
+
+
diff --git a/demos/GLLandScape/GLLandScape1w1-big_plugin13.html b/demos/GLLandScape/GLLandScape1w1-big_plugin13.html new file mode 100644 index 0000000..1dc35f8 --- /dev/null +++ b/demos/GLLandScape/GLLandScape1w1-big_plugin13.html @@ -0,0 +1,46 @@ +<HTML>
+<HEAD>
+<TITLE>Göthel Hard- und Software Entwicklungen</TITLE>
+</HEAD>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+<hr>
+<!--"CONVERTED_APPLET"-->
+<!-- CONVERTER VERSION 1.3 --> +<SCRIPT LANGUAGE="JavaScript"><!-- + var _info = navigator.userAgent; var _ns = false; + var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0); +//--></SCRIPT> +<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!-- + var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0))); +//--></SCRIPT></COMMENT> + +<SCRIPT LANGUAGE="JavaScript"><!-- + if (_ie == true) document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = 800 HEIGHT = 600 codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0"><NOEMBED><XMP>'); + else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.3" CODE = "GLLandScape1w1Applet.class" WIDTH = 800 HEIGHT = 600 frames = "55" scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html"><NOEMBED><XMP>'); +//--></SCRIPT> +<APPLET CODE = "GLLandScape1w1Applet.class" WIDTH = 800 HEIGHT = 600></XMP> +<PARAM NAME = CODE VALUE = "GLLandScape1w1Applet.class" >
+ +<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3"> +<PARAM NAME="scriptable" VALUE="false"> +<PARAM NAME = frames VALUE ="55">
+ +</APPLET> + +</NOEMBED></EMBED></OBJECT> + + +<!-- +<APPLET CODE = "GLLandScape1w1Applet.class" WIDTH = 800 HEIGHT = 600>
+<PARAM NAME = frames VALUE ="55">
+
+
+</APPLET> +--> +<!--"END_CONVERTED_APPLET"-->
+
+<hr>
+</BODY>
+</HTML>
+
+
diff --git a/demos/GLLandScape/GLLandScape1w1.html b/demos/GLLandScape/GLLandScape1w1.html new file mode 100644 index 0000000..074a19e --- /dev/null +++ b/demos/GLLandScape/GLLandScape1w1.html @@ -0,0 +1,14 @@ +<HTML>
+<HEAD>
+<TITLE>Göthel Hard- und Software Entwicklungen</TITLE>
+</HEAD>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+<hr>
+<applet code="GLLandScape1w1Applet.class" width=500 height=300>
+<param name=frames value="55">
+</applet>
+<hr>
+</BODY>
+</HTML>
+
+
diff --git a/demos/GLLandScape/GLLandScape1w1.java b/demos/GLLandScape/GLLandScape1w1.java new file mode 100644 index 0000000..9f6f1a3 --- /dev/null +++ b/demos/GLLandScape/GLLandScape1w1.java @@ -0,0 +1,781 @@ +/** + * @(#) GLLandScape1w1.java + */ +import gl4java.GLContext; +import gl4java.awt.GLAnimCanvas; +import java.awt.*; +import java.awt.event.*; +import java.lang.*; +import java.util.*; + +/** + * This is meant as an skellekton for porting/writing + * OpenGL to gl4java + * + * If you are interessting in further Documentation and/or + * the history of gl4java follow the following link. + * + * <pre> + <a href="gl4java.html#_top_">The gl4java Documentation</a> + * </pre> + * <p> + * + * This NEW dummy code uses repaint(), + * the std. java thread, and sleep to suspend with a given + * Frames per secounds value !! + * (of course - sDisplay is still avaiable, + * but i guess it is not that reliable ... comments welcome ) + * + * + * @see WinDataAccess + * @version 1.1, 3. MAI 1999 + * @author Sven Goethel + * + */ +class GLLandScape1w1 extends GLAnimCanvas +{ + /** + * Variables for the LandScape + */ + class COLOUR + { + public float r, g, b; + + public COLOUR() + { + r = 0.0f; + g = 0.0f; + b = 0.0f; + } + + } + + /* The constant MAP is used throughout the program and represents the MAP of + the matrix/landscape. */ + static final int MAP = 256; + + /* This is the holding space for the landscape. */ + float y[/*MAP+2*/][/*MAP+2*/]; + + char object[/*MAP+1*/][/*MAP+1*/]; + + /* This is the holding space for the landscape colours. */ + COLOUR c[/*MAP+1*/][/*MAP+1*/]; + + public static final int FORWARD = 1; + + public static final int UP = 2; + + public static final int TURNLEFT = 3; + + public static final int STRAFELEFT = 4; + + public static final int LOOKUP = 5; + + public static final int LOOKSET = 6; + + static final int TRUE = 1; + + static final int FALSE = 0; + + static final int WIDTH = 32; + + /* The width of the texture map. */ + byte texImg[/*WIDTH * WIDTH * 4*/]; + + int texName[/*1*/] = {0}; + + short comp = 32; + + /* Scale modifier. */ + short temp, texture_mapping = FALSE, land_fogging = TRUE, + flat_shading = FALSE; + + /* Initial eye position and vector of sight. */ + float posx, posy, posz; + + float lookx, looky, lookz; + + float mySpeed = 0; + + int myDir = FORWARD; + + // the display list for the land .. + int theLand; + + + final int MAX_PLANES = 15; + GlutPlaneObj planes[] = null; + Random random = null; + + + public GLLandScape1w1(int w, int h) + { + super(w,h); + } + + public void init_pos() + { + posx = 4500.0f; + posy = 256.0f; + posz = 4500.0f; + lookx = 4096.0f; + looky = 0.0f; + lookz = 4096.0f; + mySpeed = 0; + System.out.println("init_pos"); + } + + public void init() + { + int i, j; + /* here we should add and initialize our JAVA components */ + texImg = new byte[WIDTH * WIDTH * 4]; + y = new float[MAP + 2][MAP + 2]; + object = new char[MAP + 1][MAP + 1]; + c = new COLOUR[MAP + 1][MAP + 1]; + for(i = 0;i <= MAP;i++) + { + for(j = 0;j <= MAP;j++) + { + c[i][j] = new COLOUR(); + } + } + float fogColor[] = {0.75f, 0.75f, 1.0f, 1.0f}; + init_pos(); + // srand(224); + + create_fractal(); + genLand(); + + random = new Random(System.currentTimeMillis()); + planes = new GlutPlaneObj[MAX_PLANES]; + for (i = 0; i < MAX_PLANES; i++) + planes[i] = new GlutPlaneObj(gl, glu); + + // srand((unsigned)time(NULL)); + makeTexture(); + /* ... and furthet OpenGL init's - like you want to */ + gl.glPixelStorei(GL_UNPACK_ALIGNMENT,1); + if(texture_mapping == TRUE) + gl.glEnable(GL_TEXTURE_2D); + gl.glGenTextures(1,texName); + gl.glBindTexture(GL_TEXTURE_2D,texName[0]); + gl.glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT); + gl.glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT); + gl.glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST); + gl.glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST); + gl.glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA,WIDTH,WIDTH,0,GL_RGBA,GL_UNSIGNED_BYTE,texImg); + gl.glEnable(GL_DEPTH_TEST); + if(flat_shading == FALSE) + gl.glShadeModel(GL_SMOOTH); + else + gl.glShadeModel(GL_FLAT); + if(land_fogging == TRUE) + gl.glEnable(GL_FOG); + else + gl.glDisable(GL_FOG); + gl.glFogi(GL_FOG_MODE,GL_LINEAR); + gl.glFogfv(GL_FOG_COLOR,fogColor); + gl.glFogf(GL_FOG_DENSITY,0.4f); + gl.glFogf(GL_FOG_START,800.0f); + gl.glFogf(GL_FOG_END,1000.0f); + gl.glClearColor(0.75f,0.75f,1.0f,1.0f); + // FreeConsole(); + glj.gljCheckGL(); + + + Dimension dim = getSize(); + reshape(dim.width,dim.height); + myMove(FORWARD,mySpeed,true,false); + check_height(); + repaint(); + /* and start our working thread ... */ + start(); + } + + public void display() + { + int i; + /* Standard gl4java Init */ + if(!cvsIsInit() || glj.gljMakeCurrent() == false) + { + System.out.println("problem in use() method"); + return; + } + // ... just render it + + gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + gl.glCallList(theLand); + + gl.glShadeModel(GL_FLAT); + for (i = 0; i < MAX_PLANES; i++) + { + planes[i].display(); + } + if(flat_shading == FALSE) + gl.glShadeModel(GL_SMOOTH); + + myMove(FORWARD,mySpeed,true,false); + check_height(); + + + /* For your animation dutys ;-) */ + glj.gljSwap(); + glj.gljCheckGL(); + glj.gljFree(); + } + + public void addPlane() + { + for (int i = 0; i < MAX_PLANES; i++) + { + if (planes[i].speed == 0.0f) + { + int c = random.nextInt() & 0x07; + while (c == 0) c = random.nextInt() & 0x07; + float r = (float)((c >> 2) & 0x01); + float g = (float)((c >> 1) & 0x01); + float b = (float)(c & 0x01); + // Blue fades into the background; lighten it up. + if (c == 0x01) r = g = 0.4f; + planes[i].setColor(r,g,b); + planes[i].speed = + ((float)(random.nextInt() % 20)) * 0.001f + 0.02f; + if ((random.nextInt() & 0x01) != 0) + planes[i].speed *= -1.0f; + planes[i].theta = + ((float)(random.nextInt() % 257))*0.1111f; + planes[i].tick(); + if (isSuspended()) repaint(); + System.out.println("plane added"); + return; + } + } + } + + public void removePlane() + { + for (int i = MAX_PLANES - 1; i >= 0; i--) + { + if (planes[i].speed != 0.0f) + { + planes[i].speed = 0.0f; + if (isSuspended()) repaint(); + System.out.println("plane removed"); + return; + } + } + } + + /*************************************************************/ + /*************************************************************/ + /*************************************************************/ + /*************************************************************/ + /*************************************************************/ + /*************************************************************/ + void create_fractal() + { + int bsize, csize; + int x, z, i; + int r = 256; + /* The maximum random value. */ + float gradient, shadow = 0.5f, n; + /* Make the matrix flat. */ + for(x = 0;x < MAP + 2;x++) + for(z = 0;z < MAP + 2;z++) + y[x][z] = 0L; + bsize = MAP; + for(i = 0;i < 8;i++) + { + for(x = 0;x < MAP;x += bsize) + for(z = 0;z < MAP;z += bsize) + y[x][z] += (Math.random() * r - r / 2); + if(i > 4) + r = r / 2; + csize = bsize / 2; + if(csize > 0) + { + for(x = 0;x < MAP;x += bsize) + for(z = 0;z < MAP;z += bsize) + { + if(x < MAP) + y[x + csize][z] = (y[x + bsize][z] + y[x][z]) / 2; + if(z < MAP) + y[x][z + csize] = (y[x][z + bsize] + y[x][z]) / 2; + if(x < MAP && z < MAP) + y[x + csize][z + csize] = (y[x][z] + y[x + bsize][z] + y[x][z + bsize] + y[x + bsize][z + bsize]) / 4; + } + } + bsize = csize; + } + for(x = 0;x < MAP;x++) + { + for(z = 0;z < MAP;z++) + { + y[x][z] = y[x][z] + y[x + 1][z] + y[x + 1][z + 1] + y[x][z + 1]; + y[x][z] /= 4.0f; + } + } + for(x = MAP;x > 0;x--) + { + for(z = 0;z < MAP;z++) + { + y[x][z] = y[x][z] + y[x - 1][z] + y[x - 1][z + 1] + y[x][z + 1]; + y[x][z] /= 4.0f; + } + } + /* put trees in various places on grassland. */ + for(x = 0;x < MAP;x++) + { + for(z = 0;z < MAP;z++) + { + if(((int)(Math.random() * 256.0f)) % 8 == 0 && y[x][z] > 0 && y[x][z] < 64) + { + object[x][z] = 't'; + } + else + { + object[x][z] = 'n'; + } + } + } + for(x = 0;x < MAP;x++) + for(z = 0;z < MAP;z++) + if(y[x][z] > 8) + { + n = y[x][z]; + y[x][z] *= n; + y[x][z] /= 256.0f; + } + for(x = 0;x <= MAP;x++) + { + for(z = 0;z <= MAP;z++) + { + gradient = ((float)(y[x][z] - y[x + 1][z])) / 100.0f; + if(y[x][z] > 64) + { + if((y[x][z] - y[x][z + 1]) < 8 && (y[x][z] - y[x][z + 1]) > -8 && (y[x][z] - y[x + 1][z]) < 8 && (y[x][z] - y[x + 1][z]) > -8) + { + c[x][z].g = gradient + 0.75f; + c[x][z].r = c[x][z].g; + c[x][z].b = c[x][z].g; + } + else + { + c[x][z].r = gradient + 0.75f; + c[x][z].g = c[x][z].r * 0.8f; + c[x][z].b = c[x][z].r * 0.5f; + } + } + else + if(y[x][z] > 0) + { + c[x][z].g = gradient + 0.75f; + c[x][z].r = c[x][z].g * 0.6f; + c[x][z].b = 0.0f; + } + else + { + c[x][z].r = gradient + 1.0f; + c[x][z].g = c[x][z].r * 0.75f; + c[x][z].b = c[x][z].r * 0.5f; + } + } + } + for(x = 0;x <= MAP;x++) + for(z = 0;z <= MAP;z++) + { + if(y[x][z] < 0) + y[x][z] /= 4.0f; + } + + } + + void makeTexture() + { + int i, j, h, c; + for(i = 0;i < WIDTH;i++) + { + for(j = 0;j < WIDTH;j++) + { + c = (int)(Math.random() * 15 + 240); + h = i * WIDTH * 4 + j * 4; + texImg[h + 0] = (byte)c; + texImg[h + 1] = (byte)c; + texImg[h + 2] = (byte)c; + texImg[h + 3] = (byte)255; + } + } + } + + void check_height() + { + float x0, x1, lx, lz, x, z, midpoint; + int fx, fz; + x = (posx / (comp * 1.0f)); + z = (posz / (comp * 1.0f)); + fx = (int)(x); + fz = (int)(z); + lx = x - fx; + lz = z - fz; + if(fx >= MAP + 2 || fz >= MAP + 2 || fx < 0 || fz < 0) + { + init_pos(); + return; + } + x0 = y[fx][fz] + (y[fx][fz + 1] - y[fx][fz]) * lz; + x1 = y[fx + 1][fz] + (y[fx + 1][fz + 1] - y[fx + 1][fz]) * lz; + midpoint = x0 + (x1 - x0) * lx; + posy = midpoint + 16.0f; + } + + /* Function that moves the eye / turns the angle of sight. */ + /* Updates scene if update. */ + void myMove(int dir, float amount, boolean update, boolean fetchGLContext) + { + float diff = (float)Math.sqrt(lookx * lookx + lookz * lookz); + /* + float alpha = (float) + Math.atan(Math.abs(lookz)/Math.abs(lookx)); + if(lookx<0&&lookz>=0) + alpha+=(float)(Math.PI/2.0); + else if(lookx>=0&&lookz>=0) + alpha+=0; + else if(lookx<0&&lookz<0) + alpha+=(float)Math.PI; + else if(lookx>=0&&lookz<0) + alpha+=(float)((3.0*Math.PI)/2.0); + float _alpha = (float) (alpha*180f/Math.PI ); + */ + boolean do_repaint = false; + lookx /= diff; + lookz /= diff; + //myDir=dir; + switch(dir) + { + case FORWARD: + posx += lookx * amount; + posz += lookz * amount; + break; + case TURNLEFT: + lookx = lookx * (float)Math.cos(amount) + lookz * (float)Math.sin(amount); + lookz = lookz * (float)Math.cos(amount) - lookx * (float)Math.sin(amount); + // lookx^2 + lookz^2 != 1 for some reason. Fix. + lookx /= diff; + lookz /= diff; + do_repaint = true; + break; + case STRAFELEFT: + posx += lookz * amount; + posz -= lookx * amount; + break; + case UP: + posy += amount; + do_repaint = true; + break; + case LOOKUP: + looky += amount; + do_repaint = true; + break; + case LOOKSET: + looky = amount; + do_repaint = true; + break; + } + int x = (int)(posx / (comp * 1.0f)); + int z = (int)(posz / (comp * 1.0f)); + if(x > MAP) + posx = 0; + if(z > MAP) + posz = 0; + if(posx < 0) + posx = MAP * comp; + if(posz < 0) + posz = MAP * comp; + if (update) + { + if(fetchGLContext && glj.gljMakeCurrent() == false) + { + System.out.println("problem in use() method"); + return; + } + gl.glMatrixMode(GL_MODELVIEW); gl.glLoadIdentity(); + glu.gluLookAt(posx,posy,posz, + posx+lookx, posy+looky, + posz+lookz, 0.0f,1.0f,0.0f); + + if(fetchGLContext) + glj.gljFree(); + + if( do_repaint ) + repaint(); + } + } + + void draw_tree(int x, int z) + { + int x1, y1, z1; + y1 = (int)y[x][z]; + x1 = x * comp; + z1 = z * comp; + gl.glBegin(GL_POLYGON); + gl.glColor3f(0.6f,0.4f,0.0f); + gl.glVertex3f(x1 - 2,y1 + 5,z1); + gl.glVertex3f(x1 + 2,y1 + 5,z1); + gl.glVertex3f(x1 + 2,y1,z1); + gl.glVertex3f(x1 - 2,y1,z1); + gl.glEnd(); + gl.glBegin(GL_POLYGON); + gl.glVertex3f(x1,y1 + 5,z1 - 2); + gl.glVertex3f(x1,y1 + 5,z1 + 2); + gl.glVertex3f(x1,y1,z1 + 2); + gl.glVertex3f(x1,y1,z1 - 2); + gl.glEnd(); + gl.glBegin(GL_POLYGON); + gl.glColor3f(0.35f,0.7f,0.0f); + gl.glTexCoord2f(0.0f,0.0f); + gl.glVertex3f(x1 - 10,y1 + 5,z1); + gl.glTexCoord2f(0.5f,1.0f); + gl.glVertex3f(x1,y1 + 25,z1); + gl.glTexCoord2f(1.0f,0.0f); + gl.glVertex3f(x1 + 10,y1 + 5,z1); + gl.glEnd(); + gl.glBegin(GL_POLYGON); + gl.glColor3f(0.4f,0.8f,0.0f); + gl.glTexCoord2f(0.0f,0.0f); + gl.glVertex3f(x1,y1 + 5,z1 - 10); + gl.glTexCoord2f(0.5f,1.0f); + gl.glVertex3f(x1,y1 + 25,z1); + gl.glTexCoord2f(1.0f,0.0f); + gl.glVertex3f(x1,y1 + 5,z1 + 10); + gl.glEnd(); + } + + void genLand() + { + int x, z, position_x, position_z; + float x1, x2, z1, z2; + + theLand = gl.glGenLists(1); + gl.glNewList(theLand, GL_COMPILE); + + position_x = (int)(posx / comp); + position_z = (int)(posz / comp); + for(x = position_x - 16;x < position_x + 17;x++) + for(z = position_z - 16;z < position_z + 17;z++) + { + if(x > 0 && x < MAP && z > 0 && z < MAP) + { + x1 = x * comp; + x2 = x * comp + comp; + z1 = z * comp; + z2 = z * comp + comp; + gl.glBegin(GL_POLYGON); + gl.glColor3f(c[x][z].r,c[x][z].g,c[x][z].b); + gl.glTexCoord2f(0.0f,0.0f); + gl.glVertex3f(x1,y[x][z],z1); + gl.glColor3f(c[x + 1][z].r,c[x + 1][z].g,c[x + 1][z].b); + gl.glTexCoord2f(1.0f,0.0f); + gl.glVertex3f(x2,y[x + 1][z],z1); + gl.glColor3f(c[x][z + 1].r,c[x][z + 1].g,c[x][z + 1].b); + gl.glTexCoord2f(0.0f,1.0f); + gl.glVertex3f(x1,y[x][z + 1],z2); + gl.glEnd(); + gl.glBegin(GL_POLYGON); + gl.glColor3f(c[x + 1][z + 1].r,c[x + 1][z + 1].g,c[x + 1][z + 1].b); + gl.glTexCoord2f(1.0f,1.0f); + gl.glVertex3f(x2,y[x + 1][z + 1],z2); + gl.glColor3f(c[x][z + 1].r,c[x][z + 1].g,c[x][z + 1].b); + gl.glTexCoord2f(0.0f,1.0f); + gl.glVertex3f(x1,y[x][z + 1],z2); + gl.glColor3f(c[x + 1][z].r,c[x + 1][z].g,c[x + 1][z].b); + gl.glTexCoord2f(1.0f,0.0f); + gl.glVertex3f(x2,y[x + 1][z],z1); + gl.glEnd(); + if(object[x][z] == 't') + draw_tree(x,z); + } + } + gl.glEndList(); + glj.gljCheckGL(); + } + + public void reshape(int w, int h) + { + glj.gljResize(w,h); + gl.glViewport(0,0,w,h); + gl.glMatrixMode(GL_PROJECTION); + gl.glLoadIdentity(); + glu.gluPerspective(60.0,(double)w / (double)h,1.0,1000.0); + gl.glMatrixMode(GL_MODELVIEW); + gl.glLoadIdentity(); + glu.gluLookAt(posx,posy,posz,posx + lookx,posy + looky,posz + lookz,0.0,1.0,0.0); + } + + public float getMySpeed() + { + return mySpeed; + } + + public void setMySpeed(float s) + { + mySpeed = s; + } + + public boolean getTextureState() + { + return texture_mapping == TRUE; + } + + public void setTexture(boolean t) + { + if(t) + { + if(texture_mapping == FALSE) + { + if(glj!=null) + { + if(glj.gljMakeCurrent() == false) + { + System.out.println("problem in use() method"); + return; + } + gl.glEnable(GL_TEXTURE_2D); + texture_mapping = TRUE; + glj.gljCheckGL(); + repaint(); + } + } + } + else + { + if(texture_mapping == TRUE) + { + if(glj!=null) + { + if(glj.gljMakeCurrent() == false) + { + System.out.println("problem in use() method"); + return; + } + gl.glDisable(GL_TEXTURE_2D); + texture_mapping = FALSE; + glj.gljCheckGL(); + repaint(); + } + } + } + setSuspended(false); + } + + public boolean getFogState() + { + return land_fogging == TRUE; + } + + public void setFog(boolean t) + { + if(t) + { + if(land_fogging == FALSE) + { + if(glj!=null) + { + if(glj.gljMakeCurrent() == false) + { + System.out.println("problem in use() method"); + return; + } + gl.glEnable(GL_FOG); + land_fogging = TRUE; + glj.gljCheckGL(); + repaint(); + } + } + } + else + { + if(land_fogging == TRUE) + { + if(glj!=null) + { + if(glj.gljMakeCurrent() == false) + { + System.out.println("problem in use() method"); + return; + } + gl.glDisable(GL_FOG); + land_fogging = FALSE; + glj.gljCheckGL(); + repaint(); + } + } + } + setSuspended(false); + } + + public boolean getFlatShadeState() + { + return flat_shading == TRUE; + } + + public void setFlatShading(boolean t) + { + if(t) + { + if(flat_shading == FALSE) + { + if(glj!=null) + { + if(glj.gljMakeCurrent() == false) + { + System.out.println("problem in use() method"); + return; + } + gl.glShadeModel(GL_FLAT); + flat_shading = TRUE; + glj.gljCheckGL(); + repaint(); + } + } + } + else + { + if(flat_shading == TRUE) + { + if(glj!=null) + { + if(glj.gljMakeCurrent() == false) + { + System.out.println("problem in use() method"); + return; + } + gl.glShadeModel(GL_SMOOTH); + flat_shading = FALSE; + glj.gljCheckGL(); + repaint(); + } + } + } + setSuspended(false); + } + + public void newFractal() + { + create_fractal(); + if(!cvsIsInit() || glj.gljMakeCurrent() == false) + { + System.out.println("problem in use() method"); + return; + } + gl.glFinish(); + gl.glDeleteLists(theLand, 1); + genLand(); + check_height(); + repaint(); + setSuspended(false); + } + +} + diff --git a/demos/GLLandScape/GLLandScape1w1Applet$SpeedTimer b/demos/GLLandScape/GLLandScape1w1Applet$SpeedTimer Binary files differnew file mode 100644 index 0000000..81e347a --- /dev/null +++ b/demos/GLLandScape/GLLandScape1w1Applet$SpeedTimer diff --git a/demos/GLLandScape/GLLandScape1w1Applet.java b/demos/GLLandScape/GLLandScape1w1Applet.java new file mode 100755 index 0000000..90da5f3 --- /dev/null +++ b/demos/GLLandScape/GLLandScape1w1Applet.java @@ -0,0 +1,416 @@ + +import gl4java.GLContext; +import java.awt.*; +import java.applet.*; +import java.awt.event.*; + +public class GLLandScape1w1Applet extends Applet + implements MouseListener, KeyListener, ActionListener +{ + GLLandScape1w1 landScape = null; + + Button bAddPlane = null; + Button bRemPlane = null; + Button bTexture = null; + Button bShading = null; + Button bFog = null; + Button bNewFractal = null; + Button bInfo = null; + + Button bFps; TextField tFps; + + boolean gameOn = true; + + SpeedTimer tMySpeed = null; + + public void init() + { + init(0,0); + } + + public void init(int w, int h) + { + super.init(); + + setLayout(new BorderLayout()); + + Panel glFeatures = new Panel(); + glFeatures.setLayout(new GridLayout(6,1)); + glFeatures.add(bAddPlane =new Button("+ Plane")); + glFeatures.add(bRemPlane =new Button("- Plane")); + glFeatures.add(bTexture =new Button("Texture")); + glFeatures.add(bShading =new Button("Shading")); + glFeatures.add(bFog =new Button("Fogging")); + glFeatures.add(bNewFractal =new Button("Fractal")); + bAddPlane.addMouseListener(this); + bRemPlane.addMouseListener(this); + bTexture.addMouseListener(this); + bShading.addMouseListener(this); + bFog.addMouseListener(this); + bNewFractal.addMouseListener(this); + add("East", glFeatures); + + Panel pFps = new Panel(); + pFps.setLayout(new GridLayout(1,3)); + pFps.add(bInfo =new Button("info")); + pFps.add(bFps =new Button("get fps")); + pFps.add(tFps =new TextField()); + bInfo.addMouseListener(this); + bFps.addMouseListener(this); + tFps.addActionListener(this); + add("South", pFps); + + if(w==0 && h==0) + { + Dimension d = getSize(); + landScape= new GLLandScape1w1(d.width, d.height); + } else { + landScape= new GLLandScape1w1(w, h); + } + landScape.setAnimateFps(30.0); + landScape.addMouseListener(this); + landScape.addKeyListener(this); + + tMySpeed = new SpeedTimer(landScape, 200); + + landScape.requestFocus(); + landScape.setMySpeed(0); + + add("Center", landScape); + } + + public void destroy() + { + landScape.stop(); + landScape.cvsDispose(); + landScape.removeMouseListener(this); + landScape.removeKeyListener(this); + } + + public void start() + { + landScape.start(); + } + + public void stop() + { + landScape.stop(); + } + + public static void main( String args[] ) { + String gljLib=null; + String glLib=null; + String gluLib=null; + + if(args.length>0) + gljLib = args[0]; + if(args.length>1) + glLib = args[1]; + if(args.length>2) + gluLib = args[2]; + + if(GLContext.loadNativeLibraries(gljLib, glLib, gluLib)==false) + System.out.println("GLCanvasV2 could not load native libs:"+ + gljLib + ", " + glLib + ", " + gluLib); + + GLContext.gljNativeDebug = false; + GLContext.gljClassDebug = false; + + GLLandScape1w1Applet window = + new GLLandScape1w1Applet(); + + Frame f = new Frame(); + + f.addWindowListener( new WindowAdapter() + { + public void windowClosed(WindowEvent e) + { + System.exit(0); + } + public void windowClosing(WindowEvent e) + { + windowClosed(e); + } + } + ); + + f.setLayout(new BorderLayout()); + f.add("Center", window); + window.init(500,300); + window.start(); + Dimension ps = window.getPreferredSize(); + f.setBounds(-100,-100,99,99); + f.setVisible(true); + f.setVisible(false); + Insets i = f.getInsets(); + f.setBounds(0,0, + ps.width+i.left+i.right, + ps.height+i.top+i.bottom); + f.setVisible(true); + } + + // Methods required for the implementation of MouseListener + public void mouseEntered( MouseEvent evt ) + { + Component comp = evt.getComponent(); + if( comp.equals(landScape ) ) + { + landScape.requestFocus(); + } + } + + public void mouseExited( MouseEvent evt ) + { + } + + public void mousePressed( MouseEvent evt ) + { + } + public void mouseReleased( MouseEvent evt ) { + } + + public void mouseClicked( MouseEvent evt ) + { + Component comp = evt.getComponent(); + + if( comp.equals(bAddPlane ) ) + landScape.addPlane(); + else if( comp.equals(bRemPlane ) ) + landScape.removePlane(); + else if( comp.equals(bTexture ) ) + landScape.setTexture( ! landScape.getTextureState()); + else if( comp.equals(bNewFractal ) ) + landScape.newFractal(); + else if( comp.equals(bShading ) ) + landScape.setFlatShading(!landScape.getFlatShadeState()); + else if( comp.equals(bFog ) ) + landScape.setFog( ! landScape.getFogState()); + else if( comp.equals(landScape) ) + landScape.setSuspended(false); + else if( comp.equals(bFps) ) + { + double fps = 0; + + landScape.stopFpsCounter(); + fps=landScape.getFps(); + tFps.setText(String.valueOf(fps)); + landScape.resetFpsCounter(); + } + else if( comp.equals(bInfo) ) + { + InfoWin iw = new InfoWin(); + } + } + + + public void keyTyped(KeyEvent e) + { + } + + public void keyPressed(KeyEvent e) + { + int key = e.getKeyCode(); + + if( gameOn==true ) + { + if ( key==KeyEvent.VK_LEFT ) + { + landScape.myMove(landScape.TURNLEFT, 0.1f, true, true); + tMySpeed.start(); + } + else if ( key==KeyEvent.VK_RIGHT ) + { + landScape.myMove(landScape.TURNLEFT, -0.1f, true, true); + tMySpeed.start(); + } + else if ( key==KeyEvent.VK_UP ) + { + float v = tMySpeed.getSpeed(); + + if ( e.isShiftDown() ) + { + tMySpeed.setSpeed(v+2.0f); + } + else { + tMySpeed.setSpeed(v+1.0f); + } + tMySpeed.start(); + } + else if ( key==KeyEvent.VK_DOWN ) + { + float v = tMySpeed.getSpeed(); + + if ( e.isShiftDown() ) + tMySpeed.setSpeed(v/2.0f); + else + tMySpeed.setSpeed(v-1.0f); + tMySpeed.start(); + } + else if ( key==KeyEvent.VK_PAGE_UP ) + { + landScape.myMove(landScape.LOOKUP, 0.1f, true,true); + tMySpeed.start(); + } + else if ( key==KeyEvent.VK_PAGE_DOWN ) + { + landScape.myMove(landScape.LOOKUP, -0.1f, true,true); + tMySpeed.start(); + } + else if ( key==KeyEvent.VK_END ) + { + landScape.myMove(landScape.LOOKSET, 0f, true,true); + tMySpeed.start(); + } + } + } + + public void keyReleased(KeyEvent e) + { + int key = e.getKeyCode(); + + if( gameOn==true && + ( key==KeyEvent.VK_UP || + key==KeyEvent.VK_DOWN + ) + ) + { + //ts.start(); + } + else if( gameOn==true && + ( key==KeyEvent.VK_LEFT || + key==KeyEvent.VK_RIGHT + ) + ) + { + //landScape.noMySpeed(); + } + } + + public void actionPerformed(ActionEvent event) + { + Object source = event.getSource(); + + if ( source == tFps ) + { + try { + double FramesPerSec= + Double.valueOf(tFps.getText()).doubleValue(); + landScape.setAnimateFps(FramesPerSec); + landScape.setSuspended(false); + } catch (NumberFormatException s) { + System.out.println("wrong fps format, use float .."); + } + + } + } + + class SpeedTimer implements Runnable { + protected Thread me = null; + protected boolean to=false, started=false; + protected int _t; + + protected float speed = 0.0f; + protected GLLandScape1w1 _ls; + + public SpeedTimer(GLLandScape1w1 ls, int t) + { _ls=ls; _t=t; } + + public void start() + { + if(me!=null) stop(); + to=false; + started=true; + + me = new Thread(this); + me.start(); + } + + public void stop() { + if(me!=null) + { + me.stop(); + me=null; + started=false; + to=false; + } + } + + public void run() { + if(me!=null) + { + try {me.sleep(_t,0);} catch (InterruptedException e){} + to=true; + while(speed>1.0f) + { + speed/=2.0f; + _ls.setMySpeed(speed); + try {me.sleep(_t,0);} catch (InterruptedException e){} + } + speed = 0.0f; + _ls.setMySpeed(0f); + } + } + + public boolean isActive() { return to; } + public boolean isStarted() { return started; } + + public float getSpeed() { return speed; } + public void setSpeed(float v) + { speed=v; + _ls.setMySpeed(speed); + } + + } + + class InfoWin extends Frame + implements ActionListener + { + protected Button DismissButton; + + String text = + "GLLandScape1w1 V 1.0\n"+ + "by Sven Goethel\n"+ + "\thttp://www.jausoft.com/gl4java.html\n"+ + "\tmailto:[email protected]\n\n"+ + "The original sources for the lanscape algorythms,\n"+ + "are taken from Nicholas Anderson's Landscape V1.0 !\n"+ + "\thttp://www.fortunecity.com/skyscraper/online/263\n"+ + "\tmailto:[email protected]\n\n"+ + "usage:\n"+ + "\t ARROW-UP : accelerate\n"+ + "\t ARROW-UP + SHIFT : accelerate fast \n"+ + "\t ARROW-DOWN : de-accelerate\n"+ + "\t ARROW-DOWN + SHIFT : de-accelerate fast\n"+ + "\t ARROW-LEFT : turn left\n"+ + "\t ARROW-right : turn right\n"+ + "\t PAGE-UP : look-up\n"+ + "\t PAGE-DOWN : look-down\n"+ + "\t END : look normal\n\n"+ + "Have a lot of fun - Sven Goethel\n"; + + public InfoWin() + { + setTitle("INFO"); + setName("INFO"); + + setLayout(new BorderLayout()); + add("Center", new TextArea(text, 25, 50)); + + add("South", DismissButton = new Button("dismiss")); + DismissButton.addActionListener(this); + + pack(); + setVisible(true); + + toFront(); + } + + public void actionPerformed(ActionEvent event) { + if ( event.getSource() == DismissButton) + { + setVisible(false); + dispose(); + } + } + } +} diff --git a/demos/GLLandScape/GLLandScape1w1_plugin13.html b/demos/GLLandScape/GLLandScape1w1_plugin13.html new file mode 100644 index 0000000..32ab0bf --- /dev/null +++ b/demos/GLLandScape/GLLandScape1w1_plugin13.html @@ -0,0 +1,46 @@ +<HTML>
+<HEAD>
+<TITLE>Göthel Hard- und Software Entwicklungen</TITLE>
+</HEAD>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+<hr>
+<!--"CONVERTED_APPLET"-->
+<!-- CONVERTER VERSION 1.3 --> +<SCRIPT LANGUAGE="JavaScript"><!-- + var _info = navigator.userAgent; var _ns = false; + var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0); +//--></SCRIPT> +<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!-- + var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0))); +//--></SCRIPT></COMMENT> + +<SCRIPT LANGUAGE="JavaScript"><!-- + if (_ie == true) document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = 500 HEIGHT = 300 codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0"><NOEMBED><XMP>'); + else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.3" CODE = "GLLandScape1w1Applet.class" WIDTH = 500 HEIGHT = 300 frames = "55" scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html"><NOEMBED><XMP>'); +//--></SCRIPT> +<APPLET CODE = "GLLandScape1w1Applet.class" WIDTH = 500 HEIGHT = 300></XMP> +<PARAM NAME = CODE VALUE = "GLLandScape1w1Applet.class" >
+ +<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3"> +<PARAM NAME="scriptable" VALUE="false"> +<PARAM NAME = frames VALUE ="55">
+ +</APPLET> + +</NOEMBED></EMBED></OBJECT> + + +<!-- +<APPLET CODE = "GLLandScape1w1Applet.class" WIDTH = 500 HEIGHT = 300>
+<PARAM NAME = frames VALUE ="55">
+
+
+</APPLET> +--> +<!--"END_CONVERTED_APPLET"-->
+
+<hr>
+</BODY>
+</HTML>
+
+
diff --git a/demos/GLLandScape/GlutPlaneObj.java b/demos/GLLandScape/GlutPlaneObj.java new file mode 100644 index 0000000..3b449a7 --- /dev/null +++ b/demos/GLLandScape/GlutPlaneObj.java @@ -0,0 +1,112 @@ +/**
+ * @(#) glutplane.java
+ * @(#) author: Mark J. Kilgard (converted to Java by Ron Cemer)
+ */
+
+/* This program is freely distributable without licensing fees
+ and is provided without guarantee or warrantee expressed or
+ implied. This program is -not- in the public domain. */
+
+import java.applet.*;
+import java.awt.*;
+import java.awt.event.*;
+import java.lang.*;
+import java.util.*;
+import java.io.*;
+import java.util.*;
+import gl4java.GLContext;
+import gl4java.GLFunc;
+import gl4java.GLUFunc;
+import gl4java.GLEnum;
+import gl4java.GLUEnum;
+import gl4java.awt.GLAnimCanvas;
+import gl4java.applet.SimpleGLAnimApplet1;
+
+public class GlutPlaneObj
+ implements GLEnum, GLUEnum
+{
+ float speed = 0.0f; /* zero speed means not flying */
+ float red = 0.0f, green = 0.0f, blue = 0.0f;
+ float theta = 0.0f;
+ public float x = 0.0f, y = 0.0f, z = 0.0f, angle = 0.0f;
+
+ public void setPosition(float x, float y, float z)
+ {
+ this.x=x;
+ this.y=y;
+ this.z=z;
+ }
+
+
+ public void setColor(float r, float g, float b)
+ {
+ red = r;
+ green = g;
+ blue = b;
+ }
+
+
+ private final double M_PI = 3.14159265;
+ private final double M_PI_2 = 1.57079632;
+
+ GLFunc gl;
+ GLUFunc glu;
+
+ public GlutPlaneObj(GLFunc gl, GLUFunc glu)
+ {
+ this.gl=gl;
+ this.glu=glu;
+ }
+
+ public void display()
+ {
+
+ if (speed != 0.0f)
+ {
+ tick();
+ // System.out.println("plane: ("+x+"/"+y+"/"+z+")");
+ gl.glPushMatrix();
+ gl.glTranslatef(x, y, z);
+ gl.glRotatef(290.0f, 1.0f, 0.0f, 0.0f);
+ gl.glRotatef(angle, 0.0f, 0.0f, 1.0f);
+ // gl.glScalef(1.0f / 3.0f, 1.0f / 4.0f, 1.0f / 4.0f);
+ gl.glScalef(5.0f, 5.0f, 5.0f);
+ gl.glTranslatef(0.0f, -4.0f, -1.5f);
+ gl.glBegin(GL_TRIANGLE_STRIP);
+ /* left wing */
+ gl.glVertex3f(-7.0f, 0.0f, 2.0f);
+ gl.glVertex3f(-1.0f, 0.0f, 3.0f);
+ gl.glColor3f(red,green,blue);
+ gl.glVertex3f(-1.0f, 7.0f, 3.0f);
+ /* left side */
+ gl.glColor3f(0.6f * red, 0.6f * green, 0.6f * blue);
+ gl.glVertex3f(0.0f, 0.0f, 0.0f);
+ gl.glVertex3f(0.0f, 8.0f, 0.0f);
+ /* right side */
+ gl.glVertex3f(1.0f, 0.0f, 3.0f);
+ gl.glVertex3f(1.0f, 7.0f, 3.0f);
+ /* final tip of right wing */
+ gl.glColor3f(red, green, blue);
+ gl.glVertex3f(7.0f, 0.0f, 2.0f);
+ gl.glEnd();
+ gl.glPopMatrix();
+ }
+ }
+
+ public void tick()
+ {
+ /*
+ posx = 4500.0f;
+ posy = 256.0f;
+ posz = 4500.0f;
+ */
+ theta += speed;
+ z = 4500.0f + 600.0f * (float)Math.cos(theta);
+ x = 4500.0f + 600.0f * (float)Math.sin(2.0f * theta);
+ y = 280.0f + (float)Math.sin(theta / 3.4f) * 20.0f;
+ angle = (float)
+ (((Math.atan(2.0) + M_PI_2) * Math.sin(theta) - M_PI_2) *
+ 180.0 / M_PI);
+ if (speed < 0.0f) angle += 180.0f;
+ }
+}
diff --git a/demos/GLLandScape/LICENSE.txt b/demos/GLLandScape/LICENSE.txt new file mode 100644 index 0000000..9611410 --- /dev/null +++ b/demos/GLLandScape/LICENSE.txt @@ -0,0 +1,36 @@ +GLLandScape - A landscape generator, where you can walk through - uses GL4Java + +Copyright (C) 1999 Sven Goethel + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public +License as published by the Free Software Foundation; either +version 2 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with this library; if not, write to the +Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. + +You can also check the GNU Library General Public License +in the internet at http://www.gnu.org/copyleft/lgpl.html ! + +If you like to contact the author use: + +Sven Goethel, Elpke 5, 33605 Bielefeld, Germany +email: [email protected] +web : http://www.jausoft.com +voice: +49-521-2399440 +fax : +49-521-2399442 + +The landscape algorythms are taken from Nicholas Anderson's Landscape V1.0 ! + http://www.fortunecity.com/skyscraper/online/263 + mailto:[email protected] +Those parts are still under the Copyright (C) of Nicholas Anderson ! + +Sven Goethel, 15 January 1999 diff --git a/demos/GLLandScape/index.html b/demos/GLLandScape/index.html new file mode 100644 index 0000000..2efada2 --- /dev/null +++ b/demos/GLLandScape/index.html @@ -0,0 +1,52 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="Author" content="Ron Cemer & Sven Goethel">
+ <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
+ <title>GL4Java Landscape World</title>
+</head>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+<p>The GLLandScape World</p><BR>
+Paperplanes are flying arround a landscape !<br>
+<I>Thanxs to </I>
+<A HREF="http://pages.eidosnet.co.uk/~n.anderson/index.html">
+<I>Nicholas Anderson</I></A>
+<I> for ANSI-C sources of Landscape V1.0</I>
+<br>
+<br>
+Use the keybord's cursor keys to move arround.<br>
+The page up and down keys are used to look up and down.<br>
+This all is done to move like in Quake.<br>
+<br>
+<p> <a href="GLLandScape1.html">GLLandScape</a>
+: a LandScape V1 at 500x300
+<p> <a href="GLLandScape1-big.html">GLLandScape BIG</a>
+: a LandScape V1 at 800x600
+<p> <a href="GLLandScape1w1.html">GLLandScape-World</a>
+: a LandScape World V1 at 500x300
+<p> <a href="GLLandScape1w1-big.html">GLLandScape-World BIG</a>
+: a LandScape World V1 at 800x600
+<br>
+<br>
+<hr>
+<P ALIGN=CENTER><SPAN STYLE="text-decoration: none"><I>For use with
+the Java2-Plug-In: Tested with Win32,Netscape,Java2 <A HREF="Java2.txt">(see
+Installation-instructions Java2)</A> ! </I></SPAN><br>
+<br>
+<a href="../../Installer/java.policy">The Java2 (sdk, jre, plugin 1.3) policy file example to give GL4Java the necessary permissions (Click here) !</a>
+<br>
+</P>
+<p> <a href="GLLandScape1_plugin13.html">GLLandScape</a>
+: a LandScape V1 at 500x300
+<p> <a href="GLLandScape1-big_plugin13.html">GLLandScape BIG</a>
+: a LandScape V1 at 800x600
+<p> <a href="GLLandScape1w1_plugin13.html">GLLandScape-World</a>
+: a LandScape World V1 at 500x300
+<p> <a href="GLLandScape1w1-big_plugin13.html">GLLandScape-World BIG</a>
+: a LandScape World V1 at 800x600
+<br>
+<br>
+<hr>
+</body>
+</html>
diff --git a/demos/HodglimsNeHe/Lesson1.html b/demos/HodglimsNeHe/Lesson1.html new file mode 100644 index 0000000..1c73238 --- /dev/null +++ b/demos/HodglimsNeHe/Lesson1.html @@ -0,0 +1,35 @@ +<HTML>
+<HEAD>
+<TITLE>Lesson1 Applet: Setting Up OpenGL In Windows</TITLE>
+<STYLE TYPE="text/css">
+<!--
+A:link { COLOR: #9C9AB1; TEXT-DECORATION: none }
+A:visited { COLOR: #9C9AB1; TEXT-DECORATION: none }
+A:active { color: Yellow; TEXT-DECORATION: none }
+A:hover { color: Yellow; TEXT-DECORATION: none }
+-->
+</STYLE>
+</HEAD>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+<CENTER>
+<P>
+<FONT SIZE="2" FACE="Verdana"><B>Setting Up OpenGL In Windows</B></FONT>
+</P>
+<TABLE WIDTH="100%">
+<TR>
+<TD WIDTH="30%" ALIGN="LEFT" VALIGN="TOP">
+<P>
+<FONT SIZE="1" FACE="Verdana">
+<A HREF="index.html">Go back</A>
+</FONT>
+</P>
+</TD>
+<TD WIDTH="70%" ALIGN="CENTER" VALIGN="TOP">
+<APPLET CODE="Lesson1.class" WIDTH="400" HEIGHT="400">
+</APPLET>
+</TD>
+</TR>
+</TABLE>
+</CENTER>
+</BODY>
+</HTML>
diff --git a/demos/HodglimsNeHe/Lesson1.java b/demos/HodglimsNeHe/Lesson1.java new file mode 100644 index 0000000..fb05de2 --- /dev/null +++ b/demos/HodglimsNeHe/Lesson1.java @@ -0,0 +1,261 @@ +/**
+ * Lesson1.java
+ *
+ * Author: Darren Hodges
+ * Date: 16/12/1999
+ *
+ * Port of the NeHe OpenGL Tutorial (Lesson 1: "Setting Up OpenGL In Windows")
+ * to Java using the GL4Java interface to OpenGL.
+ * Although the title "Setting Up OpenGL In Windows" doesn't really apply
+ * to Java because it is a multi-platform language.
+ *
+ */
+
+import java.applet.*;
+import java.awt.*;
+import java.awt.event.*;
+
+//GL4Java classes
+import gl4java.GLContext;
+import gl4java.awt.GLAnimCanvas;
+
+
+public class Lesson1 extends Applet
+{
+ //Our rendering canvas
+ //We are using GLAnimCanvas because we want the canvas
+ //to be constantly redrawn
+ renderCanvas canvas = null;
+
+
+ /**
+ * void init()
+ *
+ * Initialise the applet.
+ */
+ public void init()
+ {
+ //We will use BorderLayout to layout the applet components
+ setLayout(new BorderLayout());
+
+ //Create our canvas and add it to the center of the applet
+ canvas = new renderCanvas(getSize().width, getSize().height);
+ canvas.requestFocus();
+ add("Center", canvas);
+ }
+
+
+ /**
+ * void start()
+ *
+ * Start the applet.
+ */
+ public void start()
+ {
+ //Start animating the canvas
+ canvas.start();
+ }
+
+
+ /**
+ * void stop()
+ *
+ * Stop the applet.
+ */
+ public void stop()
+ {
+ //Stop animating the canvas
+ canvas.stop();
+ }
+
+
+ /**
+ * void destroy()
+ *
+ * Destroy the applet.
+ */
+ public void destroy()
+ {
+ //Stop animating the canvas
+ canvas.stop();
+ //Destroy the canvas
+ canvas.destroy();
+ }
+
+
+
+ private class renderCanvas extends GLAnimCanvas
+ implements KeyListener, MouseListener
+ {
+ /**
+ * renderCanvas(int w, int h)
+ *
+ * Constructor.
+ */
+ public renderCanvas(int w, int h)
+ {
+ super(w, h);
+
+ //Registers this canvas to process keyboard events
+ addKeyListener(this);
+ addMouseListener(this);
+ }
+
+
+ /**
+ * void preInit()
+ *
+ * Called just BEFORE the GL-Context is created.
+ */
+ public void preInit()
+ {
+ //We want double buffering
+ doubleBuffer = true;
+ //But we dont want stereo view
+ stereoView = false;
+ }
+
+
+ /**
+ * void init()
+ *
+ * Called just AFTER the GL-Context is created.
+ */
+ public void init()
+ {
+ //This Will Clear The Background Color To Black
+ gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
+
+ //Enables Clearing Of The Depth Buffer
+ gl.glClearDepth(1.0);
+ //The Type Of Depth Test To Do
+ gl.glDepthFunc(GL_LESS);
+ //Enables Depth Testing
+ gl.glEnable(GL_DEPTH_TEST);
+
+ //Enables Smooth Color Shading
+ gl.glShadeModel(GL_SMOOTH);
+ //Select The Projection Matrix
+ gl.glMatrixMode(GL_PROJECTION);
+ //Reset The Projection Matrix
+ gl.glLoadIdentity();
+ //Calculate The Aspect Ratio Of The Window
+ glu.gluPerspective(45.0f, (float)getSize().width / (float)getSize().height, 0.1f, 100.0f);
+ //Select The Modelview Matrix
+ gl.glMatrixMode(GL_MODELVIEW);
+ }
+
+
+ /**
+ * void destroy()
+ *
+ * Destroy the canvas.
+ */
+ public void destroy()
+ {
+ //Destroy the GLContext
+ cvsDispose();
+ }
+
+
+ /**
+ * void reshape(int width, int height)
+ *
+ * Called after the first paint command.
+ */
+ public void reshape(int width, int height)
+ {
+ //Reset The Current Viewport And Perspective Transformation
+ gl.glViewport(0, 0, width, height);
+
+ //Select The Projection Matrix
+ gl.glMatrixMode(GL_PROJECTION);
+ //Reset The Projection Matrix
+ gl.glLoadIdentity();
+ //Calculate The Aspect Ratio Of The Window
+ glu.gluPerspective(45.0f, (float)getSize().width / (float)getSize().height, 0.1f, 100.0f);
+ //Select The Modelview Matrix
+ gl.glMatrixMode(GL_MODELVIEW);
+ }
+
+
+ /**
+ * void display()
+ *
+ * Draw to the canvas.
+ */
+ public void display()
+ {
+ //Ensure GL is initialised correctly
+ if (glj.gljMakeCurrent(true) == false)
+ return;
+
+ //Clear The Screen And The Depth Buffer
+ gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ //Reset The View
+ gl.glLoadIdentity();
+
+ //Swap buffers
+ glj.gljSwap();
+ }
+
+
+ /**
+ * void keyTyped(KeyEvent e)
+ *
+ * Invoked when a key has been typed. This event occurs when a key press is followed by a key release.
+ */
+ public void keyTyped(KeyEvent e)
+ {
+ //We are not handling any keyboard events yet
+ }
+
+
+ /**
+ * void keyPressed(KeyEvent e)
+ *
+ * Invoked when a key has been pressed.
+ */
+ public void keyPressed(KeyEvent e)
+ {
+ //We are not handling any keyboard events yet
+ }
+
+
+ /**
+ * void keyReleased(KeyEvent e)
+ *
+ * Invoked when a key has been released.
+ */
+ public void keyReleased(KeyEvent e)
+ {
+ //We are not handling any keyboard events yet
+ }
+
+ // Methods required for the implementation of MouseListener
+ public void mouseEntered( MouseEvent evt )
+ {
+ Component comp = evt.getComponent();
+ if( comp.equals(this ) )
+ {
+ requestFocus();
+ }
+ }
+
+ public void mouseExited( MouseEvent evt )
+ { }
+ public void mousePressed( MouseEvent evt )
+ { }
+ public void mouseReleased( MouseEvent evt )
+ { }
+ public void mouseClicked( MouseEvent evt )
+ {
+ Component comp = evt.getComponent();
+ if( comp.equals(this ) )
+ {
+ requestFocus();
+ }
+ }
+
+ }
+}
diff --git a/demos/HodglimsNeHe/Lesson11.html b/demos/HodglimsNeHe/Lesson11.html new file mode 100644 index 0000000..7976c3c --- /dev/null +++ b/demos/HodglimsNeHe/Lesson11.html @@ -0,0 +1,35 @@ +<HTML>
+<HEAD>
+<TITLE>Lesson11 Applet: OpenGL Flag Effect</TITLE>
+<STYLE TYPE="text/css">
+<!--
+A:link { COLOR: #9C9AB1; TEXT-DECORATION: none }
+A:visited { COLOR: #9C9AB1; TEXT-DECORATION: none }
+A:active { color: Yellow; TEXT-DECORATION: none }
+A:hover { color: Yellow; TEXT-DECORATION: none }
+-->
+</STYLE>
+</HEAD>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+<CENTER>
+<P>
+<FONT SIZE="2" FACE="Verdana"><B>OpenGL Flag Effect</B></FONT>
+</P>
+<TABLE WIDTH="100%">
+<TR>
+<TD WIDTH="30%" ALIGN="LEFT" VALIGN="TOP">
+<P>
+<FONT SIZE="1" FACE="Verdana">
+<A HREF="index.html">Go back</A>
+</FONT>
+</P>
+</TD>
+<TD WIDTH="70%" ALIGN="CENTER" VALIGN="TOP">
+<APPLET CODE="Lesson11.class" WIDTH="400" HEIGHT="400">
+</APPLET>
+</TD>
+</TR>
+</TABLE>
+</CENTER>
+</BODY>
+</HTML>
diff --git a/demos/HodglimsNeHe/Lesson11.java b/demos/HodglimsNeHe/Lesson11.java new file mode 100644 index 0000000..ad566ee --- /dev/null +++ b/demos/HodglimsNeHe/Lesson11.java @@ -0,0 +1,382 @@ +/**
+ * Lesson11.java
+ *
+ * Author: Darren Hodges
+ * Date: 23/12/1999
+ *
+ * Port of the NeHe OpenGL Tutorial (Lesson 11: "OpenGL Flag Effect")
+ * to Java using the GL4Java interface to OpenGL.
+ *
+ */
+
+import java.applet.*;
+import java.awt.*;
+import java.awt.event.*;
+
+//GL4Java classes
+import gl4java.GLContext;
+import gl4java.awt.GLAnimCanvas;
+import gl4java.utils.textures.*;
+
+
+public class Lesson11 extends Applet
+{
+ //Our rendering canvas
+ //We are using GLAnimCanvas because we want the canvas
+ //to be constantly redrawn
+ renderCanvas canvas = null;
+
+
+ /**
+ * void init()
+ *
+ * Initialise the applet.
+ */
+ public void init()
+ {
+ //We will use BorderLayout to layout the applet components
+ setLayout(new BorderLayout());
+
+ //Create our canvas and add it to the center of the applet
+ canvas = new renderCanvas(getSize().width, getSize().height);
+ canvas.requestFocus();
+ add("Center", canvas);
+ }
+
+
+ /**
+ * void start()
+ *
+ * Start the applet.
+ */
+ public void start()
+ {
+ //Start animating the canvas
+ canvas.start();
+ }
+
+
+ /**
+ * void stop()
+ *
+ * Stop the applet.
+ */
+ public void stop()
+ {
+ //Stop animating the canvas
+ canvas.stop();
+ }
+
+
+ /**
+ * void destroy()
+ *
+ * Destroy the applet.
+ */
+ public void destroy()
+ {
+ //Stop animating the canvas
+ canvas.stop();
+ //Destroy the canvas
+ canvas.destroy();
+ }
+
+
+
+ private class renderCanvas extends GLAnimCanvas
+ implements KeyListener, MouseListener
+ {
+ float xrot = 0.0f; //X Rotation
+ float yrot = 0.0f; //Y Rotation
+ float zrot = 0.0f; //Z Rotation
+
+ //The array for the points on the grid of our "wave"
+ float[][][] points = new float[45][45][3];
+
+ int wiggle_count = 0;
+
+ int[] texture = new int[1]; //Storage for one texture
+
+
+ /**
+ * renderCanvas(int w, int h)
+ *
+ * Constructor.
+ */
+ public renderCanvas(int w, int h)
+ {
+ super(w, h);
+
+ //Registers this canvas to process keyboard events
+ addKeyListener(this);
+ addMouseListener(this);
+ }
+
+
+ /**
+ * void preInit()
+ *
+ * Called just BEFORE the GL-Context is created.
+ */
+ public void preInit()
+ {
+ //We want double buffering
+ doubleBuffer = true;
+ //But we dont want stereo view
+ stereoView = false;
+ }
+
+
+ /**
+ * void LoadGLTextures()
+ *
+ * Load textures.
+ */
+ public void LoadGLTextures()
+ {
+ PngTextureLoader texLoader = new PngTextureLoader(gl, glu);
+ texLoader.readTexture(getCodeBase(), "data/tim.png");
+
+ if(texLoader.isOk())
+ {
+ //Create Texture
+ gl.glGenTextures(1, texture);
+ gl.glBindTexture(GL_TEXTURE_2D, texture[0]);
+
+ gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+
+ gl.glTexImage2D(GL_TEXTURE_2D,
+ 0,
+ 3,
+ texLoader.getImageWidth(),
+ texLoader.getImageHeight(),
+ 0,
+ GL_RGB,
+ GL_UNSIGNED_BYTE,
+ texLoader.getTexture());
+ }
+ }
+
+
+ /**
+ * void init()
+ *
+ * Called just AFTER the GL-Context is created.
+ */
+ public void init()
+ {
+ //Load The Texture(s)
+ LoadGLTextures();
+ //Enable Texture Mapping
+ gl.glEnable(GL_TEXTURE_2D);
+
+ //This Will Clear The Background Color To Black
+ gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
+
+ //Enables Clearing Of The Depth Buffer
+ gl.glClearDepth(1.0);
+ //The Type Of Depth Test To Do
+ gl.glDepthFunc(GL_LESS);
+ //Enables Depth Testing
+ gl.glEnable(GL_DEPTH_TEST);
+
+ //Enables Smooth Color Shading
+ gl.glShadeModel(GL_SMOOTH);
+ //Select The Projection Matrix
+ gl.glMatrixMode(GL_PROJECTION);
+ //Reset The Projection Matrix
+ gl.glLoadIdentity();
+ //Calculate The Aspect Ratio Of The Window
+ glu.gluPerspective(45.0f, (float)getSize().width / (float)getSize().height, 0.1f, 100.0f);
+ //Select The Modelview Matrix
+ gl.glMatrixMode(GL_MODELVIEW);
+
+
+ for(float float_x = 0.0f; float_x < 9.0f; float_x += 0.2f)
+ {
+ for(float float_y = 0.0f; float_y < 9.0f; float_y += 0.2f)
+ {
+ points[(int)(float_x * 5)][(int)(float_y * 5)][0] = float_x - 4.4f;
+ points[(int)(float_x * 5)][(int)(float_y * 5)][1] = float_y - 4.4f;
+ points[(int)(float_x * 5)][(int)(float_y * 5)][2] = (float)(Math.sin(((float_x * 5 * 8) / 360) * 3.14159 * 2));
+ }
+ }
+ }
+
+
+ /**
+ * void destroy()
+ *
+ * Destroy the canvas.
+ */
+ public void destroy()
+ {
+ //Destroy the GLContext
+ cvsDispose();
+ }
+
+
+ /**
+ * void reshape(int width, int height)
+ *
+ * Called after the first paint command.
+ */
+ public void reshape(int width, int height)
+ {
+ //Reset The Current Viewport And Perspective Transformation
+ gl.glViewport(0, 0, width, height);
+
+ //Select The Projection Matrix
+ gl.glMatrixMode(GL_PROJECTION);
+ //Reset The Projection Matrix
+ gl.glLoadIdentity();
+ //Calculate The Aspect Ratio Of The Window
+ glu.gluPerspective(45.0f, (float)getSize().width / (float)getSize().height, 0.1f, 100.0f);
+ //Select The Modelview Matrix
+ gl.glMatrixMode(GL_MODELVIEW);
+ }
+
+
+ /**
+ * void display()
+ *
+ * Draw to the canvas.
+ */
+ public void display()
+ {
+ //Ensure GL is initialised correctly
+ if (glj.gljMakeCurrent(true) == false)
+ return;
+
+ int x, y;
+ float float_x, float_y, float_xb, float_yb;
+
+ gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ gl.glLoadIdentity();
+ gl.glTranslatef(0.0f, 0.0f, -15.0f);
+
+ gl.glRotatef(xrot, 1.0f, 0.0f, 0.0f);
+ gl.glRotatef(yrot, 0.0f, 1.0f, 0.0f);
+ gl.glRotatef(zrot, 0.0f, 0.0f, 1.0f);
+
+ gl.glBindTexture(GL_TEXTURE_2D, texture[0]);
+
+ gl.glPolygonMode(GL_BACK, GL_FILL);
+ gl.glPolygonMode(GL_FRONT, GL_LINE);
+
+ gl.glBegin(GL_QUADS);
+
+ for(x = 0; x < 44; x++)
+ {
+ for(y = 0; y < 44; y++)
+ {
+ float_x = (float)x / 44;
+ float_y = (float)y / 44;
+ float_xb = (float)(x + 1) / 44;
+ float_yb = (float)(y + 1) / 44;
+
+ gl.glTexCoord2f(float_x, float_y);
+ gl.glVertex3f(points[x][y][0], points[x][y][1], points[x][y][2]);
+
+ gl.glTexCoord2f(float_x, float_yb);
+ gl.glVertex3f(points[x][y + 1][0], points[x][y + 1][1], points[x][y + 1][2]);
+
+ gl.glTexCoord2f(float_xb, float_yb);
+ gl.glVertex3f(points[x + 1][y + 1][0], points[x + 1][y + 1][1], points[x + 1][y + 1][2]);
+
+ gl.glTexCoord2f(float_xb, float_y);
+ gl.glVertex3f(points[x + 1][y][0], points[x + 1][y][1], points[x + 1][y][2]);
+ }
+ }
+
+ gl.glEnd();
+
+ if(wiggle_count == 2)
+ {
+ for(y = 0; y < 45; y++)
+ {
+ points[44][y][2] = points[0][y][2];
+ }
+
+ for(x = 0; x < 44; x++)
+ {
+ for(y = 0; y < 45; y++)
+ {
+ points[x][y][2] = points[x + 1][y][2];
+ }
+ }
+
+ wiggle_count = 0;
+ }
+
+ wiggle_count++;
+
+ xrot += 0.3f;
+ yrot += 0.2f;
+ zrot += 0.4f;
+
+ //Swap buffers
+ glj.gljSwap();
+ }
+
+
+ /**
+ * void keyTyped(KeyEvent e)
+ *
+ * Invoked when a key has been typed. This event occurs when a key press is followed by a key release.
+ */
+ public void keyTyped(KeyEvent e)
+ {
+ //We are not handling any keyboard events
+ }
+
+
+ /**
+ * void keyPressed(KeyEvent e)
+ *
+ * Invoked when a key has been pressed.
+ */
+ public void keyPressed(KeyEvent e)
+ {
+ //We are not handling any keyboard events
+ }
+
+
+ /**
+ * void keyReleased(KeyEvent e)
+ *
+ * Invoked when a key has been released.
+ */
+ public void keyReleased(KeyEvent e)
+ {
+ //We are not handling any keyboard events
+ }
+
+ // Methods required for the implementation of MouseListener
+ public void mouseEntered( MouseEvent evt )
+ {
+ Component comp = evt.getComponent();
+ if( comp.equals(this ) )
+ {
+ requestFocus();
+ }
+ }
+
+ public void mouseExited( MouseEvent evt )
+ { }
+ public void mousePressed( MouseEvent evt )
+ { }
+ public void mouseReleased( MouseEvent evt )
+ { }
+ public void mouseClicked( MouseEvent evt )
+ {
+ Component comp = evt.getComponent();
+ if( comp.equals(this ) )
+ {
+ requestFocus();
+ }
+ }
+
+ }
+}
diff --git a/demos/HodglimsNeHe/Lesson11_plugin13.html b/demos/HodglimsNeHe/Lesson11_plugin13.html new file mode 100644 index 0000000..28737f8 --- /dev/null +++ b/demos/HodglimsNeHe/Lesson11_plugin13.html @@ -0,0 +1,66 @@ +<HTML>
+<HEAD>
+<TITLE>Lesson11 Applet: OpenGL Flag Effect</TITLE>
+<STYLE TYPE="text/css">
+<!--
+A:link { COLOR: #9C9AB1; TEXT-DECORATION: none }
+A:visited { COLOR: #9C9AB1; TEXT-DECORATION: none }
+A:active { color: Yellow; TEXT-DECORATION: none }
+A:hover { color: Yellow; TEXT-DECORATION: none }
+-->
+</STYLE>
+</HEAD>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+<CENTER>
+<P>
+<FONT SIZE="2" FACE="Verdana"><B>OpenGL Flag Effect</B></FONT>
+</P>
+<TABLE WIDTH="100%">
+<TR>
+<TD WIDTH="30%" ALIGN="LEFT" VALIGN="TOP">
+<P>
+<FONT SIZE="1" FACE="Verdana">
+<A HREF="index.html">Go back</A>
+</FONT>
+</P>
+</TD>
+<TD WIDTH="70%" ALIGN="CENTER" VALIGN="TOP">
+<!--"CONVERTED_APPLET"-->
+<!-- CONVERTER VERSION 1.3 --> +<SCRIPT LANGUAGE="JavaScript"><!-- + var _info = navigator.userAgent; var _ns = false; + var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0); +//--></SCRIPT> +<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!-- + var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0))); +//--></SCRIPT></COMMENT> + +<SCRIPT LANGUAGE="JavaScript"><!-- + if (_ie == true) document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = "400" HEIGHT = "400" codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0"><NOEMBED><XMP>'); + else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.3" CODE = "Lesson11.class" WIDTH = "400" HEIGHT = "400" scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html"><NOEMBED><XMP>'); +//--></SCRIPT> +<APPLET CODE = "Lesson11.class" WIDTH = "400" HEIGHT = "400"></XMP> +<PARAM NAME = CODE VALUE = "Lesson11.class" >
+ +<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3"> +<PARAM NAME="scriptable" VALUE="false"> + +</APPLET> + +</NOEMBED></EMBED></OBJECT> + + +<!-- +<APPLET CODE = "Lesson11.class" WIDTH = "400" HEIGHT = "400">
+
+
+</APPLET> +--> +<!--"END_CONVERTED_APPLET"-->
+
+</TD>
+</TR>
+</TABLE>
+</CENTER>
+</BODY>
+</HTML>
diff --git a/demos/HodglimsNeHe/Lesson12.html b/demos/HodglimsNeHe/Lesson12.html new file mode 100644 index 0000000..037b1d6 --- /dev/null +++ b/demos/HodglimsNeHe/Lesson12.html @@ -0,0 +1,46 @@ +<HTML>
+<HEAD>
+<TITLE>Lesson12 Applet: Display Lists</TITLE>
+<STYLE TYPE="text/css">
+<!--
+A:link { COLOR: #9C9AB1; TEXT-DECORATION: none }
+A:visited { COLOR: #9C9AB1; TEXT-DECORATION: none }
+A:active { color: Yellow; TEXT-DECORATION: none }
+A:hover { color: Yellow; TEXT-DECORATION: none }
+-->
+</STYLE>
+</HEAD>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+<CENTER>
+<P>
+<FONT SIZE="2" FACE="Verdana"><B>Display Lists</B></FONT>
+</P>
+<TABLE WIDTH="100%">
+<TR>
+<TD WIDTH="30%" ALIGN="LEFT" VALIGN="TOP">
+<P>
+<FONT SIZE="1" FACE="Verdana"><B><U>Keys</U></B></FONT></P>
+<P>
+<FONT SIZE="1" FACE="Verdana">
+<B>UP</B> - Rotate up<BR>
+<B>DOWN</B> - Rotate down<BR>
+<B>LEFT</B> - Rotate left<BR>
+<B>RIGHT</B> - Rotate right
+</FONT>
+</P>
+<P><FONT SIZE="1" FACE="Verdana"><B>Note:</B> You must click inside the applet window before using these keys.</FONT></P>
+<P>
+<FONT SIZE="1" FACE="Verdana">
+<A HREF="index.html">Go back</A>
+</FONT>
+</P>
+</TD>
+<TD WIDTH="70%" ALIGN="CENTER" VALIGN="TOP">
+<APPLET CODE="Lesson12.class" WIDTH="400" HEIGHT="400">
+</APPLET>
+</TD>
+</TR>
+</TABLE>
+</CENTER>
+</BODY>
+</HTML>
diff --git a/demos/HodglimsNeHe/Lesson12.java b/demos/HodglimsNeHe/Lesson12.java new file mode 100644 index 0000000..86a9f02 --- /dev/null +++ b/demos/HodglimsNeHe/Lesson12.java @@ -0,0 +1,437 @@ +/**
+ * Lesson12.java
+ *
+ * Author: Darren Hodges
+ * Date: 05/01/2000
+ *
+ * Port of the NeHe OpenGL Tutorial (Lesson 12: "Display Lists")
+ * to Java using the GL4Java interface to OpenGL.
+ *
+ */
+
+import java.applet.*;
+import java.awt.*;
+import java.awt.event.*;
+
+//GL4Java classes
+import gl4java.GLContext;
+import gl4java.awt.GLAnimCanvas;
+import gl4java.utils.textures.*;
+
+
+public class Lesson12 extends Applet
+{
+ //Our rendering canvas
+ //We are using GLAnimCanvas because we want the canvas
+ //to be constantly redrawn
+ renderCanvas canvas = null;
+
+
+ /**
+ * void init()
+ *
+ * Initialise the applet.
+ */
+ public void init()
+ {
+ //We will use BorderLayout to layout the applet components
+ setLayout(new BorderLayout());
+
+ //Create our canvas and add it to the center of the applet
+ canvas = new renderCanvas(getSize().width, getSize().height);
+ canvas.requestFocus();
+ add("Center", canvas);
+ }
+
+
+ /**
+ * void start()
+ *
+ * Start the applet.
+ */
+ public void start()
+ {
+ //Start animating the canvas
+ canvas.start();
+ }
+
+
+ /**
+ * void stop()
+ *
+ * Stop the applet.
+ */
+ public void stop()
+ {
+ //Stop animating the canvas
+ canvas.stop();
+ }
+
+
+ /**
+ * void destroy()
+ *
+ * Destroy the applet.
+ */
+ public void destroy()
+ {
+ //Stop animating the canvas
+ canvas.stop();
+ //Destroy the canvas
+ canvas.destroy();
+ }
+
+
+
+ private class renderCanvas extends GLAnimCanvas
+ implements KeyListener, MouseListener
+ {
+ int[] texture = new int[1]; //Storage for one texture
+
+ int cube = 0; //Storage For The Display List
+ int top = 0; //Storage For The Second Display List
+ int xloop = 0; //Loop For X Axis
+ int yloop = 0; //Loop For Y Axis
+
+ float xrot = 0.0f; //X Rotation
+ float yrot = 0.0f; //Y Rotation
+
+ //Box colours
+ float boxcol[][] =
+ {
+ {1.0f,0.0f,0.0f},{1.0f,0.5f,0.0f},{1.0f,1.0f,0.0f},{0.0f,1.0f,0.0f},{0.0f,1.0f,1.0f}
+ };
+
+ //Box top colours
+ float topcol[][] =
+ {
+ {0.5f,0.0f,0.0f},{0.5f,0.25f,0.0f},{0.5f,0.5f,0.0f},{0.0f,0.5f,0.0f},{0.0f,0.5f,0.5f}
+ };
+
+
+ /**
+ * renderCanvas(int w, int h)
+ *
+ * Constructor.
+ */
+ public renderCanvas(int w, int h)
+ {
+ super(w, h);
+
+ //Registers this canvas to process keyboard events
+ addKeyListener(this);
+ addMouseListener(this);
+ }
+
+
+ /**
+ * void preInit()
+ *
+ * Called just BEFORE the GL-Context is created.
+ */
+ public void preInit()
+ {
+ //We want double buffering
+ doubleBuffer = true;
+ //But we dont want stereo view
+ stereoView = false;
+ }
+
+
+ /**
+ *
+ * void BuildList()
+ *
+ * Builds our display lists
+ */
+ public void BuildList()
+ {
+ //Create display list for cube
+ cube = gl.glGenLists(2);
+
+ gl.glNewList(cube, GL_COMPILE);
+ gl.glBegin(GL_QUADS);
+ //Bottom Face
+ gl.glTexCoord2f(1.0f, 1.0f); gl.glVertex3f(-1.0f, -1.0f, -1.0f); //Top Right Of The Texture and Quad
+ gl.glTexCoord2f(0.0f, 1.0f); gl.glVertex3f( 1.0f, -1.0f, -1.0f); //Top Left Of The Texture and Quad
+ gl.glTexCoord2f(0.0f, 0.0f); gl.glVertex3f( 1.0f, -1.0f, 1.0f); //Bottom Left Of The Texture and Quad
+ gl.glTexCoord2f(1.0f, 0.0f); gl.glVertex3f(-1.0f, -1.0f, 1.0f); //Bottom Right Of The Texture and Quad
+ //Front Face
+ gl.glTexCoord2f(0.0f, 0.0f); gl.glVertex3f(-1.0f, -1.0f, 1.0f); //Bottom Left Of The Texture and Quad
+ gl.glTexCoord2f(1.0f, 0.0f); gl.glVertex3f( 1.0f, -1.0f, 1.0f); //Bottom Right Of The Texture and Quad
+ gl.glTexCoord2f(1.0f, 1.0f); gl.glVertex3f( 1.0f, 1.0f, 1.0f); //Top Right Of The Texture and Quad
+ gl.glTexCoord2f(0.0f, 1.0f); gl.glVertex3f(-1.0f, 1.0f, 1.0f); //Top Left Of The Texture and Quad
+ //Back Face
+ gl.glTexCoord2f(1.0f, 0.0f); gl.glVertex3f(-1.0f, -1.0f, -1.0f); //Bottom Right Of The Texture and Quad
+ gl.glTexCoord2f(1.0f, 1.0f); gl.glVertex3f(-1.0f, 1.0f, -1.0f); //Top Right Of The Texture and Quad
+ gl.glTexCoord2f(0.0f, 1.0f); gl.glVertex3f( 1.0f, 1.0f, -1.0f); //Top Left Of The Texture and Quad
+ gl.glTexCoord2f(0.0f, 0.0f); gl.glVertex3f( 1.0f, -1.0f, -1.0f); //Bottom Left Of The Texture and Quad
+ //Right face
+ gl.glTexCoord2f(1.0f, 0.0f); gl.glVertex3f( 1.0f, -1.0f, -1.0f); //Bottom Right Of The Texture and Quad
+ gl.glTexCoord2f(1.0f, 1.0f); gl.glVertex3f( 1.0f, 1.0f, -1.0f); //Top Right Of The Texture and Quad
+ gl.glTexCoord2f(0.0f, 1.0f); gl.glVertex3f( 1.0f, 1.0f, 1.0f); //Top Left Of The Texture and Quad
+ gl.glTexCoord2f(0.0f, 0.0f); gl.glVertex3f( 1.0f, -1.0f, 1.0f); //Bottom Left Of The Texture and Quad
+ //Left Face
+ gl.glTexCoord2f(0.0f, 0.0f); gl.glVertex3f(-1.0f, -1.0f, -1.0f); //Bottom Left Of The Texture and Quad
+ gl.glTexCoord2f(1.0f, 0.0f); gl.glVertex3f(-1.0f, -1.0f, 1.0f); //Bottom Right Of The Texture and Quad
+ gl.glTexCoord2f(1.0f, 1.0f); gl.glVertex3f(-1.0f, 1.0f, 1.0f); //Top Right Of The Texture and Quad
+ gl.glTexCoord2f(0.0f, 1.0f); gl.glVertex3f(-1.0f, 1.0f, -1.0f); //Top Left Of The Texture and Quad
+ gl.glEnd();
+ gl.glEndList();
+
+ //Create display list for cube top
+ top = cube + 1;
+
+ gl.glNewList(top, GL_COMPILE);
+ gl.glBegin(GL_QUADS);
+ //Top Face
+ gl.glTexCoord2f(0.0f, 1.0f); gl.glVertex3f(-1.0f, 1.0f, -1.0f); //Top Left Of The Texture and Quad
+ gl.glTexCoord2f(0.0f, 0.0f); gl.glVertex3f(-1.0f, 1.0f, 1.0f); //Bottom Left Of The Texture and Quad
+ gl.glTexCoord2f(1.0f, 0.0f); gl.glVertex3f( 1.0f, 1.0f, 1.0f); //Bottom Right Of The Texture and Quad
+ gl.glTexCoord2f(1.0f, 1.0f); gl.glVertex3f( 1.0f, 1.0f, -1.0f); //Top Right Of The Texture and Quad
+ gl.glEnd();
+ gl.glEndList();
+ }
+
+
+ /**
+ * void LoadGLTextures()
+ *
+ * Load textures.
+ */
+ public void LoadGLTextures()
+ {
+ PngTextureLoader texLoader = new PngTextureLoader(gl, glu);
+ texLoader.readTexture(getCodeBase(), "data/cube.png");
+
+ if(texLoader.isOk())
+ {
+ //Create Texture
+ gl.glGenTextures(1, texture);
+ gl.glBindTexture(GL_TEXTURE_2D, texture[0]);
+
+ gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+
+ gl.glTexImage2D(GL_TEXTURE_2D,
+ 0,
+ 3,
+ texLoader.getImageWidth(),
+ texLoader.getImageHeight(),
+ 0,
+ GL_RGB,
+ GL_UNSIGNED_BYTE,
+ texLoader.getTexture());
+ }
+ }
+
+
+ /**
+ * void init()
+ *
+ * Called just AFTER the GL-Context is created.
+ */
+ public void init()
+ {
+ //Load The Texture(s)
+ LoadGLTextures();
+
+ //Build display lists
+ BuildList();
+
+ //Enable Texture Mapping
+ gl.glEnable(GL_TEXTURE_2D);
+
+ //This Will Clear The Background Color To Black
+ gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
+
+ //Enables Clearing Of The Depth Buffer
+ gl.glClearDepth(1.0);
+ //The Type Of Depth Test To Do
+ gl.glDepthFunc(GL_LESS);
+ //Enables Depth Testing
+ gl.glEnable(GL_DEPTH_TEST);
+
+ //Enables Smooth Color Shading
+ gl.glShadeModel(GL_SMOOTH);
+ //Select The Projection Matrix
+ gl.glMatrixMode(GL_PROJECTION);
+ //Reset The Projection Matrix
+ gl.glLoadIdentity();
+ //Calculate The Aspect Ratio Of The Window
+ glu.gluPerspective(45.0f, (float)getSize().width / (float)getSize().height, 0.1f, 100.0f);
+ //Select The Modelview Matrix
+ gl.glMatrixMode(GL_MODELVIEW);
+ }
+
+
+ /**
+ * void destroy()
+ *
+ * Destroy the canvas.
+ */
+ public void destroy()
+ {
+ //Destroy the GLContext
+ cvsDispose();
+ }
+
+
+ /**
+ * void reshape(int width, int height)
+ *
+ * Called after the first paint command.
+ */
+ public void reshape(int width, int height)
+ {
+ //Reset The Current Viewport And Perspective Transformation
+ gl.glViewport(0, 0, width, height);
+
+ //Select The Projection Matrix
+ gl.glMatrixMode(GL_PROJECTION);
+ //Reset The Projection Matrix
+ gl.glLoadIdentity();
+ //Calculate The Aspect Ratio Of The Window
+ glu.gluPerspective(45.0f, (float)getSize().width / (float)getSize().height, 0.1f, 100.0f);
+ //Select The Modelview Matrix
+ gl.glMatrixMode(GL_MODELVIEW);
+
+ //Enable 3D cards default light
+ gl.glEnable(GL_LIGHT0);
+ gl.glEnable(GL_LIGHTING);
+
+ //Enable coloured textures
+ gl.glEnable(GL_COLOR_MATERIAL);
+ }
+
+
+ /**
+ * void display()
+ *
+ * Draw to the canvas.
+ */
+ public void display()
+ {
+ //Ensure GL is initialised correctly
+ if (glj.gljMakeCurrent(true) == false)
+ return;
+
+ //Clear The Screen And The Depth Buffer
+ gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+ //Select texture
+ gl.glBindTexture(GL_TEXTURE_2D, texture[0]);
+
+ for(yloop = 1; yloop < 6; yloop++)
+ {
+ for(xloop = 0; xloop < yloop; xloop++)
+ {
+ //Reset The View
+ gl.glLoadIdentity();
+ gl.glTranslatef(1.4f + ((float)xloop * 2.8f) - ((float)yloop * 1.4f),((6.0f - (float)yloop) * 2.4f) -7.0f, -20.0f);
+ gl.glRotatef(45.0f - (2.0f * yloop) + xrot, 1.0f, 0.0f, 0.0f);
+ gl.glRotatef(45.0f + yrot, 0.0f, 1.0f, 0.0f);
+
+ //Select color
+ gl.glColor3fv(boxcol[yloop - 1]);
+ //Draw cube
+ gl.glCallList(cube);
+
+ //Select color
+ gl.glColor3fv(topcol[yloop - 1]);
+ //Draw top
+ gl.glCallList(top);
+ }
+ }
+
+ //Swap buffers
+ glj.gljSwap();
+ }
+
+
+ /**
+ * void keyTyped(KeyEvent e)
+ *
+ * Invoked when a key has been typed. This event occurs when a key press is followed by a key release.
+ */
+ public void keyTyped(KeyEvent e)
+ {
+ }
+
+
+ /**
+ * void keyPressed(KeyEvent e)
+ *
+ * Invoked when a key has been pressed.
+ */
+ public void keyPressed(KeyEvent e)
+ {
+ switch(e.getKeyCode())
+ {
+ //Rotate cubes when user presses UP
+ case KeyEvent.VK_UP:
+ {
+ xrot -= 0.2f;
+ break;
+ }
+
+ //Rotate cubes when user presses DOWN
+ case KeyEvent.VK_DOWN:
+ {
+ xrot += 0.2f;
+ break;
+ }
+
+ //Rotate cubes when user presses RIGHT
+ case KeyEvent.VK_RIGHT:
+ {
+ yrot += 0.2f;
+ break;
+ }
+
+ //Rotate cubes when user presses LEFT
+ case KeyEvent.VK_LEFT:
+ {
+ yrot -= 0.2f;
+ break;
+ }
+ }
+ }
+
+
+ /**
+ * void keyReleased(KeyEvent e)
+ *
+ * Invoked when a key has been released.
+ */
+ public void keyReleased(KeyEvent e)
+ {
+ }
+
+ // Methods required for the implementation of MouseListener
+ public void mouseEntered( MouseEvent evt )
+ {
+ Component comp = evt.getComponent();
+ if( comp.equals(this ) )
+ {
+ requestFocus();
+ }
+ }
+
+ public void mouseExited( MouseEvent evt )
+ { }
+ public void mousePressed( MouseEvent evt )
+ { }
+ public void mouseReleased( MouseEvent evt )
+ { }
+ public void mouseClicked( MouseEvent evt )
+ {
+ Component comp = evt.getComponent();
+ if( comp.equals(this ) )
+ {
+ requestFocus();
+ }
+ }
+
+ }
+}
diff --git a/demos/HodglimsNeHe/Lesson12_plugin13.html b/demos/HodglimsNeHe/Lesson12_plugin13.html new file mode 100644 index 0000000..6ac571e --- /dev/null +++ b/demos/HodglimsNeHe/Lesson12_plugin13.html @@ -0,0 +1,77 @@ +<HTML>
+<HEAD>
+<TITLE>Lesson12 Applet: Display Lists</TITLE>
+<STYLE TYPE="text/css">
+<!--
+A:link { COLOR: #9C9AB1; TEXT-DECORATION: none }
+A:visited { COLOR: #9C9AB1; TEXT-DECORATION: none }
+A:active { color: Yellow; TEXT-DECORATION: none }
+A:hover { color: Yellow; TEXT-DECORATION: none }
+-->
+</STYLE>
+</HEAD>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+<CENTER>
+<P>
+<FONT SIZE="2" FACE="Verdana"><B>Display Lists</B></FONT>
+</P>
+<TABLE WIDTH="100%">
+<TR>
+<TD WIDTH="30%" ALIGN="LEFT" VALIGN="TOP">
+<P>
+<FONT SIZE="1" FACE="Verdana"><B><U>Keys</U></B></FONT></P>
+<P>
+<FONT SIZE="1" FACE="Verdana">
+<B>UP</B> - Rotate up<BR>
+<B>DOWN</B> - Rotate down<BR>
+<B>LEFT</B> - Rotate left<BR>
+<B>RIGHT</B> - Rotate right
+</FONT>
+</P>
+<P><FONT SIZE="1" FACE="Verdana"><B>Note:</B> You must click inside the applet window before using these keys.</FONT></P>
+<P>
+<FONT SIZE="1" FACE="Verdana">
+<A HREF="index.html">Go back</A>
+</FONT>
+</P>
+</TD>
+<TD WIDTH="70%" ALIGN="CENTER" VALIGN="TOP">
+<!--"CONVERTED_APPLET"-->
+<!-- CONVERTER VERSION 1.3 --> +<SCRIPT LANGUAGE="JavaScript"><!-- + var _info = navigator.userAgent; var _ns = false; + var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0); +//--></SCRIPT> +<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!-- + var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0))); +//--></SCRIPT></COMMENT> + +<SCRIPT LANGUAGE="JavaScript"><!-- + if (_ie == true) document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = "400" HEIGHT = "400" codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0"><NOEMBED><XMP>'); + else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.3" CODE = "Lesson12.class" WIDTH = "400" HEIGHT = "400" scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html"><NOEMBED><XMP>'); +//--></SCRIPT> +<APPLET CODE = "Lesson12.class" WIDTH = "400" HEIGHT = "400"></XMP> +<PARAM NAME = CODE VALUE = "Lesson12.class" >
+ +<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3"> +<PARAM NAME="scriptable" VALUE="false"> + +</APPLET> + +</NOEMBED></EMBED></OBJECT> + + +<!-- +<APPLET CODE = "Lesson12.class" WIDTH = "400" HEIGHT = "400">
+
+
+</APPLET> +--> +<!--"END_CONVERTED_APPLET"-->
+
+</TD>
+</TR>
+</TABLE>
+</CENTER>
+</BODY>
+</HTML>
diff --git a/demos/HodglimsNeHe/Lesson16.html b/demos/HodglimsNeHe/Lesson16.html new file mode 100644 index 0000000..ea079be --- /dev/null +++ b/demos/HodglimsNeHe/Lesson16.html @@ -0,0 +1,51 @@ +<HTML>
+<HEAD>
+<TITLE>Lesson16 Applet: Cool Looking Fog</TITLE>
+<STYLE TYPE="text/css">
+<!--
+A:link { COLOR: #9C9AB1; TEXT-DECORATION: none }
+A:visited { COLOR: #9C9AB1; TEXT-DECORATION: none }
+A:active { color: Yellow; TEXT-DECORATION: none }
+A:hover { color: Yellow; TEXT-DECORATION: none }
+-->
+</STYLE>
+</HEAD>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+<CENTER>
+<P>
+<FONT SIZE="2" FACE="Verdana"><B>Cool Looking Fog</B></FONT>
+</P>
+<TABLE WIDTH="100%">
+<TR>
+<TD WIDTH="30%" ALIGN="LEFT" VALIGN="TOP">
+<P>
+<FONT SIZE="1" FACE="Verdana"><B><U>Keys</U></B></FONT></P>
+<P>
+<FONT SIZE="1" FACE="Verdana">
+<B>L</B> - Lights ON/OFF<BR>
+<B>F</B> - Change texture filter<BR>
+<B>G</B> - Change fog mode<BR>
+<B>PG_UP</B> - Zoom out<BR>
+<B>PG_DOWN</B> - Zoom in<BR>
+<B>UP</B> - Rotate cube<BR>
+<B>DOWN</B> - Rotate cube<BR>
+<B>LEFT</B> - Rotate cube<BR>
+<B>RIGHT</B> - Rotate cube
+</FONT>
+</P>
+<P><FONT SIZE="1" FACE="Verdana"><B>Note:</B> You must click inside the applet window before using these keys.</FONT></P>
+<P>
+<FONT SIZE="1" FACE="Verdana">
+<A HREF="index.html">Go back</A>
+</FONT>
+</P>
+</TD>
+<TD WIDTH="70%" ALIGN="CENTER" VALIGN="TOP">
+<APPLET CODE="Lesson16.class" WIDTH="400" HEIGHT="400">
+</APPLET>
+</TD>
+</TR>
+</TABLE>
+</CENTER>
+</BODY>
+</HTML>
diff --git a/demos/HodglimsNeHe/Lesson16.java b/demos/HodglimsNeHe/Lesson16.java new file mode 100644 index 0000000..82fa7b7 --- /dev/null +++ b/demos/HodglimsNeHe/Lesson16.java @@ -0,0 +1,551 @@ +/**
+ * Lesson16.java
+ *
+ * Author: Darren Hodges
+ * Date: 19/01/2000
+ *
+ * Port of the NeHe OpenGL Tutorial (Lesson 16: "Cool Looking Fog")
+ * to Java using the GL4Java interface to OpenGL.
+ *
+ * Note: The MipMapping code is only available in GL4Java 2.1.2.1 and later!
+ *
+ */
+
+import java.applet.*;
+import java.awt.*;
+import java.awt.event.*;
+
+//GL4Java classes
+import gl4java.GLContext;
+import gl4java.awt.GLAnimCanvas;
+import gl4java.utils.textures.*;
+
+
+public class Lesson16 extends Applet
+{
+ //Our rendering canvas
+ //We are using GLAnimCanvas because we want the canvas
+ //to be constantly redrawn
+ renderCanvas canvas = null;
+
+
+ /**
+ * void init()
+ *
+ * Initialise the applet.
+ */
+ public void init()
+ {
+ //We will use BorderLayout to layout the applet components
+ setLayout(new BorderLayout());
+
+ //Create our canvas and add it to the center of the applet
+ canvas = new renderCanvas(getSize().width, getSize().height);
+ canvas.requestFocus();
+ add("Center", canvas);
+ }
+
+
+ /**
+ * void start()
+ *
+ * Start the applet.
+ */
+ public void start()
+ {
+ //Start animating the canvas
+ canvas.start();
+ }
+
+
+ /**
+ * void stop()
+ *
+ * Stop the applet.
+ */
+ public void stop()
+ {
+ //Stop animating the canvas
+ canvas.stop();
+ }
+
+
+ /**
+ * void destroy()
+ *
+ * Destroy the applet.
+ */
+ public void destroy()
+ {
+ //Stop animating the canvas
+ canvas.stop();
+ //Destroy the canvas
+ canvas.destroy();
+ }
+
+
+
+ private class renderCanvas extends GLAnimCanvas
+ implements KeyListener, MouseListener
+ {
+ boolean light = true; //Lighting ON/OFF
+ boolean lp = false; //L Pressed?
+ boolean fp = false; //F Pressed?
+ boolean gp = false; //G Pressed?
+
+ float xrot = 0.0f; //X Rotation
+ float yrot = 0.0f; //Y Rotation
+ float xspeed = 0.0f; //X Rotation Speed
+ float yspeed = 0.0f; //Y Rotation Speed
+
+ float z = -8.0f; //Depth Into The Screen
+
+ //Ambient light
+ float[] LightAmbient = { 0.5f, 0.5f, 0.5f, 1.0f };
+
+ //Diffuse light
+ float[] LightDiffuse = { 1.0f, 1.0f, 1.0f, 1.0f };
+
+ //Light position
+ float[] LightPosition = { 0.0f, 0.0f, 2.0f, 1.0f };
+
+ int filter = 0; //Which Filter To Use
+
+ int[] texture = new int[3]; //Storage for 3 textures
+
+ //Fog
+ int[] fogMode = { GL_EXP, GL_EXP2, GL_LINEAR }; //Storage For Three Types Of Fog
+ int fogfilter = 0; //Which Fog To Use
+ float[] fogColor = { 0.5f, 0.5f, 0.5f, 1.0f }; //Fog Color
+
+
+ /**
+ * renderCanvas(int w, int h)
+ *
+ * Constructor.
+ */
+ public renderCanvas(int w, int h)
+ {
+ super(w, h);
+
+ //Registers this canvas to process keyboard events
+ addKeyListener(this);
+ addMouseListener(this);
+ }
+
+
+ /**
+ * void preInit()
+ *
+ * Called just BEFORE the GL-Context is created.
+ */
+ public void preInit()
+ {
+ //We want double buffering
+ doubleBuffer = true;
+ //But we dont want stereo view
+ stereoView = false;
+ }
+
+
+ /**
+ * void LoadGLTextures()
+ *
+ * Load textures.
+ */
+ public void LoadGLTextures()
+ {
+ PngTextureLoader texLoader = new PngTextureLoader(gl, glu);
+ texLoader.readTexture(getCodeBase(), "data/crate.png");
+
+ if(texLoader.isOk())
+ {
+ //Create Nearest Filtered Texture
+ gl.glGenTextures(3, texture);
+ gl.glBindTexture(GL_TEXTURE_2D, texture[0]);
+
+ gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+
+ gl.glTexImage2D(GL_TEXTURE_2D,
+ 0,
+ 3,
+ texLoader.getImageWidth(),
+ texLoader.getImageHeight(),
+ 0,
+ GL_RGB,
+ GL_UNSIGNED_BYTE,
+ texLoader.getTexture());
+
+ //Create Linear Filtered Texture
+ gl.glBindTexture(GL_TEXTURE_2D, texture[1]);
+ gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+
+ gl.glTexImage2D(GL_TEXTURE_2D,
+ 0,
+ 3,
+ texLoader.getImageWidth(),
+ texLoader.getImageHeight(),
+ 0,
+ GL_RGB,
+ GL_UNSIGNED_BYTE,
+ texLoader.getTexture());
+
+ //Create MipMapped Texture (Only with GL4Java 2.1.2.1 and later!)
+ gl.glBindTexture(GL_TEXTURE_2D, texture[2]);
+ gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
+
+ glu.gluBuild2DMipmaps(GL_TEXTURE_2D,
+ 3,
+ texLoader.getImageWidth(),
+ texLoader.getImageHeight(),
+ GL_RGB,
+ GL_UNSIGNED_BYTE,
+ texLoader.getTexture());
+ }
+ }
+
+
+ /**
+ * void init()
+ *
+ * Called just AFTER the GL-Context is created.
+ */
+ public void init()
+ {
+ //Load The Texture(s)
+ LoadGLTextures();
+ //Enable Texture Mapping
+ gl.glEnable(GL_TEXTURE_2D);
+
+ //This Will Clear The Background Color To Color Of Fog
+ gl.glClearColor(0.5f, 0.5f, 0.5f, 1.0f);
+
+ //Enables Clearing Of The Depth Buffer
+ gl.glClearDepth(1.0);
+ //The Type Of Depth Test To Do
+ gl.glDepthFunc(GL_LESS);
+ //Enables Depth Testing
+ gl.glEnable(GL_DEPTH_TEST);
+
+ //Enables Smooth Color Shading
+ gl.glShadeModel(GL_SMOOTH);
+ //Select The Projection Matrix
+ gl.glMatrixMode(GL_PROJECTION);
+ //Reset The Projection Matrix
+ gl.glLoadIdentity();
+ //Calculate The Aspect Ratio Of The Window
+ glu.gluPerspective(45.0f, (float)getSize().width / (float)getSize().height, 0.1f, 100.0f);
+ //Select The Modelview Matrix
+ gl.glMatrixMode(GL_MODELVIEW);
+
+ //Lights
+ gl.glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient);
+ gl.glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse);
+ gl.glLightfv(GL_LIGHT1, GL_POSITION, LightPosition);
+
+ //Enable light
+ gl.glEnable(GL_LIGHT1);
+ gl.glEnable(GL_LIGHTING);
+
+ //Enables GL_FOG
+ gl.glEnable(GL_FOG);
+ //Fog Mode
+ gl.glFogi(GL_FOG_MODE, fogMode[fogfilter]);
+ //Set Fog Color
+ gl.glFogfv(GL_FOG_COLOR, fogColor);
+ //How Dense Will The Fog Be
+ gl.glFogf(GL_FOG_DENSITY, 0.35f);
+ //Fog Hint Value
+ gl.glHint(GL_FOG_HINT, GL_DONT_CARE);
+ //Fog Start Depth
+ gl.glFogf(GL_FOG_START, 1.0f);
+ //Fog End Depth
+ gl.glFogf(GL_FOG_END, 5.0f);
+ }
+
+
+ /**
+ * void destroy()
+ *
+ * Destroy the canvas.
+ */
+ public void destroy()
+ {
+ //Destroy the GLContext
+ cvsDispose();
+ }
+
+
+ /**
+ * void reshape(int width, int height)
+ *
+ * Called after the first paint command.
+ */
+ public void reshape(int width, int height)
+ {
+ //Reset The Current Viewport And Perspective Transformation
+ gl.glViewport(0, 0, width, height);
+
+ //Select The Projection Matrix
+ gl.glMatrixMode(GL_PROJECTION);
+ //Reset The Projection Matrix
+ gl.glLoadIdentity();
+ //Calculate The Aspect Ratio Of The Window
+ glu.gluPerspective(45.0f, (float)getSize().width / (float)getSize().height, 0.1f, 100.0f);
+ //Select The Modelview Matrix
+ gl.glMatrixMode(GL_MODELVIEW);
+ }
+
+
+ /**
+ * void display()
+ *
+ * Draw to the canvas.
+ */
+ public void display()
+ {
+ //Ensure GL is initialised correctly
+ if (glj.gljMakeCurrent(true) == false)
+ return;
+
+ //Clear The Screen And The Depth Buffer
+ gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ //Reset The View
+ gl.glLoadIdentity();
+
+ //Move into the screen
+ gl.glTranslatef(0.0f, 0.0f, z);
+
+ //Rotate On The X Axis
+ gl.glRotatef(xrot,1.0f, 0.0f, 0.0f);
+ //Rotate On The Y Axis
+ gl.glRotatef(yrot, 0.0f, 1.0f, 0.0f);
+
+ //Select texture
+ gl.glBindTexture(GL_TEXTURE_2D, texture[filter]);
+
+ gl.glBegin(GL_QUADS);
+ //Front Face
+ gl.glNormal3f(0.0f, 0.0f, 1.0f);
+ gl.glTexCoord2f(0.0f, 0.0f); gl.glVertex3f(-1.0f, -1.0f, 1.0f); //Bottom Left Of The Texture and Quad
+ gl.glTexCoord2f(1.0f, 0.0f); gl.glVertex3f( 1.0f, -1.0f, 1.0f); //Bottom Right Of The Texture and Quad
+ gl.glTexCoord2f(1.0f, 1.0f); gl.glVertex3f( 1.0f, 1.0f, 1.0f); //Top Right Of The Texture and Quad
+ gl.glTexCoord2f(0.0f, 1.0f); gl.glVertex3f(-1.0f, 1.0f, 1.0f); //Top Left Of The Texture and Quad
+ //Back Face
+ gl.glNormal3f(0.0f, 0.0f, -1.0f);
+ gl.glTexCoord2f(1.0f, 0.0f); gl.glVertex3f(-1.0f, -1.0f, -1.0f); //Bottom Right Of The Texture and Quad
+ gl.glTexCoord2f(1.0f, 1.0f); gl.glVertex3f(-1.0f, 1.0f, -1.0f); //Top Right Of The Texture and Quad
+ gl.glTexCoord2f(0.0f, 1.0f); gl.glVertex3f( 1.0f, 1.0f, -1.0f); //Top Left Of The Texture and Quad
+ gl.glTexCoord2f(0.0f, 0.0f); gl.glVertex3f( 1.0f, -1.0f, -1.0f); //Bottom Left Of The Texture and Quad
+ //Top Face
+ gl.glNormal3f(0.0f, 1.0f, 0.0f);
+ gl.glTexCoord2f(0.0f, 1.0f); gl.glVertex3f(-1.0f, 1.0f, -1.0f); //Top Left Of The Texture and Quad
+ gl.glTexCoord2f(0.0f, 0.0f); gl.glVertex3f(-1.0f, 1.0f, 1.0f); //Bottom Left Of The Texture and Quad
+ gl.glTexCoord2f(1.0f, 0.0f); gl.glVertex3f( 1.0f, 1.0f, 1.0f); //Bottom Right Of The Texture and Quad
+ gl.glTexCoord2f(1.0f, 1.0f); gl.glVertex3f( 1.0f, 1.0f, -1.0f); //Top Right Of The Texture and Quad
+ //Bottom Face
+ gl.glNormal3f(0.0f, -1.0f, 0.0f);
+ gl.glTexCoord2f(1.0f, 1.0f); gl.glVertex3f(-1.0f, -1.0f, -1.0f); //Top Right Of The Texture and Quad
+ gl.glTexCoord2f(0.0f, 1.0f); gl.glVertex3f( 1.0f, -1.0f, -1.0f); //Top Left Of The Texture and Quad
+ gl.glTexCoord2f(0.0f, 0.0f); gl.glVertex3f( 1.0f, -1.0f, 1.0f); //Bottom Left Of The Texture and Quad
+ gl.glTexCoord2f(1.0f, 0.0f); gl.glVertex3f(-1.0f, -1.0f, 1.0f); //Bottom Right Of The Texture and Quad
+ //Right face
+ gl.glNormal3f(1.0f, 0.0f, 0.0f);
+ gl.glTexCoord2f(1.0f, 0.0f); gl.glVertex3f( 1.0f, -1.0f, -1.0f); //Bottom Right Of The Texture and Quad
+ gl.glTexCoord2f(1.0f, 1.0f); gl.glVertex3f( 1.0f, 1.0f, -1.0f); //Top Right Of The Texture and Quad
+ gl.glTexCoord2f(0.0f, 1.0f); gl.glVertex3f( 1.0f, 1.0f, 1.0f); //Top Left Of The Texture and Quad
+ gl.glTexCoord2f(0.0f, 0.0f); gl.glVertex3f( 1.0f, -1.0f, 1.0f); //Bottom Left Of The Texture and Quad
+ //Left Face
+ gl.glNormal3f(-1.0f, 0.0f, 0.0f);
+ gl.glTexCoord2f(0.0f, 0.0f); gl.glVertex3f(-1.0f, -1.0f, -1.0f); //Bottom Left Of The Texture and Quad
+ gl.glTexCoord2f(1.0f, 0.0f); gl.glVertex3f(-1.0f, -1.0f, 1.0f); //Bottom Right Of The Texture and Quad
+ gl.glTexCoord2f(1.0f, 1.0f); gl.glVertex3f(-1.0f, 1.0f, 1.0f); //Top Right Of The Texture and Quad
+ gl.glTexCoord2f(0.0f, 1.0f); gl.glVertex3f(-1.0f, 1.0f, -1.0f); //Top Left Of The Texture and Quad
+ gl.glEnd();
+
+ //X Axis Rotation
+ xrot += xspeed;
+ //Y Axis Rotation
+ yrot += yspeed;
+
+ //Swap buffers
+ glj.gljSwap();
+ }
+
+
+ /**
+ * void keyTyped(KeyEvent e)
+ *
+ * Invoked when a key has been typed. This event occurs when a key press is followed by a key release.
+ */
+ public void keyTyped(KeyEvent e)
+ {
+ }
+
+
+ /**
+ * void keyPressed(KeyEvent e)
+ *
+ * Invoked when a key has been pressed.
+ */
+ public void keyPressed(KeyEvent e)
+ {
+ switch(e.getKeyCode())
+ {
+ //Switch ON/OFF light when L is pressed
+ case KeyEvent.VK_L:
+ {
+ if(!lp)
+ {
+ lp = true;
+ //Toggle light
+ light = !light;
+
+ if(!light)
+ gl.glDisable(GL_LIGHTING);
+ else
+ gl.glEnable(GL_LIGHTING);
+ }
+
+ break;
+ }
+
+ //Switch filter when F is pressed
+ case KeyEvent.VK_F:
+ {
+ if(!fp)
+ {
+ fp = true;
+ //Change filter
+ filter += 1;
+ if(filter > 2)
+ filter = 0;
+ }
+
+ break;
+ }
+
+ //Switch fog mode when G is pressed
+ case KeyEvent.VK_G:
+ {
+ if(!gp)
+ {
+ gp = true;
+ //Toggle fog
+ fogfilter += 1;
+ if(fogfilter > 2)
+ fogfilter = 0;
+
+ gl.glFogi(GL_FOG_MODE, fogMode[fogfilter]); //Fog Mode
+ }
+
+ break;
+ }
+
+ //Move cube back when user presses PG_UP
+ case KeyEvent.VK_PAGE_UP:
+ {
+ z -= 0.2f;
+ break;
+ }
+
+ //Move cube forwards when user presses PG_DOWN
+ case KeyEvent.VK_PAGE_DOWN:
+ {
+ z += 0.2f;
+ break;
+ }
+
+ //Increase X rotation speed when user presses UP
+ case KeyEvent.VK_UP:
+ {
+ xspeed += 0.2f;
+ break;
+ }
+
+ //Decrease X rotation speed when user presses DOWN
+ case KeyEvent.VK_DOWN:
+ {
+ xspeed -= 0.2f;
+ break;
+ }
+
+ //Increase Y rotation speed when user presses RIGHT
+ case KeyEvent.VK_RIGHT:
+ {
+ yspeed += 0.2f;
+ break;
+ }
+
+ //Decrease Y rotation speed when user presses LEFT
+ case KeyEvent.VK_LEFT:
+ {
+ yspeed -= 0.2f;
+ break;
+ }
+ }
+ }
+
+
+ /**
+ * void keyReleased(KeyEvent e)
+ *
+ * Invoked when a key has been released.
+ */
+ public void keyReleased(KeyEvent e)
+ {
+ switch(e.getKeyCode())
+ {
+ //Key has been released
+ case KeyEvent.VK_L:
+ {
+ lp = false;
+ break;
+ }
+
+ //Key has been released
+ case KeyEvent.VK_F:
+ {
+ fp = false;
+ break;
+ }
+
+ //Key has been released
+ case KeyEvent.VK_G:
+ {
+ gp = false;
+ break;
+ }
+ }
+ }
+
+ // Methods required for the implementation of MouseListener
+ public void mouseEntered( MouseEvent evt )
+ {
+ Component comp = evt.getComponent();
+ if( comp.equals(this ) )
+ {
+ requestFocus();
+ }
+ }
+
+ public void mouseExited( MouseEvent evt )
+ { }
+ public void mousePressed( MouseEvent evt )
+ { }
+ public void mouseReleased( MouseEvent evt )
+ { }
+ public void mouseClicked( MouseEvent evt )
+ {
+ Component comp = evt.getComponent();
+ if( comp.equals(this ) )
+ {
+ requestFocus();
+ }
+ }
+
+ }
+}
diff --git a/demos/HodglimsNeHe/Lesson16_plugin13.html b/demos/HodglimsNeHe/Lesson16_plugin13.html new file mode 100644 index 0000000..43441bc --- /dev/null +++ b/demos/HodglimsNeHe/Lesson16_plugin13.html @@ -0,0 +1,82 @@ +<HTML>
+<HEAD>
+<TITLE>Lesson16 Applet: Cool Looking Fog</TITLE>
+<STYLE TYPE="text/css">
+<!--
+A:link { COLOR: #9C9AB1; TEXT-DECORATION: none }
+A:visited { COLOR: #9C9AB1; TEXT-DECORATION: none }
+A:active { color: Yellow; TEXT-DECORATION: none }
+A:hover { color: Yellow; TEXT-DECORATION: none }
+-->
+</STYLE>
+</HEAD>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+<CENTER>
+<P>
+<FONT SIZE="2" FACE="Verdana"><B>Cool Looking Fog</B></FONT>
+</P>
+<TABLE WIDTH="100%">
+<TR>
+<TD WIDTH="30%" ALIGN="LEFT" VALIGN="TOP">
+<P>
+<FONT SIZE="1" FACE="Verdana"><B><U>Keys</U></B></FONT></P>
+<P>
+<FONT SIZE="1" FACE="Verdana">
+<B>L</B> - Lights ON/OFF<BR>
+<B>F</B> - Change texture filter<BR>
+<B>G</B> - Change fog mode<BR>
+<B>PG_UP</B> - Zoom out<BR>
+<B>PG_DOWN</B> - Zoom in<BR>
+<B>UP</B> - Rotate cube<BR>
+<B>DOWN</B> - Rotate cube<BR>
+<B>LEFT</B> - Rotate cube<BR>
+<B>RIGHT</B> - Rotate cube
+</FONT>
+</P>
+<P><FONT SIZE="1" FACE="Verdana"><B>Note:</B> You must click inside the applet window before using these keys.</FONT></P>
+<P>
+<FONT SIZE="1" FACE="Verdana">
+<A HREF="index.html">Go back</A>
+</FONT>
+</P>
+</TD>
+<TD WIDTH="70%" ALIGN="CENTER" VALIGN="TOP">
+<!--"CONVERTED_APPLET"-->
+<!-- CONVERTER VERSION 1.3 --> +<SCRIPT LANGUAGE="JavaScript"><!-- + var _info = navigator.userAgent; var _ns = false; + var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0); +//--></SCRIPT> +<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!-- + var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0))); +//--></SCRIPT></COMMENT> + +<SCRIPT LANGUAGE="JavaScript"><!-- + if (_ie == true) document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = "400" HEIGHT = "400" codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0"><NOEMBED><XMP>'); + else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.3" CODE = "Lesson16.class" WIDTH = "400" HEIGHT = "400" scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html"><NOEMBED><XMP>'); +//--></SCRIPT> +<APPLET CODE = "Lesson16.class" WIDTH = "400" HEIGHT = "400"></XMP> +<PARAM NAME = CODE VALUE = "Lesson16.class" >
+ +<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3"> +<PARAM NAME="scriptable" VALUE="false"> + +</APPLET> + +</NOEMBED></EMBED></OBJECT> + + +<!-- +<APPLET CODE = "Lesson16.class" WIDTH = "400" HEIGHT = "400">
+
+
+</APPLET> +--> +<!--"END_CONVERTED_APPLET"-->
+
+</TD>
+</TR>
+</TABLE>
+</CENTER>
+</BODY>
+</HTML>
diff --git a/demos/HodglimsNeHe/Lesson18.html b/demos/HodglimsNeHe/Lesson18.html new file mode 100644 index 0000000..2cf8f5a --- /dev/null +++ b/demos/HodglimsNeHe/Lesson18.html @@ -0,0 +1,50 @@ +<HTML>
+<HEAD>
+<TITLE>Lesson18 Applet: Quadratics</TITLE>
+<STYLE TYPE="text/css">
+<!--
+A:link { COLOR: #9C9AB1; TEXT-DECORATION: none }
+A:visited { COLOR: #9C9AB1; TEXT-DECORATION: none }
+A:active { color: Yellow; TEXT-DECORATION: none }
+A:hover { color: Yellow; TEXT-DECORATION: none }
+-->
+</STYLE>
+</HEAD>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+<CENTER>
+<P>
+<FONT SIZE="2" FACE="Verdana"><B>Quadratics</B></FONT><BR>
+Ported by <A HREF="MAILTO: [email protected]">Lapo Luchini</A>
+</P>
+<TABLE WIDTH="100%">
+<TR>
+<TD WIDTH="30%" ALIGN="LEFT" VALIGN="TOP">
+<FONT SIZE="1" FACE="Verdana"><B><U>Keys</U></B></FONT></P>
+<P>
+<FONT SIZE="1" FACE="Verdana">
+<B>L</B> - Lights ON/OFF<BR>
+<B>F</B> - Change texture filter<BR>
+<B>PG_UP</B> - Zoom out<BR>
+<B>PG_DOWN</B> - Zoom in<BR>
+<B>UP</B> - Rotate cube<BR>
+<B>DOWN</B> - Rotate cube<BR>
+<B>LEFT</B> - Rotate cube<BR>
+<B>RIGHT</B> - Rotate cube
+</FONT>
+</P>
+<P><FONT SIZE="1" FACE="Verdana"><B>Note:</B> You must click inside the applet window before using these keys.</FONT></P>
+<P>
+<FONT SIZE="1" FACE="Verdana">
+<A HREF="index.html">Go back</A>
+</FONT>
+</P>
+</TD>
+<TD WIDTH="70%" ALIGN="CENTER" VALIGN="TOP">
+<APPLET CODE="Lesson18.class" WIDTH="400" HEIGHT="400">
+</APPLET>
+</TD>
+</TR>
+</TABLE>
+</CENTER>
+</BODY>
+</HTML>
diff --git a/demos/HodglimsNeHe/Lesson18.java b/demos/HodglimsNeHe/Lesson18.java new file mode 100644 index 0000000..b63a627 --- /dev/null +++ b/demos/HodglimsNeHe/Lesson18.java @@ -0,0 +1,459 @@ +/**
+ * Lesson18.java
+ *
+ * by Lapo Luchini <[email protected]>
+ * Based on Lesson 7 by Darren Hodges
+ * Date: 23/08/2000
+ *
+ * Port of the NeHe OpenGL Tutorial (Lesson 18: "Quadratics")
+ * to Java using the GL4Java interface to OpenGL.
+ *
+ * Note: The MipMapping code is only available in GL4Java 2.1.2.1 and later!
+ *
+ */
+
+import java.applet.*;
+import java.awt.*;
+import java.awt.event.*;
+
+//GL4Java classes
+import gl4java.GLContext;
+import gl4java.awt.GLAnimCanvas;
+import gl4java.utils.textures.*;
+
+public class Lesson18 extends Applet
+{
+ //Our rendering canvas
+ //We are using GLAnimCanvas because we want the canvas
+ //to be constantly redrawn
+ renderCanvas canvas=null;
+
+ /**
+ * void init()
+ *
+ * Initialise the applet.
+ */
+ public void init() {
+ //We will use BorderLayout to layout the applet components
+ setLayout(new BorderLayout());
+
+ //Create our canvas and add it to the center of the applet
+ canvas=new renderCanvas(getSize().width, getSize().height);
+ canvas.requestFocus();
+ add("Center", canvas);
+ }
+
+ /**
+ * void start()
+ *
+ * Start the applet.
+ */
+ public void start() {
+ //Start animating the canvas
+ canvas.start();
+ }
+
+ /**
+ * void stop()
+ *
+ * Stop the applet.
+ */
+ public void stop() {
+ //Stop animating the canvas
+ canvas.stop();
+ }
+
+ /**
+ * void destroy()
+ *
+ * Destroy the applet.
+ */
+ public void destroy() {
+ //Stop animating the canvas
+ canvas.stop();
+ //Destroy the canvas
+ canvas.destroy();
+ }
+
+ private class renderCanvas extends GLAnimCanvas
+ implements KeyListener, MouseListener
+ {
+ boolean light = true; //Lighting ON/OFF
+ boolean lp = false; //L Pressed?
+ boolean fp = false; //F Pressed?
+ boolean sp = false; //Spacebar Pressed?
+
+ float xrot = 0.0f; //X Rotation
+ float yrot = 0.0f; //Y Rotation
+ float xspeed = 0.0f; //X Rotation Speed
+ float yspeed = 0.0f; //Y Rotation Speed
+
+ float z = -5.0f; //Depth Into The Screen
+
+ //Ambient light
+ float[] LightAmbient = { 0.5f, 0.5f, 0.5f, 1.0f };
+
+ //Diffuse light
+ float[] LightDiffuse = { 1.0f, 1.0f, 1.0f, 1.0f };
+
+ //Light position
+ float[] LightPosition = { 0.0f, 0.0f, 2.0f, 1.0f };
+
+ int filter = 0; //Which Filter To Use
+
+ int[] texture = new int[3]; //Storage for 3 textures
+
+ int part1; // Start Of Disc
+ int part2; // End Of Disc
+ int p1=0; // Increase 1
+ int p2=1; // Increase 2
+ int quadratic; // Storage For Our Quadratic Objects
+ int object=0; // Which Object To Draw
+
+ public renderCanvas(int w, int h) {
+ super(w, h);
+ //Registers this canvas to process keyboard events
+ addKeyListener(this);
+ addMouseListener(this);
+ }
+
+ public void preInit() {
+ //We want double buffering
+ doubleBuffer = true;
+ //But we dont want stereo view
+ stereoView = false;
+ }
+
+ public void LoadTextures() {
+ PngTextureLoader texLoader=new PngTextureLoader(gl, glu);
+ // catch exception if executed by command-line
+ try {
+ texLoader.readTexture(getCodeBase(), "data/crate.png");
+ } catch(NullPointerException e) {
+ texLoader.readTexture("data/crate.png");
+ }
+ if(texLoader.isOk()) {
+ gl.glGenTextures(3, texture);
+ gl.glBindTexture(GL_TEXTURE_2D, texture[0]);
+
+ gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+
+ gl.glTexImage2D(GL_TEXTURE_2D,
+ 0,
+ 3,
+ texLoader.getImageWidth(),
+ texLoader.getImageHeight(),
+ 0,
+ GL_RGB,
+ GL_UNSIGNED_BYTE,
+ texLoader.getTexture());
+
+ //Create Linear Filtered Texture
+ gl.glBindTexture(GL_TEXTURE_2D, texture[1]);
+ gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+
+ gl.glTexImage2D(GL_TEXTURE_2D,
+ 0,
+ 3,
+ texLoader.getImageWidth(),
+ texLoader.getImageHeight(),
+ 0,
+ GL_RGB,
+ GL_UNSIGNED_BYTE,
+ texLoader.getTexture());
+
+ //Create MipMapped Texture (Only with GL4Java 2.1.2.1 and later!)
+ gl.glBindTexture(GL_TEXTURE_2D, texture[2]);
+ gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
+
+ glu.gluBuild2DMipmaps(GL_TEXTURE_2D,
+ 3,
+ texLoader.getImageWidth(),
+ texLoader.getImageHeight(), GL_RGB,
+ GL_UNSIGNED_BYTE,
+ texLoader.getTexture());
+ }
+ }
+
+ public void init() {
+ LoadTextures();
+ gl.glEnable(GL_TEXTURE_2D);
+
+ //This Will Clear The Background Color To Black
+ gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
+
+ //Enables Clearing Of The Depth Buffer
+ gl.glClearDepth(1.0);
+ //The Type Of Depth Lesson18 To Do
+ gl.glDepthFunc(GL_LESS);
+ //Enables Depth Lesson18ing
+ gl.glEnable(GL_DEPTH_TEST);
+
+ //Enables Smooth Color Shading
+ gl.glShadeModel(GL_SMOOTH);
+ //Select The Projection Matrix
+ gl.glMatrixMode(GL_PROJECTION);
+ //Reset The Projection Matrix
+ gl.glLoadIdentity();
+ //Calculate The Aspect Ratio Of The Window
+ glu.gluPerspective(45.0, (float)getSize().width / (float)getSize().height, 0.1, 100.0);
+ //Select The Modelview Matrix
+ gl.glMatrixMode(GL_MODELVIEW);
+
+ //Lights
+ gl.glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient);
+ gl.glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse);
+ gl.glLightfv(GL_LIGHT1, GL_POSITION, LightPosition);
+
+ //Enable light
+ gl.glEnable(GL_LIGHT1);
+ gl.glEnable(GL_LIGHTING);
+
+ quadratic=glu.gluNewQuadric(); // Create A Pointer To The Quadric Object ( NEW )
+ glu.gluQuadricNormals(quadratic, GLU_SMOOTH); // Create Smooth Normals ( NEW )
+ glu.gluQuadricTexture(quadratic, GL_TRUE); // Create Texture Coords ( NEW )
+ }
+
+ public void destroy() {
+ //Destroy the GLContext
+ cvsDispose();
+ }
+
+ public void reshape(int width, int height) {
+ //Reset The Current Viewport And Perspective Transformation
+ gl.glViewport(0, 0, width, height);
+
+ //Select The Projection Matrix
+ gl.glMatrixMode(GL_PROJECTION);
+ //Reset The Projection Matrix
+ gl.glLoadIdentity();
+ //Calculate The Aspect Ratio Of The Window
+ glu.gluPerspective(45.0, getSize().width/(float)getSize().height, 0.1, 100.0);
+ //Select The Modelview Matrix
+ gl.glMatrixMode(GL_MODELVIEW);
+ }
+
+ private void DrawCube() {
+ gl.glBegin(GL_QUADS);
+ //Front Face
+ gl.glNormal3f(0.0f, 0.0f, 1.0f);
+ gl.glTexCoord2f(0.0f, 0.0f); gl.glVertex3f(-1.0f, -1.0f, 1.0f); //Bottom Left Of The Texture and Quad
+ gl.glTexCoord2f(1.0f, 0.0f); gl.glVertex3f( 1.0f, -1.0f, 1.0f); //Bottom Right Of The Texture and Quad
+ gl.glTexCoord2f(1.0f, 1.0f); gl.glVertex3f( 1.0f, 1.0f, 1.0f); //Top Right Of The Texture and Quad
+ gl.glTexCoord2f(0.0f, 1.0f); gl.glVertex3f(-1.0f, 1.0f, 1.0f); //Top Left Of The Texture and Quad
+ //Back Face
+ gl.glNormal3f(0.0f, 0.0f, -1.0f);
+ gl.glTexCoord2f(1.0f, 0.0f); gl.glVertex3f(-1.0f, -1.0f, -1.0f); //Bottom Right Of The Texture and Quad
+ gl.glTexCoord2f(1.0f, 1.0f); gl.glVertex3f(-1.0f, 1.0f, -1.0f); //Top Right Of The Texture and Quad
+ gl.glTexCoord2f(0.0f, 1.0f); gl.glVertex3f( 1.0f, 1.0f, -1.0f); //Top Left Of The Texture and Quad
+ gl.glTexCoord2f(0.0f, 0.0f); gl.glVertex3f( 1.0f, -1.0f, -1.0f); //Bottom Left Of The Texture and Quad
+ //Top Face
+ gl.glNormal3f(0.0f, 1.0f, 0.0f);
+ gl.glTexCoord2f(0.0f, 1.0f); gl.glVertex3f(-1.0f, 1.0f, -1.0f); //Top Left Of The Texture and Quad
+ gl.glTexCoord2f(0.0f, 0.0f); gl.glVertex3f(-1.0f, 1.0f, 1.0f); //Bottom Left Of The Texture and Quad
+ gl.glTexCoord2f(1.0f, 0.0f); gl.glVertex3f( 1.0f, 1.0f, 1.0f); //Bottom Right Of The Texture and Quad
+ gl.glTexCoord2f(1.0f, 1.0f); gl.glVertex3f( 1.0f, 1.0f, -1.0f); //Top Right Of The Texture and Quad
+ //Bottom Face
+ gl.glNormal3f(0.0f, -1.0f, 0.0f);
+ gl.glTexCoord2f(1.0f, 1.0f); gl.glVertex3f(-1.0f, -1.0f, -1.0f); //Top Right Of The Texture and Quad
+ gl.glTexCoord2f(0.0f, 1.0f); gl.glVertex3f( 1.0f, -1.0f, -1.0f); //Top Left Of The Texture and Quad
+ gl.glTexCoord2f(0.0f, 0.0f); gl.glVertex3f( 1.0f, -1.0f, 1.0f); //Bottom Left Of The Texture and Quad
+ gl.glTexCoord2f(1.0f, 0.0f); gl.glVertex3f(-1.0f, -1.0f, 1.0f); //Bottom Right Of The Texture and Quad
+ //Right face
+ gl.glNormal3f(1.0f, 0.0f, 0.0f);
+ gl.glTexCoord2f(1.0f, 0.0f); gl.glVertex3f( 1.0f, -1.0f, -1.0f); //Bottom Right Of The Texture and Quad
+ gl.glTexCoord2f(1.0f, 1.0f); gl.glVertex3f( 1.0f, 1.0f, -1.0f); //Top Right Of The Texture and Quad
+ gl.glTexCoord2f(0.0f, 1.0f); gl.glVertex3f( 1.0f, 1.0f, 1.0f); //Top Left Of The Texture and Quad
+ gl.glTexCoord2f(0.0f, 0.0f); gl.glVertex3f( 1.0f, -1.0f, 1.0f); //Bottom Left Of The Texture and Quad
+ //Left Face
+ gl.glNormal3f(-1.0f, 0.0f, 0.0f);
+ gl.glTexCoord2f(0.0f, 0.0f); gl.glVertex3f(-1.0f, -1.0f, -1.0f); //Bottom Left Of The Texture and Quad
+ gl.glTexCoord2f(1.0f, 0.0f); gl.glVertex3f(-1.0f, -1.0f, 1.0f); //Bottom Right Of The Texture and Quad
+ gl.glTexCoord2f(1.0f, 1.0f); gl.glVertex3f(-1.0f, 1.0f, 1.0f); //Top Right Of The Texture and Quad
+ gl.glTexCoord2f(0.0f, 1.0f); gl.glVertex3f(-1.0f, 1.0f, -1.0f); //Top Left Of The Texture and Quad
+ gl.glEnd();
+ }
+
+ public void display() {
+ //Clear The Screen And The Depth Buffer
+ gl.glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
+ //Reset The View
+ gl.glLoadIdentity();
+
+ //Move into the screen
+ gl.glTranslatef(0.0f, 0.0f, z);
+
+ //Rotate On The X Axis
+ gl.glRotatef(xrot, 1.0f, 0.0f, 0.0f);
+ //Rotate On The Y Axis
+ gl.glRotatef(yrot, 0.0f, 1.0f, 0.0f);
+
+ gl.glBindTexture(GL_TEXTURE_2D, texture[filter]); // Select A Filtered Texture
+
+ switch(object) { // Check object To Find Out What To Draw
+ case 0: // Drawing Object 1
+ DrawCube(); // Draw Our Cube
+ break; // Done
+ case 1: // Drawing Object 2
+ gl.glTranslatef(0.0f,0.0f,-1.5f); // Center The Cylinder
+ glu.gluCylinder(quadratic,1.0f,1.0f,3.0f,32,32); // Draw Our Cylinder
+ break; // Done
+ case 2: // Drawing Object 3
+ glu.gluDisk(quadratic,0.5f,1.5f,32,32); // Draw A Disc (CD Shape)
+ break; // Done
+ case 3: // Drawing Object 4
+ glu.gluSphere(quadratic,1.3f,32,32); // Draw A Sphere
+ break; // Done
+ case 4: // Drawing Object 5
+ gl.glTranslatef(0.0f,0.0f,-1.5f); // Center The Cone
+ glu.gluCylinder(quadratic,1.0f,0.0f,3.0f,32,32); // A Cone With A Bottom Radius Of .5 And A Height Of 2
+ break; // Done
+ case 5: // Drawing Object 6
+ part1+=p1; // Increase Start Angle
+ part2+=p2; // Increase Sweep Angle
+ if(part1>359) { // 360 Degrees
+ p1=0; // Stop Increasing Start Angle
+ part1=0; // Set Start Angle To Zero
+ p2=1; // Start Increasing Sweep Angle
+ part2=0; // Start Sweep Angle At Zero
+ }
+ if(part2>359) { // 360 Degrees
+ p1=1; // Start Increasing Start Angle
+ p2=0; // Stop Increasing Sweep Angle
+ }
+ glu.gluPartialDisk(quadratic,0.5f,1.5f,32,32,part1,part2-part1); // A Disk Like The One Before
+ break; // Done
+ };
+ xrot+=xspeed; // Increase Rotation On X Axis
+ yrot+=yspeed; // Increase Rotation On Y Axis
+
+ //Swap buffers
+ glj.gljSwap();
+ }
+
+ public void keyTyped(KeyEvent e) {
+ //We are not handling any keyboard events yet
+ }
+ public void keyPressed(KeyEvent e) {
+ switch(e.getKeyCode()) {
+ //Switch ON/OFF light when L is pressed
+ case KeyEvent.VK_L:
+ if(!lp) {
+ lp = true;
+ //Toggle light
+ light = !light;
+
+ if(!light)
+ gl.glDisable(GL_LIGHTING);
+ else
+ gl.glEnable(GL_LIGHTING);
+ }
+
+ break;
+ //Switch filter when F is pressed
+ case KeyEvent.VK_F:
+ if(!fp) {
+ fp = true;
+ //Change filter
+ filter += 1;
+ if(filter > 2)
+ filter = 0;
+ }
+ break;
+ //Move cube back when user presses PG_UP
+ case KeyEvent.VK_PAGE_UP:
+ z -= 0.2f;
+ break;
+ //Move cube forwards when user presses PG_DOWN
+ case KeyEvent.VK_PAGE_DOWN:
+ z += 0.2f;
+ break;
+ //Increase X rotation speed when user presses UP
+ case KeyEvent.VK_UP:
+ xspeed += 0.2f;
+ break;
+ //Decrease X rotation speed when user presses DOWN
+ case KeyEvent.VK_DOWN:
+ xspeed -= 0.2f;
+ break;
+ //Increase Y rotation speed when user presses RIGHT
+ case KeyEvent.VK_RIGHT:
+ yspeed += 0.2f;
+ break;
+ //Decrease Y rotation speed when user presses LEFT
+ case KeyEvent.VK_LEFT:
+ yspeed -= 0.2f;
+ break;
+ //Switch filter when F is pressed
+ case KeyEvent.VK_SPACE:
+ if(!sp) {
+ sp = true;
+ //Change filter
+ object += 1;
+ if(object > 5)
+ object = 0;
+ }
+ break;
+ }
+ }
+ public void keyReleased(KeyEvent e) {
+ switch(e.getKeyCode()) {
+ //Key has been released
+ case KeyEvent.VK_L:
+ lp = false;
+ break;
+ //Key has been released
+ case KeyEvent.VK_F:
+ fp = false;
+ break;
+ case KeyEvent.VK_SPACE:
+ sp = false;
+ break;
+ }
+ }
+
+ // Methods required for the implementation of MouseListener
+ public void mouseEntered( MouseEvent evt )
+ {
+ Component comp = evt.getComponent();
+ if( comp.equals(this ) )
+ {
+ requestFocus();
+ }
+ }
+
+ public void mouseExited( MouseEvent evt )
+ { }
+ public void mousePressed( MouseEvent evt )
+ { }
+ public void mouseReleased( MouseEvent evt )
+ { }
+ public void mouseClicked( MouseEvent evt )
+ {
+ Component comp = evt.getComponent();
+ if( comp.equals(this ) )
+ {
+ requestFocus();
+ }
+ }
+
+ }
+ static class MyAdapter extends WindowAdapter {
+ public void windowClosing(WindowEvent e) {
+ System.exit(0);
+ }
+ }
+ public static void main(String as[]) {
+ Frame f=new Frame("Lesson18");
+ Lesson18 a=new Lesson18();
+ a.init();
+ a.start();
+ f.add("Center", a);
+ f.setSize(400, 400);
+ f.show();
+ f.addWindowListener(new MyAdapter());
+ }
+}
diff --git a/demos/HodglimsNeHe/Lesson18_plugin13.html b/demos/HodglimsNeHe/Lesson18_plugin13.html new file mode 100644 index 0000000..6c731ef --- /dev/null +++ b/demos/HodglimsNeHe/Lesson18_plugin13.html @@ -0,0 +1,81 @@ +<HTML>
+<HEAD>
+<TITLE>Lesson18 Applet: Quadratics</TITLE>
+<STYLE TYPE="text/css">
+<!--
+A:link { COLOR: #9C9AB1; TEXT-DECORATION: none }
+A:visited { COLOR: #9C9AB1; TEXT-DECORATION: none }
+A:active { color: Yellow; TEXT-DECORATION: none }
+A:hover { color: Yellow; TEXT-DECORATION: none }
+-->
+</STYLE>
+</HEAD>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+<CENTER>
+<P>
+<FONT SIZE="2" FACE="Verdana"><B>Quadratics</B></FONT><BR>
+Ported by <A HREF="MAILTO: [email protected]">Lapo Luchini</A>
+</P>
+<TABLE WIDTH="100%">
+<TR>
+<TD WIDTH="30%" ALIGN="LEFT" VALIGN="TOP">
+<FONT SIZE="1" FACE="Verdana"><B><U>Keys</U></B></FONT></P>
+<P>
+<FONT SIZE="1" FACE="Verdana">
+<B>L</B> - Lights ON/OFF<BR>
+<B>F</B> - Change texture filter<BR>
+<B>PG_UP</B> - Zoom out<BR>
+<B>PG_DOWN</B> - Zoom in<BR>
+<B>UP</B> - Rotate cube<BR>
+<B>DOWN</B> - Rotate cube<BR>
+<B>LEFT</B> - Rotate cube<BR>
+<B>RIGHT</B> - Rotate cube
+</FONT>
+</P>
+<P><FONT SIZE="1" FACE="Verdana"><B>Note:</B> You must click inside the applet window before using these keys.</FONT></P>
+<P>
+<FONT SIZE="1" FACE="Verdana">
+<A HREF="index.html">Go back</A>
+</FONT>
+</P>
+</TD>
+<TD WIDTH="70%" ALIGN="CENTER" VALIGN="TOP">
+<!--"CONVERTED_APPLET"-->
+<!-- CONVERTER VERSION 1.3 --> +<SCRIPT LANGUAGE="JavaScript"><!-- + var _info = navigator.userAgent; var _ns = false; + var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0); +//--></SCRIPT> +<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!-- + var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0))); +//--></SCRIPT></COMMENT> + +<SCRIPT LANGUAGE="JavaScript"><!-- + if (_ie == true) document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = "400" HEIGHT = "400" codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0"><NOEMBED><XMP>'); + else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.3" CODE = "Lesson18.class" WIDTH = "400" HEIGHT = "400" scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html"><NOEMBED><XMP>'); +//--></SCRIPT> +<APPLET CODE = "Lesson18.class" WIDTH = "400" HEIGHT = "400"></XMP> +<PARAM NAME = CODE VALUE = "Lesson18.class" >
+ +<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3"> +<PARAM NAME="scriptable" VALUE="false"> + +</APPLET> + +</NOEMBED></EMBED></OBJECT> + + +<!-- +<APPLET CODE = "Lesson18.class" WIDTH = "400" HEIGHT = "400">
+
+
+</APPLET> +--> +<!--"END_CONVERTED_APPLET"-->
+
+</TD>
+</TR>
+</TABLE>
+</CENTER>
+</BODY>
+</HTML>
diff --git a/demos/HodglimsNeHe/Lesson1_plugin13.html b/demos/HodglimsNeHe/Lesson1_plugin13.html new file mode 100644 index 0000000..02c7e26 --- /dev/null +++ b/demos/HodglimsNeHe/Lesson1_plugin13.html @@ -0,0 +1,66 @@ +<HTML>
+<HEAD>
+<TITLE>Lesson1 Applet: Setting Up OpenGL In Windows</TITLE>
+<STYLE TYPE="text/css">
+<!--
+A:link { COLOR: #9C9AB1; TEXT-DECORATION: none }
+A:visited { COLOR: #9C9AB1; TEXT-DECORATION: none }
+A:active { color: Yellow; TEXT-DECORATION: none }
+A:hover { color: Yellow; TEXT-DECORATION: none }
+-->
+</STYLE>
+</HEAD>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+<CENTER>
+<P>
+<FONT SIZE="2" FACE="Verdana"><B>Setting Up OpenGL In Windows</B></FONT>
+</P>
+<TABLE WIDTH="100%">
+<TR>
+<TD WIDTH="30%" ALIGN="LEFT" VALIGN="TOP">
+<P>
+<FONT SIZE="1" FACE="Verdana">
+<A HREF="index.html">Go back</A>
+</FONT>
+</P>
+</TD>
+<TD WIDTH="70%" ALIGN="CENTER" VALIGN="TOP">
+<!--"CONVERTED_APPLET"-->
+<!-- CONVERTER VERSION 1.3 --> +<SCRIPT LANGUAGE="JavaScript"><!-- + var _info = navigator.userAgent; var _ns = false; + var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0); +//--></SCRIPT> +<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!-- + var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0))); +//--></SCRIPT></COMMENT> + +<SCRIPT LANGUAGE="JavaScript"><!-- + if (_ie == true) document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = "400" HEIGHT = "400" codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0"><NOEMBED><XMP>'); + else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.3" CODE = "Lesson1.class" WIDTH = "400" HEIGHT = "400" scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html"><NOEMBED><XMP>'); +//--></SCRIPT> +<APPLET CODE = "Lesson1.class" WIDTH = "400" HEIGHT = "400"></XMP> +<PARAM NAME = CODE VALUE = "Lesson1.class" >
+ +<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3"> +<PARAM NAME="scriptable" VALUE="false"> + +</APPLET> + +</NOEMBED></EMBED></OBJECT> + + +<!-- +<APPLET CODE = "Lesson1.class" WIDTH = "400" HEIGHT = "400">
+
+
+</APPLET> +--> +<!--"END_CONVERTED_APPLET"-->
+
+</TD>
+</TR>
+</TABLE>
+</CENTER>
+</BODY>
+</HTML>
diff --git a/demos/HodglimsNeHe/Lesson2.html b/demos/HodglimsNeHe/Lesson2.html new file mode 100644 index 0000000..8589c39 --- /dev/null +++ b/demos/HodglimsNeHe/Lesson2.html @@ -0,0 +1,35 @@ +<HTML>
+<HEAD>
+<TITLE>Lesson2 Applet: Your First Polygon</TITLE>
+<STYLE TYPE="text/css">
+<!--
+A:link { COLOR: #9C9AB1; TEXT-DECORATION: none }
+A:visited { COLOR: #9C9AB1; TEXT-DECORATION: none }
+A:active { color: Yellow; TEXT-DECORATION: none }
+A:hover { color: Yellow; TEXT-DECORATION: none }
+-->
+</STYLE>
+</HEAD>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+<CENTER>
+<P>
+<FONT SIZE="2" FACE="Verdana"><B>Your First Polygon</B></FONT>
+</P>
+<TABLE WIDTH="100%">
+<TR>
+<TD WIDTH="30%" ALIGN="LEFT" VALIGN="TOP">
+<P>
+<FONT SIZE="1" FACE="Verdana">
+<A HREF="index.html">Go back</A>
+</FONT>
+</P>
+</TD>
+<TD WIDTH="70%" ALIGN="CENTER" VALIGN="TOP">
+<APPLET CODE="Lesson2.class" WIDTH="400" HEIGHT="400">
+</APPLET>
+</TD>
+</TR>
+</TABLE>
+</CENTER>
+</BODY>
+</HTML>
diff --git a/demos/HodglimsNeHe/Lesson2.java b/demos/HodglimsNeHe/Lesson2.java new file mode 100644 index 0000000..8f6eb2c --- /dev/null +++ b/demos/HodglimsNeHe/Lesson2.java @@ -0,0 +1,280 @@ +/**
+ * Lesson2.java
+ *
+ * Author: Darren Hodges
+ * Date: 16/12/1999
+ *
+ * Port of the NeHe OpenGL Tutorial (Lesson 2: "Your First Polygon")
+ * to Java using the GL4Java interface to OpenGL.
+ *
+ */
+
+import java.applet.*;
+import java.awt.*;
+import java.awt.event.*;
+
+//GL4Java classes
+import gl4java.GLContext;
+import gl4java.awt.GLAnimCanvas;
+
+
+public class Lesson2 extends Applet
+{
+ //Our rendering canvas
+ //We are using GLAnimCanvas because we want the canvas
+ //to be constantly redrawn
+ renderCanvas canvas = null;
+
+
+ /**
+ * void init()
+ *
+ * Initialise the applet.
+ */
+ public void init()
+ {
+ //We will use BorderLayout to layout the applet components
+ setLayout(new BorderLayout());
+
+ //Create our canvas and add it to the center of the applet
+ canvas = new renderCanvas(getSize().width, getSize().height);
+ canvas.requestFocus();
+ add("Center", canvas);
+ }
+
+
+ /**
+ * void start()
+ *
+ * Start the applet.
+ */
+ public void start()
+ {
+ //Start animating the canvas
+ canvas.start();
+ }
+
+
+ /**
+ * void stop()
+ *
+ * Stop the applet.
+ */
+ public void stop()
+ {
+ //Stop animating the canvas
+ canvas.stop();
+ }
+
+
+ /**
+ * void destroy()
+ *
+ * Destroy the applet.
+ */
+ public void destroy()
+ {
+ //Stop animating the canvas
+ canvas.stop();
+ //Destroy the canvas
+ canvas.destroy();
+ }
+
+
+
+ private class renderCanvas extends GLAnimCanvas
+ implements KeyListener, MouseListener
+ {
+ /**
+ * renderCanvas(int w, int h)
+ *
+ * Constructor.
+ */
+ public renderCanvas(int w, int h)
+ {
+ super(w, h);
+
+ //Registers this canvas to process keyboard events
+ addKeyListener(this);
+ addMouseListener(this);
+ }
+
+
+ /**
+ * void preInit()
+ *
+ * Called just BEFORE the GL-Context is created.
+ */
+ public void preInit()
+ {
+ //We want double buffering
+ doubleBuffer = true;
+ //But we dont want stereo view
+ stereoView = false;
+ }
+
+
+ /**
+ * void init()
+ *
+ * Called just AFTER the GL-Context is created.
+ */
+ public void init()
+ {
+ //This Will Clear The Background Color To Black
+ gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
+
+ //Enables Clearing Of The Depth Buffer
+ gl.glClearDepth(1.0);
+ //The Type Of Depth Test To Do
+ gl.glDepthFunc(GL_LESS);
+ //Enables Depth Testing
+ gl.glEnable(GL_DEPTH_TEST);
+
+ //Enables Smooth Color Shading
+ gl.glShadeModel(GL_SMOOTH);
+ //Select The Projection Matrix
+ gl.glMatrixMode(GL_PROJECTION);
+ //Reset The Projection Matrix
+ gl.glLoadIdentity();
+ //Calculate The Aspect Ratio Of The Window
+ glu.gluPerspective(45.0f, (float)getSize().width / (float)getSize().height, 0.1f, 100.0f);
+ //Select The Modelview Matrix
+ gl.glMatrixMode(GL_MODELVIEW);
+ }
+
+
+ /**
+ * void destroy()
+ *
+ * Destroy the canvas.
+ */
+ public void destroy()
+ {
+ //Destroy the GLContext
+ cvsDispose();
+ }
+
+
+ /**
+ * void reshape(int width, int height)
+ *
+ * Called after the first paint command.
+ */
+ public void reshape(int width, int height)
+ {
+ //Reset The Current Viewport And Perspective Transformation
+ gl.glViewport(0, 0, width, height);
+
+ //Select The Projection Matrix
+ gl.glMatrixMode(GL_PROJECTION);
+ //Reset The Projection Matrix
+ gl.glLoadIdentity();
+ //Calculate The Aspect Ratio Of The Window
+ glu.gluPerspective(45.0f, (float)getSize().width / (float)getSize().height, 0.1f, 100.0f);
+ //Select The Modelview Matrix
+ gl.glMatrixMode(GL_MODELVIEW);
+ }
+
+
+ /**
+ * void display()
+ *
+ * Draw to the canvas.
+ */
+ public void display()
+ {
+ //Ensure GL is initialised correctly
+ if (glj.gljMakeCurrent(true) == false)
+ return;
+
+ //Clear The Screen And The Depth Buffer
+ gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ //Reset The View
+ gl.glLoadIdentity();
+
+ //Move Left 1.5 Units And Into The Screen 8.0
+ gl.glTranslatef(-1.5f, 0.0f, -8.0f);
+
+ //Draw triangle
+ gl.glBegin(GL_POLYGON);
+ gl.glVertex3f(0.0f, 1.0f, 0.0f); //Top
+ gl.glVertex3f(1.0f, -1.0f, 0.0f); //Bottom Right
+ gl.glVertex3f(-1.0f, -1.0f, 0.0f); //Bottom Left
+ gl.glEnd();
+
+ //Move Right 3 Units
+ gl.glTranslatef(3.0f, 0.0f, 0.0f);
+
+ //Draw rectangle
+ gl.glBegin(GL_QUADS);
+ gl.glVertex3f(-1.0f, 1.0f, 0.0f); //Top Left
+ gl.glVertex3f(1.0f, 1.0f, 0.0f); //Top Right
+ gl.glVertex3f(1.0f, -1.0f, 0.0f); //Bottom Right
+ gl.glVertex3f(-1.0f, -1.0f, 0.0f); //Bottom Left
+ gl.glEnd();
+
+ //Swap buffers
+ glj.gljSwap();
+ }
+
+
+ /**
+ * void keyTyped(KeyEvent e)
+ *
+ * Invoked when a key has been typed. This event occurs when a key press is followed by a key release.
+ */
+ public void keyTyped(KeyEvent e)
+ {
+ //We are not handling any keyboard events yet
+ }
+
+
+ /**
+ * void keyPressed(KeyEvent e)
+ *
+ * Invoked when a key has been pressed.
+ */
+ public void keyPressed(KeyEvent e)
+ {
+ //We are not handling any keyboard events yet
+ }
+
+
+ /**
+ * void keyReleased(KeyEvent e)
+ *
+ * Invoked when a key has been released.
+ */
+ public void keyReleased(KeyEvent e)
+ {
+ //We are not handling any keyboard events yet
+ }
+
+ // Methods required for the implementation of MouseListener
+ public void mouseEntered( MouseEvent evt )
+ {
+ Component comp = evt.getComponent();
+ if( comp.equals(this ) )
+ {
+ requestFocus();
+ }
+ }
+
+ public void mouseExited( MouseEvent evt )
+ { }
+ public void mousePressed( MouseEvent evt )
+ { }
+ public void mouseReleased( MouseEvent evt )
+ { }
+ public void mouseClicked( MouseEvent evt )
+ {
+ Component comp = evt.getComponent();
+ if( comp.equals(this ) )
+ {
+ requestFocus();
+ }
+ }
+
+ }
+}
diff --git a/demos/HodglimsNeHe/Lesson2_plugin13.html b/demos/HodglimsNeHe/Lesson2_plugin13.html new file mode 100644 index 0000000..238a26e --- /dev/null +++ b/demos/HodglimsNeHe/Lesson2_plugin13.html @@ -0,0 +1,66 @@ +<HTML>
+<HEAD>
+<TITLE>Lesson2 Applet: Your First Polygon</TITLE>
+<STYLE TYPE="text/css">
+<!--
+A:link { COLOR: #9C9AB1; TEXT-DECORATION: none }
+A:visited { COLOR: #9C9AB1; TEXT-DECORATION: none }
+A:active { color: Yellow; TEXT-DECORATION: none }
+A:hover { color: Yellow; TEXT-DECORATION: none }
+-->
+</STYLE>
+</HEAD>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+<CENTER>
+<P>
+<FONT SIZE="2" FACE="Verdana"><B>Your First Polygon</B></FONT>
+</P>
+<TABLE WIDTH="100%">
+<TR>
+<TD WIDTH="30%" ALIGN="LEFT" VALIGN="TOP">
+<P>
+<FONT SIZE="1" FACE="Verdana">
+<A HREF="index.html">Go back</A>
+</FONT>
+</P>
+</TD>
+<TD WIDTH="70%" ALIGN="CENTER" VALIGN="TOP">
+<!--"CONVERTED_APPLET"-->
+<!-- CONVERTER VERSION 1.3 --> +<SCRIPT LANGUAGE="JavaScript"><!-- + var _info = navigator.userAgent; var _ns = false; + var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0); +//--></SCRIPT> +<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!-- + var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0))); +//--></SCRIPT></COMMENT> + +<SCRIPT LANGUAGE="JavaScript"><!-- + if (_ie == true) document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = "400" HEIGHT = "400" codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0"><NOEMBED><XMP>'); + else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.3" CODE = "Lesson2.class" WIDTH = "400" HEIGHT = "400" scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html"><NOEMBED><XMP>'); +//--></SCRIPT> +<APPLET CODE = "Lesson2.class" WIDTH = "400" HEIGHT = "400"></XMP> +<PARAM NAME = CODE VALUE = "Lesson2.class" >
+ +<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3"> +<PARAM NAME="scriptable" VALUE="false"> + +</APPLET> + +</NOEMBED></EMBED></OBJECT> + + +<!-- +<APPLET CODE = "Lesson2.class" WIDTH = "400" HEIGHT = "400">
+
+
+</APPLET> +--> +<!--"END_CONVERTED_APPLET"-->
+
+</TD>
+</TR>
+</TABLE>
+</CENTER>
+</BODY>
+</HTML>
diff --git a/demos/HodglimsNeHe/Lesson3.html b/demos/HodglimsNeHe/Lesson3.html new file mode 100644 index 0000000..863c4e8 --- /dev/null +++ b/demos/HodglimsNeHe/Lesson3.html @@ -0,0 +1,35 @@ +<HTML>
+<HEAD>
+<TITLE>Lesson3 Applet: Colors</TITLE>
+<STYLE TYPE="text/css">
+<!--
+A:link { COLOR: #9C9AB1; TEXT-DECORATION: none }
+A:visited { COLOR: #9C9AB1; TEXT-DECORATION: none }
+A:active { color: Yellow; TEXT-DECORATION: none }
+A:hover { color: Yellow; TEXT-DECORATION: none }
+-->
+</STYLE>
+</HEAD>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+<CENTER>
+<P>
+<FONT SIZE="2" FACE="Verdana"><B>Colors</B></FONT>
+</P>
+<TABLE WIDTH="100%">
+<TR>
+<TD WIDTH="30%" ALIGN="LEFT" VALIGN="TOP">
+<P>
+<FONT SIZE="1" FACE="Verdana">
+<A HREF="index.html">Go back</A>
+</FONT>
+</P>
+</TD>
+<TD WIDTH="70%" ALIGN="CENTER" VALIGN="TOP">
+<APPLET CODE="Lesson3.class" WIDTH="400" HEIGHT="400">
+</APPLET>
+</TD>
+</TR>
+</TABLE>
+</CENTER>
+</BODY>
+</HTML>
diff --git a/demos/HodglimsNeHe/Lesson3.java b/demos/HodglimsNeHe/Lesson3.java new file mode 100644 index 0000000..b5e3377 --- /dev/null +++ b/demos/HodglimsNeHe/Lesson3.java @@ -0,0 +1,284 @@ +/**
+ * Lesson3.java
+ *
+ * Author: Darren Hodges
+ * Date: 16/12/1999
+ *
+ * Port of the NeHe OpenGL Tutorial (Lesson 3: "Colors")
+ * to Java using the GL4Java interface to OpenGL.
+ *
+ */
+
+import java.applet.*;
+import java.awt.*;
+import java.awt.event.*;
+
+//GL4Java classes
+import gl4java.GLContext;
+import gl4java.awt.GLAnimCanvas;
+
+
+public class Lesson3 extends Applet
+{
+ //Our rendering canvas
+ //We are using GLAnimCanvas because we want the canvas
+ //to be constantly redrawn
+ renderCanvas canvas = null;
+
+
+ /**
+ * void init()
+ *
+ * Initialise the applet.
+ */
+ public void init()
+ {
+ //We will use BorderLayout to layout the applet components
+ setLayout(new BorderLayout());
+
+ //Create our canvas and add it to the center of the applet
+ canvas = new renderCanvas(getSize().width, getSize().height);
+ canvas.requestFocus();
+ add("Center", canvas);
+ }
+
+
+ /**
+ * void start()
+ *
+ * Start the applet.
+ */
+ public void start()
+ {
+ //Start animating the canvas
+ canvas.start();
+ }
+
+
+ /**
+ * void stop()
+ *
+ * Stop the applet.
+ */
+ public void stop()
+ {
+ //Stop animating the canvas
+ canvas.stop();
+ }
+
+
+ /**
+ * void destroy()
+ *
+ * Destroy the applet.
+ */
+ public void destroy()
+ {
+ //Stop animating the canvas
+ canvas.stop();
+ //Destroy the canvas
+ canvas.destroy();
+ }
+
+
+
+ private class renderCanvas extends GLAnimCanvas
+ implements KeyListener, MouseListener
+ {
+ /**
+ * renderCanvas(int w, int h)
+ *
+ * Constructor.
+ */
+ public renderCanvas(int w, int h)
+ {
+ super(w, h);
+
+ //Registers this canvas to process keyboard events
+ addKeyListener(this);
+ addMouseListener(this);
+ }
+
+
+ /**
+ * void preInit()
+ *
+ * Called just BEFORE the GL-Context is created.
+ */
+ public void preInit()
+ {
+ //We want double buffering
+ doubleBuffer = true;
+ //But we dont want stereo view
+ stereoView = false;
+ }
+
+
+ /**
+ * void init()
+ *
+ * Called just AFTER the GL-Context is created.
+ */
+ public void init()
+ {
+ //This Will Clear The Background Color To Black
+ gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
+
+ //Enables Clearing Of The Depth Buffer
+ gl.glClearDepth(1.0);
+ //The Type Of Depth Test To Do
+ gl.glDepthFunc(GL_LESS);
+ //Enables Depth Testing
+ gl.glEnable(GL_DEPTH_TEST);
+
+ //Enables Smooth Color Shading
+ gl.glShadeModel(GL_SMOOTH);
+ //Select The Projection Matrix
+ gl.glMatrixMode(GL_PROJECTION);
+ //Reset The Projection Matrix
+ gl.glLoadIdentity();
+ //Calculate The Aspect Ratio Of The Window
+ glu.gluPerspective(45.0f, (float)getSize().width / (float)getSize().height, 0.1f, 100.0f);
+ //Select The Modelview Matrix
+ gl.glMatrixMode(GL_MODELVIEW);
+ }
+
+
+ /**
+ * void destroy()
+ *
+ * Destroy the canvas.
+ */
+ public void destroy()
+ {
+ //Destroy the GLContext
+ cvsDispose();
+ }
+
+
+ /**
+ * void reshape(int width, int height)
+ *
+ * Called after the first paint command.
+ */
+ public void reshape(int width, int height)
+ {
+ //Reset The Current Viewport And Perspective Transformation
+ gl.glViewport(0, 0, width, height);
+
+ //Select The Projection Matrix
+ gl.glMatrixMode(GL_PROJECTION);
+ //Reset The Projection Matrix
+ gl.glLoadIdentity();
+ //Calculate The Aspect Ratio Of The Window
+ glu.gluPerspective(45.0f, (float)getSize().width / (float)getSize().height, 0.1f, 100.0f);
+ //Select The Modelview Matrix
+ gl.glMatrixMode(GL_MODELVIEW);
+ }
+
+
+ /**
+ * void display()
+ *
+ * Draw to the canvas.
+ */
+ public void display()
+ {
+ //Ensure GL is initialised correctly
+ if (glj.gljMakeCurrent(true) == false)
+ return;
+
+ //Clear The Screen And The Depth Buffer
+ gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ //Reset The View
+ gl.glLoadIdentity();
+
+ //Move Left 1.5 Units And Into The Screen 8.0
+ gl.glTranslatef(-1.5f, 0.0f, -8.0f);
+
+ //Draw triangle
+ gl.glBegin(GL_POLYGON);
+ gl.glColor3f(1.0f, 0.0f, 0.0f); //Set The Color To Red
+ gl.glVertex3f(0.0f, 1.0f, 0.0f); //Top
+ gl.glColor3f(0.0f, 1.0f, 0.0f); //Set The Color To Green
+ gl.glVertex3f(-1.0f, -1.0f, 0.0f); //Bottom Left
+ gl.glColor3f(0.0f, 0.0f, 1.0f); //Set The Color To Blue
+ gl.glVertex3f(1.0f, -1.0f, 0.0f); //Bottom Right
+ gl.glEnd();
+
+ //Move Right 3 Units
+ gl.glTranslatef(3.0f, 0.0f, 0.0f);
+
+ //Draw rectangle
+ gl.glBegin(GL_QUADS);
+ gl.glColor3f(0.5f, 0.5f, 1.0f); //Set The Color To Blue One Time Only
+ gl.glVertex3f(-1.0f, 1.0f, 0.0f); //Top Left
+ gl.glVertex3f(1.0f, 1.0f, 0.0f); //Top Right
+ gl.glVertex3f(1.0f, -1.0f, 0.0f); //Bottom Right
+ gl.glVertex3f(-1.0f, -1.0f, 0.0f); //Bottom Left
+ gl.glEnd();
+
+ //Swap buffers
+ glj.gljSwap();
+ }
+
+
+ /**
+ * void keyTyped(KeyEvent e)
+ *
+ * Invoked when a key has been typed. This event occurs when a key press is followed by a key release.
+ */
+ public void keyTyped(KeyEvent e)
+ {
+ //We are not handling any keyboard events yet
+ }
+
+
+ /**
+ * void keyPressed(KeyEvent e)
+ *
+ * Invoked when a key has been pressed.
+ */
+ public void keyPressed(KeyEvent e)
+ {
+ //We are not handling any keyboard events yet
+ }
+
+
+ /**
+ * void keyReleased(KeyEvent e)
+ *
+ * Invoked when a key has been released.
+ */
+ public void keyReleased(KeyEvent e)
+ {
+ //We are not handling any keyboard events yet
+ }
+
+ // Methods required for the implementation of MouseListener
+ public void mouseEntered( MouseEvent evt )
+ {
+ Component comp = evt.getComponent();
+ if( comp.equals(this ) )
+ {
+ requestFocus();
+ }
+ }
+
+ public void mouseExited( MouseEvent evt )
+ { }
+ public void mousePressed( MouseEvent evt )
+ { }
+ public void mouseReleased( MouseEvent evt )
+ { }
+ public void mouseClicked( MouseEvent evt )
+ {
+ Component comp = evt.getComponent();
+ if( comp.equals(this ) )
+ {
+ requestFocus();
+ }
+ }
+
+ }
+}
diff --git a/demos/HodglimsNeHe/Lesson3_plugin13.html b/demos/HodglimsNeHe/Lesson3_plugin13.html new file mode 100644 index 0000000..8c7c414 --- /dev/null +++ b/demos/HodglimsNeHe/Lesson3_plugin13.html @@ -0,0 +1,66 @@ +<HTML>
+<HEAD>
+<TITLE>Lesson3 Applet: Colors</TITLE>
+<STYLE TYPE="text/css">
+<!--
+A:link { COLOR: #9C9AB1; TEXT-DECORATION: none }
+A:visited { COLOR: #9C9AB1; TEXT-DECORATION: none }
+A:active { color: Yellow; TEXT-DECORATION: none }
+A:hover { color: Yellow; TEXT-DECORATION: none }
+-->
+</STYLE>
+</HEAD>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+<CENTER>
+<P>
+<FONT SIZE="2" FACE="Verdana"><B>Colors</B></FONT>
+</P>
+<TABLE WIDTH="100%">
+<TR>
+<TD WIDTH="30%" ALIGN="LEFT" VALIGN="TOP">
+<P>
+<FONT SIZE="1" FACE="Verdana">
+<A HREF="index.html">Go back</A>
+</FONT>
+</P>
+</TD>
+<TD WIDTH="70%" ALIGN="CENTER" VALIGN="TOP">
+<!--"CONVERTED_APPLET"-->
+<!-- CONVERTER VERSION 1.3 --> +<SCRIPT LANGUAGE="JavaScript"><!-- + var _info = navigator.userAgent; var _ns = false; + var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0); +//--></SCRIPT> +<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!-- + var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0))); +//--></SCRIPT></COMMENT> + +<SCRIPT LANGUAGE="JavaScript"><!-- + if (_ie == true) document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = "400" HEIGHT = "400" codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0"><NOEMBED><XMP>'); + else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.3" CODE = "Lesson3.class" WIDTH = "400" HEIGHT = "400" scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html"><NOEMBED><XMP>'); +//--></SCRIPT> +<APPLET CODE = "Lesson3.class" WIDTH = "400" HEIGHT = "400"></XMP> +<PARAM NAME = CODE VALUE = "Lesson3.class" >
+ +<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3"> +<PARAM NAME="scriptable" VALUE="false"> + +</APPLET> + +</NOEMBED></EMBED></OBJECT> + + +<!-- +<APPLET CODE = "Lesson3.class" WIDTH = "400" HEIGHT = "400">
+
+
+</APPLET> +--> +<!--"END_CONVERTED_APPLET"-->
+
+</TD>
+</TR>
+</TABLE>
+</CENTER>
+</BODY>
+</HTML>
diff --git a/demos/HodglimsNeHe/Lesson4.html b/demos/HodglimsNeHe/Lesson4.html new file mode 100644 index 0000000..04a1ddc --- /dev/null +++ b/demos/HodglimsNeHe/Lesson4.html @@ -0,0 +1,35 @@ +<HTML>
+<HEAD>
+<TITLE>Lesson4 Applet: Rotation</TITLE>
+<STYLE TYPE="text/css">
+<!--
+A:link { COLOR: #9C9AB1; TEXT-DECORATION: none }
+A:visited { COLOR: #9C9AB1; TEXT-DECORATION: none }
+A:active { color: Yellow; TEXT-DECORATION: none }
+A:hover { color: Yellow; TEXT-DECORATION: none }
+-->
+</STYLE>
+</HEAD>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+<CENTER>
+<P>
+<FONT SIZE="2" FACE="Verdana"><B>Rotation</B></FONT>
+</P>
+<TABLE WIDTH="100%">
+<TR>
+<TD WIDTH="30%" ALIGN="LEFT" VALIGN="TOP">
+<P>
+<FONT SIZE="1" FACE="Verdana">
+<A HREF="index.html">Go back</A>
+</FONT>
+</P>
+</TD>
+<TD WIDTH="70%" ALIGN="CENTER" VALIGN="TOP">
+<APPLET CODE="Lesson4.class" WIDTH="400" HEIGHT="400">
+</APPLET>
+</TD>
+</TR>
+</TABLE>
+</CENTER>
+</BODY>
+</HTML>
diff --git a/demos/HodglimsNeHe/Lesson4.java b/demos/HodglimsNeHe/Lesson4.java new file mode 100644 index 0000000..ada7dd5 --- /dev/null +++ b/demos/HodglimsNeHe/Lesson4.java @@ -0,0 +1,304 @@ +/**
+ * Lesson4.java
+ *
+ * Author: Darren Hodges
+ * Date: 16/12/1999
+ *
+ * Port of the NeHe OpenGL Tutorial (Lesson 4: "Rotation")
+ * to Java using the GL4Java interface to OpenGL.
+ *
+ */
+
+import java.applet.*;
+import java.awt.*;
+import java.awt.event.*;
+
+//GL4Java classes
+import gl4java.GLContext;
+import gl4java.awt.GLAnimCanvas;
+
+
+public class Lesson4 extends Applet
+{
+ //Our rendering canvas
+ //We are using GLAnimCanvas because we want the canvas
+ //to be constantly redrawn
+ renderCanvas canvas = null;
+
+
+ /**
+ * void init()
+ *
+ * Initialise the applet.
+ */
+ public void init()
+ {
+ //We will use BorderLayout to layout the applet components
+ setLayout(new BorderLayout());
+
+ //Create our canvas and add it to the center of the applet
+ canvas = new renderCanvas(getSize().width, getSize().height);
+ canvas.requestFocus();
+ add("Center", canvas);
+ }
+
+
+ /**
+ * void start()
+ *
+ * Start the applet.
+ */
+ public void start()
+ {
+ //Start animating the canvas
+ canvas.start();
+ }
+
+
+ /**
+ * void stop()
+ *
+ * Stop the applet.
+ */
+ public void stop()
+ {
+ //Stop animating the canvas
+ canvas.stop();
+ }
+
+
+ /**
+ * void destroy()
+ *
+ * Destroy the applet.
+ */
+ public void destroy()
+ {
+ //Stop animating the canvas
+ canvas.stop();
+ //Destroy the canvas
+ canvas.destroy();
+ }
+
+
+
+ private class renderCanvas extends GLAnimCanvas
+ implements KeyListener, MouseListener
+ {
+ //Angle For The Triangle
+ float rtri = 0.0f;
+ //Angle For The Quad
+ float rquad = 0.0f;
+
+
+ /**
+ * renderCanvas(int w, int h)
+ *
+ * Constructor.
+ */
+ public renderCanvas(int w, int h)
+ {
+ super(w, h);
+
+ //Registers this canvas to process keyboard events
+ addKeyListener(this);
+ addMouseListener(this);
+ }
+
+
+ /**
+ * void preInit()
+ *
+ * Called just BEFORE the GL-Context is created.
+ */
+ public void preInit()
+ {
+ //We want double buffering
+ doubleBuffer = true;
+ //But we dont want stereo view
+ stereoView = false;
+ }
+
+
+ /**
+ * void init()
+ *
+ * Called just AFTER the GL-Context is created.
+ */
+ public void init()
+ {
+ //This Will Clear The Background Color To Black
+ gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
+
+ //Enables Clearing Of The Depth Buffer
+ gl.glClearDepth(1.0);
+ //The Type Of Depth Test To Do
+ gl.glDepthFunc(GL_LESS);
+ //Enables Depth Testing
+ gl.glEnable(GL_DEPTH_TEST);
+
+ //Enables Smooth Color Shading
+ gl.glShadeModel(GL_SMOOTH);
+ //Select The Projection Matrix
+ gl.glMatrixMode(GL_PROJECTION);
+ //Reset The Projection Matrix
+ gl.glLoadIdentity();
+ //Calculate The Aspect Ratio Of The Window
+ glu.gluPerspective(45.0f, (float)getSize().width / (float)getSize().height, 0.1f, 100.0f);
+ //Select The Modelview Matrix
+ gl.glMatrixMode(GL_MODELVIEW);
+ }
+
+
+ /**
+ * void destroy()
+ *
+ * Destroy the canvas.
+ */
+ public void destroy()
+ {
+ //Destroy the GLContext
+ cvsDispose();
+ }
+
+
+ /**
+ * void reshape(int width, int height)
+ *
+ * Called after the first paint command.
+ */
+ public void reshape(int width, int height)
+ {
+ //Reset The Current Viewport And Perspective Transformation
+ gl.glViewport(0, 0, width, height);
+
+ //Select The Projection Matrix
+ gl.glMatrixMode(GL_PROJECTION);
+ //Reset The Projection Matrix
+ gl.glLoadIdentity();
+ //Calculate The Aspect Ratio Of The Window
+ glu.gluPerspective(45.0f, (float)getSize().width / (float)getSize().height, 0.1f, 100.0f);
+ //Select The Modelview Matrix
+ gl.glMatrixMode(GL_MODELVIEW);
+ }
+
+
+ /**
+ * void display()
+ *
+ * Draw to the canvas.
+ */
+ public void display()
+ {
+ //Ensure GL is initialised correctly
+ if (glj.gljMakeCurrent(true) == false)
+ return;
+
+ //Clear The Screen And The Depth Buffer
+ gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ //Reset The View
+ gl.glLoadIdentity();
+
+ //Move Left 1.5 Units And Into The Screen 8.0
+ gl.glTranslatef(-1.5f, 0.0f, -8.0f);
+
+ //Rotate The Triangle On The Y axis
+ gl.glRotatef(rtri, 0.0f, 1.0f, 0.0f);
+
+ //Draw triangle
+ gl.glBegin(GL_POLYGON);
+ gl.glColor3f(1.0f, 0.0f, 0.0f); //Set The Color To Red
+ gl.glVertex3f(0.0f, 1.0f, 0.0f); //Top
+ gl.glColor3f(0.0f, 1.0f, 0.0f); //Set The Color To Green
+ gl.glVertex3f(-1.0f, -1.0f, 0.0f); //Bottom Left
+ gl.glColor3f(0.0f,0.0f,1.0f); //Set The Color To Blue
+ gl.glVertex3f(1.0f, -1.0f, 0.0f); //Bottom Right
+ gl.glEnd();
+
+ //Reset The View
+ gl.glLoadIdentity();
+
+ //Move right and into the screen
+ gl.glTranslatef(1.5f, 0.0f, -8.0f);
+
+ //Rotate The Quad On The X axis
+ gl.glRotatef(rquad, 1.0f, 0.0f, 0.0f);
+
+ //Draw rectangle
+ gl.glBegin(GL_QUADS);
+ gl.glColor3f(0.5f, 0.5f, 1.0f); //Set The Color To Blue One Time Only
+ gl.glVertex3f(-1.0f, 1.0f, 0.0f); //Top Left
+ gl.glVertex3f(1.0f, 1.0f, 0.0f); //Top Right
+ gl.glVertex3f(1.0f, -1.0f, 0.0f); //Bottom Right
+ gl.glVertex3f(-1.0f, -1.0f, 0.0f); //Bottom Left
+ gl.glEnd();
+
+ //Increase The Rotation Variable For The Triangle
+ rtri += 0.2f;
+ //Decrease The Rotation Variable For The Quad
+ rquad -= 0.15f;
+
+ //Swap buffers
+ glj.gljSwap();
+ }
+
+
+ /**
+ * void keyTyped(KeyEvent e)
+ *
+ * Invoked when a key has been typed. This event occurs when a key press is followed by a key release.
+ */
+ public void keyTyped(KeyEvent e)
+ {
+ //We are not handling any keyboard events yet
+ }
+
+
+ /**
+ * void keyPressed(KeyEvent e)
+ *
+ * Invoked when a key has been pressed.
+ */
+ public void keyPressed(KeyEvent e)
+ {
+ //We are not handling any keyboard events yet
+ }
+
+
+ /**
+ * void keyReleased(KeyEvent e)
+ *
+ * Invoked when a key has been released.
+ */
+ public void keyReleased(KeyEvent e)
+ {
+ //We are not handling any keyboard events yet
+ }
+
+ // Methods required for the implementation of MouseListener
+ public void mouseEntered( MouseEvent evt )
+ {
+ Component comp = evt.getComponent();
+ if( comp.equals(this ) )
+ {
+ requestFocus();
+ }
+ }
+
+ public void mouseExited( MouseEvent evt )
+ { }
+ public void mousePressed( MouseEvent evt )
+ { }
+ public void mouseReleased( MouseEvent evt )
+ { }
+ public void mouseClicked( MouseEvent evt )
+ {
+ Component comp = evt.getComponent();
+ if( comp.equals(this ) )
+ {
+ requestFocus();
+ }
+ }
+
+ }
+}
diff --git a/demos/HodglimsNeHe/Lesson4_plugin13.html b/demos/HodglimsNeHe/Lesson4_plugin13.html new file mode 100644 index 0000000..045a94d --- /dev/null +++ b/demos/HodglimsNeHe/Lesson4_plugin13.html @@ -0,0 +1,66 @@ +<HTML>
+<HEAD>
+<TITLE>Lesson4 Applet: Rotation</TITLE>
+<STYLE TYPE="text/css">
+<!--
+A:link { COLOR: #9C9AB1; TEXT-DECORATION: none }
+A:visited { COLOR: #9C9AB1; TEXT-DECORATION: none }
+A:active { color: Yellow; TEXT-DECORATION: none }
+A:hover { color: Yellow; TEXT-DECORATION: none }
+-->
+</STYLE>
+</HEAD>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+<CENTER>
+<P>
+<FONT SIZE="2" FACE="Verdana"><B>Rotation</B></FONT>
+</P>
+<TABLE WIDTH="100%">
+<TR>
+<TD WIDTH="30%" ALIGN="LEFT" VALIGN="TOP">
+<P>
+<FONT SIZE="1" FACE="Verdana">
+<A HREF="index.html">Go back</A>
+</FONT>
+</P>
+</TD>
+<TD WIDTH="70%" ALIGN="CENTER" VALIGN="TOP">
+<!--"CONVERTED_APPLET"-->
+<!-- CONVERTER VERSION 1.3 --> +<SCRIPT LANGUAGE="JavaScript"><!-- + var _info = navigator.userAgent; var _ns = false; + var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0); +//--></SCRIPT> +<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!-- + var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0))); +//--></SCRIPT></COMMENT> + +<SCRIPT LANGUAGE="JavaScript"><!-- + if (_ie == true) document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = "400" HEIGHT = "400" codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0"><NOEMBED><XMP>'); + else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.3" CODE = "Lesson4.class" WIDTH = "400" HEIGHT = "400" scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html"><NOEMBED><XMP>'); +//--></SCRIPT> +<APPLET CODE = "Lesson4.class" WIDTH = "400" HEIGHT = "400"></XMP> +<PARAM NAME = CODE VALUE = "Lesson4.class" >
+ +<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3"> +<PARAM NAME="scriptable" VALUE="false"> + +</APPLET> + +</NOEMBED></EMBED></OBJECT> + + +<!-- +<APPLET CODE = "Lesson4.class" WIDTH = "400" HEIGHT = "400">
+
+
+</APPLET> +--> +<!--"END_CONVERTED_APPLET"-->
+
+</TD>
+</TR>
+</TABLE>
+</CENTER>
+</BODY>
+</HTML>
diff --git a/demos/HodglimsNeHe/Lesson5.html b/demos/HodglimsNeHe/Lesson5.html new file mode 100644 index 0000000..7ab275b --- /dev/null +++ b/demos/HodglimsNeHe/Lesson5.html @@ -0,0 +1,35 @@ +<HTML>
+<HEAD>
+<TITLE>Lesson5 Applet: Solid Objects</TITLE>
+<STYLE TYPE="text/css">
+<!--
+A:link { COLOR: #9C9AB1; TEXT-DECORATION: none }
+A:visited { COLOR: #9C9AB1; TEXT-DECORATION: none }
+A:active { color: Yellow; TEXT-DECORATION: none }
+A:hover { color: Yellow; TEXT-DECORATION: none }
+-->
+</STYLE>
+</HEAD>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+<CENTER>
+<P>
+<FONT SIZE="2" FACE="Verdana"><B>Solid Objects</B></FONT>
+</P>
+<TABLE WIDTH="100%">
+<TR>
+<TD WIDTH="30%" ALIGN="LEFT" VALIGN="TOP">
+<P>
+<FONT SIZE="1" FACE="Verdana">
+<A HREF="index.html">Go back</A>
+</FONT>
+</P>
+</TD>
+<TD WIDTH="70%" ALIGN="CENTER" VALIGN="TOP">
+<APPLET CODE="Lesson5.class" WIDTH="400" HEIGHT="400">
+</APPLET>
+</TD>
+</TR>
+</TABLE>
+</CENTER>
+</BODY>
+</HTML>
diff --git a/demos/HodglimsNeHe/Lesson5.java b/demos/HodglimsNeHe/Lesson5.java new file mode 100644 index 0000000..026ecb3 --- /dev/null +++ b/demos/HodglimsNeHe/Lesson5.java @@ -0,0 +1,355 @@ +/**
+ * Lesson5.java
+ *
+ * Author: Darren Hodges
+ * Date: 16/12/1999
+ *
+ * Port of the NeHe OpenGL Tutorial (Lesson 5: "Solid Objects")
+ * to Java using the GL4Java interface to OpenGL.
+ *
+ */
+
+import java.applet.*;
+import java.awt.*;
+import java.awt.event.*;
+
+//GL4Java classes
+import gl4java.GLContext;
+import gl4java.awt.GLAnimCanvas;
+
+
+public class Lesson5 extends Applet
+{
+ //Our rendering canvas
+ //We are using GLAnimCanvas because we want the canvas
+ //to be constantly redrawn
+ renderCanvas canvas = null;
+
+
+ /**
+ * void init()
+ *
+ * Initialise the applet.
+ */
+ public void init()
+ {
+ //We will use BorderLayout to layout the applet components
+ setLayout(new BorderLayout());
+
+ //Create our canvas and add it to the center of the applet
+ canvas = new renderCanvas(getSize().width, getSize().height);
+ canvas.requestFocus();
+ add("Center", canvas);
+ }
+
+
+ /**
+ * void start()
+ *
+ * Start the applet.
+ */
+ public void start()
+ {
+ //Start animating the canvas
+ canvas.start();
+ }
+
+
+ /**
+ * void stop()
+ *
+ * Stop the applet.
+ */
+ public void stop()
+ {
+ //Stop animating the canvas
+ canvas.stop();
+ }
+
+
+ /**
+ * void destroy()
+ *
+ * Destroy the applet.
+ */
+ public void destroy()
+ {
+ //Stop animating the canvas
+ canvas.stop();
+ //Destroy the canvas
+ canvas.destroy();
+ }
+
+
+
+ private class renderCanvas extends GLAnimCanvas
+ implements KeyListener, MouseListener
+ {
+ //Angle For The Pyramid
+ float rtri = 0.0f;
+ //Angle For The Cube
+ float rquad = 0.0f;
+
+
+ /**
+ * renderCanvas(int w, int h)
+ *
+ * Constructor.
+ */
+ public renderCanvas(int w, int h)
+ {
+ super(w, h);
+
+ //Registers this canvas to process keyboard events
+ addKeyListener(this);
+ addMouseListener(this);
+ }
+
+
+ /**
+ * void preInit()
+ *
+ * Called just BEFORE the GL-Context is created.
+ */
+ public void preInit()
+ {
+ //We want double buffering
+ doubleBuffer = true;
+ //But we dont want stereo view
+ stereoView = false;
+ }
+
+
+ /**
+ * void init()
+ *
+ * Called just AFTER the GL-Context is created.
+ */
+ public void init()
+ {
+ //This Will Clear The Background Color To Black
+ gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
+
+ //Enables Clearing Of The Depth Buffer
+ gl.glClearDepth(1.0);
+ //The Type Of Depth Test To Do
+ gl.glDepthFunc(GL_LESS);
+ //Enables Depth Testing
+ gl.glEnable(GL_DEPTH_TEST);
+
+ //Enables Smooth Color Shading
+ gl.glShadeModel(GL_SMOOTH);
+ //Select The Projection Matrix
+ gl.glMatrixMode(GL_PROJECTION);
+ //Reset The Projection Matrix
+ gl.glLoadIdentity();
+ //Calculate The Aspect Ratio Of The Window
+ glu.gluPerspective(45.0f, (float)getSize().width / (float)getSize().height, 0.1f, 100.0f);
+ //Select The Modelview Matrix
+ gl.glMatrixMode(GL_MODELVIEW);
+ }
+
+
+ /**
+ * void destroy()
+ *
+ * Destroy the canvas.
+ */
+ public void destroy()
+ {
+ //Destroy the GLContext
+ cvsDispose();
+ }
+
+
+ /**
+ * void reshape(int width, int height)
+ *
+ * Called after the first paint command.
+ */
+ public void reshape(int width, int height)
+ {
+ //Reset The Current Viewport And Perspective Transformation
+ gl.glViewport(0, 0, width, height);
+
+ //Select The Projection Matrix
+ gl.glMatrixMode(GL_PROJECTION);
+ //Reset The Projection Matrix
+ gl.glLoadIdentity();
+ //Calculate The Aspect Ratio Of The Window
+ glu.gluPerspective(45.0f, (float)getSize().width / (float)getSize().height, 0.1f, 100.0f);
+ //Select The Modelview Matrix
+ gl.glMatrixMode(GL_MODELVIEW);
+ }
+
+
+ /**
+ * void display()
+ *
+ * Draw to the canvas.
+ */
+ public void display()
+ {
+ //Ensure GL is initialised correctly
+ if (glj.gljMakeCurrent(true) == false)
+ return;
+
+ //Clear The Screen And The Depth Buffer
+ gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ //Reset The View
+ gl.glLoadIdentity();
+
+ //Move Left 1.5 Units And Into The Screen 8.0
+ gl.glTranslatef(-1.5f, 0.0f, -8.0f);
+
+ //Rotate The Pyramid On Its Y axis
+ gl.glRotatef(rtri, 0.0f, 1.0f, 0.0f);
+
+ //Draw pyramid
+ gl.glBegin(GL_POLYGON);
+ gl.glColor3f(1.0f, 0.0f, 0.0f); //Red
+ gl.glVertex3f(0.0f, 1.0f, 0.0f); //Top Of Triangle (Front)
+ gl.glColor3f(0.0f, 1.0f, 0.0f); //Green
+ gl.glVertex3f(-1.0f, -1.0f, 1.0f); //Left Of Triangle (Front)
+ gl.glColor3f(0.0f, 0.0f, 1.0f); //Blue
+ gl.glVertex3f(1.0f, -1.0f, 1.0f); //Right Of Triangle (Front)
+
+ gl.glColor3f(1.0f, 0.0f, 0.0f); //Red
+ gl.glVertex3f(0.0f, 1.0f, 0.0f); //Top Of Triangle (Right)
+ gl.glColor3f(0.0f, 0.0f, 1.0f); //Blue
+ gl.glVertex3f(1.0f, -1.0f, 1.0f); //Left Of Triangle (Right)
+ gl.glColor3f(0.0f, 1.0f, 0.0f); //Green
+ gl.glVertex3f(1.0f, -1.0f, -1.0f); //Right Of Triangle (Right)
+
+ gl.glColor3f(1.0f,0.0f,0.0f); //Red
+ gl.glVertex3f(0.0f, 1.0f, 0.0f); //Top Of Triangle (Back)
+ gl.glColor3f(0.0f, 1.0f, 0.0f); //Green
+ gl.glVertex3f(1.0f, -1.0f, -1.0f); //Left Of Triangle (Back)
+ gl.glColor3f(0.0f, 0.0f, 1.0f); //Blue
+ gl.glVertex3f(-1.0f, -1.0f, -1.0f); //Right Of Triangle (Back)
+
+ gl.glColor3f(1.0f, 0.0f, 0.0f); //Red
+ gl.glVertex3f(0.0f, 1.0f, 0.0f); //Top Of Triangle (Left)
+ gl.glColor3f(0.0f, 0.0f, 1.0f); //Blue
+ gl.glVertex3f(-1.0f, -1.0f, -1.0f); //Left Of Triangle (Left)
+ gl.glColor3f(0.0f, 1.0f, 0.0f); //Green
+ gl.glVertex3f(-1.0f, -1.0f, 1.0f); //Right Of Triangle (Left)
+ gl.glEnd();
+
+ //Reset The View
+ gl.glLoadIdentity();
+
+ //Move right and into the screen
+ gl.glTranslatef(1.5f, 0.0f, -8.0f);
+
+ //Rotate The Cube On X, Y & Z
+ gl.glRotatef(rquad, 1.0f, 1.0f, 1.0f);
+
+ //Draw cube
+ gl.glBegin(GL_QUADS);
+ gl.glColor3f(0.0f, 1.0f, 0.0f); //Set The Color To Blue
+ gl.glVertex3f(1.0f, 1.0f, -1.0f); //Top Right Of The Quad (Top)
+ gl.glVertex3f(-1.0f, 1.0f, -1.0f); //Top Left Of The Quad (Top)
+ gl.glVertex3f(-1.0f, 1.0f, 1.0f); //Bottom Left Of The Quad (Top)
+ gl.glVertex3f(1.0f, 1.0f, 1.0f); //Bottom Right Of The Quad (Top)
+
+ gl.glColor3f(1.0f, 0.5f, 0.0f); //Set The Color To Orange
+ gl.glVertex3f(1.0f, -1.0f, 1.0f); //Top Right Of The Quad (Bottom)
+ gl.glVertex3f(-1.0f, -1.0f, 1.0f); //Top Left Of The Quad (Bottom)
+ gl.glVertex3f(-1.0f, -1.0f, -1.0f); //Bottom Left Of The Quad (Bottom)
+ gl.glVertex3f(1.0f, -1.0f, -1.0f); //Bottom Right Of The Quad (Bottom)
+
+ gl.glColor3f(1.0f, 0.0f, 0.0f); //Set The Color To Red
+ gl.glVertex3f(1.0f, 1.0f, 1.0f); //Top Right Of The Quad (Front)
+ gl.glVertex3f(-1.0f, 1.0f, 1.0f); //Top Left Of The Quad (Front)
+ gl.glVertex3f(-1.0f, -1.0f, 1.0f); //Bottom Left Of The Quad (Front)
+ gl.glVertex3f(1.0f, -1.0f, 1.0f); //Bottom Right Of The Quad (Front)
+
+ gl.glColor3f(1.0f, 1.0f, 0.0f); //Set The Color To Yellow
+ gl.glVertex3f(1.0f, -1.0f, -1.0f); //Top Right Of The Quad (Back)
+ gl.glVertex3f(-1.0f, -1.0f, -1.0f); //Top Left Of The Quad (Back)
+ gl.glVertex3f(-1.0f, 1.0f, -1.0f); //Bottom Left Of The Quad (Back)
+ gl.glVertex3f(1.0f, 1.0f, -1.0f); //Bottom Right Of The Quad (Back)
+
+ gl.glColor3f(0.0f, 0.0f, 1.0f); //Set The Color To Blue
+ gl.glVertex3f(-1.0f, 1.0f, 1.0f); //Top Right Of The Quad (Left)
+ gl.glVertex3f(-1.0f, 1.0f, -1.0f); //Top Left Of The Quad (Left)
+ gl.glVertex3f(-1.0f, -1.0f, -1.0f); //Bottom Left Of The Quad (Left)
+ gl.glVertex3f(-1.0f, -1.0f, 1.0f); //Bottom Right Of The Quad (Left)
+
+ gl.glColor3f(1.0f, 0.0f, 1.0f); //Set The Color To Violet
+ gl.glVertex3f(1.0f, 1.0f, -1.0f); //Top Right Of The Quad (Right)
+ gl.glVertex3f(1.0f, 1.0f, 1.0f); //Top Left Of The Quad (Right)
+ gl.glVertex3f(1.0f, -1.0f, 1.0f); //Bottom Left Of The Quad (Right)
+ gl.glVertex3f(1.0f, -1.0f, -1.0f); //Bottom Right Of The Quad (Right)
+ gl.glEnd();
+
+ //Increase The Rotation Variable For The Pyramid
+ rtri += 0.2f;
+ //Decrease The Rotation Variable For The Cube
+ rquad -= 0.15f;
+
+ //Swap buffers
+ glj.gljSwap();
+ }
+
+
+ /**
+ * void keyTyped(KeyEvent e)
+ *
+ * Invoked when a key has been typed. This event occurs when a key press is followed by a key release.
+ */
+ public void keyTyped(KeyEvent e)
+ {
+ //We are not handling any keyboard events yet
+ }
+
+
+ /**
+ * void keyPressed(KeyEvent e)
+ *
+ * Invoked when a key has been pressed.
+ */
+ public void keyPressed(KeyEvent e)
+ {
+ //We are not handling any keyboard events yet
+ }
+
+
+ /**
+ * void keyReleased(KeyEvent e)
+ *
+ * Invoked when a key has been released.
+ */
+ public void keyReleased(KeyEvent e)
+ {
+ //We are not handling any keyboard events yet
+ }
+
+ // Methods required for the implementation of MouseListener
+ public void mouseEntered( MouseEvent evt )
+ {
+ Component comp = evt.getComponent();
+ if( comp.equals(this ) )
+ {
+ requestFocus();
+ }
+ }
+
+ public void mouseExited( MouseEvent evt )
+ { }
+ public void mousePressed( MouseEvent evt )
+ { }
+ public void mouseReleased( MouseEvent evt )
+ { }
+ public void mouseClicked( MouseEvent evt )
+ {
+ Component comp = evt.getComponent();
+ if( comp.equals(this ) )
+ {
+ requestFocus();
+ }
+ }
+
+ }
+}
diff --git a/demos/HodglimsNeHe/Lesson5_plugin13.html b/demos/HodglimsNeHe/Lesson5_plugin13.html new file mode 100644 index 0000000..4e79716 --- /dev/null +++ b/demos/HodglimsNeHe/Lesson5_plugin13.html @@ -0,0 +1,66 @@ +<HTML>
+<HEAD>
+<TITLE>Lesson5 Applet: Solid Objects</TITLE>
+<STYLE TYPE="text/css">
+<!--
+A:link { COLOR: #9C9AB1; TEXT-DECORATION: none }
+A:visited { COLOR: #9C9AB1; TEXT-DECORATION: none }
+A:active { color: Yellow; TEXT-DECORATION: none }
+A:hover { color: Yellow; TEXT-DECORATION: none }
+-->
+</STYLE>
+</HEAD>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+<CENTER>
+<P>
+<FONT SIZE="2" FACE="Verdana"><B>Solid Objects</B></FONT>
+</P>
+<TABLE WIDTH="100%">
+<TR>
+<TD WIDTH="30%" ALIGN="LEFT" VALIGN="TOP">
+<P>
+<FONT SIZE="1" FACE="Verdana">
+<A HREF="index.html">Go back</A>
+</FONT>
+</P>
+</TD>
+<TD WIDTH="70%" ALIGN="CENTER" VALIGN="TOP">
+<!--"CONVERTED_APPLET"-->
+<!-- CONVERTER VERSION 1.3 --> +<SCRIPT LANGUAGE="JavaScript"><!-- + var _info = navigator.userAgent; var _ns = false; + var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0); +//--></SCRIPT> +<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!-- + var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0))); +//--></SCRIPT></COMMENT> + +<SCRIPT LANGUAGE="JavaScript"><!-- + if (_ie == true) document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = "400" HEIGHT = "400" codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0"><NOEMBED><XMP>'); + else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.3" CODE = "Lesson5.class" WIDTH = "400" HEIGHT = "400" scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html"><NOEMBED><XMP>'); +//--></SCRIPT> +<APPLET CODE = "Lesson5.class" WIDTH = "400" HEIGHT = "400"></XMP> +<PARAM NAME = CODE VALUE = "Lesson5.class" >
+ +<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3"> +<PARAM NAME="scriptable" VALUE="false"> + +</APPLET> + +</NOEMBED></EMBED></OBJECT> + + +<!-- +<APPLET CODE = "Lesson5.class" WIDTH = "400" HEIGHT = "400">
+
+
+</APPLET> +--> +<!--"END_CONVERTED_APPLET"-->
+
+</TD>
+</TR>
+</TABLE>
+</CENTER>
+</BODY>
+</HTML>
diff --git a/demos/HodglimsNeHe/Lesson6.html b/demos/HodglimsNeHe/Lesson6.html new file mode 100644 index 0000000..b3a6032 --- /dev/null +++ b/demos/HodglimsNeHe/Lesson6.html @@ -0,0 +1,35 @@ +<HTML>
+<HEAD>
+<TITLE>Lesson6 Applet: Texture Mapping</TITLE>
+<STYLE TYPE="text/css">
+<!--
+A:link { COLOR: #9C9AB1; TEXT-DECORATION: none }
+A:visited { COLOR: #9C9AB1; TEXT-DECORATION: none }
+A:active { color: Yellow; TEXT-DECORATION: none }
+A:hover { color: Yellow; TEXT-DECORATION: none }
+-->
+</STYLE>
+</HEAD>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+<CENTER>
+<P>
+<FONT SIZE="2" FACE="Verdana"><B>Texture Mapping</B></FONT>
+</P>
+<TABLE WIDTH="100%">
+<TR>
+<TD WIDTH="30%" ALIGN="LEFT" VALIGN="TOP">
+<P>
+<FONT SIZE="1" FACE="Verdana">
+<A HREF="index.html">Go back</A>
+</FONT>
+</P>
+</TD>
+<TD WIDTH="70%" ALIGN="CENTER" VALIGN="TOP">
+<APPLET CODE="Lesson6.class" WIDTH="400" HEIGHT="400">
+</APPLET>
+</TD>
+</TR>
+</TABLE>
+</CENTER>
+</BODY>
+</HTML>
diff --git a/demos/HodglimsNeHe/Lesson6.java b/demos/HodglimsNeHe/Lesson6.java new file mode 100644 index 0000000..ae85d76 --- /dev/null +++ b/demos/HodglimsNeHe/Lesson6.java @@ -0,0 +1,357 @@ +/**
+ * Lesson6.java
+ *
+ * Author: Darren Hodges
+ * Date: 16/12/1999
+ *
+ * Port of the NeHe OpenGL Tutorial (Lesson 6: "Texture Mapping")
+ * to Java using the GL4Java interface to OpenGL.
+ *
+ */
+
+import java.applet.*;
+import java.awt.*;
+import java.awt.event.*;
+
+//GL4Java classes
+import gl4java.GLContext;
+import gl4java.awt.GLAnimCanvas;
+import gl4java.utils.textures.*;
+
+
+public class Lesson6 extends Applet
+{
+ //Our rendering canvas
+ //We are using GLAnimCanvas because we want the canvas
+ //to be constantly redrawn
+ renderCanvas canvas = null;
+
+
+ /**
+ * void init()
+ *
+ * Initialise the applet.
+ */
+ public void init()
+ {
+ //We will use BorderLayout to layout the applet components
+ setLayout(new BorderLayout());
+
+ //Create our canvas and add it to the center of the applet
+ canvas = new renderCanvas(getSize().width, getSize().height);
+ canvas.requestFocus();
+ add("Center", canvas);
+ }
+
+
+ /**
+ * void start()
+ *
+ * Start the applet.
+ */
+ public void start()
+ {
+ //Start animating the canvas
+ canvas.start();
+ }
+
+
+ /**
+ * void stop()
+ *
+ * Stop the applet.
+ */
+ public void stop()
+ {
+ //Stop animating the canvas
+ canvas.stop();
+ }
+
+
+ /**
+ * void destroy()
+ *
+ * Destroy the applet.
+ */
+ public void destroy()
+ {
+ //Stop animating the canvas
+ canvas.stop();
+ //Destroy the canvas
+ canvas.destroy();
+ }
+
+
+
+ private class renderCanvas extends GLAnimCanvas
+ implements KeyListener, MouseListener
+ {
+ float xrot = 0.0f; //X Rotation
+ float yrot = 0.0f; //Y Rotation
+ float zrot = 0.0f; //Z Rotation
+
+ int[] texture = new int[1]; //Storage for one texture
+
+
+ /**
+ * renderCanvas(int w, int h)
+ *
+ * Constructor.
+ */
+ public renderCanvas(int w, int h)
+ {
+ super(w, h);
+
+ //Registers this canvas to process keyboard events
+ addKeyListener(this);
+ addMouseListener(this);
+ }
+
+
+ /**
+ * void preInit()
+ *
+ * Called just BEFORE the GL-Context is created.
+ */
+ public void preInit()
+ {
+ //We want double buffering
+ doubleBuffer = true;
+ //But we dont want stereo view
+ stereoView = false;
+ }
+
+
+ /**
+ * void LoadGLTextures()
+ *
+ * Load textures.
+ */
+ public void LoadGLTextures()
+ {
+ PngTextureLoader texLoader = new PngTextureLoader(gl, glu);
+ texLoader.readTexture(getCodeBase(), "data/nehe.png");
+
+ if(texLoader.isOk())
+ {
+ //Create Texture
+ gl.glGenTextures(1, texture);
+ gl.glBindTexture(GL_TEXTURE_2D, texture[0]);
+
+ gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+
+ gl.glTexImage2D(GL_TEXTURE_2D,
+ 0,
+ 3,
+ texLoader.getImageWidth(),
+ texLoader.getImageHeight(),
+ 0,
+ GL_RGB,
+ GL_UNSIGNED_BYTE,
+ texLoader.getTexture());
+ }
+ }
+
+
+ /**
+ * void init()
+ *
+ * Called just AFTER the GL-Context is created.
+ */
+ public void init()
+ {
+ //Load The Texture(s)
+ LoadGLTextures();
+ //Enable Texture Mapping
+ gl.glEnable(GL_TEXTURE_2D);
+
+ //This Will Clear The Background Color To Black
+ gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
+
+ //Enables Clearing Of The Depth Buffer
+ gl.glClearDepth(1.0);
+ //The Type Of Depth Test To Do
+ gl.glDepthFunc(GL_LESS);
+ //Enables Depth Testing
+ gl.glEnable(GL_DEPTH_TEST);
+
+ //Enables Smooth Color Shading
+ gl.glShadeModel(GL_SMOOTH);
+ //Select The Projection Matrix
+ gl.glMatrixMode(GL_PROJECTION);
+ //Reset The Projection Matrix
+ gl.glLoadIdentity();
+ //Calculate The Aspect Ratio Of The Window
+ glu.gluPerspective(45.0f, (float)getSize().width / (float)getSize().height, 0.1f, 100.0f);
+ //Select The Modelview Matrix
+ gl.glMatrixMode(GL_MODELVIEW);
+ }
+
+
+ /**
+ * void destroy()
+ *
+ * Destroy the canvas.
+ */
+ public void destroy()
+ {
+ //Destroy the GLContext
+ cvsDispose();
+ }
+
+
+ /**
+ * void reshape(int width, int height)
+ *
+ * Called after the first paint command.
+ */
+ public void reshape(int width, int height)
+ {
+ //Reset The Current Viewport And Perspective Transformation
+ gl.glViewport(0, 0, width, height);
+
+ //Select The Projection Matrix
+ gl.glMatrixMode(GL_PROJECTION);
+ //Reset The Projection Matrix
+ gl.glLoadIdentity();
+ //Calculate The Aspect Ratio Of The Window
+ glu.gluPerspective(45.0f, (float)getSize().width / (float)getSize().height, 0.1f, 100.0f);
+ //Select The Modelview Matrix
+ gl.glMatrixMode(GL_MODELVIEW);
+ }
+
+
+ /**
+ * void display()
+ *
+ * Draw to the canvas.
+ */
+ public void display()
+ {
+ //Ensure GL is initialised correctly
+ if (glj.gljMakeCurrent(true) == false)
+ return;
+
+ //Clear The Screen And The Depth Buffer
+ gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ //Reset The View
+ gl.glLoadIdentity();
+
+ //Move into the screen
+ gl.glTranslatef(0.0f, 0.0f, -8.0f);
+
+ //Rotate On The X Axis
+ gl.glRotatef(xrot,1.0f, 0.0f, 0.0f);
+ //Rotate On The Y Axis
+ gl.glRotatef(yrot, 0.0f, 1.0f, 0.0f);
+ //Rotate On The Z Axis
+ gl.glRotatef(zrot, 0.0f, 0.0f, 1.0f);
+
+ //Select texture
+ gl.glBindTexture(GL_TEXTURE_2D, texture[0]);
+
+ gl.glBegin(GL_QUADS);
+ //Front Face
+ gl.glTexCoord2f(0.0f, 0.0f); gl.glVertex3f(-1.0f, -1.0f, 1.0f); //Bottom Left Of The Texture and Quad
+ gl.glTexCoord2f(1.0f, 0.0f); gl.glVertex3f( 1.0f, -1.0f, 1.0f); //Bottom Right Of The Texture and Quad
+ gl.glTexCoord2f(1.0f, 1.0f); gl.glVertex3f( 1.0f, 1.0f, 1.0f); //Top Right Of The Texture and Quad
+ gl.glTexCoord2f(0.0f, 1.0f); gl.glVertex3f(-1.0f, 1.0f, 1.0f); //Top Left Of The Texture and Quad
+ //Back Face
+ gl.glTexCoord2f(1.0f, 0.0f); gl.glVertex3f(-1.0f, -1.0f, -1.0f); //Bottom Right Of The Texture and Quad
+ gl.glTexCoord2f(1.0f, 1.0f); gl.glVertex3f(-1.0f, 1.0f, -1.0f); //Top Right Of The Texture and Quad
+ gl.glTexCoord2f(0.0f, 1.0f); gl.glVertex3f( 1.0f, 1.0f, -1.0f); //Top Left Of The Texture and Quad
+ gl.glTexCoord2f(0.0f, 0.0f); gl.glVertex3f( 1.0f, -1.0f, -1.0f); //Bottom Left Of The Texture and Quad
+ //Top Face
+ gl.glTexCoord2f(0.0f, 1.0f); gl.glVertex3f(-1.0f, 1.0f, -1.0f); //Top Left Of The Texture and Quad
+ gl.glTexCoord2f(0.0f, 0.0f); gl.glVertex3f(-1.0f, 1.0f, 1.0f); //Bottom Left Of The Texture and Quad
+ gl.glTexCoord2f(1.0f, 0.0f); gl.glVertex3f( 1.0f, 1.0f, 1.0f); //Bottom Right Of The Texture and Quad
+ gl.glTexCoord2f(1.0f, 1.0f); gl.glVertex3f( 1.0f, 1.0f, -1.0f); //Top Right Of The Texture and Quad
+ //Bottom Face
+ gl.glTexCoord2f(1.0f, 1.0f); gl.glVertex3f(-1.0f, -1.0f, -1.0f); //Top Right Of The Texture and Quad
+ gl.glTexCoord2f(0.0f, 1.0f); gl.glVertex3f( 1.0f, -1.0f, -1.0f); //Top Left Of The Texture and Quad
+ gl.glTexCoord2f(0.0f, 0.0f); gl.glVertex3f( 1.0f, -1.0f, 1.0f); //Bottom Left Of The Texture and Quad
+ gl.glTexCoord2f(1.0f, 0.0f); gl.glVertex3f(-1.0f, -1.0f, 1.0f); //Bottom Right Of The Texture and Quad
+ //Right face
+ gl.glTexCoord2f(1.0f, 0.0f); gl.glVertex3f( 1.0f, -1.0f, -1.0f); //Bottom Right Of The Texture and Quad
+ gl.glTexCoord2f(1.0f, 1.0f); gl.glVertex3f( 1.0f, 1.0f, -1.0f); //Top Right Of The Texture and Quad
+ gl.glTexCoord2f(0.0f, 1.0f); gl.glVertex3f( 1.0f, 1.0f, 1.0f); //Top Left Of The Texture and Quad
+ gl.glTexCoord2f(0.0f, 0.0f); gl.glVertex3f( 1.0f, -1.0f, 1.0f); //Bottom Left Of The Texture and Quad
+ //Left Face
+ gl.glTexCoord2f(0.0f, 0.0f); gl.glVertex3f(-1.0f, -1.0f, -1.0f); //Bottom Left Of The Texture and Quad
+ gl.glTexCoord2f(1.0f, 0.0f); gl.glVertex3f(-1.0f, -1.0f, 1.0f); //Bottom Right Of The Texture and Quad
+ gl.glTexCoord2f(1.0f, 1.0f); gl.glVertex3f(-1.0f, 1.0f, 1.0f); //Top Right Of The Texture and Quad
+ gl.glTexCoord2f(0.0f, 1.0f); gl.glVertex3f(-1.0f, 1.0f, -1.0f); //Top Left Of The Texture and Quad
+ gl.glEnd();
+
+ //X Axis Rotation
+ xrot += 0.3f;
+ //Y Axis Rotation
+ yrot += 0.2f;
+ //Z Axis Rotation
+ zrot += 0.4f;
+
+ //Swap buffers
+ glj.gljSwap();
+ }
+
+
+ /**
+ * void keyTyped(KeyEvent e)
+ *
+ * Invoked when a key has been typed. This event occurs when a key press is followed by a key release.
+ */
+ public void keyTyped(KeyEvent e)
+ {
+ //We are not handling any keyboard events yet
+ }
+
+
+ /**
+ * void keyPressed(KeyEvent e)
+ *
+ * Invoked when a key has been pressed.
+ */
+ public void keyPressed(KeyEvent e)
+ {
+ //We are not handling any keyboard events yet
+ }
+
+
+ /**
+ * void keyReleased(KeyEvent e)
+ *
+ * Invoked when a key has been released.
+ */
+ public void keyReleased(KeyEvent e)
+ {
+ //We are not handling any keyboard events yet
+ }
+
+ // Methods required for the implementation of MouseListener
+ public void mouseEntered( MouseEvent evt )
+ {
+ Component comp = evt.getComponent();
+ if( comp.equals(this ) )
+ {
+ requestFocus();
+ }
+ }
+
+ public void mouseExited( MouseEvent evt )
+ { }
+ public void mousePressed( MouseEvent evt )
+ { }
+ public void mouseReleased( MouseEvent evt )
+ { }
+ public void mouseClicked( MouseEvent evt )
+ {
+ Component comp = evt.getComponent();
+ if( comp.equals(this ) )
+ {
+ requestFocus();
+ }
+ }
+
+ }
+}
diff --git a/demos/HodglimsNeHe/Lesson6_plugin13.html b/demos/HodglimsNeHe/Lesson6_plugin13.html new file mode 100644 index 0000000..46bfd1d --- /dev/null +++ b/demos/HodglimsNeHe/Lesson6_plugin13.html @@ -0,0 +1,66 @@ +<HTML>
+<HEAD>
+<TITLE>Lesson6 Applet: Texture Mapping</TITLE>
+<STYLE TYPE="text/css">
+<!--
+A:link { COLOR: #9C9AB1; TEXT-DECORATION: none }
+A:visited { COLOR: #9C9AB1; TEXT-DECORATION: none }
+A:active { color: Yellow; TEXT-DECORATION: none }
+A:hover { color: Yellow; TEXT-DECORATION: none }
+-->
+</STYLE>
+</HEAD>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+<CENTER>
+<P>
+<FONT SIZE="2" FACE="Verdana"><B>Texture Mapping</B></FONT>
+</P>
+<TABLE WIDTH="100%">
+<TR>
+<TD WIDTH="30%" ALIGN="LEFT" VALIGN="TOP">
+<P>
+<FONT SIZE="1" FACE="Verdana">
+<A HREF="index.html">Go back</A>
+</FONT>
+</P>
+</TD>
+<TD WIDTH="70%" ALIGN="CENTER" VALIGN="TOP">
+<!--"CONVERTED_APPLET"-->
+<!-- CONVERTER VERSION 1.3 --> +<SCRIPT LANGUAGE="JavaScript"><!-- + var _info = navigator.userAgent; var _ns = false; + var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0); +//--></SCRIPT> +<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!-- + var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0))); +//--></SCRIPT></COMMENT> + +<SCRIPT LANGUAGE="JavaScript"><!-- + if (_ie == true) document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = "400" HEIGHT = "400" codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0"><NOEMBED><XMP>'); + else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.3" CODE = "Lesson6.class" WIDTH = "400" HEIGHT = "400" scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html"><NOEMBED><XMP>'); +//--></SCRIPT> +<APPLET CODE = "Lesson6.class" WIDTH = "400" HEIGHT = "400"></XMP> +<PARAM NAME = CODE VALUE = "Lesson6.class" >
+ +<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3"> +<PARAM NAME="scriptable" VALUE="false"> + +</APPLET> + +</NOEMBED></EMBED></OBJECT> + + +<!-- +<APPLET CODE = "Lesson6.class" WIDTH = "400" HEIGHT = "400">
+
+
+</APPLET> +--> +<!--"END_CONVERTED_APPLET"-->
+
+</TD>
+</TR>
+</TABLE>
+</CENTER>
+</BODY>
+</HTML>
diff --git a/demos/HodglimsNeHe/Lesson7.html b/demos/HodglimsNeHe/Lesson7.html new file mode 100644 index 0000000..2a69b88 --- /dev/null +++ b/demos/HodglimsNeHe/Lesson7.html @@ -0,0 +1,50 @@ +<HTML>
+<HEAD>
+<TITLE>Lesson7 Applet: Texture Filters, Lighting & Keyboard Control</TITLE>
+<STYLE TYPE="text/css">
+<!--
+A:link { COLOR: #9C9AB1; TEXT-DECORATION: none }
+A:visited { COLOR: #9C9AB1; TEXT-DECORATION: none }
+A:active { color: Yellow; TEXT-DECORATION: none }
+A:hover { color: Yellow; TEXT-DECORATION: none }
+-->
+</STYLE>
+</HEAD>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+<CENTER>
+<P>
+<FONT SIZE="2" FACE="Verdana"><B>Texture Filters, Lighting & Keyboard Control</B></FONT>
+</P>
+<TABLE WIDTH="100%">
+<TR>
+<TD WIDTH="30%" ALIGN="LEFT" VALIGN="TOP">
+<P>
+<FONT SIZE="1" FACE="Verdana"><B><U>Keys</U></B></FONT></P>
+<P>
+<FONT SIZE="1" FACE="Verdana">
+<B>L</B> - Lights ON/OFF<BR>
+<B>F</B> - Change texture filter<BR>
+<B>PG_UP</B> - Zoom out<BR>
+<B>PG_DOWN</B> - Zoom in<BR>
+<B>UP</B> - Rotate cube<BR>
+<B>DOWN</B> - Rotate cube<BR>
+<B>LEFT</B> - Rotate cube<BR>
+<B>RIGHT</B> - Rotate cube
+</FONT>
+</P>
+<P><FONT SIZE="1" FACE="Verdana"><B>Note:</B> You must click inside the applet window before using these keys.</FONT></P>
+<P>
+<FONT SIZE="1" FACE="Verdana">
+<A HREF="index.html">Go back</A>
+</FONT>
+</P>
+</TD>
+<TD WIDTH="70%" ALIGN="CENTER" VALIGN="TOP">
+<APPLET CODE="Lesson7.class" WIDTH="400" HEIGHT="400">
+</APPLET>
+</TD>
+</TR>
+</TABLE>
+</CENTER>
+</BODY>
+</HTML>
diff --git a/demos/HodglimsNeHe/Lesson7.java b/demos/HodglimsNeHe/Lesson7.java new file mode 100644 index 0000000..d6f65f4 --- /dev/null +++ b/demos/HodglimsNeHe/Lesson7.java @@ -0,0 +1,504 @@ +/**
+ * Lesson7.java
+ *
+ * Author: Darren Hodges
+ * Date: 17/12/1999
+ *
+ * Port of the NeHe OpenGL Tutorial (Lesson 7: "Texture Filters, Lighting & Keyboard Control")
+ * to Java using the GL4Java interface to OpenGL.
+ *
+ * Note: The MipMapping code is only available in GL4Java 2.1.2.1 and later!
+ *
+ */
+
+import java.applet.*;
+import java.awt.*;
+import java.awt.event.*;
+
+//GL4Java classes
+import gl4java.GLContext;
+import gl4java.awt.GLAnimCanvas;
+import gl4java.utils.textures.*;
+
+
+public class Lesson7 extends Applet
+{
+ //Our rendering canvas
+ //We are using GLAnimCanvas because we want the canvas
+ //to be constantly redrawn
+ renderCanvas canvas = null;
+
+
+ /**
+ * void init()
+ *
+ * Initialise the applet.
+ */
+ public void init()
+ {
+ //We will use BorderLayout to layout the applet components
+ setLayout(new BorderLayout());
+
+ //Create our canvas and add it to the center of the applet
+ canvas = new renderCanvas(getSize().width, getSize().height);
+ canvas.requestFocus();
+ add("Center", canvas);
+ }
+
+
+ /**
+ * void start()
+ *
+ * Start the applet.
+ */
+ public void start()
+ {
+ //Start animating the canvas
+ canvas.start();
+ }
+
+
+ /**
+ * void stop()
+ *
+ * Stop the applet.
+ */
+ public void stop()
+ {
+ //Stop animating the canvas
+ canvas.stop();
+ }
+
+
+ /**
+ * void destroy()
+ *
+ * Destroy the applet.
+ */
+ public void destroy()
+ {
+ //Stop animating the canvas
+ canvas.stop();
+ //Destroy the canvas
+ canvas.destroy();
+ }
+
+
+
+ private class renderCanvas extends GLAnimCanvas
+ implements KeyListener, MouseListener
+ {
+ boolean light = true; //Lighting ON/OFF
+ boolean lp = false; //L Pressed?
+ boolean fp = false; //F Pressed?
+
+ float xrot = 0.0f; //X Rotation
+ float yrot = 0.0f; //Y Rotation
+ float xspeed = 0.0f; //X Rotation Speed
+ float yspeed = 0.0f; //Y Rotation Speed
+
+ float z = -8.0f; //Depth Into The Screen
+
+ //Ambient light
+ float[] LightAmbient = { 0.5f, 0.5f, 0.5f, 1.0f };
+
+ //Diffuse light
+ float[] LightDiffuse = { 1.0f, 1.0f, 1.0f, 1.0f };
+
+ //Light position
+ float[] LightPosition = { 0.0f, 0.0f, 2.0f, 1.0f };
+
+ int filter = 0; //Which Filter To Use
+
+ int[] texture = new int[3]; //Storage for 3 textures
+
+
+ /**
+ * renderCanvas(int w, int h)
+ *
+ * Constructor.
+ */
+ public renderCanvas(int w, int h)
+ {
+ super(w, h);
+
+ //Registers this canvas to process keyboard events
+ addKeyListener(this);
+ addMouseListener(this);
+ }
+
+
+ /**
+ * void preInit()
+ *
+ * Called just BEFORE the GL-Context is created.
+ */
+ public void preInit()
+ {
+ //We want double buffering
+ doubleBuffer = true;
+ //But we dont want stereo view
+ stereoView = false;
+ }
+
+
+ /**
+ * void LoadGLTextures()
+ *
+ * Load textures.
+ */
+ public void LoadGLTextures()
+ {
+ PngTextureLoader texLoader = new PngTextureLoader(gl, glu);
+ texLoader.readTexture(getCodeBase(), "data/crate.png");
+
+ if(texLoader.isOk())
+ {
+ //Create Nearest Filtered Texture
+ gl.glGenTextures(3, texture);
+ gl.glBindTexture(GL_TEXTURE_2D, texture[0]);
+
+ gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+
+ gl.glTexImage2D(GL_TEXTURE_2D,
+ 0,
+ 3,
+ texLoader.getImageWidth(),
+ texLoader.getImageHeight(),
+ 0,
+ GL_RGB,
+ GL_UNSIGNED_BYTE,
+ texLoader.getTexture());
+
+ //Create Linear Filtered Texture
+ gl.glBindTexture(GL_TEXTURE_2D, texture[1]);
+ gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+
+ gl.glTexImage2D(GL_TEXTURE_2D,
+ 0,
+ 3,
+ texLoader.getImageWidth(),
+ texLoader.getImageHeight(),
+ 0,
+ GL_RGB,
+ GL_UNSIGNED_BYTE,
+ texLoader.getTexture());
+
+ //Create MipMapped Texture (Only with GL4Java 2.1.2.1 and later!)
+ gl.glBindTexture(GL_TEXTURE_2D, texture[2]);
+ gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
+
+ glu.gluBuild2DMipmaps(GL_TEXTURE_2D,
+ 3,
+ texLoader.getImageWidth(),
+ texLoader.getImageHeight(), GL_RGB,
+ GL_UNSIGNED_BYTE,
+ texLoader.getTexture());
+ }
+ }
+
+
+ /**
+ * void init()
+ *
+ * Called just AFTER the GL-Context is created.
+ */
+ public void init()
+ {
+ //Load The Texture(s)
+ LoadGLTextures();
+ //Enable Texture Mapping
+ gl.glEnable(GL_TEXTURE_2D);
+
+ //This Will Clear The Background Color To Black
+ gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
+
+ //Enables Clearing Of The Depth Buffer
+ gl.glClearDepth(1.0);
+ //The Type Of Depth Test To Do
+ gl.glDepthFunc(GL_LESS);
+ //Enables Depth Testing
+ gl.glEnable(GL_DEPTH_TEST);
+
+ //Enables Smooth Color Shading
+ gl.glShadeModel(GL_SMOOTH);
+ //Select The Projection Matrix
+ gl.glMatrixMode(GL_PROJECTION);
+ //Reset The Projection Matrix
+ gl.glLoadIdentity();
+ //Calculate The Aspect Ratio Of The Window
+ glu.gluPerspective(45.0f, (float)getSize().width / (float)getSize().height, 0.1f, 100.0f);
+ //Select The Modelview Matrix
+ gl.glMatrixMode(GL_MODELVIEW);
+
+ //Lights
+ gl.glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient);
+ gl.glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse);
+ gl.glLightfv(GL_LIGHT1, GL_POSITION, LightPosition);
+
+ //Enable light
+ gl.glEnable(GL_LIGHT1);
+ gl.glEnable(GL_LIGHTING);
+ }
+
+
+ /**
+ * void destroy()
+ *
+ * Destroy the canvas.
+ */
+ public void destroy()
+ {
+ //Destroy the GLContext
+ cvsDispose();
+ }
+
+
+ /**
+ * void reshape(int width, int height)
+ *
+ * Called after the first paint command.
+ */
+ public void reshape(int width, int height)
+ {
+ //Reset The Current Viewport And Perspective Transformation
+ gl.glViewport(0, 0, width, height);
+
+ //Select The Projection Matrix
+ gl.glMatrixMode(GL_PROJECTION);
+ //Reset The Projection Matrix
+ gl.glLoadIdentity();
+ //Calculate The Aspect Ratio Of The Window
+ glu.gluPerspective(45.0f, (float)getSize().width / (float)getSize().height, 0.1f, 100.0f);
+ //Select The Modelview Matrix
+ gl.glMatrixMode(GL_MODELVIEW);
+ }
+
+
+ /**
+ * void display()
+ *
+ * Draw to the canvas.
+ */
+ public void display()
+ {
+ //Ensure GL is initialised correctly
+ if (glj.gljMakeCurrent(true) == false)
+ return;
+
+ //Clear The Screen And The Depth Buffer
+ gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ //Reset The View
+ gl.glLoadIdentity();
+
+ //Move into the screen
+ gl.glTranslatef(0.0f, 0.0f, z);
+
+ //Rotate On The X Axis
+ gl.glRotatef(xrot,1.0f, 0.0f, 0.0f);
+ //Rotate On The Y Axis
+ gl.glRotatef(yrot, 0.0f, 1.0f, 0.0f);
+
+ //Select texture
+ gl.glBindTexture(GL_TEXTURE_2D, texture[filter]);
+
+ gl.glBegin(GL_QUADS);
+ //Front Face
+ gl.glNormal3f(0.0f, 0.0f, 1.0f);
+ gl.glTexCoord2f(0.0f, 0.0f); gl.glVertex3f(-1.0f, -1.0f, 1.0f); //Bottom Left Of The Texture and Quad
+ gl.glTexCoord2f(1.0f, 0.0f); gl.glVertex3f( 1.0f, -1.0f, 1.0f); //Bottom Right Of The Texture and Quad
+ gl.glTexCoord2f(1.0f, 1.0f); gl.glVertex3f( 1.0f, 1.0f, 1.0f); //Top Right Of The Texture and Quad
+ gl.glTexCoord2f(0.0f, 1.0f); gl.glVertex3f(-1.0f, 1.0f, 1.0f); //Top Left Of The Texture and Quad
+ //Back Face
+ gl.glNormal3f(0.0f, 0.0f, -1.0f);
+ gl.glTexCoord2f(1.0f, 0.0f); gl.glVertex3f(-1.0f, -1.0f, -1.0f); //Bottom Right Of The Texture and Quad
+ gl.glTexCoord2f(1.0f, 1.0f); gl.glVertex3f(-1.0f, 1.0f, -1.0f); //Top Right Of The Texture and Quad
+ gl.glTexCoord2f(0.0f, 1.0f); gl.glVertex3f( 1.0f, 1.0f, -1.0f); //Top Left Of The Texture and Quad
+ gl.glTexCoord2f(0.0f, 0.0f); gl.glVertex3f( 1.0f, -1.0f, -1.0f); //Bottom Left Of The Texture and Quad
+ //Top Face
+ gl.glNormal3f(0.0f, 1.0f, 0.0f);
+ gl.glTexCoord2f(0.0f, 1.0f); gl.glVertex3f(-1.0f, 1.0f, -1.0f); //Top Left Of The Texture and Quad
+ gl.glTexCoord2f(0.0f, 0.0f); gl.glVertex3f(-1.0f, 1.0f, 1.0f); //Bottom Left Of The Texture and Quad
+ gl.glTexCoord2f(1.0f, 0.0f); gl.glVertex3f( 1.0f, 1.0f, 1.0f); //Bottom Right Of The Texture and Quad
+ gl.glTexCoord2f(1.0f, 1.0f); gl.glVertex3f( 1.0f, 1.0f, -1.0f); //Top Right Of The Texture and Quad
+ //Bottom Face
+ gl.glNormal3f(0.0f, -1.0f, 0.0f);
+ gl.glTexCoord2f(1.0f, 1.0f); gl.glVertex3f(-1.0f, -1.0f, -1.0f); //Top Right Of The Texture and Quad
+ gl.glTexCoord2f(0.0f, 1.0f); gl.glVertex3f( 1.0f, -1.0f, -1.0f); //Top Left Of The Texture and Quad
+ gl.glTexCoord2f(0.0f, 0.0f); gl.glVertex3f( 1.0f, -1.0f, 1.0f); //Bottom Left Of The Texture and Quad
+ gl.glTexCoord2f(1.0f, 0.0f); gl.glVertex3f(-1.0f, -1.0f, 1.0f); //Bottom Right Of The Texture and Quad
+ //Right face
+ gl.glNormal3f(1.0f, 0.0f, 0.0f);
+ gl.glTexCoord2f(1.0f, 0.0f); gl.glVertex3f( 1.0f, -1.0f, -1.0f); //Bottom Right Of The Texture and Quad
+ gl.glTexCoord2f(1.0f, 1.0f); gl.glVertex3f( 1.0f, 1.0f, -1.0f); //Top Right Of The Texture and Quad
+ gl.glTexCoord2f(0.0f, 1.0f); gl.glVertex3f( 1.0f, 1.0f, 1.0f); //Top Left Of The Texture and Quad
+ gl.glTexCoord2f(0.0f, 0.0f); gl.glVertex3f( 1.0f, -1.0f, 1.0f); //Bottom Left Of The Texture and Quad
+ //Left Face
+ gl.glNormal3f(-1.0f, 0.0f, 0.0f);
+ gl.glTexCoord2f(0.0f, 0.0f); gl.glVertex3f(-1.0f, -1.0f, -1.0f); //Bottom Left Of The Texture and Quad
+ gl.glTexCoord2f(1.0f, 0.0f); gl.glVertex3f(-1.0f, -1.0f, 1.0f); //Bottom Right Of The Texture and Quad
+ gl.glTexCoord2f(1.0f, 1.0f); gl.glVertex3f(-1.0f, 1.0f, 1.0f); //Top Right Of The Texture and Quad
+ gl.glTexCoord2f(0.0f, 1.0f); gl.glVertex3f(-1.0f, 1.0f, -1.0f); //Top Left Of The Texture and Quad
+ gl.glEnd();
+
+ //X Axis Rotation
+ xrot += xspeed;
+ //Y Axis Rotation
+ yrot += yspeed;
+
+ //Swap buffers
+ glj.gljSwap();
+ }
+
+ // Methods required for the implementation of MouseListener
+ public void mouseEntered( MouseEvent evt )
+ {
+ Component comp = evt.getComponent();
+ if( comp.equals(this ) )
+ {
+ requestFocus();
+ }
+ }
+
+ public void mouseExited( MouseEvent evt )
+ { }
+ public void mousePressed( MouseEvent evt )
+ { }
+ public void mouseReleased( MouseEvent evt )
+ { }
+ public void mouseClicked( MouseEvent evt )
+ {
+ Component comp = evt.getComponent();
+ if( comp.equals(this ) )
+ {
+ requestFocus();
+ }
+ }
+
+
+ /**
+ * void keyTyped(KeyEvent e)
+ *
+ * Invoked when a key has been typed. This event occurs when a key press is followed by a key release.
+ */
+ public void keyTyped(KeyEvent e)
+ {
+ }
+
+
+ /**
+ * void keyPressed(KeyEvent e)
+ *
+ * Invoked when a key has been pressed.
+ */
+ public void keyPressed(KeyEvent e)
+ {
+ switch(e.getKeyCode())
+ {
+ //Switch ON/OFF light when L is pressed
+ case KeyEvent.VK_L:
+ {
+ if(!lp)
+ {
+ lp = true;
+ //Toggle light
+ light = !light;
+
+ if(!light)
+ gl.glDisable(GL_LIGHTING);
+ else
+ gl.glEnable(GL_LIGHTING);
+ }
+
+ break;
+ }
+
+ //Switch filter when F is pressed
+ case KeyEvent.VK_F:
+ {
+ if(!fp)
+ {
+ fp = true;
+ //Change filter
+ filter += 1;
+ if(filter > 2)
+ filter = 0;
+ }
+
+ break;
+ }
+
+ //Move cube back when user presses PG_UP
+ case KeyEvent.VK_PAGE_UP:
+ {
+ z -= 0.2f;
+ break;
+ }
+
+ //Move cube forwards when user presses PG_DOWN
+ case KeyEvent.VK_PAGE_DOWN:
+ {
+ z += 0.2f;
+ break;
+ }
+
+ //Increase X rotation speed when user presses UP
+ case KeyEvent.VK_UP:
+ {
+ xspeed += 0.2f;
+ break;
+ }
+
+ //Decrease X rotation speed when user presses DOWN
+ case KeyEvent.VK_DOWN:
+ {
+ xspeed -= 0.2f;
+ break;
+ }
+
+ //Increase Y rotation speed when user presses RIGHT
+ case KeyEvent.VK_RIGHT:
+ {
+ yspeed += 0.2f;
+ break;
+ }
+
+ //Decrease Y rotation speed when user presses LEFT
+ case KeyEvent.VK_LEFT:
+ {
+ yspeed -= 0.2f;
+ break;
+ }
+ }
+ }
+
+
+ /**
+ * void keyReleased(KeyEvent e)
+ *
+ * Invoked when a key has been released.
+ */
+ public void keyReleased(KeyEvent e)
+ {
+ switch(e.getKeyCode())
+ {
+ //Key has been released
+ case KeyEvent.VK_L:
+ {
+ lp = false;
+ break;
+ }
+
+ //Key has been released
+ case KeyEvent.VK_F:
+ {
+ fp = false;
+ break;
+ }
+ }
+ }
+ }
+}
diff --git a/demos/HodglimsNeHe/Lesson7_plugin13.html b/demos/HodglimsNeHe/Lesson7_plugin13.html new file mode 100644 index 0000000..81d1e43 --- /dev/null +++ b/demos/HodglimsNeHe/Lesson7_plugin13.html @@ -0,0 +1,81 @@ +<HTML>
+<HEAD>
+<TITLE>Lesson7 Applet: Texture Filters, Lighting & Keyboard Control</TITLE>
+<STYLE TYPE="text/css">
+<!--
+A:link { COLOR: #9C9AB1; TEXT-DECORATION: none }
+A:visited { COLOR: #9C9AB1; TEXT-DECORATION: none }
+A:active { color: Yellow; TEXT-DECORATION: none }
+A:hover { color: Yellow; TEXT-DECORATION: none }
+-->
+</STYLE>
+</HEAD>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+<CENTER>
+<P>
+<FONT SIZE="2" FACE="Verdana"><B>Texture Filters, Lighting & Keyboard Control</B></FONT>
+</P>
+<TABLE WIDTH="100%">
+<TR>
+<TD WIDTH="30%" ALIGN="LEFT" VALIGN="TOP">
+<P>
+<FONT SIZE="1" FACE="Verdana"><B><U>Keys</U></B></FONT></P>
+<P>
+<FONT SIZE="1" FACE="Verdana">
+<B>L</B> - Lights ON/OFF<BR>
+<B>F</B> - Change texture filter<BR>
+<B>PG_UP</B> - Zoom out<BR>
+<B>PG_DOWN</B> - Zoom in<BR>
+<B>UP</B> - Rotate cube<BR>
+<B>DOWN</B> - Rotate cube<BR>
+<B>LEFT</B> - Rotate cube<BR>
+<B>RIGHT</B> - Rotate cube
+</FONT>
+</P>
+<P><FONT SIZE="1" FACE="Verdana"><B>Note:</B> You must click inside the applet window before using these keys.</FONT></P>
+<P>
+<FONT SIZE="1" FACE="Verdana">
+<A HREF="index.html">Go back</A>
+</FONT>
+</P>
+</TD>
+<TD WIDTH="70%" ALIGN="CENTER" VALIGN="TOP">
+<!--"CONVERTED_APPLET"-->
+<!-- CONVERTER VERSION 1.3 --> +<SCRIPT LANGUAGE="JavaScript"><!-- + var _info = navigator.userAgent; var _ns = false; + var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0); +//--></SCRIPT> +<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!-- + var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0))); +//--></SCRIPT></COMMENT> + +<SCRIPT LANGUAGE="JavaScript"><!-- + if (_ie == true) document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = "400" HEIGHT = "400" codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0"><NOEMBED><XMP>'); + else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.3" CODE = "Lesson7.class" WIDTH = "400" HEIGHT = "400" scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html"><NOEMBED><XMP>'); +//--></SCRIPT> +<APPLET CODE = "Lesson7.class" WIDTH = "400" HEIGHT = "400"></XMP> +<PARAM NAME = CODE VALUE = "Lesson7.class" >
+ +<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3"> +<PARAM NAME="scriptable" VALUE="false"> + +</APPLET> + +</NOEMBED></EMBED></OBJECT> + + +<!-- +<APPLET CODE = "Lesson7.class" WIDTH = "400" HEIGHT = "400">
+
+
+</APPLET> +--> +<!--"END_CONVERTED_APPLET"-->
+
+</TD>
+</TR>
+</TABLE>
+</CENTER>
+</BODY>
+</HTML>
diff --git a/demos/HodglimsNeHe/Lesson8.html b/demos/HodglimsNeHe/Lesson8.html new file mode 100644 index 0000000..dd21ea2 --- /dev/null +++ b/demos/HodglimsNeHe/Lesson8.html @@ -0,0 +1,51 @@ +<HTML>
+<HEAD>
+<TITLE>Lesson8 Applet: Blending</TITLE>
+<STYLE TYPE="text/css">
+<!--
+A:link { COLOR: #9C9AB1; TEXT-DECORATION: none }
+A:visited { COLOR: #9C9AB1; TEXT-DECORATION: none }
+A:active { color: Yellow; TEXT-DECORATION: none }
+A:hover { color: Yellow; TEXT-DECORATION: none }
+-->
+</STYLE>
+</HEAD>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+<CENTER>
+<P>
+<FONT SIZE="2" FACE="Verdana"><B>Blending</B></FONT>
+</P>
+<TABLE WIDTH="100%">
+<TR>
+<TD WIDTH="30%" ALIGN="LEFT" VALIGN="TOP">
+<P>
+<FONT SIZE="1" FACE="Verdana"><B><U>Keys</U></B></FONT></P>
+<P>
+<FONT SIZE="1" FACE="Verdana">
+<B>L</B> - Lights ON/OFF<BR>
+<B>F</B> - Change texture filter<BR>
+<B>B</B> - Blending ON/OFF<BR>
+<B>PG_UP</B> - Zoom out<BR>
+<B>PG_DOWN</B> - Zoom in<BR>
+<B>UP</B> - Rotate cube<BR>
+<B>DOWN</B> - Rotate cube<BR>
+<B>LEFT</B> - Rotate cube<BR>
+<B>RIGHT</B> - Rotate cube
+</FONT>
+</P>
+<P><FONT SIZE="1" FACE="Verdana"><B>Note:</B> You must click inside the applet window before using these keys.</FONT></P>
+<P>
+<FONT SIZE="1" FACE="Verdana">
+<A HREF="index.html">Go back</A>
+</FONT>
+</P>
+</TD>
+<TD WIDTH="70%" ALIGN="CENTER" VALIGN="TOP">
+<APPLET CODE="Lesson8.class" WIDTH="400" HEIGHT="400">
+</APPLET>
+</TD>
+</TR>
+</TABLE>
+</CENTER>
+</BODY>
+</HTML>
diff --git a/demos/HodglimsNeHe/Lesson8.java b/demos/HodglimsNeHe/Lesson8.java new file mode 100644 index 0000000..f8735d5 --- /dev/null +++ b/demos/HodglimsNeHe/Lesson8.java @@ -0,0 +1,545 @@ +/**
+ * Lesson8.java
+ *
+ * Author: Darren Hodges
+ * Date: 21/12/1999
+ *
+ * Port of the NeHe OpenGL Tutorial (Lesson 8: "Blending")
+ * to Java using the GL4Java interface to OpenGL.
+ *
+ * Note: The MipMapping code is only available in GL4Java 2.1.2.1 and later!
+ *
+ */
+
+import java.applet.*;
+import java.awt.*;
+import java.awt.event.*;
+
+//GL4Java classes
+import gl4java.GLContext;
+import gl4java.awt.GLAnimCanvas;
+import gl4java.utils.textures.*;
+
+
+public class Lesson8 extends Applet
+{
+ //Our rendering canvas
+ //We are using GLAnimCanvas because we want the canvas
+ //to be constantly redrawn
+ renderCanvas canvas = null;
+
+
+ /**
+ * void init()
+ *
+ * Initialise the applet.
+ */
+ public void init()
+ {
+ //We will use BorderLayout to layout the applet components
+ setLayout(new BorderLayout());
+
+ //Create our canvas and add it to the center of the applet
+ canvas = new renderCanvas(getSize().width, getSize().height);
+ canvas.requestFocus();
+ add("Center", canvas);
+ }
+
+
+ /**
+ * void start()
+ *
+ * Start the applet.
+ */
+ public void start()
+ {
+ //Start animating the canvas
+ canvas.start();
+ }
+
+
+ /**
+ * void stop()
+ *
+ * Stop the applet.
+ */
+ public void stop()
+ {
+ //Stop animating the canvas
+ canvas.stop();
+ }
+
+
+ /**
+ * void destroy()
+ *
+ * Destroy the applet.
+ */
+ public void destroy()
+ {
+ //Stop animating the canvas
+ canvas.stop();
+ //Destroy the canvas
+ canvas.destroy();
+ }
+
+
+
+ private class renderCanvas extends GLAnimCanvas
+ implements KeyListener, MouseListener
+ {
+ boolean light = true; //Lighting ON/OFF
+ boolean lp = false; //L Pressed?
+ boolean fp = false; //F Pressed?
+ boolean blend = true; //Blending ON/OFF
+ boolean bp = false; //B Pressed?
+
+ float xrot = 0.0f; //X Rotation
+ float yrot = 0.0f; //Y Rotation
+ float xspeed = 0.0f; //X Rotation Speed
+ float yspeed = 0.0f; //Y Rotation Speed
+
+ float z = -8.0f; //Depth Into The Screen
+
+ //Ambient light
+ float[] LightAmbient = { 0.5f, 0.5f, 0.5f, 1.0f };
+
+ //Diffuse light
+ float[] LightDiffuse = { 1.0f, 1.0f, 1.0f, 1.0f };
+
+ //Light position
+ float[] LightPosition = { 0.0f, 0.0f, 2.0f, 1.0f };
+
+ int filter = 0; //Which Filter To Use
+
+ int[] texture = new int[3]; //Storage for 3 textures
+
+
+ /**
+ * renderCanvas(int w, int h)
+ *
+ * Constructor.
+ */
+ public renderCanvas(int w, int h)
+ {
+ super(w, h);
+
+ //Registers this canvas to process keyboard events
+ addKeyListener(this);
+ addMouseListener(this);
+ }
+
+
+ /**
+ * void preInit()
+ *
+ * Called just BEFORE the GL-Context is created.
+ */
+ public void preInit()
+ {
+ //We want double buffering
+ doubleBuffer = true;
+ //But we dont want stereo view
+ stereoView = false;
+ }
+
+
+ /**
+ * void LoadGLTextures()
+ *
+ * Load textures.
+ */
+ public void LoadGLTextures()
+ {
+ PngTextureLoader texLoader = new PngTextureLoader(gl, glu);
+ texLoader.readTexture(getCodeBase(), "data/glass.png");
+
+ //Full Brightness, 50% Alpha
+ gl.glColor4f(1.0f, 1.0f, 1.0f, 0.5f);
+ //Blending Function For Translucency Based On Source Alpha Value
+ gl.glBlendFunc(GL_SRC_ALPHA, GL_ONE);
+
+ if(texLoader.isOk())
+ {
+ //Create Nearest Filtered Texture
+ gl.glGenTextures(3, texture);
+ gl.glBindTexture(GL_TEXTURE_2D, texture[0]);
+
+ gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+
+ gl.glTexImage2D(GL_TEXTURE_2D,
+ 0,
+ 3,
+ texLoader.getImageWidth(),
+ texLoader.getImageHeight(),
+ 0,
+ GL_RGB,
+ GL_UNSIGNED_BYTE,
+ texLoader.getTexture());
+
+ //Create Linear Filtered Texture
+ gl.glBindTexture(GL_TEXTURE_2D, texture[1]);
+ gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+
+ gl.glTexImage2D(GL_TEXTURE_2D,
+ 0,
+ 3,
+ texLoader.getImageWidth(),
+ texLoader.getImageHeight(),
+ 0,
+ GL_RGB,
+ GL_UNSIGNED_BYTE,
+ texLoader.getTexture());
+
+
+ //Create MipMapped Texture (Only with GL4Java 2.1.2.1 and later!)
+ gl.glBindTexture(GL_TEXTURE_2D, texture[2]);
+ gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
+
+ glu.gluBuild2DMipmaps(GL_TEXTURE_2D,
+ 3,
+ texLoader.getImageWidth(),
+ texLoader.getImageHeight(),
+ GL_RGB,
+ GL_UNSIGNED_BYTE,
+ texLoader.getTexture());
+ }
+ }
+
+
+ /**
+ * void init()
+ *
+ * Called just AFTER the GL-Context is created.
+ */
+ public void init()
+ {
+ //Load The Texture(s)
+ LoadGLTextures();
+ //Enable Texture Mapping
+ gl.glEnable(GL_TEXTURE_2D);
+
+ //This Will Clear The Background Color To Black
+ gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
+
+ //Enables Clearing Of The Depth Buffer
+ gl.glClearDepth(1.0);
+ //The Type Of Depth Test To Do
+ gl.glDepthFunc(GL_LESS);
+ //Enables Depth Testing
+ gl.glEnable(GL_DEPTH_TEST);
+
+ //Enables Smooth Color Shading
+ gl.glShadeModel(GL_SMOOTH);
+ //Select The Projection Matrix
+ gl.glMatrixMode(GL_PROJECTION);
+ //Reset The Projection Matrix
+ gl.glLoadIdentity();
+ //Calculate The Aspect Ratio Of The Window
+ glu.gluPerspective(45.0f, (float)getSize().width / (float)getSize().height, 0.1f, 100.0f);
+ //Select The Modelview Matrix
+ gl.glMatrixMode(GL_MODELVIEW);
+
+ //Lights
+ gl.glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient);
+ gl.glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse);
+ gl.glLightfv(GL_LIGHT1, GL_POSITION, LightPosition);
+
+ //Enable light
+ gl.glEnable(GL_LIGHT1);
+ gl.glEnable(GL_LIGHTING);
+ }
+
+
+ /**
+ * void destroy()
+ *
+ * Destroy the canvas.
+ */
+ public void destroy()
+ {
+ //Destroy the GLContext
+ cvsDispose();
+ }
+
+
+ /**
+ * void reshape(int width, int height)
+ *
+ * Called after the first paint command.
+ */
+ public void reshape(int width, int height)
+ {
+ //Reset The Current Viewport And Perspective Transformation
+ gl.glViewport(0, 0, width, height);
+
+ //Select The Projection Matrix
+ gl.glMatrixMode(GL_PROJECTION);
+ //Reset The Projection Matrix
+ gl.glLoadIdentity();
+ //Calculate The Aspect Ratio Of The Window
+ glu.gluPerspective(45.0f, (float)getSize().width / (float)getSize().height, 0.1f, 100.0f);
+ //Select The Modelview Matrix
+ gl.glMatrixMode(GL_MODELVIEW);
+ }
+
+
+ /**
+ * void display()
+ *
+ * Draw to the canvas.
+ */
+ public void display()
+ {
+ //Ensure GL is initialised correctly
+ if (glj.gljMakeCurrent(true) == false)
+ return;
+
+ //Clear The Screen And The Depth Buffer
+ gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ //Reset The View
+ gl.glLoadIdentity();
+
+ //Move into the screen
+ gl.glTranslatef(0.0f, 0.0f, z);
+
+ //Rotate On The X Axis
+ gl.glRotatef(xrot,1.0f, 0.0f, 0.0f);
+ //Rotate On The Y Axis
+ gl.glRotatef(yrot, 0.0f, 1.0f, 0.0f);
+
+ //Select texture
+ gl.glBindTexture(GL_TEXTURE_2D, texture[filter]);
+
+ gl.glBegin(GL_QUADS);
+ //Front Face
+ gl.glNormal3f(0.0f, 0.0f, 1.0f);
+ gl.glTexCoord2f(0.0f, 0.0f); gl.glVertex3f(-1.0f, -1.0f, 1.0f); //Bottom Left Of The Texture and Quad
+ gl.glTexCoord2f(1.0f, 0.0f); gl.glVertex3f( 1.0f, -1.0f, 1.0f); //Bottom Right Of The Texture and Quad
+ gl.glTexCoord2f(1.0f, 1.0f); gl.glVertex3f( 1.0f, 1.0f, 1.0f); //Top Right Of The Texture and Quad
+ gl.glTexCoord2f(0.0f, 1.0f); gl.glVertex3f(-1.0f, 1.0f, 1.0f); //Top Left Of The Texture and Quad
+ //Back Face
+ gl.glNormal3f(0.0f, 0.0f, -1.0f);
+ gl.glTexCoord2f(1.0f, 0.0f); gl.glVertex3f(-1.0f, -1.0f, -1.0f); //Bottom Right Of The Texture and Quad
+ gl.glTexCoord2f(1.0f, 1.0f); gl.glVertex3f(-1.0f, 1.0f, -1.0f); //Top Right Of The Texture and Quad
+ gl.glTexCoord2f(0.0f, 1.0f); gl.glVertex3f( 1.0f, 1.0f, -1.0f); //Top Left Of The Texture and Quad
+ gl.glTexCoord2f(0.0f, 0.0f); gl.glVertex3f( 1.0f, -1.0f, -1.0f); //Bottom Left Of The Texture and Quad
+ //Top Face
+ gl.glNormal3f(0.0f, 1.0f, 0.0f);
+ gl.glTexCoord2f(0.0f, 1.0f); gl.glVertex3f(-1.0f, 1.0f, -1.0f); //Top Left Of The Texture and Quad
+ gl.glTexCoord2f(0.0f, 0.0f); gl.glVertex3f(-1.0f, 1.0f, 1.0f); //Bottom Left Of The Texture and Quad
+ gl.glTexCoord2f(1.0f, 0.0f); gl.glVertex3f( 1.0f, 1.0f, 1.0f); //Bottom Right Of The Texture and Quad
+ gl.glTexCoord2f(1.0f, 1.0f); gl.glVertex3f( 1.0f, 1.0f, -1.0f); //Top Right Of The Texture and Quad
+ //Bottom Face
+ gl.glNormal3f(0.0f, -1.0f, 0.0f);
+ gl.glTexCoord2f(1.0f, 1.0f); gl.glVertex3f(-1.0f, -1.0f, -1.0f); //Top Right Of The Texture and Quad
+ gl.glTexCoord2f(0.0f, 1.0f); gl.glVertex3f( 1.0f, -1.0f, -1.0f); //Top Left Of The Texture and Quad
+ gl.glTexCoord2f(0.0f, 0.0f); gl.glVertex3f( 1.0f, -1.0f, 1.0f); //Bottom Left Of The Texture and Quad
+ gl.glTexCoord2f(1.0f, 0.0f); gl.glVertex3f(-1.0f, -1.0f, 1.0f); //Bottom Right Of The Texture and Quad
+ //Right face
+ gl.glNormal3f(1.0f, 0.0f, 0.0f);
+ gl.glTexCoord2f(1.0f, 0.0f); gl.glVertex3f( 1.0f, -1.0f, -1.0f); //Bottom Right Of The Texture and Quad
+ gl.glTexCoord2f(1.0f, 1.0f); gl.glVertex3f( 1.0f, 1.0f, -1.0f); //Top Right Of The Texture and Quad
+ gl.glTexCoord2f(0.0f, 1.0f); gl.glVertex3f( 1.0f, 1.0f, 1.0f); //Top Left Of The Texture and Quad
+ gl.glTexCoord2f(0.0f, 0.0f); gl.glVertex3f( 1.0f, -1.0f, 1.0f); //Bottom Left Of The Texture and Quad
+ //Left Face
+ gl.glNormal3f(-1.0f, 0.0f, 0.0f);
+ gl.glTexCoord2f(0.0f, 0.0f); gl.glVertex3f(-1.0f, -1.0f, -1.0f); //Bottom Left Of The Texture and Quad
+ gl.glTexCoord2f(1.0f, 0.0f); gl.glVertex3f(-1.0f, -1.0f, 1.0f); //Bottom Right Of The Texture and Quad
+ gl.glTexCoord2f(1.0f, 1.0f); gl.glVertex3f(-1.0f, 1.0f, 1.0f); //Top Right Of The Texture and Quad
+ gl.glTexCoord2f(0.0f, 1.0f); gl.glVertex3f(-1.0f, 1.0f, -1.0f); //Top Left Of The Texture and Quad
+ gl.glEnd();
+
+ //X Axis Rotation
+ xrot += xspeed;
+ //Y Axis Rotation
+ yrot += yspeed;
+
+ //Swap buffers
+ glj.gljSwap();
+ }
+
+
+ /**
+ * void keyTyped(KeyEvent e)
+ *
+ * Invoked when a key has been typed. This event occurs when a key press is followed by a key release.
+ */
+ public void keyTyped(KeyEvent e)
+ {
+ }
+
+
+ /**
+ * void keyPressed(KeyEvent e)
+ *
+ * Invoked when a key has been pressed.
+ */
+ public void keyPressed(KeyEvent e)
+ {
+ switch(e.getKeyCode())
+ {
+ //Switch ON/OFF light when L is pressed
+ case KeyEvent.VK_L:
+ {
+ if(!lp)
+ {
+ lp = true;
+ //Toggle light
+ light = !light;
+
+ if(!light)
+ gl.glDisable(GL_LIGHTING);
+ else
+ gl.glEnable(GL_LIGHTING);
+ }
+
+ break;
+ }
+
+ //Switch filter when F is pressed
+ case KeyEvent.VK_F:
+ {
+ if(!fp)
+ {
+ fp = true;
+ //Change filter
+ filter += 1;
+ if(filter > 2)
+ filter = 0;
+ }
+
+ break;
+ }
+
+ //Switch blending when B is pressed
+ case KeyEvent.VK_B:
+ {
+ if(!bp)
+ {
+ bp = true;
+ //Toggle blending
+ blend = !blend;
+
+ if(blend)
+ {
+ gl.glEnable(GL_BLEND); //Turn Blending On
+ gl.glDisable(GL_DEPTH_TEST); //Turn Depth Testing Off
+ }
+ else
+ {
+ gl.glDisable(GL_BLEND); //Turn Blending Off
+ gl.glEnable(GL_DEPTH_TEST); //Turn Depth Testing On
+ }
+ }
+
+ break;
+ }
+
+ //Move cube back when user presses PG_UP
+ case KeyEvent.VK_PAGE_UP:
+ {
+ z -= 0.2f;
+ break;
+ }
+
+ //Move cube forwards when user presses PG_DOWN
+ case KeyEvent.VK_PAGE_DOWN:
+ {
+ z += 0.2f;
+ break;
+ }
+
+ //Increase X rotation speed when user presses UP
+ case KeyEvent.VK_UP:
+ {
+ xspeed += 0.2f;
+ break;
+ }
+
+ //Decrease X rotation speed when user presses DOWN
+ case KeyEvent.VK_DOWN:
+ {
+ xspeed -= 0.2f;
+ break;
+ }
+
+ //Increase Y rotation speed when user presses RIGHT
+ case KeyEvent.VK_RIGHT:
+ {
+ yspeed += 0.2f;
+ break;
+ }
+
+ //Decrease Y rotation speed when user presses LEFT
+ case KeyEvent.VK_LEFT:
+ {
+ yspeed -= 0.2f;
+ break;
+ }
+ }
+ }
+
+
+ /**
+ * void keyReleased(KeyEvent e)
+ *
+ * Invoked when a key has been released.
+ */
+ public void keyReleased(KeyEvent e)
+ {
+ switch(e.getKeyCode())
+ {
+ //Key has been released
+ case KeyEvent.VK_L:
+ {
+ lp = false;
+ break;
+ }
+
+ //Key has been released
+ case KeyEvent.VK_F:
+ {
+ fp = false;
+ break;
+ }
+
+ //Key has been released
+ case KeyEvent.VK_B:
+ {
+ bp = false;
+ break;
+ }
+ }
+ }
+
+ // Methods required for the implementation of MouseListener
+ public void mouseEntered( MouseEvent evt )
+ {
+ Component comp = evt.getComponent();
+ if( comp.equals(this ) )
+ {
+ requestFocus();
+ }
+ }
+
+ public void mouseExited( MouseEvent evt )
+ { }
+ public void mousePressed( MouseEvent evt )
+ { }
+ public void mouseReleased( MouseEvent evt )
+ { }
+ public void mouseClicked( MouseEvent evt )
+ {
+ Component comp = evt.getComponent();
+ if( comp.equals(this ) )
+ {
+ requestFocus();
+ }
+ }
+
+ }
+}
diff --git a/demos/HodglimsNeHe/Lesson8_plugin13.html b/demos/HodglimsNeHe/Lesson8_plugin13.html new file mode 100644 index 0000000..e774d49 --- /dev/null +++ b/demos/HodglimsNeHe/Lesson8_plugin13.html @@ -0,0 +1,82 @@ +<HTML>
+<HEAD>
+<TITLE>Lesson8 Applet: Blending</TITLE>
+<STYLE TYPE="text/css">
+<!--
+A:link { COLOR: #9C9AB1; TEXT-DECORATION: none }
+A:visited { COLOR: #9C9AB1; TEXT-DECORATION: none }
+A:active { color: Yellow; TEXT-DECORATION: none }
+A:hover { color: Yellow; TEXT-DECORATION: none }
+-->
+</STYLE>
+</HEAD>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+<CENTER>
+<P>
+<FONT SIZE="2" FACE="Verdana"><B>Blending</B></FONT>
+</P>
+<TABLE WIDTH="100%">
+<TR>
+<TD WIDTH="30%" ALIGN="LEFT" VALIGN="TOP">
+<P>
+<FONT SIZE="1" FACE="Verdana"><B><U>Keys</U></B></FONT></P>
+<P>
+<FONT SIZE="1" FACE="Verdana">
+<B>L</B> - Lights ON/OFF<BR>
+<B>F</B> - Change texture filter<BR>
+<B>B</B> - Blending ON/OFF<BR>
+<B>PG_UP</B> - Zoom out<BR>
+<B>PG_DOWN</B> - Zoom in<BR>
+<B>UP</B> - Rotate cube<BR>
+<B>DOWN</B> - Rotate cube<BR>
+<B>LEFT</B> - Rotate cube<BR>
+<B>RIGHT</B> - Rotate cube
+</FONT>
+</P>
+<P><FONT SIZE="1" FACE="Verdana"><B>Note:</B> You must click inside the applet window before using these keys.</FONT></P>
+<P>
+<FONT SIZE="1" FACE="Verdana">
+<A HREF="index.html">Go back</A>
+</FONT>
+</P>
+</TD>
+<TD WIDTH="70%" ALIGN="CENTER" VALIGN="TOP">
+<!--"CONVERTED_APPLET"-->
+<!-- CONVERTER VERSION 1.3 --> +<SCRIPT LANGUAGE="JavaScript"><!-- + var _info = navigator.userAgent; var _ns = false; + var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0); +//--></SCRIPT> +<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!-- + var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0))); +//--></SCRIPT></COMMENT> + +<SCRIPT LANGUAGE="JavaScript"><!-- + if (_ie == true) document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = "400" HEIGHT = "400" codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0"><NOEMBED><XMP>'); + else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.3" CODE = "Lesson8.class" WIDTH = "400" HEIGHT = "400" scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html"><NOEMBED><XMP>'); +//--></SCRIPT> +<APPLET CODE = "Lesson8.class" WIDTH = "400" HEIGHT = "400"></XMP> +<PARAM NAME = CODE VALUE = "Lesson8.class" >
+ +<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3"> +<PARAM NAME="scriptable" VALUE="false"> + +</APPLET> + +</NOEMBED></EMBED></OBJECT> + + +<!-- +<APPLET CODE = "Lesson8.class" WIDTH = "400" HEIGHT = "400">
+
+
+</APPLET> +--> +<!--"END_CONVERTED_APPLET"-->
+
+</TD>
+</TR>
+</TABLE>
+</CENTER>
+</BODY>
+</HTML>
diff --git a/demos/HodglimsNeHe/Lesson9.html b/demos/HodglimsNeHe/Lesson9.html new file mode 100644 index 0000000..2c7b6bb --- /dev/null +++ b/demos/HodglimsNeHe/Lesson9.html @@ -0,0 +1,47 @@ +<HTML>
+<HEAD>
+<TITLE>Lesson9 Applet: Moving Bitmaps In 3D Space</TITLE>
+<STYLE TYPE="text/css">
+<!--
+A:link { COLOR: #9C9AB1; TEXT-DECORATION: none }
+A:visited { COLOR: #9C9AB1; TEXT-DECORATION: none }
+A:active { color: Yellow; TEXT-DECORATION: none }
+A:hover { color: Yellow; TEXT-DECORATION: none }
+-->
+</STYLE>
+</HEAD>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+<CENTER>
+<P>
+<FONT SIZE="2" FACE="Verdana"><B>Moving Bitmaps In 3D Space</B></FONT>
+</P>
+<TABLE WIDTH="100%">
+<TR>
+<TD WIDTH="30%" ALIGN="LEFT" VALIGN="TOP">
+<P>
+<FONT SIZE="1" FACE="Verdana"><B><U>Keys</U></B></FONT></P>
+<P>
+<FONT SIZE="1" FACE="Verdana">
+<B>T</B> - Twinkle ON/OFF<BR>
+<B>PG_UP</B> - Zoom out<BR>
+<B>PG_DOWN</B> - Zoom in<BR>
+<B>UP</B> - Rotate up<BR>
+<B>DOWN</B> - Rotate down
+</FONT>
+</P>
+<P><FONT SIZE="1" FACE="Verdana"><B>Note:</B> You must click inside the applet window before using these keys.</FONT></P>
+<P>
+<FONT SIZE="1" FACE="Verdana">
+<A HREF="index.html">Go back</A>
+</FONT>
+</P>
+</TD>
+<TD WIDTH="70%" ALIGN="CENTER" VALIGN="TOP">
+<APPLET CODE="Lesson9.class" WIDTH="400" HEIGHT="400">
+</APPLET>
+</TD>
+</TR>
+</TABLE>
+</CENTER>
+</BODY>
+</HTML>
diff --git a/demos/HodglimsNeHe/Lesson9.java b/demos/HodglimsNeHe/Lesson9.java new file mode 100644 index 0000000..4c4a92d --- /dev/null +++ b/demos/HodglimsNeHe/Lesson9.java @@ -0,0 +1,451 @@ +/**
+ * Lesson9.java
+ *
+ * Author: Darren Hodges
+ * Date: 21/12/1999
+ *
+ * Port of the NeHe OpenGL Tutorial (Lesson 9: "Moving Bitmaps In 3D Space")
+ * to Java using the GL4Java interface to OpenGL.
+ *
+ */
+
+
+import java.applet.*;
+import java.awt.*;
+import java.awt.event.*;
+
+//GL4Java classes
+import gl4java.GLContext;
+import gl4java.awt.GLAnimCanvas;
+import gl4java.utils.textures.*;
+
+
+public class Lesson9 extends Applet
+{
+ //Our rendering canvas
+ //We are using GLAnimCanvas because we want the canvas
+ //to be constantly redrawn
+ renderCanvas canvas = null;
+
+
+ /**
+ * void init()
+ *
+ * Initialise the applet.
+ */
+ public void init()
+ {
+ //We will use BorderLayout to layout the applet components
+ setLayout(new BorderLayout());
+
+ //Create our canvas and add it to the center of the applet
+ canvas = new renderCanvas(getSize().width, getSize().height);
+ canvas.requestFocus();
+ add("Center", canvas);
+ }
+
+
+ /**
+ * void start()
+ *
+ * Start the applet.
+ */
+ public void start()
+ {
+ //Start animating the canvas
+ canvas.start();
+ }
+
+
+ /**
+ * void stop()
+ *
+ * Stop the applet.
+ */
+ public void stop()
+ {
+ //Stop animating the canvas
+ canvas.stop();
+ }
+
+
+ /**
+ * void destroy()
+ *
+ * Destroy the applet.
+ */
+ public void destroy()
+ {
+ //Stop animating the canvas
+ canvas.stop();
+ //Destroy the canvas
+ canvas.destroy();
+ }
+
+
+
+ private class renderCanvas extends GLAnimCanvas
+ implements KeyListener, MouseListener
+ {
+ boolean twinkle = true; //Twinkling stars
+ boolean tp = false; //T Pressed?
+ final int NUM = 50; //NUMber of stars to draw
+
+ Star[] star = new Star[NUM]; //Array of stars
+
+ float zoom = -15.0f; //Viewing Distance Away From Stars
+ float tilt = 90.0f; //Tilt The View
+ float spin = 0.0f; //Spin Twinkling Stars
+
+ int loop = 0; //General loop Variable
+
+ int[] texture = new int[1]; //Storage For One Texture
+
+
+ /**
+ * renderCanvas(int w, int h)
+ *
+ * Constructor.
+ */
+ public renderCanvas(int w, int h)
+ {
+ super(w, h);
+
+ //Registers this canvas to process keyboard events
+ addKeyListener(this);
+ addMouseListener(this);
+ }
+
+
+ /**
+ * void preInit()
+ *
+ * Called just BEFORE the GL-Context is created.
+ */
+ public void preInit()
+ {
+ //We want double buffering
+ doubleBuffer = true;
+ //But we dont want stereo view
+ stereoView = false;
+ }
+
+
+ /**
+ * void LoadGLTextures()
+ *
+ * Load textures.
+ */
+ public void LoadGLTextures()
+ {
+ PngTextureLoader texLoader = new PngTextureLoader(gl, glu);
+ texLoader.readTexture(getCodeBase(), "data/star.png");
+
+ if(texLoader.isOk())
+ {
+ //Create Texture
+ gl.glGenTextures(1, texture);
+ gl.glBindTexture(GL_TEXTURE_2D, texture[0]);
+
+ gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+
+ gl.glTexImage2D(GL_TEXTURE_2D,
+ 0,
+ 3,
+ texLoader.getImageWidth(),
+ texLoader.getImageHeight(),
+ 0,
+ GL_RGB,
+ GL_UNSIGNED_BYTE,
+ texLoader.getTexture());
+ }
+ }
+
+
+ /**
+ * void init()
+ *
+ * Called just AFTER the GL-Context is created.
+ */
+ public void init()
+ {
+ //Load The Texture(s)
+ LoadGLTextures();
+ //Enable Texture Mapping
+ gl.glEnable(GL_TEXTURE_2D);
+
+ //This Will Clear The Background Color To Black
+ gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
+
+ //Enables Clearing Of The Depth Buffer
+ gl.glClearDepth(1.0);
+
+ //Enables Smooth Color Shading
+ gl.glShadeModel(GL_SMOOTH);
+
+ //Select The Projection Matrix
+ gl.glMatrixMode(GL_PROJECTION);
+
+ //Reset The Projection Matrix
+ gl.glLoadIdentity();
+
+ //Calculate The Aspect Ratio Of The Window
+ glu.gluPerspective(45.0f, (float)getSize().width / (float)getSize().height, 0.1f, 100.0f);
+ //Select The Modelview Matrix
+ gl.glMatrixMode(GL_MODELVIEW);
+
+ //Set The Blending Function For Translucency
+ gl.glBlendFunc(GL_SRC_ALPHA, GL_ONE);
+ //Enable Blending
+ gl.glEnable(GL_BLEND);
+
+ //Create A Loop That Goes Through All The Stars
+ for(loop = 0; loop < NUM; loop++)
+ {
+ star[loop] = new Star();
+ star[loop].angle = 0.0f; //Start All The Stars At Angle Zero
+ star[loop].dist = ((float)(loop) / NUM) * 5.0f; //Calculate Distance From The Center
+ star[loop].r = (byte)(256 * Math.random()); //Give star[loop] A Random Red Intensity
+ star[loop].g = (byte)(256 * Math.random()); //Give star[loop] A Random Green Intensity
+ star[loop].b = (byte)(256 * Math.random()); //Give star[loop] A Random Blue Intensity
+ }
+ }
+
+
+ /**
+ * void destroy()
+ *
+ * Destroy the canvas.
+ */
+ public void destroy()
+ {
+ //Destroy the GLContext
+ cvsDispose();
+ }
+
+
+ /**
+ * void reshape(int width, int height)
+ *
+ * Called after the first paint command.
+ */
+ public void reshape(int width, int height)
+ {
+ //Reset The Current Viewport And Perspective Transformation
+ gl.glViewport(0, 0, width, height);
+
+ //Select The Projection Matrix
+ gl.glMatrixMode(GL_PROJECTION);
+ //Reset The Projection Matrix
+ gl.glLoadIdentity();
+ //Calculate The Aspect Ratio Of The Window
+ glu.gluPerspective(45.0f, (float)getSize().width / (float)getSize().height, 0.1f, 100.0f);
+ //Select The Modelview Matrix
+ gl.glMatrixMode(GL_MODELVIEW);
+ }
+
+
+ /**
+ * void display()
+ *
+ * Draw to the canvas.
+ */
+ public void display()
+ {
+ //Ensure GL is initialised correctly
+ if (glj.gljMakeCurrent(true) == false)
+ return;
+
+ //Clear The Screen And The Depth Buffer
+ gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+ //Select Our Texture
+ gl.glBindTexture(GL_TEXTURE_2D, texture[0]);
+
+ //Loop Through All The Stars
+ for(loop = 0; loop < NUM; loop++)
+ {
+ gl.glLoadIdentity(); //Reset The View Before We Draw Each Star
+ gl.glTranslatef(0.0f, 0.0f, zoom); //Zoom Into The Screen (Using The Value In 'zoom')
+ gl.glRotatef(tilt, 1.0f, 0.0f, 0.0f); //Tilt The View (Using The Value In 'tilt')
+ gl.glRotatef(star[loop].angle, 0.0f, 1.0f, 0.0f); //Rotate To The Current Stars Angle
+ gl.glTranslatef(star[loop].dist, 0.0f, 0.0f); //Move Forward On The X Plane
+ gl.glRotatef(-star[loop].angle, 0.0f, 1.0f, 0.0f); //Cancel The Current Stars Angle
+ gl.glRotatef(-tilt, 1.0f, 0.0f, 0.0f); //Cancel The Screen Tilt
+
+ //Twinkling Stars Enabled
+ if(twinkle)
+ {
+ //Assign A Color Using Bytes
+ gl.glColor4ub(star[(NUM - loop) - 1].r, star[(NUM - loop) - 1].g, star[(NUM - loop) - 1].b, (byte)255);
+ gl.glBegin(GL_QUADS); //Begin Drawing The Textured Quad
+ gl.glTexCoord2f(0.0f, 0.0f); gl.glVertex3f(-1.0f, -1.0f, 0.0f);
+ gl.glTexCoord2f(1.0f, 0.0f); gl.glVertex3f(1.0f, -1.0f, 0.0f);
+ gl.glTexCoord2f(1.0f, 1.0f); gl.glVertex3f(1.0f, 1.0f, 0.0f);
+ gl.glTexCoord2f(0.0f, 1.0f); gl.glVertex3f(-1.0f, 1.0f, 0.0f);
+ gl.glEnd(); //Done Drawing The Textured Quad
+ }
+
+ gl. glRotatef(spin,0.0f,0.0f,1.0f); //Rotate The Star On The Z Axis
+ //Assign A Color Using Bytes
+ gl.glColor4ub(star[loop].r, star[loop].g, star[loop].b, (byte)255);
+ gl.glBegin(GL_QUADS); //Begin Drawing The Textured Quad
+ gl.glTexCoord2f(0.0f, 0.0f); gl.glVertex3f(-1.0f, -1.0f, 0.0f);
+ gl.glTexCoord2f(1.0f, 0.0f); gl.glVertex3f(1.0f,-1.0f, 0.0f);
+ gl.glTexCoord2f(1.0f, 1.0f); gl.glVertex3f(1.0f, 1.0f, 0.0f);
+ gl.glTexCoord2f(0.0f, 1.0f); gl.glVertex3f(-1.0f, 1.0f, 0.0f);
+ gl.glEnd(); //Done Drawing The Textured Quad
+
+ spin += 0.01f; //Used To Spin The Stars
+ star[loop].angle += (float)(loop / (float)NUM); //Changes The Angle Of A Star
+ star[loop].dist -= 0.01f; //Changes The Distance Of A Star
+
+ //Is The Star In The Middle Yet?
+ if(star[loop].dist < 0.0f)
+ {
+ star[loop].dist += 5.0f; //Move The Star 5 Units From The Center
+ star[loop].r = (byte)(256 * Math.random()); //Give It A New Red Value
+ star[loop].g = (byte)(256 * Math.random()); //Give It A New Green Value
+ star[loop].b = (byte)(256 * Math.random()); //Give It A New Blue Value
+ }
+ }
+
+ //Swap buffers
+ glj.gljSwap();
+ }
+
+
+ /**
+ * void keyTyped(KeyEvent e)
+ *
+ * Invoked when a key has been typed. This event occurs when a key press is followed by a key release.
+ */
+ public void keyTyped(KeyEvent e)
+ {
+ }
+
+
+ /**
+ * void keyPressed(KeyEvent e)
+ *
+ * Invoked when a key has been pressed.
+ */
+ public void keyPressed(KeyEvent e)
+ {
+ switch(e.getKeyCode())
+ {
+ //Switch ON/OFF twinkle when T is pressed
+ case KeyEvent.VK_T:
+ {
+ if(!tp)
+ {
+ tp = true;
+ //Toggle twinkle
+ twinkle = !twinkle;
+ }
+
+ break;
+ }
+
+ //Tilt screen up when user presses UP
+ case KeyEvent.VK_UP:
+ {
+ //Tilt The Screen Up
+ tilt -= 0.5f;
+ break;
+ }
+
+ //Tilt screen down when user presses DOWN
+ case KeyEvent.VK_DOWN:
+ {
+ //Tilt The Screen Down
+ tilt += 0.5f;
+ break;
+ }
+
+ //Zoom out when user presses PG_UP
+ case KeyEvent.VK_PAGE_UP:
+ {
+ //Zoom out
+ zoom -= 0.2f;
+ break;
+ }
+
+ //Zoom in when user presses PG_DOWN
+ case KeyEvent.VK_PAGE_DOWN:
+ {
+ //Zoom in
+ zoom += 0.2f;
+ break;
+ }
+ }
+ }
+
+
+ /**
+ * void keyReleased(KeyEvent e)
+ *
+ * Invoked when a key has been released.
+ */
+ public void keyReleased(KeyEvent e)
+ {
+ switch(e.getKeyCode())
+ {
+ //Key has been released
+ case KeyEvent.VK_T:
+ {
+ tp = false;
+ break;
+ }
+ }
+ }
+
+ // Methods required for the implementation of MouseListener
+ public void mouseEntered( MouseEvent evt )
+ {
+ Component comp = evt.getComponent();
+ if( comp.equals(this ) )
+ {
+ requestFocus();
+ }
+ }
+
+ public void mouseExited( MouseEvent evt )
+ { }
+ public void mousePressed( MouseEvent evt )
+ { }
+ public void mouseReleased( MouseEvent evt )
+ { }
+ public void mouseClicked( MouseEvent evt )
+ {
+ Component comp = evt.getComponent();
+ if( comp.equals(this ) )
+ {
+ requestFocus();
+ }
+ }
+
+ }
+
+
+
+ public class Star
+ {
+ byte r, g, b; //Stars colour
+ float dist; //Stars distance from center
+ float angle; //Stars current angle
+
+
+ /**
+ * Star()
+ *
+ * Constructor.
+ */
+ public Star()
+ {
+ r = g = b = 0;
+ dist = angle = 0.0f;
+ }
+ }
+}
diff --git a/demos/HodglimsNeHe/Lesson9_plugin13.html b/demos/HodglimsNeHe/Lesson9_plugin13.html new file mode 100644 index 0000000..18b6f52 --- /dev/null +++ b/demos/HodglimsNeHe/Lesson9_plugin13.html @@ -0,0 +1,78 @@ +<HTML>
+<HEAD>
+<TITLE>Lesson9 Applet: Moving Bitmaps In 3D Space</TITLE>
+<STYLE TYPE="text/css">
+<!--
+A:link { COLOR: #9C9AB1; TEXT-DECORATION: none }
+A:visited { COLOR: #9C9AB1; TEXT-DECORATION: none }
+A:active { color: Yellow; TEXT-DECORATION: none }
+A:hover { color: Yellow; TEXT-DECORATION: none }
+-->
+</STYLE>
+</HEAD>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+<CENTER>
+<P>
+<FONT SIZE="2" FACE="Verdana"><B>Moving Bitmaps In 3D Space</B></FONT>
+</P>
+<TABLE WIDTH="100%">
+<TR>
+<TD WIDTH="30%" ALIGN="LEFT" VALIGN="TOP">
+<P>
+<FONT SIZE="1" FACE="Verdana"><B><U>Keys</U></B></FONT></P>
+<P>
+<FONT SIZE="1" FACE="Verdana">
+<B>T</B> - Twinkle ON/OFF<BR>
+<B>PG_UP</B> - Zoom out<BR>
+<B>PG_DOWN</B> - Zoom in<BR>
+<B>UP</B> - Rotate up<BR>
+<B>DOWN</B> - Rotate down
+</FONT>
+</P>
+<P><FONT SIZE="1" FACE="Verdana"><B>Note:</B> You must click inside the applet window before using these keys.</FONT></P>
+<P>
+<FONT SIZE="1" FACE="Verdana">
+<A HREF="index.html">Go back</A>
+</FONT>
+</P>
+</TD>
+<TD WIDTH="70%" ALIGN="CENTER" VALIGN="TOP">
+<!--"CONVERTED_APPLET"-->
+<!-- CONVERTER VERSION 1.3 --> +<SCRIPT LANGUAGE="JavaScript"><!-- + var _info = navigator.userAgent; var _ns = false; + var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0); +//--></SCRIPT> +<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!-- + var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0))); +//--></SCRIPT></COMMENT> + +<SCRIPT LANGUAGE="JavaScript"><!-- + if (_ie == true) document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = "400" HEIGHT = "400" codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0"><NOEMBED><XMP>'); + else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.3" CODE = "Lesson9.class" WIDTH = "400" HEIGHT = "400" scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html"><NOEMBED><XMP>'); +//--></SCRIPT> +<APPLET CODE = "Lesson9.class" WIDTH = "400" HEIGHT = "400"></XMP> +<PARAM NAME = CODE VALUE = "Lesson9.class" >
+ +<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3"> +<PARAM NAME="scriptable" VALUE="false"> + +</APPLET> + +</NOEMBED></EMBED></OBJECT> + + +<!-- +<APPLET CODE = "Lesson9.class" WIDTH = "400" HEIGHT = "400">
+
+
+</APPLET> +--> +<!--"END_CONVERTED_APPLET"-->
+
+</TD>
+</TR>
+</TABLE>
+</CENTER>
+</BODY>
+</HTML>
diff --git a/demos/HodglimsNeHe/data/Star.png b/demos/HodglimsNeHe/data/Star.png Binary files differnew file mode 100644 index 0000000..e933c74 --- /dev/null +++ b/demos/HodglimsNeHe/data/Star.png diff --git a/demos/HodglimsNeHe/data/crate.png b/demos/HodglimsNeHe/data/crate.png Binary files differnew file mode 100644 index 0000000..41d120f --- /dev/null +++ b/demos/HodglimsNeHe/data/crate.png diff --git a/demos/HodglimsNeHe/data/cube.png b/demos/HodglimsNeHe/data/cube.png Binary files differnew file mode 100644 index 0000000..40d08ac --- /dev/null +++ b/demos/HodglimsNeHe/data/cube.png diff --git a/demos/HodglimsNeHe/data/glass.png b/demos/HodglimsNeHe/data/glass.png Binary files differnew file mode 100644 index 0000000..8fd87b1 --- /dev/null +++ b/demos/HodglimsNeHe/data/glass.png diff --git a/demos/HodglimsNeHe/data/nehe.png b/demos/HodglimsNeHe/data/nehe.png Binary files differnew file mode 100644 index 0000000..0cbdc4d --- /dev/null +++ b/demos/HodglimsNeHe/data/nehe.png diff --git a/demos/HodglimsNeHe/data/tim.png b/demos/HodglimsNeHe/data/tim.png Binary files differnew file mode 100644 index 0000000..e1922d6 --- /dev/null +++ b/demos/HodglimsNeHe/data/tim.png diff --git a/demos/HodglimsNeHe/index.html b/demos/HodglimsNeHe/index.html new file mode 100644 index 0000000..88ac1fb --- /dev/null +++ b/demos/HodglimsNeHe/index.html @@ -0,0 +1,38 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en"> +<html> +<head> + <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> + <meta name="Author" content="Ron Cemer & Sven Goethel"> + <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]"> + <title>Misc Demos</title> +</head> +<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff"> +<p>Here are the +<a href="http://nehe.gamedev.net/opengl.asp">NeHe OpenGL Tutorial Demos</a> +originally ported by +<a href="http://dev.knowledgeassociates.com/Hodglim/nehe/nehe.shtml">Hodglim</a> +for <B> GL4Java >= 2.4.0.0: </B> <br> +<br> +This demos have added <I>requestFocus()</I> statements, +especially for the events: <I>mouseEntered</I> and <I>mouseClicked</I> !<br> +<br> +<p><a href="index_plugin13.html">To use the Java2 Plug-In (Java2, JRE, Plug-In 1.3), click here !</a><br> +<br> +<br> + <p> <a href="Lesson1.html">Lesson 1</a> : Lesson 1 - Setting Up OpenGL In Windows + <p> <a href="Lesson2.html">Lesson 2</a> : Lesson 2 - Your First Polygon + <p> <a href="Lesson3.html">Lesson 3</a> : Lesson 3 - Colors + <p> <a href="Lesson4.html">Lesson 4</a> : Lesson 4 - Rotation + <p> <a href="Lesson5.html">Lesson 5</a> : Lesson 5 - Solid Objects + <p> <a href="Lesson6.html">Lesson 6</a> : Lesson 6 - Texture Mapping + <p> <a href="Lesson7.html">Lesson 7</a> : Lesson 7 - Texture Filters, Lighting & Keyboard Control + <p> <a href="Lesson8.html">Lesson 8</a> : Lesson 8 - Blending + <p> <a href="Lesson9.html">Lesson 9</a> : Lesson 9 - Moving Bitmaps In 3D Space +<p> <a href="Lesson11.html">Lesson 11</a> : Lesson 11 - OpenGL Flag Effect +<p> <a href="Lesson12.html">Lesson 12</a> : Lesson 12 - Display Lists +<p> <a href="Lesson16.html">Lesson 16</a> : Lesson 16 - Cool Looking Fog +<p> <a href="Lesson18.html">Lesson 18</a> : Lesson 18 - Quadratics +<br> +<br> +</body> +</html> diff --git a/demos/HodglimsNeHe/index_plugin13.html b/demos/HodglimsNeHe/index_plugin13.html new file mode 100644 index 0000000..754940c --- /dev/null +++ b/demos/HodglimsNeHe/index_plugin13.html @@ -0,0 +1,41 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en"> +<html> +<head> + <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> + <meta name="Author" content="Ron Cemer & Sven Goethel"> + <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]"> + <title>Misc Demos</title> +</head> +<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff"> +<p>Here are the +<a href="http://nehe.gamedev.net/opengl.asp">NeHe OpenGL Tutorial Demos</a> +originally ported by +<a href="http://dev.knowledgeassociates.com/Hodglim/nehe/nehe.shtml">Hodglim</a> +for <B> GL4Java >= 2.4.0.0: </B> <br> +<br> +This demos have added <I>requestFocus()</I> statements, +especially for the events: <I>mouseEntered</I> and <I>mouseClicked</I> !<br> +<br> +<hr> +<br> +<a href="../../Installer/java.policy">The Java2 (sdk, jre, plugin 1.3) policy file example to give GL4Java the necessary permissions (Click here) !</a> +<br> +<hr> +<br> + <p> <a href="Lesson1_plugin13.html">Lesson 1</a> : Lesson 1 - Setting Up OpenGL In Windows + <p> <a href="Lesson2_plugin13.html">Lesson 2</a> : Lesson 2 - Your First Polygon + <p> <a href="Lesson3_plugin13.html">Lesson 3</a> : Lesson 3 - Colors + <p> <a href="Lesson4_plugin13.html">Lesson 4</a> : Lesson 4 - Rotation + <p> <a href="Lesson5_plugin13.html">Lesson 5</a> : Lesson 5 - Solid Objects + <p> <a href="Lesson6_plugin13.html">Lesson 6</a> : Lesson 6 - Texture Mapping + <p> <a href="Lesson7_plugin13.html">Lesson 7</a> : Lesson 7 - Texture Filters, Lighting & Keyboard Control + <p> <a href="Lesson8_plugin13.html">Lesson 8</a> : Lesson 8 - Blending + <p> <a href="Lesson9_plugin13.html">Lesson 9</a> : Lesson 9 - Moving Bitmaps In 3D Space +<p> <a href="Lesson11_plugin13.html">Lesson 11</a> : Lesson 11 - OpenGL Flag Effect +<p> <a href="Lesson12_plugin13.html">Lesson 12</a> : Lesson 12 - Display Lists +<p> <a href="Lesson16_plugin13.html">Lesson 16</a> : Lesson 16 - Cool Looking Fog +<p> <a href="Lesson18_plugin13.html">Lesson 18</a> : Lesson 18 - Quadratics +<br> +<br> +</body> +</html> diff --git a/demos/Java2Applet.bat b/demos/Java2Applet.bat new file mode 100755 index 0000000..d43b97d --- /dev/null +++ b/demos/Java2Applet.bat @@ -0,0 +1 @@ +appletviewer.exe -J-Djava.security.policy=gl4java.policy glLogoCvsApplet.html
diff --git a/demos/Java2AppletB.bat b/demos/Java2AppletB.bat new file mode 100755 index 0000000..be9d7a4 --- /dev/null +++ b/demos/Java2AppletB.bat @@ -0,0 +1 @@ +appletviewer.exe -J-Djava.security.policy=gl4java.policy glOlympicCvsApplet.html
diff --git a/demos/Java2AppletC.bat b/demos/Java2AppletC.bat new file mode 100755 index 0000000..cd2c22e --- /dev/null +++ b/demos/Java2AppletC.bat @@ -0,0 +1 @@ +appletviewer.exe -J-Djava.security.policy=gl4java.policy testTextPPM1.html
diff --git a/demos/MiscDemos/DrawColoredPrimitives.html b/demos/MiscDemos/DrawColoredPrimitives.html new file mode 100644 index 0000000..a812c94 --- /dev/null +++ b/demos/MiscDemos/DrawColoredPrimitives.html @@ -0,0 +1,14 @@ +<HTML>
+<HEAD>
+<TITLE>Göthel Hard- und Software Entwicklungen</TITLE>
+</HEAD>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+<hr>
+<applet code="DrawColoredPrimitives.class" width=500 height=300>
+<param name=frames value="55">
+</applet>
+<hr>
+</BODY>
+</HTML>
+
+
diff --git a/demos/MiscDemos/DrawColoredPrimitives.java b/demos/MiscDemos/DrawColoredPrimitives.java new file mode 100755 index 0000000..0e6725b --- /dev/null +++ b/demos/MiscDemos/DrawColoredPrimitives.java @@ -0,0 +1,142 @@ +/**
+ * @(#) DrawColoredPrimitives.java
+ * @(#) author: Joe Zimmerman (converted to Java by Sven Goethel)
+ */
+
+/* This program is free software under the license of LGPL */
+
+import java.applet.*;
+import java.awt.*;
+import java.awt.event.*;
+import java.lang.*;
+import java.util.*;
+import java.io.*;
+import java.util.*;
+import gl4java.GLContext;
+import gl4java.awt.GLAnimCanvas;
+import gl4java.applet.SimpleGLAnimApplet1;
+
+public class DrawColoredPrimitives extends SimpleGLAnimApplet1
+{
+
+ public void init(int w, int h)
+ {
+ super.init();
+ canvas = new gldemo(w, h);
+ add("Center", canvas);
+ }
+
+ public void init()
+ {
+ super.init();
+ Dimension d = getSize();
+ canvas = new gldemo(d.width, d.height);
+ add("Center", canvas);
+ }
+
+ public static void main( String args[] ) {
+ DrawColoredPrimitives applet =
+ new DrawColoredPrimitives();
+
+ Frame f = new Frame("DrawColoredPrimitives");
+
+ f.addWindowListener( new WindowAdapter()
+ {
+ public void windowClosed(WindowEvent e)
+ {
+ System.exit(0);
+ }
+ public void windowClosing(WindowEvent e)
+ {
+ windowClosed(e);
+ }
+ }
+ );
+
+ f.setLayout(new BorderLayout());
+ f.add("Center", applet);
+ applet.init(500,300);
+ applet.start();
+ Dimension ps = applet.getPreferredSize();
+ f.setBounds(-100,-100,99,99);
+ f.setVisible(true);
+ f.setVisible(false);
+ Insets i = f.getInsets();
+ f.setBounds(0,0,
+ ps.width+i.left+i.right,
+ ps.height+i.top+i.bottom);
+ f.setVisible(true);
+ }
+
+ private class gldemo extends GLAnimCanvas
+ {
+ float rotate;
+
+ float LightAmbient[] = { 0.75f, 0.75f, 0.75f, 1.5f};
+ float LightDiffuse[] = { 1.0f, 1.0f, 1.0f, 0.9f};
+ float LightSpecular[] = { 0.8f, 0.8f, 0.8f, 1.0f};
+
+ public gldemo(int w, int h)
+ {
+ super(w, h);
+ GLContext.gljNativeDebug = false;
+ GLContext.gljClassDebug = false;
+ setAnimateFps(30.0);
+ }
+
+ public void preInit()
+ {
+ doubleBuffer = true;
+ stereoView = false;
+ }
+
+ public void init()
+ {
+ reshape(getSize().width, getSize().height);
+
+ gl.glEnable(GL_LIGHT0);
+ gl.glLightfv(GL_LIGHT0, GL_AMBIENT, LightAmbient);
+ gl.glLightfv(GL_LIGHT0, GL_DIFFUSE, LightDiffuse);
+ gl.glLightfv(GL_LIGHT0, GL_SPECULAR, LightSpecular);
+
+ glj.gljCheckGL();
+ }
+
+ public void reshape(int width, int height)
+ {
+ gl.glMatrixMode(GL_PROJECTION);
+ gl.glLoadIdentity();
+ glu.gluPerspective(45, (float)width/(float)height, 1, 700);
+ gl.glMatrixMode(GL_MODELVIEW);
+ gl.glLoadIdentity();
+ gl.glViewport(0,0,width,height);
+ }
+
+ public void display()
+ {
+ if (glj.gljMakeCurrent() == false) return;
+
+ gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+ gl.glMatrixMode(GL_MODELVIEW);
+ gl.glLoadIdentity();
+
+ gl.glColor4f(1, 1, 1, 1);
+
+ rotate++;
+
+ gl.glTranslatef(0, 0, -5);
+ gl.glRotatef(rotate, 0, 1, 0);
+ gl.glBegin(GL_POLYGON);
+ gl.glNormal3f( 1, 0, 0);
+ gl.glColor4f(1, 0, 0, 1); gl.glVertex3f( 0, 1, 0);
+ gl.glColor4f(0, 1, 0, 1); gl.glVertex3f(-1, -1, 0);
+ gl.glColor4f(0, 0, 1, 1); gl.glVertex3f( 1, -1, 0);
+ gl.glEnd();
+
+ glj.gljSwap();
+ glj.gljCheckGL();
+ glj.gljFree();
+ }
+ }
+}
diff --git a/demos/MiscDemos/DrawColoredPrimitives2.html b/demos/MiscDemos/DrawColoredPrimitives2.html new file mode 100644 index 0000000..6881a77 --- /dev/null +++ b/demos/MiscDemos/DrawColoredPrimitives2.html @@ -0,0 +1,16 @@ +<HTML>
+<HEAD>
+<TITLE>Göthel Hard- und Software Entwicklungen</TITLE>
+</HEAD>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+Press the Right-Mouse Button for a Menu !
+<br>
+<hr>
+<applet code="DrawColoredPrimitives2.class" width=500 height=300>
+<param name=frames value="55">
+</applet>
+<hr>
+</BODY>
+</HTML>
+
+
diff --git a/demos/MiscDemos/DrawColoredPrimitives2.java b/demos/MiscDemos/DrawColoredPrimitives2.java new file mode 100644 index 0000000..fad8668 --- /dev/null +++ b/demos/MiscDemos/DrawColoredPrimitives2.java @@ -0,0 +1,302 @@ +/**
+ * @(#) DrawColoredPrimitives2.java
+ * @(#) author: Joe Zimmerman (converted to Java by Sven Goethel)
+ */
+
+/* This program is free software under the license of LGPL */
+
+import java.applet.*;
+import java.awt.*;
+import java.awt.event.*;
+import java.lang.*;
+import java.util.*;
+import java.io.*;
+import java.util.*;
+import gl4java.GLContext;
+import gl4java.awt.GLAnimCanvas;
+import gl4java.applet.SimpleGLAnimApplet1;
+
+public class DrawColoredPrimitives2 extends SimpleGLAnimApplet1
+{
+
+ public void init()
+ {
+ super.init();
+ Dimension d = getSize();
+ canvas = new gldemo(d.width, d.height);
+ add("Center", canvas);
+ }
+
+ public static void main( String args[] ) {
+ DrawColoredPrimitives2 applet =
+ new DrawColoredPrimitives2();
+
+ Frame f = new Frame("DrawColoredPrimitives2");
+
+ f.addWindowListener( new WindowAdapter()
+ {
+ public void windowClosed(WindowEvent e)
+ {
+ System.exit(0);
+ }
+ public void windowClosing(WindowEvent e)
+ {
+ windowClosed(e);
+ }
+ }
+ );
+
+ f.setLayout(new BorderLayout());
+ f.add("Center", applet);
+ applet.setSize(500,300);
+ applet.init();
+ applet.start();
+ Dimension ps = applet.getPreferredSize();
+ f.setBounds(-100,-100,99,99);
+ f.setVisible(true);
+ f.setVisible(false);
+ Insets i = f.getInsets();
+ f.setBounds(0,0,
+ ps.width+i.left+i.right,
+ ps.height+i.top+i.bottom);
+ f.setVisible(true);
+ }
+
+ private class gldemo extends GLAnimCanvas
+ implements MouseListener, ActionListener
+ {
+ private PopupMenu menu = null;
+ private boolean menu_showing = false;
+ private boolean save_suspended = false;
+ private final String VIEW_FRONT = "View Front";
+ private final String VIEW_TOP = "View Top";
+ private final String VIEW_BOTTOM = "View Bottom";
+
+ final float M_PI = 3.14159265f;
+ final float M_PI_2 = 1.57079632f;
+ float rotate;
+ float rotationStep = 1;
+ int view = 0; /* 0 = front, 1 = top, 2 = bottom */
+
+ float LightAmbient[] = { 0.75f, 0.75f, 0.75f, 1.5f};
+ float LightDiffuse[] = { 1.0f, 1.0f, 1.0f, 0.9f};
+ float LightSpecular[] = { 0.8f, 0.8f, 0.8f, 1.0f};
+
+ public gldemo(int w, int h)
+ {
+ super(w, h);
+ GLContext.gljNativeDebug = false;
+ GLContext.gljClassDebug = false;
+ setAnimateFps(30.0);
+ }
+
+ public void preInit()
+ {
+ doubleBuffer = true;
+ stereoView = false;
+ }
+
+ public void init()
+ {
+ reshape(getSize().width, getSize().height);
+
+ gl.glEnable(GL_LIGHT0);
+ gl.glLightfv(GL_LIGHT0, GL_AMBIENT, LightAmbient);
+ gl.glLightfv(GL_LIGHT0, GL_DIFFUSE, LightDiffuse);
+ gl.glLightfv(GL_LIGHT0, GL_SPECULAR, LightSpecular);
+
+ glj.gljCheckGL();
+
+ menu = new PopupMenu("Options");
+ menu.add(VIEW_FRONT);
+ menu.add(VIEW_TOP);
+ menu.add(VIEW_BOTTOM);
+ menu.addActionListener(this);
+ add(menu);
+
+ addMouseListener(this);
+ }
+
+ public void doCleanup()
+ {
+ removeMouseListener(this);
+ menu.removeActionListener(this);
+ }
+
+ public void reshape(int width, int height)
+ {
+ gl.glMatrixMode(GL_PROJECTION);
+ gl.glLoadIdentity();
+ glu.gluPerspective(45, (float)width/(float)height, 1, 700);
+ gl.glMatrixMode(GL_MODELVIEW);
+ gl.glLoadIdentity();
+ gl.glViewport(0,0,width,height);
+ }
+
+ public void display()
+ {
+ if (glj.gljMakeCurrent() == false) return;
+
+ gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+ gl.glMatrixMode(GL_MODELVIEW);
+ gl.glLoadIdentity();
+
+ gl.glTranslatef(0, 0, -5);
+
+ if(view==1)
+ {
+ gl.glRotatef(90f, 1, 0, 0);
+ } else if(view==2)
+ {
+ gl.glRotatef(-90f, 1, 0, 0);
+ }
+
+ gl.glColor4f(1, 1, 1, 1);
+
+ rotate+=rotationStep;
+ if(rotate>=180.0f || rotate<=0.0f)
+ rotationStep*=-1.0f;
+
+ gl.glRotatef(rotate, 0, 1, 0);
+
+
+ gl.glBegin(GL_POLYGON);
+ gl.glNormal3f( 1, 0, 0);
+
+ // top vertex
+ gl.glColor4f(1, 0, 0, 1); gl.glVertex3f( 0, 1, 0);
+ // bottom left vertex
+ gl.glColor4f(0, 1, 0, 1); gl.glVertex3f(-1, -1, 1);
+ // bottom right vertex
+ gl.glColor4f(0, 0, 1, 1); gl.glVertex3f( 1, -1, 1);
+ gl.glEnd();
+
+ gl.glBegin(GL_POLYGON);
+ gl.glNormal3f( 1, 0, 0);
+
+ // top vertex
+ gl.glColor4f(1, 0, 0, 1); gl.glVertex3f( 0, 1, 0);
+ // bottom left vertex
+ gl.glColor4f(0, 1, 0, 1); gl.glVertex3f( 1, -1, -1);
+ // bottom right vertex
+ gl.glColor4f(0, 0, 1, 1); gl.glVertex3f( 1, -1, 1);
+ gl.glEnd();
+
+ gl.glBegin(GL_POLYGON);
+ gl.glNormal3f( 1, 0, 0);
+
+ // top vertex
+ gl.glColor4f(1, 0, 0, 1); gl.glVertex3f( 0, 1, 0);
+ // bottom left vertex
+ gl.glColor4f(0, 1, 0, 1); gl.glVertex3f( 1, -1, -1);
+ // bottom right vertex
+ gl.glColor4f(0, 0, 1, 1); gl.glVertex3f(-1, -1, -1);
+ gl.glEnd();
+
+ gl.glBegin(GL_POLYGON);
+ gl.glNormal3f( 1, 0, 0);
+
+ // top vertex
+ gl.glColor4f(1, 0, 0, 1); gl.glVertex3f( 0, 1, 0);
+ // bottom left vertex
+ gl.glColor4f(0, 1, 0, 1); gl.glVertex3f(-1, -1, 1);
+ // bottom right vertex
+ gl.glColor4f(0, 0, 1, 1); gl.glVertex3f(-1, -1, -1);
+ gl.glEnd();
+
+
+ // bottom square polygon
+ gl.glBegin(GL_POLYGON);
+ gl.glNormal3f( 1, 0, 0);
+
+ gl.glColor4f(0, 0, 1, 1); gl.glVertex3f( 1, -1, 1);
+ gl.glColor4f(0, 1, 0, 1); gl.glVertex3f(-1, -1, 1);
+ gl.glColor4f(0, 0, 1, 1); gl.glVertex3f(-1, -1, -1);
+ gl.glColor4f(0, 1, 0, 1); gl.glVertex3f( 1, -1, -1);
+ gl.glEnd();
+
+
+ glj.gljSwap();
+ glj.gljCheckGL();
+ glj.gljFree();
+ }
+
+ // Methods required for the implementation of MouseListener
+ public void mouseEntered(MouseEvent evt)
+ {
+ }
+
+ public void mouseExited(MouseEvent evt)
+ {
+ }
+
+ public void mousePressed(MouseEvent evt)
+ {
+ if (!menu_showing)
+ {
+ if ((evt.getModifiers() & evt.BUTTON3_MASK) != 0)
+ {
+ menu_showing = true;
+ save_suspended = isSuspended();
+ if (!save_suspended)
+ {
+ setSuspended(true);
+ repaint(100);
+ try
+ {
+ Thread.currentThread().sleep(200);
+ }
+ catch (Exception e)
+ { }
+ }
+ menu.show(this,evt.getX(),evt.getY());
+ }
+ else
+ {
+ // Must be left button.
+ if (isSuspended()) repaint();
+ }
+ }
+ else
+ {
+ menu_showing = false;
+ setSuspended(save_suspended);
+ }
+ }
+
+ public void mouseReleased(MouseEvent evt)
+ {
+ }
+
+ public void mouseClicked(MouseEvent evt)
+ {
+ }
+
+ // Method required for the implementation of ActionListener
+ public void actionPerformed(ActionEvent evt)
+ {
+ String c = evt.getActionCommand();
+ if (c.equals(VIEW_FRONT))
+ {
+ view=0;
+ }
+ else if (c.equals(VIEW_TOP))
+ {
+ view=1;
+ }
+ else if (c.equals(VIEW_BOTTOM))
+ {
+ view=2;
+ }
+ if (menu_showing)
+ {
+ menu_showing = false;
+ setSuspended(save_suspended);
+ }
+ }
+
+
+
+ }
+}
diff --git a/demos/MiscDemos/DrawColoredPrimitives2_plugin13.html b/demos/MiscDemos/DrawColoredPrimitives2_plugin13.html new file mode 100644 index 0000000..ba23c36 --- /dev/null +++ b/demos/MiscDemos/DrawColoredPrimitives2_plugin13.html @@ -0,0 +1,48 @@ +<HTML>
+<HEAD>
+<TITLE>Göthel Hard- und Software Entwicklungen</TITLE>
+</HEAD>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+Press the Right-Mouse Button for a Menu !
+<br>
+<hr>
+<!--"CONVERTED_APPLET"-->
+<!-- CONVERTER VERSION 1.3 --> +<SCRIPT LANGUAGE="JavaScript"><!-- + var _info = navigator.userAgent; var _ns = false; + var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0); +//--></SCRIPT> +<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!-- + var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0))); +//--></SCRIPT></COMMENT> + +<SCRIPT LANGUAGE="JavaScript"><!-- + if (_ie == true) document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = 500 HEIGHT = 300 codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0"><NOEMBED><XMP>'); + else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.3" CODE = "DrawColoredPrimitives2.class" WIDTH = 500 HEIGHT = 300 frames = "55" scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html"><NOEMBED><XMP>'); +//--></SCRIPT> +<APPLET CODE = "DrawColoredPrimitives2.class" WIDTH = 500 HEIGHT = 300></XMP> +<PARAM NAME = CODE VALUE = "DrawColoredPrimitives2.class" >
+ +<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3"> +<PARAM NAME="scriptable" VALUE="false"> +<PARAM NAME = frames VALUE ="55">
+ +</APPLET> + +</NOEMBED></EMBED></OBJECT> + + +<!-- +<APPLET CODE = "DrawColoredPrimitives2.class" WIDTH = 500 HEIGHT = 300>
+<PARAM NAME = frames VALUE ="55">
+
+
+</APPLET> +--> +<!--"END_CONVERTED_APPLET"-->
+
+<hr>
+</BODY>
+</HTML>
+
+
diff --git a/demos/MiscDemos/DrawColoredPrimitives_plugin13.html b/demos/MiscDemos/DrawColoredPrimitives_plugin13.html new file mode 100644 index 0000000..101fd55 --- /dev/null +++ b/demos/MiscDemos/DrawColoredPrimitives_plugin13.html @@ -0,0 +1,46 @@ +<HTML>
+<HEAD>
+<TITLE>Göthel Hard- und Software Entwicklungen</TITLE>
+</HEAD>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+<hr>
+<!--"CONVERTED_APPLET"-->
+<!-- CONVERTER VERSION 1.3 --> +<SCRIPT LANGUAGE="JavaScript"><!-- + var _info = navigator.userAgent; var _ns = false; + var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0); +//--></SCRIPT> +<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!-- + var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0))); +//--></SCRIPT></COMMENT> + +<SCRIPT LANGUAGE="JavaScript"><!-- + if (_ie == true) document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = 500 HEIGHT = 300 codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0"><NOEMBED><XMP>'); + else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.3" CODE = "DrawColoredPrimitives.class" WIDTH = 500 HEIGHT = 300 frames = "55" scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html"><NOEMBED><XMP>'); +//--></SCRIPT> +<APPLET CODE = "DrawColoredPrimitives.class" WIDTH = 500 HEIGHT = 300></XMP> +<PARAM NAME = CODE VALUE = "DrawColoredPrimitives.class" >
+ +<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3"> +<PARAM NAME="scriptable" VALUE="false"> +<PARAM NAME = frames VALUE ="55">
+ +</APPLET> + +</NOEMBED></EMBED></OBJECT> + + +<!-- +<APPLET CODE = "DrawColoredPrimitives.class" WIDTH = 500 HEIGHT = 300>
+<PARAM NAME = frames VALUE ="55">
+
+
+</APPLET> +--> +<!--"END_CONVERTED_APPLET"-->
+
+<hr>
+</BODY>
+</HTML>
+
+
diff --git a/demos/MiscDemos/GLImageViewerCanvas.java b/demos/MiscDemos/GLImageViewerCanvas.java new file mode 100755 index 0000000..320242c --- /dev/null +++ b/demos/MiscDemos/GLImageViewerCanvas.java @@ -0,0 +1,126 @@ +import gl4java.*; +import gl4java.awt.*; +import gl4java.utils.textures.*; + +import java.awt.*; +import java.awt.event.*; +import java.net.*; + +public class GLImageViewerCanvas extends Frame + implements ActionListener, ItemListener +{ + GLImageCanvas glImageCanvas = null; + + private Choice fileTypeChoice = null; + private Button loadButton = null; + private Button saveButton = null; + private Button normalButton = null; + private Checkbox aspectCheck = null; + + public GLImageViewerCanvas(String title) + { + super(title); + setSize(500, 300); + Dimension d = getSize(); + setLayout(new BorderLayout()); + + addWindowListener( new WindowAdapter() + { + public void windowClosed(WindowEvent e) + { + System.exit(0); + } + public void windowClosing(WindowEvent e) + { + windowClosed(e); + } + } + ); + + Panel filePanel = new Panel(); + filePanel.setLayout(new FlowLayout(FlowLayout.CENTER)); + + fileTypeChoice = new Choice(); + fileTypeChoice.add("any"); + fileTypeChoice.add("tga"); + fileTypeChoice.add("png"); + fileTypeChoice.add("ppm"); + filePanel.add(fileTypeChoice); + + loadButton = new Button("load.."); + loadButton.addActionListener(this); + filePanel.add(loadButton); + + saveButton = new Button("save.."); + saveButton.addActionListener(this); + filePanel.add(saveButton); + + normalButton = new Button("normal"); + normalButton.addActionListener(this); + filePanel.add(normalButton); + + aspectCheck = new Checkbox("aspect", true); + aspectCheck.addItemListener(this); + filePanel.add(aspectCheck); + add("North", filePanel); + + glImageCanvas = new GLImageCanvas(d.width, d.height); + glImageCanvas.setName("GLImageCanvas"); + glImageCanvas.setKeepAspectRatio(aspectCheck.getState()); + add("Center", glImageCanvas); + + pack(); + setVisible(true); + } + + public void actionPerformed(ActionEvent e) + { + Object src = e.getSource(); + if(src.equals(loadButton)) + { + FileDialog fd = new FileDialog(this,"Bitmap Load Menu", + FileDialog.LOAD); + fd.show(); + String fname = fd.getDirectory() + fd.getFile() ; + fname = fname.replace('\\','/'); + fname = fname.trim(); + + setTitle(fname); + glImageCanvas.loadTexture(fname, + fileTypeChoice.getSelectedItem() ); + repaint(); + } else if(src.equals(saveButton)) + { + FileDialog fd = new FileDialog(this,"TGA-Image Save Menu", + FileDialog.SAVE); + fd.show(); + String fname = fd.getDirectory() + fd.getFile() ; + fname = fname.replace('\\','/'); + fname = fname.trim(); + + setTitle(fname); + glImageCanvas.snapshot( new TGATextureGrabber(glImageCanvas.gl), + fname); + repaint(); + } else if(src.equals(normalButton)) + { + glImageCanvas.setOriginalSize(); + } + } + + public void itemStateChanged(ItemEvent e) + { + if(aspectCheck.equals(e.getItemSelectable())) + { + glImageCanvas.setKeepAspectRatio(aspectCheck.getState()); + } + } + + public static void main( String args[] ) + { + GLContext.gljNativeDebug = true; + GLContext.gljClassDebug = true; + GLImageViewerCanvas applet = + new GLImageViewerCanvas("GLImageViewerCanvas"); + } +} diff --git a/demos/MiscDemos/GLImageViewerWorld.java b/demos/MiscDemos/GLImageViewerWorld.java new file mode 100755 index 0000000..f00bd06 --- /dev/null +++ b/demos/MiscDemos/GLImageViewerWorld.java @@ -0,0 +1,112 @@ +import gl4java.*; +import gl4java.awt.*; +import gl4java.utils.textures.*; + +import java.awt.*; +import java.awt.event.*; +import java.net.*; + +public class GLImageViewerWorld extends Frame + implements ActionListener +{ + GLImageWorld1 glImageCanvas = null; + + private Choice fileTypeChoice = null; + private Button loadButton = null; + private Button saveButton = null; + private Button normalButton = null; + + public GLImageViewerWorld(String title) + { + super(title); + setSize(500, 300); + Dimension d = getSize(); + setLayout(new BorderLayout()); + + addWindowListener( new WindowAdapter() + { + public void windowClosed(WindowEvent e) + { + System.exit(0); + } + public void windowClosing(WindowEvent e) + { + windowClosed(e); + } + } + ); + + Panel filePanel = new Panel(); + filePanel.setLayout(new FlowLayout(FlowLayout.CENTER)); + + fileTypeChoice = new Choice(); + fileTypeChoice.add("any"); + fileTypeChoice.add("tga"); + fileTypeChoice.add("png"); + fileTypeChoice.add("ppm"); + filePanel.add(fileTypeChoice); + + loadButton = new Button("load.."); + loadButton.addActionListener(this); + filePanel.add(loadButton); + + saveButton = new Button("save.."); + saveButton.addActionListener(this); + filePanel.add(saveButton); + + normalButton = new Button("normal"); + normalButton.addActionListener(this); + filePanel.add(normalButton); + + add("North", filePanel); + + glImageCanvas = new GLImageWorld1(d.width, d.height); + glImageCanvas.setName("GLImageWorld1"); + add("Center", glImageCanvas); + + pack(); + setVisible(true); + } + + public void actionPerformed(ActionEvent e) + { + Object src = e.getSource(); + if(src.equals(loadButton)) + { + FileDialog fd = new FileDialog(this,"Bitmap Load Menu", + FileDialog.LOAD); + fd.show(); + String fname = fd.getDirectory() + fd.getFile() ; + fname = fname.replace('\\','/'); + fname = fname.trim(); + + setTitle(fname); + glImageCanvas.loadTexture(fname, + fileTypeChoice.getSelectedItem() ); + repaint(); + } else if(src.equals(saveButton)) + { + FileDialog fd = new FileDialog(this,"TGA-Image Save Menu", + FileDialog.SAVE); + fd.show(); + String fname = fd.getDirectory() + fd.getFile() ; + fname = fname.replace('\\','/'); + fname = fname.trim(); + + setTitle(fname); + glImageCanvas.snapshot( new TGATextureGrabber(glImageCanvas.gl), + fname); + repaint(); + } else if(src.equals(normalButton)) + { + glImageCanvas.setOriginalPerspective(); + } + } + + public static void main( String args[] ) + { + GLImageViewerWorld applet = + new GLImageViewerWorld("GLImageViewerWorld"); + } +} + diff --git a/demos/MiscDemos/GLImageWorld1.java b/demos/MiscDemos/GLImageWorld1.java new file mode 100755 index 0000000..6ac78f5 --- /dev/null +++ b/demos/MiscDemos/GLImageWorld1.java @@ -0,0 +1,456 @@ +import gl4java.*; +import gl4java.awt.*; +import gl4java.utils.textures.*; + +import java.awt.*; +import java.awt.event.*; +import java.net.*; + +public class GLImageWorld1 extends GLCanvas + implements MouseListener,MouseMotionListener +{ + float []mPosObjTrans; + float []mPosObjRot; + + Point mousePoint; + Point oldMousePoint; + boolean mouseMoveFlag; + + + TextureGrabber textGrab4Snapshot = null; + String textGrab4SnapshotFName = null; + + TextureLoader txtLoader = null; + int texName[] = {0}; + + public GLImageWorld1 (int w, int h) + { + super(w, h); + } + + /** + * Creates a snapshot (save texture/image) of the current + * GL-Context ! + * + * The snapshot itself is created delayed, + * so no return value is avaiable. + * Because this is a non critical path, I hope its enough ! + * + * @param tg The TextureGrabber + * @param fname The filename + * @see TextureGrabber + */ + public void snapshot(TextureGrabber tg, String fname) + { + textGrab4Snapshot=tg; + textGrab4SnapshotFName=fname; + repaint(); + } + + public void setOriginalPerspective() + { + setOriginalPerspective(true); + } + + private void setOriginalPerspective(boolean fetchGL) + { + for(int i=0;i<16;i++) + mPosObjTrans[i]=0f; + mPosObjTrans[0]=mPosObjTrans[5]=mPosObjTrans[10]=mPosObjTrans[15]=1f; + for(int i=0;i<16;i++) + mPosObjRot[i]=0f; + mPosObjRot[0]=mPosObjRot[5]=mPosObjRot[10]=mPosObjRot[15]=1f; + + if(fetchGL) + { + if( glj.gljMakeCurrent() == false ) + System.out.println("problem in use() method"); + } + + TranlateObj(0f,0f,-10f); + SetCamera(); + + if(fetchGL) + { + glj.gljCheckGL(); + glj.gljFree(); + repaint(); + } + } + + public void preInit() + { + // createOwnWindow = true; + } + + public void init() + { + gl.glEnable(GL_TEXTURE_2D); + + gl.glGenTextures(1,texName); + gl.glBindTexture(GL_TEXTURE_2D,texName[0]); + + //gl.glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP); + //gl.glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP); + //gl.glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); + //gl.glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); + gl.glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP); + gl.glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP); + gl.glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST); + gl.glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST); + gl.glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + + // cameraMatrix init + mPosObjTrans=new float[16]; + mPosObjRot=new float[16]; + + setOriginalPerspective(false); + + gl.glShadeModel (GL_SMOOTH); + gl.glEnable(GL_DEPTH_TEST); + + gl.glClearColor(0.2f, 0.2f, 0.2f, 1.0f); + gl.glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); + glj.gljCheckGL(); + + addMouseListener(this); + addMouseMotionListener(this); + mouseMoveFlag=false; + + reshape(getSize().width, getSize().height); + } + + /** + * These variables are very important + * to respect the texture-size ratio ! + */ + float texMaxPosX = 1f; + float texMaxPosY = 1f; + + public boolean loadTexture(String name, String type) + { + boolean ok = true; + + if( glj.gljMakeCurrent() == false ) + { + System.out.println("problem in use() method"); + return false; + } + + // texture laden + if(type.equals("png")) + txtLoader = new PngTextureLoader(gl, glu); + else if(type.equals("ppm")) + txtLoader = new PPMAsciiTextureLoader(gl, glu); + else if(type.equals("tga")) + txtLoader = new TGATextureLoader(gl, glu); + else if(type.equals("any")) + txtLoader = new AWTTextureLoader(this, gl, glu); + else { + System.out.println("Imagetype: "+type+" is currently not supported !"); + ok = false; + } + + if(ok) + { + try { + txtLoader.readTexture(name); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + + if(ok && txtLoader.isOk()) + { + gl.glEnable(GL_TEXTURE_2D); + + txtLoader.texImage2DScaled4BestSize(); + + texMaxPosX = 1f; + texMaxPosY = 1f; + float texAspect = txtLoader.getTextureWidth()/ + txtLoader.getTextureHeight(); + + if(txtLoader.getTextureWidth()>txtLoader.getTextureHeight()) + texMaxPosY = 1f/texAspect; + else + texMaxPosX = texAspect; + System.out.println("texture succesfully loaded !"); + System.out.println("texture: "+txtLoader); + } + glj.gljCheckGL(); + glj.gljFree(); + if(ok) + repaint(); + return ok; + } + + public void display() + { + int i; + + /* Standard GL4Java Init */ + if( glj.gljMakeCurrent() == false ) + { + System.out.println("problem in use() method"); + return; + } + + // just render it + gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + SetCamera(); + + DrawScene(); + + if(textGrab4Snapshot!=null) + { + textGrab4Snapshot.grabPixels(GL_BACK, + 0, 0, cvsGetWidth(), cvsGetHeight()); + if(textGrab4SnapshotFName!=null) + textGrab4Snapshot.write2File(textGrab4SnapshotFName); + + textGrab4Snapshot =null; + textGrab4SnapshotFName=null; + } + + /* For your animation dutys ;-) */ + glj.gljSwap(); + glj.gljCheckGL(); + glj.gljFree(); + } + + public void reshape(int w, int h) + { + gl.glMatrixMode (GL_MODELVIEW); + gl.glViewport (0, 0, w, h); + gl.glLoadIdentity(); + SetCamera(); + } + + + public void drawGrid(float x0, float y0, + float width, float height, float step) + { + float i,j; + + /* draw grid */ + gl.glBegin(GL_LINES); + for(i=x0;i<width;i+=step) + for(j=y0;j<height;j+=step) + { + if(i==0f && j==0f) + gl.glColor3f (1f,0f,0f); + else + gl.glColor3f (0.6f,0.5f,0.5f); + gl.glVertex2f(0f,j); + gl.glVertex2f(width,j); + gl.glVertex2f(i,height); + gl.glVertex2f(i,0f); + } + gl.glEnd(); + } + + void DrawScene() + { + gl.glMatrixMode (GL_MODELVIEW); + gl.glLoadIdentity (); + + // kamera setzen + gl.glLoadMatrixf(mPosObjTrans); + gl.glMultMatrixf(mPosObjRot); + + gl.glPushMatrix(); + gl.glDisable(GL_TEXTURE_2D); + drawGrid(0f, 0f, 10f, 10f, 0.5f); + gl.glPopMatrix(); + + // obj zeichnen + + gl.glPushMatrix(); + gl.glScalef(2f,2f,2f); + gl.glColor3f(1f,0f,0f); + gl.glDisable(GL_TEXTURE_2D); + DrawObj(); + gl.glPopMatrix(); + + if(texName[0]!=0) + gl.glEnable(GL_TEXTURE_2D); + + gl.glEnable(GL_BLEND); + gl.glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); + + gl.glColor3f(1f,1f,1f); + + gl.glPushMatrix(); + gl.glScalef(3f,3f,3f); + gl.glTranslatef(-1f,0f,1f); + DrawObj(); + gl.glPopMatrix(); + + gl.glPushMatrix(); + gl.glScalef(3f,3f,3f); + gl.glTranslatef(1f,0f,1f); + DrawObj(); + gl.glPopMatrix(); + + gl.glPushMatrix(); + gl.glScalef(3f,3f,3f); + gl.glTranslatef(-2f,1f,1f); + Billboard(); + DrawObj(); + gl.glPopMatrix(); + + gl.glDisable(GL_BLEND); + } + + void DrawObj() + { + gl.glPushMatrix(); + gl.glBegin(GL_QUADS); + gl.glNormal3f(0f,0f,1f); + gl.glTexCoord2f(0f,0f); + gl.glVertex3f(0f,0f,0f); + + gl.glNormal3f(0f,0f,1f); + gl.glTexCoord2f(0f,1f); + gl.glVertex3f(0f,texMaxPosY,0f); + + gl.glNormal3f(0f,0f,1f); + gl.glTexCoord2f(1f,1f); + gl.glVertex3f(texMaxPosX,texMaxPosY,0f); + + gl.glNormal3f(0f,0f,1f); + gl.glTexCoord2f(1f,0f); + gl.glVertex3f(texMaxPosX,0f,0f); + gl.glEnd(); + gl.glPopMatrix(); + } + + float winaspect = 1f; + float imgaspect = 1f; + float imgwidth = 1f; + float imgheight = 1f; + + void SetCamera() + { + Dimension dim=getSize(); + float aspect=(float)dim.width/(float)dim.height; + + gl.glMatrixMode (GL_PROJECTION); + gl.glLoadIdentity (); + glu.gluPerspective(60f,aspect,.01,100); + } + + void RotateObj(float degree, + float axisX, + float axisY, + float axisZ) + { + if( glj.gljMakeCurrent() == false ) + { + System.out.println("problem in use() method"); + return; + } + + gl.glMatrixMode (GL_MODELVIEW); + gl.glLoadIdentity (); + + // kamera setzen + gl.glRotatef(degree,axisX,axisY,axisZ); + gl.glMultMatrixf(mPosObjRot); + gl.glGetFloatv(GL_MODELVIEW_MATRIX,mPosObjRot); + + repaint(); + } + + void TranlateObj(float x,float y,float z) + { + if( glj.gljMakeCurrent() == false ) + { + System.out.println("problem in use() method"); + return; + } + + gl.glMatrixMode (GL_MODELVIEW); + gl.glLoadIdentity (); + + // kamera setzen + gl.glLoadMatrixf(mPosObjTrans); + gl.glTranslatef(x,y,z); + gl.glGetFloatv(GL_MODELVIEW_MATRIX,mPosObjTrans); + + repaint(); + } + + // entfernt rotationen aus aktueller matrix + double Billboard() + { + float[] mat=new float[16]; + + gl.glGetFloatv(GL_MODELVIEW_MATRIX,mat); + mat[0] = mat[5] = mat[10] = 1; + mat[1] = mat[2] = mat[4] = mat[6] = mat[8] = mat[9] = 0; + gl.glLoadMatrixf(mat); + + return mat[14]; + } + + // Methods required for the implementation of MouseListener + public void mouseEntered( MouseEvent evt ) + { + } + + public void mouseExited( MouseEvent evt ) + { + } + + public void mousePressed( MouseEvent evt ) + { + if(mouseMoveFlag==false) + { // start drag + mouseMoveFlag=true; + mousePoint=evt.getPoint(); + } + } + + public void mouseReleased( MouseEvent evt ) + { + mouseMoveFlag=false; + } + + public void mouseClicked( MouseEvent evt ) + { + Component comp = evt.getComponent(); + } + + public void mouseDragged(MouseEvent e) + { + if(mouseMoveFlag==true) + { + oldMousePoint=new Point(mousePoint); + mousePoint=e.getPoint(); + + Point dif=new Point(mousePoint.x-oldMousePoint.x, + mousePoint.y-oldMousePoint.y); + + if(e.isShiftDown()==true) + TranlateObj((float)dif.x/6.0f,(float)dif.y/-6.0f,0f); + else if(e.isAltDown()==true) + { + TranlateObj(0f,0f,(float)dif.y/6.0f); + RotateObj(dif.x,0f,0f,1f); + } + else + { + RotateObj(dif.x,0f,1f,0f); + RotateObj(dif.y,1f,0f,0f); + } + } + } + public void mouseMoved(MouseEvent e) + { + } + + +} + diff --git a/demos/MiscDemos/PerformanceCheck.sh b/demos/MiscDemos/PerformanceCheck.sh new file mode 100755 index 0000000..5934e9d --- /dev/null +++ b/demos/MiscDemos/PerformanceCheck.sh @@ -0,0 +1,56 @@ +#! /bin/sh + +# +# Prerequisites: +# +# - Unix Shell Environment, e.g. A Unix :-), cygwin32, ... +# +# - The native gears executabel in your PATH environment +# +# - The Shell Setup scripts for all your installed java1.1.X-java2 JVM's +# under ./PerformanceEtc/profile.jdk* !!! +# Here you have to setup the PATH, CLASSPATH well ! +# + +if [ -z "$1" -o -z "$2" ] ; then + echo usage: $0 \<nativeprog and java class\> \<logfilename\> + echo e.g.: $0 gears gl4j2.4.1-linux-xf68-4.0.1-tdfx-gears.log + exit 1 +fi + +testdelay=40s + +tstprog=$1 +logfile=$2 +rm -f $logfile + +echo >> $logfile +echo =============================================== >> $logfile +echo >> $logfile +echo using native $tstprog >> $logfile +($tstprog -info >> $logfile 2>&1) & +sleep $testdelay && kill -15 $! +sleep 5s +echo >> $logfile +echo >> $logfile + +for i in ./PerformanceEtc/profile.jdk* ; do + echo >> $logfile + echo =============================================== >> $logfile + echo >> $logfile + echo using $tstprog on $i >> $logfile + echo >> $logfile + . $i + if [ -z "$(echo $i | grep ibm)" ] ; then + java -version >> $logfile 2>&1 + else + java -fullversion >> $logfile 2>&1 + fi + echo JAVA_COMPILER $JAVA_COMPILER >> $logfile + echo >> $logfile + ( java $tstprog -perftest >> $logfile 2>&1) & + sleep $testdelay && kill -15 $! + sleep 5s + echo >> $logfile + echo >> $logfile +done diff --git a/demos/MiscDemos/PerformanceEtc/profile.jdk1.2-sun b/demos/MiscDemos/PerformanceEtc/profile.jdk1.2-sun new file mode 100644 index 0000000..6483b1e --- /dev/null +++ b/demos/MiscDemos/PerformanceEtc/profile.jdk1.2-sun @@ -0,0 +1,48 @@ + +export NS_JAVA= +# export DYN_JAVA=true # some motif bugs are there :-( +export DYN_JAVA= + +export JAVA_HOME=/usr/local/lib/jdk1.2-sun +export JDK_HOME=$JAVA_HOME + +export JAVA_COMPILER=javacomp + +THREADS_FLAG=native +export THREADS_FLAG + +CLASSPATH=. + +# +# 1st the PATH for classes +# +for i in /usr/local/projects/java \ + $HOME/lib/classes \ + /usr/local/lib-java \ + ; do + test -e $i && CLASSPATH=$CLASSPATH:$i +done + +# +# 2nd the JAR/ZIP-Archives for classes +# +for i in $HOME/lib/classes/*.jar \ + /usr/local/lib-java/*.jar \ + ; do + test -e $i && CLASSPATH=$CLASSPATH:$i +done +export CLASSPATH + +# +# Be sure to respect, that the latter directory in this +# for-loop is the first entry in the PATH env-var !!!!! +# +for i in /usr/local/lib-java/JavaCC/bin \ + /usr/local/lib-java/bin \ + /usr/local/lib-java/JSDK/bin \ + $JAVA_HOME/bin \ + ; do + test -e $i && PATH=$i:$PATH +done +export PATH + diff --git a/demos/MiscDemos/PerformanceEtc/profile.jdk1.3-ibm b/demos/MiscDemos/PerformanceEtc/profile.jdk1.3-ibm new file mode 100644 index 0000000..841718d --- /dev/null +++ b/demos/MiscDemos/PerformanceEtc/profile.jdk1.3-ibm @@ -0,0 +1,52 @@ + +export NS_JAVA= +# export DYN_JAVA=true # some motif bugs are there :-( +export DYN_JAVA= + +export JAVA_HOME=/usr/local/lib/jdk1.3-ibm +export JDK_HOME=$JAVA_HOME + +export JAVA_COMPILER=jitc +#unset JAVA_COMPILER + +export HOTJAVA_HOME=/usr/local/lib-java/HotJava +export SWING_HOME= + +THREADS_FLAG=native +export THREADS_FLAG + +CLASSPATH=. + +# +# 1st the PATH for classes +# +for i in /usr/local/projects/java \ + $HOME/lib/classes \ + /usr/local/lib-java \ + ; do + test -e $i && CLASSPATH=$CLASSPATH:$i +done + +# +# 2nd the JAR/ZIP-Archives for classes +# +for i in $HOME/lib/classes/*.jar \ + /usr/local/lib-java/*.jar \ + ; do + test -e $i && CLASSPATH=$CLASSPATH:$i +done +export CLASSPATH + +# +# Be sure to respect, that the latter directory in this +# for-loop is the first entry in the PATH env-var !!!!! +# +for i in /usr/local/lib-java/JavaCC/bin \ + /usr/local/lib-java/bin \ + /usr/local/lib-java/JSDK/bin \ + $JAVA_HOME/bin \ + ; do + test -e $i && PATH=$i:$PATH +done +export PATH + diff --git a/demos/MiscDemos/PerformanceEtc/profile.jdk1.3-sun b/demos/MiscDemos/PerformanceEtc/profile.jdk1.3-sun new file mode 100644 index 0000000..752c6fe --- /dev/null +++ b/demos/MiscDemos/PerformanceEtc/profile.jdk1.3-sun @@ -0,0 +1,52 @@ + +export NS_JAVA= +# export DYN_JAVA=true # some motif bugs are there :-( +export DYN_JAVA= + +export JAVA_HOME=/usr/local/lib/jdk1.3-sun +export JDK_HOME=$JAVA_HOME + +unset JAVA_COMPILER +export TYA_LOGFILE= + +export HOTJAVA_HOME=/usr/local/lib-java/HotJava +export SWING_HOME= + +THREADS_FLAG=native +export THREADS_FLAG + +CLASSPATH=. + +# +# 1st the PATH for classes +# +for i in /usr/local/projects/java \ + $HOME/lib/classes \ + /usr/local/lib-java \ + ; do + test -e $i && CLASSPATH=$CLASSPATH:$i +done + +# +# 2nd the JAR/ZIP-Archives for classes +# +for i in $HOME/lib/classes/*.jar \ + /usr/local/lib-java/*.jar \ + ; do + test -e $i && CLASSPATH=$CLASSPATH:$i +done +export CLASSPATH + +# +# Be sure to respect, that the latter directory in this +# for-loop is the first entry in the PATH env-var !!!!! +# +for i in /usr/local/lib-java/JavaCC/bin \ + /usr/local/lib-java/bin \ + /usr/local/lib-java/JSDK/bin \ + $JAVA_HOME/bin \ + ; do + test -e $i && PATH=$i:$PATH +done +export PATH + diff --git a/demos/MiscDemos/PerformanceEtc/profile.jdk118-ibm b/demos/MiscDemos/PerformanceEtc/profile.jdk118-ibm new file mode 100644 index 0000000..925684a --- /dev/null +++ b/demos/MiscDemos/PerformanceEtc/profile.jdk118-ibm @@ -0,0 +1,48 @@ + +export NS_JAVA= +# export DYN_JAVA=true # some motif bugs are there :-( +export DYN_JAVA= + +export JAVA_HOME=/usr/local/lib/jdk118-ibm +export JDK_HOME=$JAVA_HOME + +export JAVA_COMPILER=jitc + +THREADS_FLAG=native +export THREADS_FLAG + +CLASSPATH=$JAVA_HOME/lib/classes.zip:. + +# +# 1st the PATH for classes +# +for i in /usr/local/projects/java \ + $HOME/lib/classes \ + /usr/local/lib-java \ + ; do + test -e $i && CLASSPATH=$CLASSPATH:$i +done + +# +# 2nd the JAR/ZIP-Archives for classes +# +for i in $HOME/lib/classes/*.jar \ + /usr/local/lib-java/*.jar \ + ; do + test -e $i && CLASSPATH=$CLASSPATH:$i +done +export CLASSPATH + +# +# Be sure to respect, that the latter directory in this +# for-loop is the first entry in the PATH env-var !!!!! +# +for i in /usr/local/lib-java/JavaCC/bin \ + /usr/local/lib-java/bin \ + $JAVA_HOME/bin \ + ; do + test -e $i && PATH=$i:$PATH +done +export PATH + + diff --git a/demos/MiscDemos/PerformanceEtc/profile.jdk118_v1 b/demos/MiscDemos/PerformanceEtc/profile.jdk118_v1 new file mode 100644 index 0000000..f36395a --- /dev/null +++ b/demos/MiscDemos/PerformanceEtc/profile.jdk118_v1 @@ -0,0 +1,50 @@ + +export NS_JAVA= +# export DYN_JAVA=true # some motif bugs are there :-( +export DYN_JAVA= + +export JAVA_HOME=/usr/local/lib/jdk118_v1 +export JDK_HOME=$JAVA_HOME + +export JAVA_COMPILER=tya +export TYA_LOGFILE=/var/log/tya.log + +THREADS_FLAG=native +export THREADS_FLAG + +CLASSPATH=$JAVA_HOME/lib/classes.zip:. + +# +# 1st the PATH for classes +# +for i in /usr/local/projects/java \ + $HOME/lib/classes \ + /usr/local/lib-java \ + ; do + test -e $i && CLASSPATH=$CLASSPATH:$i +done + +# +# 2nd the JAR/ZIP-Archives for classes +# +for i in $HOME/lib/classes/*.jar \ + /usr/local/lib-java/*.jar \ + ; do + test -e $i && CLASSPATH=$CLASSPATH:$i +done +export CLASSPATH + +# +# Be sure to respect, that the latter directory in this +# for-loop is the first entry in the PATH env-var !!!!! +# +for i in /usr/local/lib-java/JavaCC/bin \ + /usr/local/lib-java/bin \ + /usr/local/lib-java/JSDK/bin \ + $JAVA_HOME/bin \ + ; do + test -e $i && PATH=$i:$PATH +done +export PATH + + diff --git a/demos/MiscDemos/PerformanceLogs/gl4j2.4.1-linux-ppc-500mhz-xf68-4.0.1-DRI-soft.log b/demos/MiscDemos/PerformanceLogs/gl4j2.4.1-linux-ppc-500mhz-xf68-4.0.1-DRI-soft.log new file mode 100644 index 0000000..cc0831c --- /dev/null +++ b/demos/MiscDemos/PerformanceLogs/gl4j2.4.1-linux-ppc-500mhz-xf68-4.0.1-DRI-soft.log @@ -0,0 +1,82 @@ + +=============================================== + +using native gears + + + +=============================================== + +using gears on ./PerformanceEtc/profile.jdk118 + +dirname: too many arguments +Try `dirname --help' for more information. +java version "1.1.8" +JAVA_COMPILER mwjit + +dirname: too many arguments +Try `dirname --help' for more information. +libmwjit.so: cannot open shared object file: No such file or directory (libmwjit.so) +Warning: JIT compiler "mwjit" not found. Will use interpreter. +loading libs(gl, glu): null, null: true +useFpsSleep: false +useRepaint: false +GL VERSION : 1.2 Mesa 3.3 beta +GL RENDERER: Mesa GLX Indirect +GL VENDOR : Precision Insight, Inc. +453 frames in 5.004 seconds = 90.5275779376499 FPS +455 frames in 5.001 seconds = 90.98180363927214 FPS +454 frames in 5.003 seconds = 90.74555266839896 FPS +456 frames in 5.009 seconds = 91.03613495707725 FPS +454 frames in 5.003 seconds = 90.74555266839896 FPS +456 frames in 5.01 seconds = 91.0179640718563 FPS +453 frames in 5.005 seconds = 90.5094905094905 FPS + + + +=============================================== + +using gears on ./PerformanceEtc/profile.jdk122 + +java version "1.2.2" +Classic VM (build Linux_JDK_1.2.2_FCS, native threads, nojit) +JAVA_COMPILER + +loading libs(gl, glu): null, null: true +useFpsSleep: false +useRepaint: false +GL VERSION : 1.2 Mesa 3.3 beta +GL RENDERER: Mesa GLX Indirect +GL VENDOR : Precision Insight, Inc. +450 frames in 5.007 seconds = 89.87417615338526 FPS +450 frames in 5.009 seconds = 89.83829107606309 FPS +452 frames in 5.007 seconds = 90.2736169362892 FPS +454 frames in 5.009 seconds = 90.63685366340586 FPS +452 frames in 5.002 seconds = 90.36385445821672 FPS +454 frames in 5.005 seconds = 90.70929070929071 FPS + + + +=============================================== + +using gears on ./PerformanceEtc/profile.jdk13 + +java version "1.3.0beta" +Java(TM) 2 Runtime Environment, Standard Edition (build Blackdown-1.3.0beta-b02) +Classic VM (build Blackdown-1.3.0beta-b02, native threads, nojit) +JAVA_COMPILER + +loading libs(gl, glu): null, null: true +useFpsSleep: false +useRepaint: false +GL VERSION : 1.2 Mesa 3.3 beta +GL RENDERER: Mesa GLX Indirect +GL VENDOR : Precision Insight, Inc. +447 frames in 5.007 seconds = 89.27501497902936 FPS +449 frames in 5.01 seconds = 89.62075848303394 FPS +450 frames in 5.005 seconds = 89.91008991008991 FPS +451 frames in 5.002 seconds = 90.16393442622952 FPS +450 frames in 5.005 seconds = 89.91008991008991 FPS +452 frames in 5.009 seconds = 90.23757236973447 FPS + + diff --git a/demos/MiscDemos/PerformanceLogs/gl4j2.4.1-linux-x86-350mhz-Mesa321-soft-gears.log b/demos/MiscDemos/PerformanceLogs/gl4j2.4.1-linux-x86-350mhz-Mesa321-soft-gears.log new file mode 100644 index 0000000..91f2e6f --- /dev/null +++ b/demos/MiscDemos/PerformanceLogs/gl4j2.4.1-linux-x86-350mhz-Mesa321-soft-gears.log @@ -0,0 +1,130 @@ + +=============================================== + +using native gears +GL_RENDERER = Mesa X11 +GL_VERSION = 1.2 Mesa 3.2.1 +GL_VENDOR = Brian Paul +GL_EXTENSIONS = GL_EXT_blend_color GL_EXT_blend_minmax GL_EXT_blend_logic_op GL_EXT_blend_subtract GL_EXT_packed_pixels GL_EXT_paletted_texture GL_EXT_point_parameters GL_EXT_polygon_offset GL_EXT_vertex_array GL_EXT_texture_object GL_EXT_texture3D GL_MESA_window_pos GL_MESA_resize_buffers GL_EXT_shared_texture_palette GL_EXT_rescale_normal GL_EXT_abgr GL_SGIS_texture_edge_clamp GL_EXT_stencil_wrap GL_INGR_blend_func_separate GL_ARB_multitexture GL_NV_texgen_reflection GL_PGI_misc_hints GL_EXT_compiled_vertex_array GL_EXT_clip_volume_hint +492 frames in 5.004 seconds = 98.3213 FPS +510 frames in 5.007 seconds = 101.857 FPS +510 frames in 5.007 seconds = 101.857 FPS +510 frames in 5.007 seconds = 101.857 FPS +510 frames in 5.006 seconds = 101.878 FPS +510 frames in 5.006 seconds = 101.878 FPS +510 frames in 5.007 seconds = 101.857 FPS + + + +=============================================== + +using gears on ./PerformanceEtc/profile.jdk118-ibm + +java full version "JDK 1.1.8 IBM build l118-19991221 (JIT enabled: jitc)" +JAVA_COMPILER jitc + +loading libs(gl, glu): null, null: true +useFpsSleep: false +useRepaint: false +Xt error: attempt to add non-widget child "dsm" to parent "MToolkit app" which supports only widgets +SIGABRT received at bfffdc98 in /lib/libpthread.so.0. Processing terminated +Writing stack trace to javacore4308.txt ... OK + + + +=============================================== + +using gears on ./PerformanceEtc/profile.jdk118_v1 + +java version "1.1.8" +JAVA_COMPILER tya + + TYA 1.5 (for J117 / Linux). Copyright (c) 1997,98,99 The TYA Team + Contact The TYA Team via Albrecht Kleine <[email protected]> +loading libs(gl, glu): null, null: true +useFpsSleep: false +useRepaint: false +GL VERSION : 1.2 Mesa 3.2.1 +GL RENDERER: Mesa X11 +GL VENDOR : Brian Paul +500 frames in 5.003 seconds = 99.94003597841295 FPS +501 frames in 5.004 seconds = 100.11990407673862 FPS +502 frames in 5.009 seconds = 100.21960471151925 FPS +502 frames in 5.01 seconds = 100.1996007984032 FPS +502 frames in 5.008 seconds = 100.23961661341853 FPS +502 frames in 5.009 seconds = 100.21960471151925 FPS +502 frames in 5.004 seconds = 100.3197442046363 FPS +502 frames in 5.007 seconds = 100.25963650888757 FPS + + + +=============================================== + +using gears on ./PerformanceEtc/profile.jdk1.2-sun + +java version "1.2.2" +Classic VM (build 1.2.2_006, native threads, javacomp) +JAVA_COMPILER javacomp + +loading libs(gl, glu): null, null: true +useFpsSleep: false +useRepaint: false +GL VERSION : 1.2 Mesa 3.2.1 +GL RENDERER: Mesa X11 +GL VENDOR : Brian Paul +499 frames in 5.007 seconds = 99.66047533453167 FPS +501 frames in 5.006 seconds = 100.07990411506192 FPS +502 frames in 5.003 seconds = 100.3397961223266 FPS +501 frames in 5.0 seconds = 100.2 FPS +502 frames in 5.008 seconds = 100.23961661341853 FPS +502 frames in 5.003 seconds = 100.3397961223266 FPS +501 frames in 5.009 seconds = 100.01996406468356 FPS + + + +=============================================== + +using gears on ./PerformanceEtc/profile.jdk1.3-ibm + +java full version "J2RE 1.3.0 IBM build cxdev-20000502" +JAVA_COMPILER jitc + +loading libs(gl, glu): null, null: true +useFpsSleep: false +useRepaint: false +GL VERSION : 1.2 Mesa 3.2.1 +GL RENDERER: Mesa X11 +GL VENDOR : Brian Paul +498 frames in 5.005 seconds = 99.5004995004995 FPS +500 frames in 5.0 seconds = 100.0 FPS +500 frames in 5.0 seconds = 100.0 FPS +501 frames in 5.009 seconds = 100.01996406468356 FPS +497 frames in 5.0 seconds = 99.4 FPS +504 frames in 5.001 seconds = 100.77984403119376 FPS + + + +=============================================== + +using gears on ./PerformanceEtc/profile.jdk1.3-sun + +java version "1.3.0beta_refresh" +Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0beta_refresh-b09) +Java HotSpot(TM) Client VM (build 1.3.0beta-b07, mixed mode) +JAVA_COMPILER + +loading libs(gl, glu): null, null: true +useFpsSleep: false +useRepaint: false +GL VERSION : 1.2 Mesa 3.2.1 +GL RENDERER: Mesa X11 +GL VENDOR : Brian Paul +498 frames in 5.0 seconds = 99.6 FPS +499 frames in 5.007 seconds = 99.66047533453167 FPS +500 frames in 5.0 seconds = 100.0 FPS +498 frames in 5.007 seconds = 99.46075494307969 FPS +501 frames in 5.0 seconds = 100.2 FPS +501 frames in 5.0 seconds = 100.2 FPS +500 frames in 5.008 seconds = 99.84025559105432 FPS + + diff --git a/demos/MiscDemos/PerformanceLogs/gl4j2.4.1-linux-x86-350mhz-xf68-4.0.1-DRI-soft-gears.log b/demos/MiscDemos/PerformanceLogs/gl4j2.4.1-linux-x86-350mhz-xf68-4.0.1-DRI-soft-gears.log new file mode 100644 index 0000000..355b563 --- /dev/null +++ b/demos/MiscDemos/PerformanceLogs/gl4j2.4.1-linux-x86-350mhz-xf68-4.0.1-DRI-soft-gears.log @@ -0,0 +1,137 @@ + +=============================================== + +using native gears +GL_RENDERER = Mesa GLX Indirect +GL_VERSION = 1.2 Mesa 3.3 beta +GL_VENDOR = Precision Insight, Inc. +GL_EXTENSIONS = GL_EXT_abgr GL_EXT_blend_color GL_EXT_blend_minmax GL_EXT_blend_subtract +455 frames in 5.002 seconds = 90.9636 FPS +464 frames in 5.003 seconds = 92.7444 FPS +471 frames in 5.01 seconds = 94.012 FPS +471 frames in 5.008 seconds = 94.0495 FPS +471 frames in 5.009 seconds = 94.0307 FPS +471 frames in 5.008 seconds = 94.0495 FPS +470 frames in 5.002 seconds = 93.9624 FPS + + + +=============================================== + +using gears on ./PerformanceEtc/profile.jdk118-ibm + +java full version "JDK 1.1.8 IBM build l118-19991221 (JIT enabled: jitc)" +JAVA_COMPILER jitc + +loading libs(gl, glu): null, null: true +useFpsSleep: false +useRepaint: false +GL VERSION : 1.2 Mesa 3.3 beta +GL RENDERER: Mesa GLX Indirect +GL VENDOR : Precision Insight, Inc. +446 frames in 5.004 seconds = 89.12869704236611 FPS +445 frames in 5.006 seconds = 88.89332800639232 FPS +455 frames in 5.004 seconds = 90.92725819344525 FPS +455 frames in 5.003 seconds = 90.94543274035578 FPS +455 frames in 5.002 seconds = 90.96361455417833 FPS +455 frames in 5.002 seconds = 90.96361455417833 FPS +454 frames in 5.005 seconds = 90.70929070929071 FPS + + + +=============================================== + +using gears on ./PerformanceEtc/profile.jdk118_v1 + +java version "1.1.8" +JAVA_COMPILER tya + + TYA 1.5 (for J117 / Linux). Copyright (c) 1997,98,99 The TYA Team + Contact The TYA Team via Albrecht Kleine <[email protected]> +loading libs(gl, glu): null, null: true +useFpsSleep: false +useRepaint: false +GL VERSION : 1.2 Mesa 3.3 beta +GL RENDERER: Mesa GLX Indirect +GL VENDOR : Precision Insight, Inc. +461 frames in 5.0 seconds = 92.2 FPS +462 frames in 5.005 seconds = 92.3076923076923 FPS +463 frames in 5.008 seconds = 92.4520766773163 FPS +463 frames in 5.007 seconds = 92.47054124226084 FPS +463 frames in 5.008 seconds = 92.4520766773163 FPS +463 frames in 5.007 seconds = 92.47054124226084 FPS +462 frames in 5.01 seconds = 92.21556886227545 FPS +462 frames in 5.002 seconds = 92.36305477808877 FPS + + + +=============================================== + +using gears on ./PerformanceEtc/profile.jdk1.2-sun + +java version "1.2.2" +Classic VM (build 1.2.2_006, native threads, javacomp) +JAVA_COMPILER javacomp + +loading libs(gl, glu): null, null: true +useFpsSleep: false +useRepaint: false +GL VERSION : 1.2 Mesa 3.3 beta +GL RENDERER: Mesa GLX Indirect +GL VENDOR : Precision Insight, Inc. +461 frames in 5.004 seconds = 92.12629896083135 FPS +463 frames in 5.008 seconds = 92.4520766773163 FPS +464 frames in 5.007 seconds = 92.67026163371281 FPS +464 frames in 5.005 seconds = 92.70729270729271 FPS +464 frames in 5.006 seconds = 92.6887734718338 FPS +464 frames in 5.008 seconds = 92.65175718849841 FPS +462 frames in 5.001 seconds = 92.38152369526094 FPS + + + +=============================================== + +using gears on ./PerformanceEtc/profile.jdk1.3-ibm + +java full version "J2RE 1.3.0 IBM build cxdev-20000502" +JAVA_COMPILER jitc + +loading libs(gl, glu): null, null: true +useFpsSleep: false +useRepaint: false +GL VERSION : 1.2 Mesa 3.3 beta +GL RENDERER: Mesa GLX Indirect +GL VENDOR : Precision Insight, Inc. +456 frames in 5.006 seconds = 91.09069117059528 FPS +459 frames in 5.006 seconds = 91.68997203355973 FPS +459 frames in 5.005 seconds = 91.70829170829171 FPS +459 frames in 5.003 seconds = 91.74495302818309 FPS +455 frames in 5.009 seconds = 90.83649431024156 FPS +462 frames in 5.0 seconds = 92.4 FPS + + + +=============================================== + +using gears on ./PerformanceEtc/profile.jdk1.3-sun + +java version "1.3.0beta_refresh" +Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0beta_refresh-b09) +Java HotSpot(TM) Client VM (build 1.3.0beta-b07, mixed mode) +JAVA_COMPILER + +loading libs(gl, glu): null, null: true +useFpsSleep: false +useRepaint: false +GL VERSION : 1.2 Mesa 3.3 beta +GL RENDERER: Mesa GLX Indirect +GL VENDOR : Precision Insight, Inc. +462 frames in 5.009 seconds = 92.23397883809143 FPS +461 frames in 5.007 seconds = 92.07110045935691 FPS +463 frames in 5.005 seconds = 92.50749250749251 FPS +462 frames in 5.007 seconds = 92.27082085080887 FPS +466 frames in 5.005 seconds = 93.10689310689311 FPS +466 frames in 5.004 seconds = 93.12549960031976 FPS +464 frames in 5.005 seconds = 92.70729270729271 FPS + + diff --git a/demos/MiscDemos/PerformanceLogs/gl4j2.4.1-linux-x86-350mhz-xf68-4.0.1-NVidia-GForce256-gears.log b/demos/MiscDemos/PerformanceLogs/gl4j2.4.1-linux-x86-350mhz-xf68-4.0.1-NVidia-GForce256-gears.log new file mode 100644 index 0000000..e21c362 --- /dev/null +++ b/demos/MiscDemos/PerformanceLogs/gl4j2.4.1-linux-x86-350mhz-xf68-4.0.1-NVidia-GForce256-gears.log @@ -0,0 +1,131 @@ + +=============================================== + +using native gears +GL_RENDERER = GeForce 256/AGP +GL_VERSION = 1.2.1 +GL_VENDOR = NVIDIA Corporation +GL_EXTENSIONS = GL_ARB_multitexture GL_ARB_texture_compression GL_ARB_texture_cube_map GL_ARB_texture_env_add GL_ARB_transpose_matrix GL_EXT_abgr GL_EXT_bgra GL_EXT_blend_color GL_EXT_blend_minmax GL_EXT_blend_subtract GL_EXT_compiled_vertex_array GL_EXT_fog_coord GL_EXT_packed_pixels GL_EXT_paletted_texture GL_EXT_point_parameters GL_EXT_rescale_normal GL_EXT_secondary_color GL_EXT_separate_specular_color GL_EXT_shared_texture_palette GL_EXT_stencil_wrap GL_EXT_texture_compression_s3tc GL_EXT_texture_edge_clamp GL_EXT_texture_env_add GL_EXT_texture_env_combine GL_EXT_texture_cube_map GL_EXT_texture_filter_anisotropic GL_EXT_texture_lod GL_EXT_texture_lod_bias GL_EXT_texture_object GL_EXT_vertex_array GL_EXT_vertex_weighting GL_KTX_buffer_region GL_NV_blend_square GL_NV_fence GL_NV_fog_distance GL_NV_light_max_exponent GL_NV_register_combiners GL_NV_texgen_emboss GL_NV_texgen_reflection GL_NV_texture_env_combine4 GL_NV_vertex_array_range GL_S3_s3tc GL_SGIS_multitexture GL_SGIS_texture_lod +5380 frames in 5 seconds = 1076 FPS +5452 frames in 5 seconds = 1090.4 FPS +5496 frames in 5 seconds = 1099.2 FPS +5495 frames in 5 seconds = 1099 FPS +5496 frames in 5 seconds = 1099.2 FPS +5496 frames in 5 seconds = 1099.2 FPS +5494 frames in 5 seconds = 1098.8 FPS + + + +=============================================== + +using gears on ./PerformanceEtc/profile.jdk118-ibm + +java full version "JDK 1.1.8 IBM build l118-19991221 (JIT enabled: jitc)" +JAVA_COMPILER jitc + +loading libs(gl, glu): null, null: true +useFpsSleep: false +useRepaint: false +GL VERSION : 1.2.1 +GL RENDERER: GeForce 256/AGP +GL VENDOR : NVIDIA Corporation +4969 frames in 5.0 seconds = 993.8 FPS +4937 frames in 5.0 seconds = 987.4 FPS +5065 frames in 5.0 seconds = 1013.0 FPS +5062 frames in 5.0 seconds = 1012.4 FPS +5066 frames in 5.0 seconds = 1013.2 FPS +5062 frames in 5.0 seconds = 1012.4 FPS +5053 frames in 5.0 seconds = 1010.6 FPS + + + +=============================================== + +using gears on ./PerformanceEtc/profile.jdk118_v1 + +java version "1.1.8" +JAVA_COMPILER tya + + TYA 1.5 (for J117 / Linux). Copyright (c) 1997,98,99 The TYA Team + Contact The TYA Team via Albrecht Kleine <[email protected]> +loading libs(gl, glu): null, null: true +useFpsSleep: false +useRepaint: false +GL VERSION : 1.2.1 +GL RENDERER: GeForce 256/AGP +GL VENDOR : NVIDIA Corporation +5132 frames in 5.0 seconds = 1026.4 FPS +5174 frames in 5.0 seconds = 1034.8 FPS +5180 frames in 5.0 seconds = 1036.0 FPS +5180 frames in 5.0 seconds = 1036.0 FPS +5179 frames in 5.0 seconds = 1035.8 FPS +5179 frames in 5.0 seconds = 1035.8 FPS +5166 frames in 5.0 seconds = 1033.2 FPS +5179 frames in 5.0 seconds = 1035.8 FPS + + + +=============================================== + +using gears on ./PerformanceEtc/profile.jdk1.2-sun + +java version "1.2.2" +Classic VM (build 1.2.2_006, native threads, javacomp) +JAVA_COMPILER javacomp + +loading libs(gl, glu): null, null: true +useFpsSleep: false +useRepaint: false +GL VERSION : 1.2.1 +GL RENDERER: GeForce 256/AGP +GL VENDOR : NVIDIA Corporation +5112 frames in 5.0 seconds = 1022.4 FPS +5168 frames in 5.0 seconds = 1033.6 FPS +5176 frames in 5.0 seconds = 1035.2 FPS +5178 frames in 5.0 seconds = 1035.6 FPS +5177 frames in 5.0 seconds = 1035.4 FPS +5178 frames in 5.0 seconds = 1035.6 FPS +5168 frames in 5.0 seconds = 1033.6 FPS + + + +=============================================== + +using gears on ./PerformanceEtc/profile.jdk1.3-ibm + +java full version "J2RE 1.3.0 IBM build cxdev-20000502" +JAVA_COMPILER jitc + +loading libs(gl, glu): null, null: true +useFpsSleep: false +useRepaint: false +GL VERSION : 1.2.1 +GL RENDERER: GeForce 256/AGP +GL VENDOR : NVIDIA Corporation +5079 frames in 5.0 seconds = 1015.8 FPS +5229 frames in 5.0 seconds = 1045.8 FPS +5230 frames in 5.0 seconds = 1046.0 FPS + +=============================================== + +using gears on ./PerformanceEtc/profile.jdk1.3-sun + +java version "1.3.0beta_refresh" +Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0beta_refresh-b09) +Java HotSpot(TM) Client VM (build 1.3.0beta-b07, mixed mode) +JAVA_COMPILER + +loading libs(gl, glu): null, null: true +useFpsSleep: false +useRepaint: false +GL VERSION : 1.2.1 +GL RENDERER: GeForce 256/AGP +GL VENDOR : NVIDIA Corporation +4894 frames in 5.0 seconds = 978.8 FPS +5043 frames in 5.0 seconds = 1008.6 FPS +5063 frames in 5.0 seconds = 1012.6 FPS +5065 frames in 5.0 seconds = 1013.0 FPS +5065 frames in 5.0 seconds = 1013.0 FPS +5064 frames in 5.0 seconds = 1012.8 FPS + + diff --git a/demos/MiscDemos/PerformanceLogs/index.html b/demos/MiscDemos/PerformanceLogs/index.html new file mode 100644 index 0000000..20ebe96 --- /dev/null +++ b/demos/MiscDemos/PerformanceLogs/index.html @@ -0,0 +1,15 @@ +<HEAD> +<TITLE></TITLE> +</HEAD> +<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff"> +<H1></H1> +<HR><PRE> +<IMG SRC="/icons/back.gif" ALT="[DIR]"> <A HREF="..">Parent Directory</A> +<IMG SRC="/icons/compressed.gif" ALT="[ ]"> <A HREF="gl4j2.4.1-linux-ppc-500mhz-xf68-4.0.1-DRI-soft.log">gl4j2.4.1-linux-ppc-500mhz-xf68-4.0.1-DRI-soft.log</A> (4 kBytes) +<IMG SRC="/icons/compressed.gif" ALT="[ ]"> <A HREF="gl4j2.4.1-linux-x86-350mhz-Mesa321-soft-gears.log">gl4j2.4.1-linux-x86-350mhz-Mesa321-soft-gears.log</A> (8 kBytes) +<IMG SRC="/icons/compressed.gif" ALT="[ ]"> <A HREF="gl4j2.4.1-linux-x86-350mhz-xf68-4.0.1-DRI-soft-gears.log">gl4j2.4.1-linux-x86-350mhz-xf68-4.0.1-DRI-soft-gears.log</A> (8 kBytes) +<IMG SRC="/icons/compressed.gif" ALT="[ ]"> <A HREF="gl4j2.4.1-linux-x86-350mhz-xf68-4.0.1-NVidia-GForce256-gears.log">gl4j2.4.1-linux-x86-350mhz-xf68-4.0.1-NVidia-GForce256-gears.log</A> (8 kBytes) +</PRE><HR> +<PRE> +<PRE> +</BODY> diff --git a/demos/MiscDemos/SharedGLTest.java b/demos/MiscDemos/SharedGLTest.java new file mode 100644 index 0000000..1377b20 --- /dev/null +++ b/demos/MiscDemos/SharedGLTest.java @@ -0,0 +1,73 @@ +import java.awt.*; +import gl4java.*; +import gl4java.awt.*; + +public class SharedGLTest extends Frame { + public static void main(String[] args) { + SharedGLTest t1 = new SharedGLTest(); + t1.setVisible(true); + + do { // Wait until t1 is fully created and displayed. + if(t1.getGLContext() != null) break; + } + while(true); + + SharedGLTest t2 = new SharedGLTest(t1.getGLContext()); + t2.setVisible(true); + } + + public SharedGLTest() { this(null); } + public SharedGLTest(GLContext shareWith) { + super(); + setBounds(50, 0, 200, 200); + c = new MyCanvas(100, 100, shareWith); + add(c); + } + + private MyCanvas c; + public GLContext getGLContext() { return c.getGLContext(); } + + private class MyCanvas extends GLCanvas { + + public MyCanvas(int w, int h) { + super(w, h); + } + + public MyCanvas(int w, int h, GLContext shareWith) { + super(w, h); + sharedGLContext = shareWith; + } + + public void display() { + if( glj.gljMakeCurrent() == false ) { + System.out.println("problem in use() method"); + return; + } + + GLFunc gl = glj.getGLFunc(); + buildCallList(gl); // Really build something only once. + gl.glCallList(callList); + + + glj.gljSwap(); + glj.gljCheckGL(); + glj.gljFree(); + } + } + private static int callList; + private static boolean alreadyDone; + private static void buildCallList(GLFunc gl) { // Build only one call list for both GLCanvas. + if(alreadyDone) return; + alreadyDone = true; + + callList = gl.glGenLists(1); + + gl.glNewList(callList, gl.GL_COMPILE); + gl.glClearColor(1f, 0f, 0f, 1f); + gl.glClear(gl.GL_COLOR_BUFFER_BIT); // Clear the GLCanvas with red. + gl.glEndList(); + } +} + + + diff --git a/demos/MiscDemos/SharedGLTest2.html b/demos/MiscDemos/SharedGLTest2.html new file mode 100644 index 0000000..802e43b --- /dev/null +++ b/demos/MiscDemos/SharedGLTest2.html @@ -0,0 +1,13 @@ +<HTML> +<HEAD> +<TITLE>Göthel Hard- und Software Entwicklungen</TITLE> +</HEAD> +<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff"> +<hr> +<applet code="SharedGLTest2.class" width=200 height=400> +<param name=frames value="55"> +</applet> +<hr> +</BODY> +</HTML> + diff --git a/demos/MiscDemos/SharedGLTest2.java b/demos/MiscDemos/SharedGLTest2.java new file mode 100755 index 0000000..e1dcb23 --- /dev/null +++ b/demos/MiscDemos/SharedGLTest2.java @@ -0,0 +1,144 @@ +import java.applet.*; +import java.awt.*; +import java.awt.event.*; +import gl4java.*; +import gl4java.awt.*; + +public class SharedGLTest2 extends Applet + implements MouseListener +{ + + MyCanvas canvas = null; + Button addButton = null; + int canvasNumber = 0; + Panel pAllCvs = null; + Dimension d = null; + + public void init() + { + d = getSize(); + setLayout(new BorderLayout()); + addButton = new Button ("add gl"); + addButton.addMouseListener(this); + add("South", addButton); + + pAllCvs = new Panel(); + pAllCvs.setLayout(new GridLayout(4,1)); + add("Center", pAllCvs); + + canvas = new MyCanvas (d.width/2, d.height/2, null); + pAllCvs.add(canvas); + canvasNumber=1; + } + + public static void main( String args[] ) + { + Frame mainFrame = new Frame("SharedGLTest2"); + + SharedGLTest2 applet = new SharedGLTest2(); + + applet.setSize(400, 400); + applet.init(); + applet.start(); + + mainFrame.add(applet); + + mainFrame.pack(); + mainFrame.setVisible(true); + } + + public void start() + { + } + + + public void stop() + { + } + + // Methods required for the implementation of MouseListener + public void mouseEntered( MouseEvent evt ) + { + } + + public void mouseExited( MouseEvent evt ) + { + } + + public void mousePressed( MouseEvent evt ) + { + } + + public void mouseReleased( MouseEvent evt ) + { + } + + public void mouseClicked( MouseEvent evt ) + { + Component comp = evt.getComponent(); + + if( canvas!=null && comp.equals(addButton) ) + { + if(canvasNumber<4) + { + MyCanvas _canvas = + new MyCanvas (d.width/2,d.height/2,canvas.getGLContext()); + pAllCvs.add(_canvas); + canvasNumber++; + pAllCvs.invalidate(); + pAllCvs.validate(); + if(canvasNumber==4) + addButton.setEnabled(false); + } + } + } + + private static int callList=0; + + protected class MyCanvas extends GLCanvas + { + public MyCanvas(int w, int h, GLContext shareWith) + { + super(w, h); + sharedGLContext = shareWith; + } + + public void init() + { + if(sharedGLContext==null && callList==0) + { + buildCallList(); // Really build something only once. + } + } + + public void display() + { + if( glj.gljMakeCurrent() == false ) { + System.out.println("problem in use() method"); + return; + } + + if(callList!=0) + gl.glCallList(callList); + + glj.gljSwap(); + glj.gljCheckGL(); + glj.gljFree(); + } + + /** + * Build only one call list for both GLCanvas. + */ + protected void buildCallList() + { + callList = gl.glGenLists(1); + + gl.glNewList(callList, gl.GL_COMPILE); + gl.glClearColor(1f, 0f, 0f, 1f); + gl.glClear(gl.GL_COLOR_BUFFER_BIT); // Clear the GLCanvas with red. + gl.glEndList(); + } + } + +} + diff --git a/demos/MiscDemos/SharedGLTest2_plugin13.html b/demos/MiscDemos/SharedGLTest2_plugin13.html new file mode 100644 index 0000000..75bb289 --- /dev/null +++ b/demos/MiscDemos/SharedGLTest2_plugin13.html @@ -0,0 +1,45 @@ +<HTML> +<HEAD> +<TITLE>Göthel Hard- und Software Entwicklungen</TITLE> +</HEAD> +<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff"> +<hr> +<!--"CONVERTED_APPLET"--> +<!-- CONVERTER VERSION 1.3 --> +<SCRIPT LANGUAGE="JavaScript"><!-- + var _info = navigator.userAgent; var _ns = false; + var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0); +//--></SCRIPT> +<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!-- + var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0))); +//--></SCRIPT></COMMENT> + +<SCRIPT LANGUAGE="JavaScript"><!-- + if (_ie == true) document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = 200 HEIGHT = 400 codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0"><NOEMBED><XMP>'); + else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.3" CODE = "SharedGLTest2.class" WIDTH = 200 HEIGHT = 400 frames = "55" scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html"><NOEMBED><XMP>'); +//--></SCRIPT> +<APPLET CODE = "SharedGLTest2.class" WIDTH = 200 HEIGHT = 400></XMP> +<PARAM NAME = CODE VALUE = "SharedGLTest2.class" > + +<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3"> +<PARAM NAME="scriptable" VALUE="false"> +<PARAM NAME = frames VALUE ="55"> + +</APPLET> + +</NOEMBED></EMBED></OBJECT> + + +<!-- +<APPLET CODE = "SharedGLTest2.class" WIDTH = 200 HEIGHT = 400> +<PARAM NAME = frames VALUE ="55"> + + +</APPLET> +--> +<!--"END_CONVERTED_APPLET"--> + +<hr> +</BODY> +</HTML> + diff --git a/demos/MiscDemos/TriangleRotate.html b/demos/MiscDemos/TriangleRotate.html new file mode 100644 index 0000000..5dad555 --- /dev/null +++ b/demos/MiscDemos/TriangleRotate.html @@ -0,0 +1,14 @@ +<HTML>
+<HEAD>
+<TITLE>Göthel Hard- und Software Entwicklungen</TITLE>
+</HEAD>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+<hr>
+<applet code="TriangleRotate.class" width=500 height=300>
+<param name=frames value="55">
+</applet>
+<hr>
+</BODY>
+</HTML>
+
+
diff --git a/demos/MiscDemos/TriangleRotate.java b/demos/MiscDemos/TriangleRotate.java new file mode 100755 index 0000000..c2d93f7 --- /dev/null +++ b/demos/MiscDemos/TriangleRotate.java @@ -0,0 +1,139 @@ +/**
+ * @(#) TriangleRotate.java
+ * @(#) author: Joe Zimmerman (converted to Java by Sven Goethel)
+ */
+
+/* This program is free software under the license of LGPL */
+
+import java.applet.*;
+import java.awt.*;
+import java.awt.event.*;
+import java.lang.*;
+import java.util.*;
+import java.io.*;
+import java.util.*;
+import gl4java.GLContext;
+import gl4java.awt.GLAnimCanvas;
+import gl4java.applet.SimpleGLAnimApplet1;
+
+public class TriangleRotate extends SimpleGLAnimApplet1
+{
+
+ public void init()
+ {
+ super.init();
+ Dimension d = getSize();
+ canvas = new gldemo(d.width, d.height);
+ add("Center", canvas);
+ }
+
+ public static void main( String args[] ) {
+ GLContext.gljNativeDebug = true;
+ GLContext.gljClassDebug = true;
+ TriangleRotate applet =
+ new TriangleRotate();
+
+ Frame f = new Frame("TriangleRotate");
+
+ f.addWindowListener( new WindowAdapter()
+ {
+ public void windowClosed(WindowEvent e)
+ {
+ System.exit(0);
+ }
+ public void windowClosing(WindowEvent e)
+ {
+ windowClosed(e);
+ }
+ }
+ );
+
+ f.setLayout(new BorderLayout());
+ f.add("Center", applet);
+ applet.setSize(500,300);
+ applet.init();
+ applet.start();
+ Dimension ps = applet.getPreferredSize();
+ f.setBounds(-100,-100,99,99);
+ f.setVisible(true);
+ f.setVisible(false);
+ Insets i = f.getInsets();
+ f.setBounds(0,0,
+ ps.width+i.left+i.right,
+ ps.height+i.top+i.bottom);
+ f.setVisible(true);
+ }
+
+ private class gldemo extends GLAnimCanvas
+ {
+ float rotate;
+
+ float LightAmbient[] = { 0.75f, 0.75f, 0.75f, 1.5f};
+ float LightDiffuse[] = { 1.0f, 1.0f, 1.0f, 0.9f};
+ float LightSpecular[] = { 0.8f, 0.8f, 0.8f, 1.0f};
+
+ public gldemo(int w, int h)
+ {
+ super(w, h);
+ GLContext.gljNativeDebug = false;
+ GLContext.gljClassDebug = false;
+ setAnimateFps(30.0);
+ }
+
+ public void preInit()
+ {
+ doubleBuffer = true;
+ stereoView = false;
+ createOwnWindow = true;
+ }
+
+ public void init()
+ {
+ reshape(getSize().width, getSize().height);
+
+ gl.glEnable(GL_LIGHT0);
+ gl.glLightfv(GL_LIGHT0, GL_AMBIENT, LightAmbient);
+ gl.glLightfv(GL_LIGHT0, GL_DIFFUSE, LightDiffuse);
+ gl.glLightfv(GL_LIGHT0, GL_SPECULAR, LightSpecular);
+
+ glj.gljCheckGL();
+ }
+
+ public void reshape(int width, int height)
+ {
+ gl.glMatrixMode(GL_PROJECTION);
+ gl.glLoadIdentity();
+ glu.gluPerspective(45, (float)width/(float)height, 1, 700);
+ gl.glMatrixMode(GL_MODELVIEW);
+ gl.glLoadIdentity();
+ gl.glViewport(0,0,width,height);
+ }
+
+ public void display()
+ {
+ if (glj.gljMakeCurrent() == false) return;
+
+ gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+ gl.glMatrixMode(GL_MODELVIEW);
+ gl.glLoadIdentity();
+
+ gl.glColor4f(1, 1, 1, 1);
+
+ rotate++;
+
+ gl.glTranslatef(0, 0, -10);
+ gl.glRotatef(rotate, 0, 1, 0);
+ gl.glBegin(GL_POLYGON);
+ gl.glNormal3f( 1, 0, 0);
+ gl.glVertex3f( 0, 1, 0);
+ gl.glVertex3f(-1, -1, 0);
+ gl.glVertex3f( 1, -1, 0);
+ gl.glEnd();
+
+ glj.gljSwap();
+ glj.gljCheckGL();
+ glj.gljFree();
+ }
+ }
+}
diff --git a/demos/MiscDemos/TriangleRotate_plugin13.html b/demos/MiscDemos/TriangleRotate_plugin13.html new file mode 100644 index 0000000..444fa8b --- /dev/null +++ b/demos/MiscDemos/TriangleRotate_plugin13.html @@ -0,0 +1,46 @@ +<HTML>
+<HEAD>
+<TITLE>Göthel Hard- und Software Entwicklungen</TITLE>
+</HEAD>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+<hr>
+<!--"CONVERTED_APPLET"-->
+<!-- CONVERTER VERSION 1.3 --> +<SCRIPT LANGUAGE="JavaScript"><!-- + var _info = navigator.userAgent; var _ns = false; + var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0); +//--></SCRIPT> +<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!-- + var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0))); +//--></SCRIPT></COMMENT> + +<SCRIPT LANGUAGE="JavaScript"><!-- + if (_ie == true) document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = 500 HEIGHT = 300 codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0"><NOEMBED><XMP>'); + else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.3" CODE = "TriangleRotate.class" WIDTH = 500 HEIGHT = 300 frames = "55" scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html"><NOEMBED><XMP>'); +//--></SCRIPT> +<APPLET CODE = "TriangleRotate.class" WIDTH = 500 HEIGHT = 300></XMP> +<PARAM NAME = CODE VALUE = "TriangleRotate.class" >
+ +<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3"> +<PARAM NAME="scriptable" VALUE="false"> +<PARAM NAME = frames VALUE ="55">
+ +</APPLET> + +</NOEMBED></EMBED></OBJECT> + + +<!-- +<APPLET CODE = "TriangleRotate.class" WIDTH = 500 HEIGHT = 300>
+<PARAM NAME = frames VALUE ="55">
+
+
+</APPLET> +--> +<!--"END_CONVERTED_APPLET"-->
+
+<hr>
+</BODY>
+</HTML>
+
+
diff --git a/demos/MiscDemos/accanti.html b/demos/MiscDemos/accanti.html new file mode 100644 index 0000000..9730abd --- /dev/null +++ b/demos/MiscDemos/accanti.html @@ -0,0 +1,17 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
+ <title>OpenGL Demo - ported by Sven Goethel</title>
+</head>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+Teapots applet
+<br>Originially written by Silicon Graphics
+<br>Ported to Java by Sven Goethel
+<br>
+<applet code="accanti.class" width=400 height=400>
+</applet>
+<hr>
+</body>
+</html>
diff --git a/demos/MiscDemos/accanti.java b/demos/MiscDemos/accanti.java new file mode 100644 index 0000000..3191452 --- /dev/null +++ b/demos/MiscDemos/accanti.java @@ -0,0 +1,258 @@ +/** + * @(#) accanti.java + * @(#) author: Silicon Graphics, Inc. (converted to Java by Sven Goethel) + */ + +/* + * This program demonstrates lots of material properties. + * A single light source illuminates the objects. + */ + +import java.applet.*; +import java.awt.*; +import java.awt.event.*; +import java.lang.*; +import java.util.*; +import java.io.*; +import java.util.*; +import gl4java.GLContext; +import gl4java.awt.GLCanvas; + +import gl4java.utils.glut.*; + +public class accanti extends Applet +{ + accantiCanvas canvas = null; + + + /* Initialize the applet */ + + + public void init() + { + Dimension d = getSize(); + setLayout(new BorderLayout()); + canvas = new accantiCanvas(d.width, d.height); + add("Center", canvas); + } + + + /* Start the applet */ + + + public void start() + { + } + + + /* Stop the applet */ + + + public void stop() + { + } + + public static void main( String args[] ) { + GLContext.gljNativeDebug = true; + GLContext.gljClassDebug = true; + + accanti applet = + new accanti(); + + Frame f = new Frame("accanti"); + + f.addWindowListener( new WindowAdapter() + { + public void windowClosed(WindowEvent e) + { + System.exit(0); + } + public void windowClosing(WindowEvent e) + { + windowClosed(e); + } + } + ); + + f.setLayout(new BorderLayout()); + f.add("Center", applet); + applet.setSize(500,300); + applet.init(); + applet.start(); + Dimension ps = applet.getPreferredSize(); + f.setBounds(-100,-100,99,99); + f.setVisible(true); + f.setVisible(false); + Insets i = f.getInsets(); + f.setBounds(0,0, + ps.width+i.left+i.right, + ps.height+i.top+i.bottom); + f.setVisible(true); + } + + /* Local GLCanvas extension class */ + + + private class accantiCanvas extends GLCanvas + { + int teapotList; + GLUTFunc glut = null; + + public accantiCanvas(int w, int h) + { + super(w, h); + } + + public void preInit() + { + doubleBuffer = true; + stereoView = false; + accumSize = 8; + } + + + boolean hasAccumulatorBits = false; + + public void init() + { + int aRbits[] = { 0 }; + int aGbits[] = { 0 }; + int aBbits[] = { 0 }; + int aAbits[] = { 0 }; + + glut = new GLUTFuncLightImpl(gl, glu); + + reshape(getSize().width, getSize().height); + + float mat_ambient[] = { 1.0f, 1.0f, 1.0f, 1.0f }; + float mat_specular[] = { 1.0f, 1.0f, 1.0f, 1.0f }; + float light_position[] = { 0.0f, 0.0f, 10.0f, 1.0f }; + float lm_ambient[] = { 0.2f, 0.2f, 0.2f, 1.0f }; + + gl.glGetIntegerv(GL_ACCUM_RED_BITS, aRbits); + gl.glGetIntegerv(GL_ACCUM_GREEN_BITS, aGbits); + gl.glGetIntegerv(GL_ACCUM_BLUE_BITS, aBbits); + gl.glGetIntegerv(GL_ACCUM_ALPHA_BITS, aAbits); + + System.out.println("Accumulation Buffer Bits:"); + System.out.println("\t red: "+aRbits[0]); + System.out.println("\t green: "+aGbits[0]); + System.out.println("\t blue: "+aBbits[0]); + System.out.println("\t alpha: "+aAbits[0]); + + hasAccumulatorBits = aRbits[0] > 0 || aGbits[0] > 0 || + aBbits[0] > 0 || aAbits[0] > 0 ; + + System.out.println("Has Accumulator Bits: "+hasAccumulatorBits); + + gl.glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient); + gl.glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); + gl.glMaterialf(GL_FRONT, GL_SHININESS, 50.0f); + gl.glLightfv(GL_LIGHT0, GL_POSITION, light_position); + gl.glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lm_ambient); + + gl.glEnable(GL_LIGHTING); + gl.glEnable(GL_LIGHT0); + gl.glDepthFunc(GL_LESS); + gl.glEnable(GL_DEPTH_TEST); + gl.glShadeModel (GL_FLAT); + + gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); + gl.glClearAccum(0.0f, 0.0f, 0.0f, 0.0f); + } + + void displayObjects() + { + float torus_diffuse[] = { 0.7f, 0.7f, 0.0f, 1.0f }; + float cube_diffuse[] = { 0.0f, 0.7f, 0.7f, 1.0f }; + float sphere_diffuse[] = { 0.7f, 0.0f, 0.7f, 1.0f }; + float octa_diffuse[] = { 0.7f, 0.4f, 0.4f, 1.0f }; + + gl.glPushMatrix (); + gl.glRotatef (30.0f, 1.0f, 0.0f, 0.0f); + + gl.glPushMatrix (); + gl.glTranslatef (-0.80f, 0.35f, 0.0f); + gl.glRotatef (100.0f, 1.0f, 0.0f, 0.0f); + gl.glMaterialfv(GL_FRONT, GL_DIFFUSE, torus_diffuse); + glut.glutSolidTorus (0.275f, 0.85f, 16, 16); + gl.glPopMatrix (); + + gl.glPushMatrix (); + gl.glTranslatef (-0.75f, -0.50f, 0.0f); + gl.glRotatef (45.0f, 0.0f, 0.0f, 1.0f); + gl.glRotatef (45.0f, 1.0f, 0.0f, 0.0f); + gl.glMaterialfv(GL_FRONT, GL_DIFFUSE, cube_diffuse); + glut.glutSolidCube (1.5f); + gl.glPopMatrix (); + + gl.glPushMatrix (); + gl.glTranslatef (0.75f, 0.60f, 0.0f); + gl.glRotatef (30.0f, 1.0f, 0.0f, 0.0f); + gl.glMaterialfv(GL_FRONT, GL_DIFFUSE, sphere_diffuse); + glut.glutSolidSphere (1.0f, 16, 16); + gl.glPopMatrix (); + + gl.glPushMatrix (); + gl.glTranslatef (0.70f, -0.90f, 0.25f); + gl.glMaterialfv(GL_FRONT, GL_DIFFUSE, octa_diffuse); + glut.glutSolidOctahedron (); + gl.glPopMatrix (); + + gl.glPopMatrix (); + } + + public void display() + { + int viewport[]=new int[4]; + int jitter; + int ACSIZE=8; + + if (glj.gljMakeCurrent() == false) return; + + gl.glGetIntegerv (GL_VIEWPORT, viewport); + glj.gljCheckGL(); + + if(hasAccumulatorBits) + gl.glClear(GL_ACCUM_BUFFER_BIT); + glj.gljCheckGL(); + + for (jitter = 0; jitter < ACSIZE; jitter++) { + gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + gl.glPushMatrix (); + + /* Note that 4.5f is the distance in world space between + * left and right and bottom and top. + * This formula converts fractional pixel movement to + * world coordinates. + */ + gl.glTranslatef (/*j8[jitter].x**/4.5f/viewport[2], + /*j8[jitter].y**/4.5f/viewport[3], 0.0f); + displayObjects (); + gl.glPopMatrix (); + if(hasAccumulatorBits) + gl.glAccum(GL_ACCUM, 1.0f/(float)ACSIZE); + glj.gljCheckGL(); + } + if(hasAccumulatorBits) + gl.glAccum (GL_RETURN, 1.0f); + glj.gljCheckGL(); + + glj.gljSwap(); + glj.gljCheckGL(); + glj.gljFree(); + } + + public void reshape(int w, int h) + { + gl.glViewport(0, 0, w, h); + gl.glMatrixMode(GL_PROJECTION); + gl.glLoadIdentity(); + if (w <= h) + gl.glOrtho (-2.25f, 2.25f, -2.25f*h/w, 2.25f*h/w, -10.0f, 10.0f); + else + gl.glOrtho (-2.25f*w/h, 2.25f*w/h, -2.25f, 2.25f, -10.0f, 10.0f); + gl.glMatrixMode(GL_MODELVIEW); + } + } +} diff --git a/demos/MiscDemos/accanti_plugin13.html b/demos/MiscDemos/accanti_plugin13.html new file mode 100644 index 0000000..0a1597d --- /dev/null +++ b/demos/MiscDemos/accanti_plugin13.html @@ -0,0 +1,48 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
+ <title>OpenGL Demo - ported by Sven Goethel</title>
+</head>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+Teapots applet
+<br>Originially written by Silicon Graphics
+<br>Ported to Java by Sven Goethel
+<br>
+<!--"CONVERTED_APPLET"-->
+<!-- CONVERTER VERSION 1.3 --> +<SCRIPT LANGUAGE="JavaScript"><!-- + var _info = navigator.userAgent; var _ns = false; + var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0); +//--></SCRIPT> +<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!-- + var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0))); +//--></SCRIPT></COMMENT> + +<SCRIPT LANGUAGE="JavaScript"><!-- + if (_ie == true) document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = 400 HEIGHT = 400 codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0"><NOEMBED><XMP>'); + else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.3" CODE = "accanti.class" WIDTH = 400 HEIGHT = 400 scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html"><NOEMBED><XMP>'); +//--></SCRIPT> +<APPLET CODE = "accanti.class" WIDTH = 400 HEIGHT = 400></XMP> +<PARAM NAME = CODE VALUE = "accanti.class" >
+ +<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3"> +<PARAM NAME="scriptable" VALUE="false"> + +</APPLET> + +</NOEMBED></EMBED></OBJECT> + + +<!-- +<APPLET CODE = "accanti.class" WIDTH = 400 HEIGHT = 400>
+
+
+</APPLET> +--> +<!--"END_CONVERTED_APPLET"-->
+
+<hr>
+</body>
+</html>
diff --git a/demos/MiscDemos/alpha3D.html b/demos/MiscDemos/alpha3D.html new file mode 100644 index 0000000..43e5aaf --- /dev/null +++ b/demos/MiscDemos/alpha3D.html @@ -0,0 +1,17 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
+ <title>OpenGL Demo - ported by Sven Goethel</title>
+</head>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+Teapots applet
+<br>Originially written by Silicon Graphics
+<br>Ported to Java by Sven Goethel
+<br>
+<applet code="alpha3D.class" width=400 height=400>
+</applet>
+<hr>
+</body>
+</html>
diff --git a/demos/MiscDemos/alpha3D.java b/demos/MiscDemos/alpha3D.java new file mode 100644 index 0000000..a982375 --- /dev/null +++ b/demos/MiscDemos/alpha3D.java @@ -0,0 +1,287 @@ +/** + * @(#) alpha3D.java + * @(#) author: Silicon Graphics, Inc. (converted to Java by Sven Goethel) + */ + +/* + * This program demonstrates lots of material properties. + * A single light source illuminates the objects. + */ + +import java.applet.*; +import java.awt.*; +import java.awt.event.*; +import java.lang.*; +import java.util.*; +import java.io.*; +import java.util.*; +import gl4java.GLContext; +import gl4java.awt.GLCanvas; +import gl4java.awt.GLAnimCanvas; +import gl4java.applet.SimpleGLAnimApplet1; + +import gl4java.utils.glut.*; + +public class alpha3D extends SimpleGLAnimApplet1 +{ + static final float MAXZ = 8.0f; + static final float MINZ = -8.0f; + static final float ZINC = 0.4f; + + /* Initialize the applet */ + + + public void init() + { + super.init(); + Dimension d = getSize(); + canvas = new alpha3DCanvas(d.width, d.height); + add("Center", canvas); + } + + + public static void main( String args[] ) { + alpha3D applet = + new alpha3D(); + + Frame f = new Frame("alpha3D"); + + f.addWindowListener( new WindowAdapter() + { + public void windowClosed(WindowEvent e) + { + System.exit(0); + } + public void windowClosing(WindowEvent e) + { + windowClosed(e); + } + } + ); + + f.setLayout(new BorderLayout()); + f.add("Center", applet); + applet.setSize(500,300); + applet.init(); + applet.start(); + Dimension ps = applet.getPreferredSize(); + f.setBounds(-100,-100,99,99); + f.setVisible(true); + f.setVisible(false); + Insets i = f.getInsets(); + f.setBounds(0,0, + ps.width+i.left+i.right, + ps.height+i.top+i.bottom); + f.setVisible(true); + } + /* Local GLCanvas extension class */ + + + private class alpha3DCanvas extends GLAnimCanvas + implements MouseListener, ActionListener + { + private PopupMenu menu = null; + private boolean menu_showing = false; + private boolean save_suspended = false; + private final String MENUE_0 = "Alpha Mode"; + private final String MENUE_1 = "Real Mode"; + + GLUTFunc glut = null; + + float solidZ = MAXZ; + float transparentZ = MINZ; + int sphereList, cubeList; + + public alpha3DCanvas(int w, int h) + { + super(w, h); + GLContext.gljNativeDebug = false; + GLContext.gljClassDebug = false; + setAnimateFps(30.0); + } + + public void preInit() + { + doubleBuffer = true; + stereoView = false; + } + + + public void init() + { + glut = new GLUTFuncLightImpl(gl, glu); + + reshape(getSize().width, getSize().height); + + float mat_specular[] = { 1.0f, 1.0f, 1.0f, 0.15f }; + float mat_shininess[] = { 100.0f }; + float position[] = { 0.5f, 0.5f, 1.0f, 0.0f }; + + gl.glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); + gl.glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess); + gl.glLightfv(GL_LIGHT0, GL_POSITION, position); + + gl.glEnable(GL_LIGHTING); + gl.glEnable(GL_LIGHT0); + gl.glEnable(GL_DEPTH_TEST); + + sphereList = gl.glGenLists(1); + gl.glNewList(sphereList, GL_COMPILE); + glut.glutSolidSphere (0.4f, 16, 16); + gl.glEndList(); + + cubeList = gl.glGenLists(1); + gl.glNewList(cubeList, GL_COMPILE); + glut.glutSolidCube (0.6f); + gl.glEndList(); + + menu = new PopupMenu("Options"); + menu.add(MENUE_0); + menu.add(MENUE_1); + menu.addActionListener(this); + add(menu); + + addMouseListener(this); + } + + public void display() + { + if (glj.gljMakeCurrent() == false) return; + + float mat_solid[] = { 0.75f, 0.75f, 0.0f, 1.0f }; + float mat_zero[] = { 0.0f, 0.0f, 0.0f, 1.0f }; + float mat_transparent[] = { 0.0f, 0.8f, 0.8f, 0.6f }; + float mat_emission[] = { 0.0f, 0.3f, 0.3f, 0.6f }; + + gl.glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + gl.glPushMatrix (); + gl.glTranslatef (-0.15f, -0.15f, solidZ); + gl.glMaterialfv(GL_FRONT, GL_EMISSION, mat_zero); + gl.glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_solid); + gl.glCallList (sphereList); + gl.glPopMatrix (); + + gl.glPushMatrix (); + gl.glTranslatef (0.15f, 0.15f, transparentZ); + gl.glRotatef (15.0f, 1.0f, 1.0f, 0.0f); + gl.glRotatef (30.0f, 0.0f, 1.0f, 0.0f); + gl.glMaterialfv(GL_FRONT, GL_EMISSION, mat_emission); + gl.glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_transparent); + gl.glEnable (GL_BLEND); + gl.glDepthMask (GL_FALSE); + gl.glBlendFunc (GL_SRC_ALPHA, GL_ONE); + gl.glCallList (cubeList); + gl.glDepthMask (GL_TRUE); + gl.glDisable (GL_BLEND); + gl.glPopMatrix (); + + glj.gljSwap(); + glj.gljCheckGL(); + glj.gljFree(); + + animate(); + } + + public void reshape(int w, int h) + { + gl.glViewport(0, 0, (int) w, (int) h); + gl.glMatrixMode(GL_PROJECTION); + gl.glLoadIdentity(); + if (w <= h) + gl.glOrtho (-1.5f, 1.5f, -1.5f*(float)h/(float)w, + 1.5f*(float)h/(float)w, -10.0f, 10.0f); + else + gl.glOrtho (-1.5f*(float)w/(float)h, + 1.5f*(float)w/(float)h, -1.5f, 1.5f, -10.0f, 10.0f); + gl.glMatrixMode(GL_MODELVIEW); + gl.glLoadIdentity(); + } + + void animate() + { + if (solidZ <= MINZ || transparentZ >= MAXZ) + setSuspended(true); + else { + solidZ -= ZINC; + transparentZ += ZINC; + } + } + + // Methods required for the implementation of MouseListener + public void mouseEntered(MouseEvent evt) + { + } + + public void mouseExited(MouseEvent evt) + { + } + + public void mousePressed(MouseEvent evt) + { + if (!menu_showing) + { + if ((evt.getModifiers() & evt.BUTTON3_MASK) != 0) + { + menu_showing = true; + save_suspended = isSuspended(); + if (!save_suspended) + { + setSuspended(true); + repaint(100); + try + { + Thread.currentThread().sleep(200); + } + catch (Exception e) + { } + } + menu.show(this,evt.getX(),evt.getY()); + } + else + { + // Must be left button. + if (isSuspended()) repaint(); + } + } + else + { + menu_showing = false; + setSuspended(save_suspended); + } + } + + public void mouseReleased(MouseEvent evt) + { + } + + public void mouseClicked(MouseEvent evt) + { + } + + // Method required for the implementation of ActionListener + public void actionPerformed(ActionEvent evt) + { + String c = evt.getActionCommand(); + if (c.equals(MENUE_0)) + { + solidZ = MAXZ; + transparentZ = MINZ; + setSuspended(false); + return ; + } + else if (c.equals(MENUE_1)) + { + solidZ = MAXZ; + transparentZ = MINZ; + setSuspended(true); + repaint(); + } + if (menu_showing) + { + menu_showing = false; + setSuspended(save_suspended); + } + } + } +} diff --git a/demos/MiscDemos/alpha3D_plugin13.html b/demos/MiscDemos/alpha3D_plugin13.html new file mode 100644 index 0000000..5b0e6b7 --- /dev/null +++ b/demos/MiscDemos/alpha3D_plugin13.html @@ -0,0 +1,48 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
+ <title>OpenGL Demo - ported by Sven Goethel</title>
+</head>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+Teapots applet
+<br>Originially written by Silicon Graphics
+<br>Ported to Java by Sven Goethel
+<br>
+<!--"CONVERTED_APPLET"-->
+<!-- CONVERTER VERSION 1.3 --> +<SCRIPT LANGUAGE="JavaScript"><!-- + var _info = navigator.userAgent; var _ns = false; + var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0); +//--></SCRIPT> +<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!-- + var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0))); +//--></SCRIPT></COMMENT> + +<SCRIPT LANGUAGE="JavaScript"><!-- + if (_ie == true) document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = 400 HEIGHT = 400 codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0"><NOEMBED><XMP>'); + else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.3" CODE = "alpha3D.class" WIDTH = 400 HEIGHT = 400 scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html"><NOEMBED><XMP>'); +//--></SCRIPT> +<APPLET CODE = "alpha3D.class" WIDTH = 400 HEIGHT = 400></XMP> +<PARAM NAME = CODE VALUE = "alpha3D.class" >
+ +<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3"> +<PARAM NAME="scriptable" VALUE="false"> + +</APPLET> + +</NOEMBED></EMBED></OBJECT> + + +<!-- +<APPLET CODE = "alpha3D.class" WIDTH = 400 HEIGHT = 400>
+
+
+</APPLET> +--> +<!--"END_CONVERTED_APPLET"-->
+
+<hr>
+</body>
+</html>
diff --git a/demos/MiscDemos/anti.html b/demos/MiscDemos/anti.html new file mode 100644 index 0000000..95146a3 --- /dev/null +++ b/demos/MiscDemos/anti.html @@ -0,0 +1,17 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
+ <title>OpenGL Demo - ported by Sven Goethel</title>
+</head>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+Teapots applet
+<br>Originially written by Silicon Graphics
+<br>Ported to Java by Sven Goethel
+<br>
+<applet code="anti.class" width=400 height=400>
+</applet>
+<hr>
+</body>
+</html>
diff --git a/demos/MiscDemos/anti.java b/demos/MiscDemos/anti.java new file mode 100644 index 0000000..eafb66a --- /dev/null +++ b/demos/MiscDemos/anti.java @@ -0,0 +1,162 @@ +/** + * @(#) anti.java + * @(#) author: Silicon Graphics, Inc. (converted to Java by Ron Cemer) + */ + +/* + * This program demonstrates lots of material properties. + * A single light source illuminates the objects. + */ + +import java.applet.*; +import java.awt.*; +import java.awt.event.*; +import java.lang.*; +import java.util.*; +import java.io.*; +import java.util.*; +import gl4java.GLContext; +import gl4java.awt.GLCanvas; + +import gl4java.utils.glut.*; + +public class anti extends Applet +{ + antiCanvas canvas = null; + + + /* Initialize the applet */ + + + public void init() + { + Dimension d = getSize(); + setLayout(new BorderLayout()); + canvas = new antiCanvas(d.width, d.height); + add("Center", canvas); + } + + + /* Start the applet */ + + + public void start() + { + } + + + /* Stop the applet */ + + + public void stop() + { + } + + public static void main( String args[] ) { + anti applet = + new anti(); + + Frame f = new Frame("anti"); + + f.addWindowListener( new WindowAdapter() + { + public void windowClosed(WindowEvent e) + { + System.exit(0); + } + public void windowClosing(WindowEvent e) + { + windowClosed(e); + } + } + ); + + f.setLayout(new BorderLayout()); + f.add("Center", applet); + applet.setSize(500,300); + applet.init(); + applet.start(); + Dimension ps = applet.getPreferredSize(); + f.setBounds(-100,-100,99,99); + f.setVisible(true); + f.setVisible(false); + Insets i = f.getInsets(); + f.setBounds(0,0, + ps.width+i.left+i.right, + ps.height+i.top+i.bottom); + f.setVisible(true); + } + /* Local GLCanvas extension class */ + + + private class antiCanvas extends GLCanvas + { + GLUTFunc glut = null; + + public antiCanvas(int w, int h) + { + super(w, h); + GLContext.gljNativeDebug = false; + GLContext.gljClassDebug = false; + } + + public void preInit() + { + doubleBuffer = true; + stereoView = false; + } + +/* Initialize antialia(float)Math.sing for RGBA mode, including alpha + * blending, hint, and line width. Print out implementation + * specific info on line width granularity and width. + */ + public void init() + { + glut = new GLUTFuncLightImpl(gl, glu); + + reshape(getSize().width, getSize().height); + + float values[]=new float[2]; + gl.glGetFloatv (GL_LINE_WIDTH_GRANULARITY, values); + System.out.println("GL_LINE_WIDTH_GRANULARITY value is "+values[0]); + + gl.glGetFloatv (GL_LINE_WIDTH_RANGE, values); + System.out.println("GL_LINE_WIDTH_RANGE values are "+ + values[0] + ", " +values[1]); + + gl.glEnable (GL_LINE_SMOOTH); + gl.glEnable (GL_BLEND); + gl.glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + gl.glHint (GL_LINE_SMOOTH_HINT, GL_DONT_CARE); + gl.glLineWidth (1.5f); + + gl.glShadeModel(GL_FLAT); + gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); + gl.glDepthFunc(GL_LESS); + gl.glEnable(GL_DEPTH_TEST); + } + + public void display() + { + if (glj.gljMakeCurrent() == false) return; + gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + gl.glColor4f (1.0f, 1.0f, 1.0f, 1.0f); + glut.glutWireIcosahedron(); + glj.gljSwap(); + glj.gljFree(); + } + + public void reshape(int w, int h) + { + gl.glViewport(0, 0, w, h); + gl.glMatrixMode(GL_PROJECTION); + gl.glLoadIdentity(); + glu.gluPerspective (45.0f, (float) w/(float) h, 3.0f, 5.0f); + + gl.glMatrixMode(GL_MODELVIEW); + gl.glLoadIdentity (); + gl.glTranslatef (0.0f, 0.0f, -4.0f); /* move object into view */ + } + } +} + diff --git a/demos/MiscDemos/anti_plugin13.html b/demos/MiscDemos/anti_plugin13.html new file mode 100644 index 0000000..1800131 --- /dev/null +++ b/demos/MiscDemos/anti_plugin13.html @@ -0,0 +1,48 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
+ <title>OpenGL Demo - ported by Sven Goethel</title>
+</head>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+Teapots applet
+<br>Originially written by Silicon Graphics
+<br>Ported to Java by Sven Goethel
+<br>
+<!--"CONVERTED_APPLET"-->
+<!-- CONVERTER VERSION 1.3 --> +<SCRIPT LANGUAGE="JavaScript"><!-- + var _info = navigator.userAgent; var _ns = false; + var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0); +//--></SCRIPT> +<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!-- + var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0))); +//--></SCRIPT></COMMENT> + +<SCRIPT LANGUAGE="JavaScript"><!-- + if (_ie == true) document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = 400 HEIGHT = 400 codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0"><NOEMBED><XMP>'); + else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.3" CODE = "anti.class" WIDTH = 400 HEIGHT = 400 scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html"><NOEMBED><XMP>'); +//--></SCRIPT> +<APPLET CODE = "anti.class" WIDTH = 400 HEIGHT = 400></XMP> +<PARAM NAME = CODE VALUE = "anti.class" >
+ +<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3"> +<PARAM NAME="scriptable" VALUE="false"> + +</APPLET> + +</NOEMBED></EMBED></OBJECT> + + +<!-- +<APPLET CODE = "anti.class" WIDTH = 400 HEIGHT = 400>
+
+
+</APPLET> +--> +<!--"END_CONVERTED_APPLET"-->
+
+<hr>
+</body>
+</html>
diff --git a/demos/MiscDemos/coloredCross.java b/demos/MiscDemos/coloredCross.java new file mode 100644 index 0000000..52cab5b --- /dev/null +++ b/demos/MiscDemos/coloredCross.java @@ -0,0 +1,111 @@ +import gl4java.awt.*; +import java.applet.*; +import java.awt.*; +import java.awt.Dimension; +import java.awt.event.*; +import java.lang.*; +import java.util.*; +import gl4java.*; + +public class coloredCross extends Applet +{ + MyCanvas canvas = null; + + public void init() + { + Dimension d = getSize(); + setLayout(new BorderLayout()); + canvas = new MyCanvas (d.width, d.height); + add("Center", canvas); + } + + public static void main( String args[] ) + { + Frame mainFrame = new Frame("coloredCross"); + + coloredCross applet = new coloredCross(); + + applet.setSize(400, 400); + applet.init(); + applet.start(); + + mainFrame.add(applet); + + mainFrame.pack(); + mainFrame.setVisible(true); + } + + public void start() + { + } + + + public void stop() + { + } + + protected class MyCanvas extends GLCanvas + { + public MyCanvas(int w, int h) { + super(w,h); + GLContext.gljNativeDebug = false; + GLContext.gljClassDebug = false; + } + + public void init() { + reshape(getSize().width, getSize().height); + } + + public void display() + { + /* Standard GL4Java Init */ + if( glj.gljMakeCurrent() == false ) + { + System.out.println("problem in use() method"); + return; + } + + System.out.println("display()"); + + gl.glPushMatrix(); + gl.glClear(GL_COLOR_BUFFER_BIT); + + gl.glBegin(GLEnum.GL_LINES); + gl.glColor4f(0f, 0f, 1f, 1f); + gl.glVertex3i( 0, 0, 0); + gl.glVertex3i( 10, 10, 0); + + gl.glColor4f(0f, 1f, 0f, 1f); + gl.glVertex3i( 0, 10, 0); + gl.glVertex3i( 10, 0, 0); + + gl.glColor4f(1f, 0f, 0f, 1f); + gl.glVertex3i( 0, 5, 0); + gl.glVertex3i( 10, 5, 0); + + gl.glColor4f(1f, 1f, 1f, 1f); + gl.glVertex3i( 5, 0, 0); + gl.glVertex3i( 5, 10, 0); + gl.glEnd(); + + gl.glPopMatrix(); + + /* For your animation dutys ;-) */ + glj.gljSwap(); + glj.gljCheckGL(); + glj.gljFree(); + + System.out.println("display() done"); + + } + + public void reshape( int width, int height ) + { + gl.glViewport(0, 0, width, height); + gl.glMatrixMode(GL_PROJECTION); + gl.glLoadIdentity(); + gl.glOrtho(0, 10, 0, 10, -50.0,50.0); + gl.glMatrixMode(GL_MODELVIEW); + } + } +} diff --git a/demos/MiscDemos/depthcue.html b/demos/MiscDemos/depthcue.html new file mode 100644 index 0000000..53cba75 --- /dev/null +++ b/demos/MiscDemos/depthcue.html @@ -0,0 +1,17 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
+ <title>OpenGL Demo - ported by Sven Goethel</title>
+</head>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+Teapots applet
+<br>Originially written by Silicon Graphics
+<br>Ported to Java by Sven Goethel
+<br>
+<applet code="depthcue.class" width=400 height=400>
+</applet>
+<hr>
+</body>
+</html>
diff --git a/demos/MiscDemos/depthcue.java b/demos/MiscDemos/depthcue.java new file mode 100644 index 0000000..3b6f04b --- /dev/null +++ b/demos/MiscDemos/depthcue.java @@ -0,0 +1,140 @@ +/** + * @(#) depthcue.java + * @(#) author: Silicon Graphics, Inc. (converted to Java by Ron Cemer) + */ + +/* + * This program demonstrates lots of material properties. + * A single light source illuminates the objects. + */ + +import java.applet.*; +import java.awt.*; +import java.awt.event.*; +import java.lang.*; +import java.util.*; +import java.io.*; +import java.util.*; +import gl4java.GLContext; +import gl4java.awt.GLCanvas; + +import gl4java.utils.glut.*; + +public class depthcue extends Applet +{ + depthcueCanvas canvas = null; + + + /* Initialize the applet */ + + + public void init() + { + Dimension d = getSize(); + setLayout(new BorderLayout()); + canvas = new depthcueCanvas(d.width, d.height); + add("Center", canvas); + } + + + /* Start the applet */ + + + public void start() + { + } + + + /* Stop the applet */ + + + public void stop() + { + } + + public static void main( String args[] ) + { + Frame mainFrame = new Frame("teapots"); + + depthcue applet = new depthcue(); + + applet.setSize(400, 400); + applet.init(); + applet.start(); + + mainFrame.add(applet); + + mainFrame.pack(); + mainFrame.setVisible(true); + } + + + /* Local GLCanvas extension class */ + + + private class depthcueCanvas extends GLCanvas + { + GLUTFunc glut = null; + + public depthcueCanvas(int w, int h) + { + super(w, h); + GLContext.gljNativeDebug = false; + GLContext.gljClassDebug = false; + } + + public void preInit() + { + doubleBuffer = true; + stereoView = false; + } + +/* Initialize depthcuealia(float)Math.sing for RGBA mode, including alpha + * blending, hint, and line width. Print out implementation + * specific info on line width granularity and width. + */ + public void init() + { + glut = new GLUTFuncLightImpl(gl, glu); + + reshape(getSize().width, getSize().height); + + float fogColor[] = {0.0f, 0.0f, 0.0f, 1.0f}; + + gl.glEnable(GL_FOG); + gl.glFogi (GL_FOG_MODE, GL_LINEAR); + gl.glHint (GL_FOG_HINT, GL_NICEST); /* per pixel */ + gl.glFogf (GL_FOG_START, 3.0f); + gl.glFogf (GL_FOG_END, 5.0f); + gl.glFogfv (GL_FOG_COLOR, fogColor); + gl.glClearColor(0.0f, 0.0f, 0.0f, 1.0f); + + gl.glShadeModel(GL_FLAT); + gl.glDepthFunc(GL_LESS); + gl.glEnable(GL_DEPTH_TEST); + } + + public void display() + { + if (glj.gljMakeCurrent() == false) return; + gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + gl.glColor3f (1.0f, 1.0f, 1.0f); + glut.glutWireIcosahedron(); + glj.gljSwap(); + glj.gljFree(); + } + + public void reshape(int w, int h) + { + gl.glViewport(0, 0, w, h); + gl.glMatrixMode(GL_PROJECTION); + gl.glLoadIdentity(); + glu.gluPerspective (45.0f, (float) w/(float) h, 3.0f, 5.0f); + + gl.glMatrixMode(GL_MODELVIEW); + gl.glLoadIdentity (); + gl.glTranslatef (0.0f, 0.0f, -4.0f); /* move object into view */ + } + } +} + diff --git a/demos/MiscDemos/depthcue_plugin13.html b/demos/MiscDemos/depthcue_plugin13.html new file mode 100644 index 0000000..a4b4a9e --- /dev/null +++ b/demos/MiscDemos/depthcue_plugin13.html @@ -0,0 +1,48 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
+ <title>OpenGL Demo - ported by Sven Goethel</title>
+</head>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+Teapots applet
+<br>Originially written by Silicon Graphics
+<br>Ported to Java by Sven Goethel
+<br>
+<!--"CONVERTED_APPLET"-->
+<!-- CONVERTER VERSION 1.3 --> +<SCRIPT LANGUAGE="JavaScript"><!-- + var _info = navigator.userAgent; var _ns = false; + var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0); +//--></SCRIPT> +<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!-- + var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0))); +//--></SCRIPT></COMMENT> + +<SCRIPT LANGUAGE="JavaScript"><!-- + if (_ie == true) document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = 400 HEIGHT = 400 codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0"><NOEMBED><XMP>'); + else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.3" CODE = "depthcue.class" WIDTH = 400 HEIGHT = 400 scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html"><NOEMBED><XMP>'); +//--></SCRIPT> +<APPLET CODE = "depthcue.class" WIDTH = 400 HEIGHT = 400></XMP> +<PARAM NAME = CODE VALUE = "depthcue.class" >
+ +<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3"> +<PARAM NAME="scriptable" VALUE="false"> + +</APPLET> + +</NOEMBED></EMBED></OBJECT> + + +<!-- +<APPLET CODE = "depthcue.class" WIDTH = 400 HEIGHT = 400>
+
+
+</APPLET> +--> +<!--"END_CONVERTED_APPLET"-->
+
+<hr>
+</body>
+</html>
diff --git a/demos/MiscDemos/gears.html b/demos/MiscDemos/gears.html new file mode 100644 index 0000000..56ebd8e --- /dev/null +++ b/demos/MiscDemos/gears.html @@ -0,0 +1,13 @@ +<HTML> +<HEAD> +<TITLE>Göthel Hard- und Software Entwicklungen</TITLE> +</HEAD> +<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff"> +<hr> +<applet code="gears.class" width=550 height=400> +<param name=frames value="55"> +</applet> +<hr> +</BODY> +</HTML> + diff --git a/demos/MiscDemos/gears.java b/demos/MiscDemos/gears.java new file mode 100644 index 0000000..b61d711 --- /dev/null +++ b/demos/MiscDemos/gears.java @@ -0,0 +1,437 @@ +/**
+ * @(#) gears.java
+ * @(#) author: Brian Paul (converted to Java by Ron Cemer and Sven Goethel)
+ *
+ * This version is equal to Brian Paul's version 1.2 1999/10/21
+ */
+
+import java.applet.*;
+import java.awt.*;
+import java.awt.event.*;
+import java.lang.*;
+import java.util.*;
+import java.io.*;
+import java.util.*;
+import gl4java.GLContext;
+import gl4java.GLEnum;
+import gl4java.awt.GLAnimCanvas;
+import gl4java.applet.SimpleGLAnimApplet1;
+
+public class gears extends SimpleGLAnimApplet1
+{
+
+ /* Initialize the applet */
+
+
+ public void init()
+ {
+ init(false);
+ }
+
+ public void init(boolean showGL)
+ {
+ super.init();
+ Dimension d = getSize();
+ canvas = new gearsCanvas(showGL, d.width, d.height);
+ add("Center", canvas);
+ }
+
+
+ public static void main( String args[] )
+ {
+ int i = 0;
+ String glLib = null;
+ String gluLib = null;
+ boolean perftest=false;
+
+ while(args.length>i)
+ {
+ if(args[i].equals("-perftest"))
+ {
+ perftest=true;
+ } else if(args[i].equals("-glLib"))
+ {
+ i++;
+ if(args.length>i)
+ glLib=args[i];
+ } else if(args[i].equals("-gluLib"))
+ {
+ i++;
+ if(args.length>i)
+ gluLib=args[i];
+ } else {
+ System.out.println("illegal arg "+i+": "+args[i]);
+ }
+ i++;
+ }
+
+ if(!perftest)
+ {
+ GLContext.gljNativeDebug = true;
+ GLContext.gljClassDebug = true;
+ }
+
+ System.out.println("loading libs(gl, glu): "+
+ glLib+", "+gluLib+": "+
+ GLContext.loadNativeLibraries(null, glLib, gluLib));
+
+ Frame mainFrame = new Frame("gears");
+
+ gears applet = new gears();
+
+ applet.setSize(300, 300);
+ applet.init(true);
+
+ if(perftest)
+ {
+ applet.canvas.setUseFpsSleep(false);
+ applet.canvas.setUseRepaint(false);
+ System.out.println("useFpsSleep: "+
+ applet.canvas.getUseFpsSleep());
+ System.out.println("useRepaint: "+
+ applet.canvas.getUseRepaint());
+ }
+
+ applet.start();
+
+ mainFrame.add(applet);
+
+ mainFrame.pack();
+ mainFrame.setVisible(true);
+ }
+
+
+ /* Local GLAnimCanvas extension class */
+
+
+ private class gearsCanvas extends GLAnimCanvas implements MouseListener, MouseMotionListener
+ {
+ private static final float M_PI = 3.14159265f;
+
+ private long T0 = 0;
+ private long Frames = 0;
+
+ private float view_rotx = 20.0f, view_roty = 30.0f, view_rotz = 0.0f;
+ private int gear1, gear2, gear3;
+ private float angle = 0.0f;
+
+ private int prevMouseX, prevMouseY;
+ private boolean mouseRButtonDown = false;
+
+ private boolean showGL = false;
+
+ public gearsCanvas(int w, int h)
+ {
+ this(false, w, h);
+ }
+
+ public gearsCanvas(boolean showGL, int w, int h)
+ {
+ super(w, h);
+ setAnimateFps(30.0);
+
+ this.showGL=showGL;
+ }
+
+ public void preInit()
+ {
+ doubleBuffer = true;
+ stereoView = false;
+ }
+
+ public void init()
+ {
+ reshape(getSize().width, getSize().height);
+
+ float pos[] = { 5.0f, 5.0f, 10.0f, 0.0f };
+ float red[] = { 0.8f, 0.1f, 0.0f, 1.0f };
+ float green[] = { 0.0f, 0.8f, 0.2f, 1.0f };
+ float blue[] = { 0.2f, 0.2f, 1.0f, 1.0f };
+
+ gl.glLightfv(GL_LIGHT0, GL_POSITION, pos);
+ gl.glEnable(GL_CULL_FACE);
+ gl.glEnable(GL_LIGHTING);
+ gl.glEnable(GL_LIGHT0);
+ gl.glEnable(GL_DEPTH_TEST);
+
+ /* make the gears */
+ gear1 = gl.glGenLists(1);
+ gl.glNewList(gear1, GL_COMPILE);
+ gl.glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red);
+ gear(1.0f, 4.0f, 1.0f, 20, 0.7f);
+ gl.glEndList();
+
+ gear2 = gl.glGenLists(1);
+ gl.glNewList(gear2, GL_COMPILE);
+ gl.glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green);
+ gear(0.5f, 2.0f, 2.0f, 10, 0.7f);
+ gl.glEndList();
+
+ gear3 = gl.glGenLists(1);
+ gl.glNewList(gear3, GL_COMPILE);
+ gl.glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue);
+ gear(1.3f, 2.0f, 0.5f, 10, 0.7f);
+ gl.glEndList();
+
+ gl.glEnable(GL_NORMALIZE);
+
+ glj.gljCheckGL();
+
+ addMouseListener(this);
+ addMouseMotionListener(this);
+
+ T0=System.currentTimeMillis();
+ }
+
+ public void doCleanup()
+ {
+ System.out.println("destroy(): " + this);
+ removeMouseListener(this);
+ removeMouseMotionListener(this);
+ }
+
+ public void reshape(int width, int height)
+ {
+ float h = (float)height / (float)width;
+
+ gl.glViewport(0,0,width,height);
+ gl.glMatrixMode(GL_PROJECTION);
+ gl.glLoadIdentity();
+ gl.glFrustum(-1.0f, 1.0f, -h, h, 5.0f, 60.0f);
+ gl.glMatrixMode(GL_MODELVIEW);
+ gl.glLoadIdentity();
+ gl.glTranslatef(0.0f, 0.0f, -40.0f);
+ }
+
+ public void display()
+ {
+ if (glj.gljMakeCurrent() == false) return;
+
+ if(showGL)
+ {
+ showGL=false;
+ System.out.println("GL VERSION : "+gl.glGetString(GL_VERSION));
+ System.out.println("GL RENDERER: "+gl.glGetString(GL_RENDERER));
+ System.out.println("GL VENDOR : "+gl.glGetString(GL_VENDOR));
+ }
+
+ angle += 2.0f;
+
+ gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+ gl.glPushMatrix();
+ gl.glRotatef(view_rotx, 1.0f, 0.0f, 0.0f);
+ gl.glRotatef(view_roty, 0.0f, 1.0f, 0.0f);
+ gl.glRotatef(view_rotz, 0.0f, 0.0f, 1.0f);
+
+ gl.glPushMatrix();
+ gl.glTranslatef(-3.0f, -2.0f, 0.0f);
+ gl.glRotatef(angle, 0.0f, 0.0f, 1.0f);
+ gl.glCallList(gear1);
+ gl.glPopMatrix();
+
+ gl.glPushMatrix();
+ gl.glTranslatef(3.1f, -2.0f, 0.0f);
+ gl.glRotatef(-2.0f * angle - 9.0f, 0.0f, 0.0f, 1.0f);
+ gl.glCallList(gear2);
+ gl.glPopMatrix();
+
+ gl.glPushMatrix();
+ gl.glTranslatef(-3.1f, 4.2f, 0.0f);
+ gl.glRotatef(-2.0f * angle - 25.0f, 0.0f, 0.0f, 1.0f);
+ gl.glCallList(gear3);
+ gl.glPopMatrix();
+
+ gl.glPopMatrix();
+
+ glj.gljSwap();
+ glj.gljCheckGL();
+ glj.gljFree();
+
+ Frames++;
+
+ long t=System.currentTimeMillis();
+ if(t - T0 >= 5000)
+ {
+ double seconds = (double)(t - T0) / 1000.0;
+ double fps = (double)Frames / seconds;
+ System.out.println(Frames+" frames in "+seconds+" seconds = "+
+ fps+" FPS");
+ T0 = t;
+ Frames = 0;
+ }
+ }
+
+ private void gear
+ (float inner_radius,
+ float outer_radius,
+ float width,
+ int teeth,
+ float tooth_depth)
+ {
+ int i;
+ float r0, r1, r2;
+ float angle, da;
+ float u, v, len;
+
+ r0 = inner_radius;
+ r1 = outer_radius - tooth_depth / 2.0f;
+ r2 = outer_radius + tooth_depth / 2.0f;
+
+ da = 2.0f * M_PI / teeth / 4.0f;
+
+ gl.glShadeModel(GL_FLAT);
+
+ gl.glNormal3f(0.0f, 0.0f, 1.0f);
+
+ /* draw front face */
+ gl.glBegin(GL_QUAD_STRIP);
+ for (i = 0; i <= teeth; i++)
+ {
+ angle = i * 2.0f * M_PI / teeth;
+ gl.glVertex3f(r0 * (float)Math.cos(angle), r0 * (float)Math.sin(angle), width * 0.5f);
+ gl.glVertex3f(r1 * (float)Math.cos(angle), r1 * (float)Math.sin(angle), width * 0.5f);
+ if(i < teeth)
+ {
+ gl.glVertex3f(r0 * (float)Math.cos(angle), r0 * (float)Math.sin(angle), width * 0.5f);
+ gl.glVertex3f(r1 * (float)Math.cos(angle + 3.0f * da), r1 * (float)Math.sin(angle + 3.0f * da), width * 0.5f);
+ }
+ }
+ gl.glEnd();
+
+ /* draw front sides of teeth */
+ gl.glBegin(GL_QUADS);
+ for (i = 0; i < teeth; i++)
+ {
+ angle = i * 2.0f * M_PI / teeth;
+ gl.glVertex3f(r1 * (float)Math.cos(angle), r1 * (float)Math.sin(angle), width * 0.5f);
+ gl.glVertex3f(r2 * (float)Math.cos(angle + da), r2 * (float)Math.sin(angle + da), width * 0.5f);
+ gl.glVertex3f(r2 * (float)Math.cos(angle + 2.0f * da), r2 * (float)Math.sin(angle + 2.0f * da), width * 0.5f);
+ gl.glVertex3f(r1 * (float)Math.cos(angle + 3.0f * da), r1 * (float)Math.sin(angle + 3.0f * da), width * 0.5f);
+ }
+ gl.glEnd();
+
+ /* draw back face */
+ gl.glBegin(GL_QUAD_STRIP);
+ for (i = 0; i <= teeth; i++)
+ {
+ angle = i * 2.0f * M_PI / teeth;
+ gl.glVertex3f(r1 * (float)Math.cos(angle), r1 * (float)Math.sin(angle), -width * 0.5f);
+ gl.glVertex3f(r0 * (float)Math.cos(angle), r0 * (float)Math.sin(angle), -width * 0.5f);
+ gl.glVertex3f(r1 * (float)Math.cos(angle + 3 * da), r1 * (float)Math.sin(angle + 3 * da), -width * 0.5f);
+ gl.glVertex3f(r0 * (float)Math.cos(angle), r0 * (float)Math.sin(angle), -width * 0.5f);
+ }
+ gl.glEnd();
+
+ /* draw back sides of teeth */
+ gl.glBegin(GL_QUADS);
+ for (i = 0; i < teeth; i++)
+ {
+ angle = i * 2.0f * M_PI / teeth;
+ gl.glVertex3f(r1 * (float)Math.cos(angle + 3 * da), r1 * (float)Math.sin(angle + 3 * da), -width * 0.5f);
+ gl.glVertex3f(r2 * (float)Math.cos(angle + 2 * da), r2 * (float)Math.sin(angle + 2 * da), -width * 0.5f);
+ gl.glVertex3f(r2 * (float)Math.cos(angle + da), r2 * (float)Math.sin(angle + da), -width * 0.5f);
+ gl.glVertex3f(r1 * (float)Math.cos(angle), r1 * (float)Math.sin(angle), -width * 0.5f);
+ }
+ gl.glEnd();
+
+ /* draw outward faces of teeth */
+ gl.glBegin(GL_QUAD_STRIP);
+ for (i = 0; i < teeth; i++)
+ {
+ angle = i * 2.0f * M_PI / teeth;
+ gl.glVertex3f(r1 * (float)Math.cos(angle), r1 * (float)Math.sin(angle), width * 0.5f);
+ gl.glVertex3f(r1 * (float)Math.cos(angle), r1 * (float)Math.sin(angle), -width * 0.5f);
+ u = r2 * (float)Math.cos(angle + da) - r1 * (float)Math.cos(angle);
+ v = r2 * (float)Math.sin(angle + da) - r1 * (float)Math.sin(angle);
+ len = (float)Math.sqrt(u * u + v * v);
+ u /= len;
+ v /= len;
+ gl.glNormal3f(v, -u, 0.0f);
+ gl.glVertex3f(r2 * (float)Math.cos(angle + da), r2 * (float)Math.sin(angle + da), width * 0.5f);
+ gl.glVertex3f(r2 * (float)Math.cos(angle + da), r2 * (float)Math.sin(angle + da), -width * 0.5f);
+ gl.glNormal3f((float)Math.cos(angle), (float)Math.sin(angle), 0.0f);
+ gl.glVertex3f(r2 * (float)Math.cos(angle + 2 * da), r2 * (float)Math.sin(angle + 2 * da), width * 0.5f);
+ gl.glVertex3f(r2 * (float)Math.cos(angle + 2 * da), r2 * (float)Math.sin(angle + 2 * da), -width * 0.5f);
+ u = r1 * (float)Math.cos(angle + 3 * da) - r2 * (float)Math.cos(angle + 2 * da);
+ v = r1 * (float)Math.sin(angle + 3 * da) - r2 * (float)Math.sin(angle + 2 * da);
+ gl.glNormal3f(v, -u, 0.0f);
+ gl.glVertex3f(r1 * (float)Math.cos(angle + 3 * da), r1 * (float)Math.sin(angle + 3 * da), width * 0.5f);
+ gl.glVertex3f(r1 * (float)Math.cos(angle + 3 * da), r1 * (float)Math.sin(angle + 3 * da), -width * 0.5f);
+ gl.glNormal3f((float)Math.cos(angle), (float)Math.sin(angle), 0.0f);
+ }
+ gl.glVertex3f(r1 * (float)Math.cos(0), r1 * (float)Math.sin(0), width * 0.5f);
+ gl.glVertex3f(r1 * (float)Math.cos(0), r1 * (float)Math.sin(0), -width * 0.5f);
+ gl.glEnd();
+
+ gl.glShadeModel(GL_SMOOTH);
+
+ /* draw inside radius cylinder */
+ gl.glBegin(GL_QUAD_STRIP);
+ for (i = 0; i <= teeth; i++)
+ {
+ angle = i * 2.0f * M_PI / teeth;
+ gl.glNormal3f(-(float)Math.cos(angle), -(float)Math.sin(angle), 0.0f);
+ gl.glVertex3f(r0 * (float)Math.cos(angle), r0 * (float)Math.sin(angle), -width * 0.5f);
+ gl.glVertex3f(r0 * (float)Math.cos(angle), r0 * (float)Math.sin(angle), width * 0.5f);
+ }
+ gl.glEnd();
+ }
+
+ // Methods required for the implementation of MouseListener
+ public void mouseEntered( MouseEvent evt )
+ {
+ }
+
+ public void mouseExited( MouseEvent evt )
+ {
+ }
+
+ public void mousePressed( MouseEvent evt )
+ {
+ prevMouseX = evt.getX();
+ prevMouseY = evt.getY();
+ if ((evt.getModifiers() & evt.BUTTON3_MASK) != 0)
+ {
+ mouseRButtonDown = true;
+ evt.consume();
+ }
+ }
+
+ public void mouseReleased( MouseEvent evt )
+ {
+ if ((evt.getModifiers() & evt.BUTTON3_MASK) != 0)
+ {
+ mouseRButtonDown = false;
+ evt.consume();
+ }
+ }
+
+ public void mouseClicked( MouseEvent evt )
+ {
+ }
+
+ // Methods required for the implementation of MouseMotionListener
+ public void mouseDragged( MouseEvent evt )
+ {
+ int x = evt.getX();
+ int y = evt.getY();
+ Dimension size = getSize();
+
+ float thetaY = 360.0f * ( (float)(x-prevMouseX)/(float)size.width);
+ float thetaX = 360.0f * ( (float)(prevMouseY-y)/(float)size.height);
+
+ prevMouseX = x;
+ prevMouseY = y;
+
+ view_rotx += thetaX;
+ view_roty += thetaY;
+
+ evt.consume();
+ }
+
+ public void mouseMoved( MouseEvent evt )
+ {
+ }
+ }
+}
diff --git a/demos/MiscDemos/gears_plugin13.html b/demos/MiscDemos/gears_plugin13.html new file mode 100644 index 0000000..acaaea5 --- /dev/null +++ b/demos/MiscDemos/gears_plugin13.html @@ -0,0 +1,45 @@ +<HTML> +<HEAD> +<TITLE>Göthel Hard- und Software Entwicklungen</TITLE> +</HEAD> +<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff"> +<hr> +<!--"CONVERTED_APPLET"--> +<!-- CONVERTER VERSION 1.3 --> +<SCRIPT LANGUAGE="JavaScript"><!-- + var _info = navigator.userAgent; var _ns = false; + var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0); +//--></SCRIPT> +<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!-- + var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0))); +//--></SCRIPT></COMMENT> + +<SCRIPT LANGUAGE="JavaScript"><!-- + if (_ie == true) document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = 550 HEIGHT = 400 codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0"><NOEMBED><XMP>'); + else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.3" CODE = "gears.class" WIDTH = 550 HEIGHT = 400 frames = "55" scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html"><NOEMBED><XMP>'); +//--></SCRIPT> +<APPLET CODE = "gears.class" WIDTH = 550 HEIGHT = 400></XMP> +<PARAM NAME = CODE VALUE = "gears.class" > + +<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3"> +<PARAM NAME="scriptable" VALUE="false"> +<PARAM NAME = frames VALUE ="55"> + +</APPLET> + +</NOEMBED></EMBED></OBJECT> + + +<!-- +<APPLET CODE = "gears.class" WIDTH = 550 HEIGHT = 400> +<PARAM NAME = frames VALUE ="55"> + + +</APPLET> +--> +<!--"END_CONVERTED_APPLET"--> + +<hr> +</BODY> +</HTML> + diff --git a/demos/MiscDemos/glJavaFontTest1.java b/demos/MiscDemos/glJavaFontTest1.java new file mode 100644 index 0000000..78ccd39 --- /dev/null +++ b/demos/MiscDemos/glJavaFontTest1.java @@ -0,0 +1,120 @@ +// Font rendering using GL4Java +// by Pontus Lidman +// (c) 2000 MathCore AB + +import gl4java.awt.*; +import javax.swing.*; +import java.awt.Dimension; +import gl4java.GLContext; +import gl4java.GLFunc; + +import java.awt.Font; +import java.awt.Shape; +import java.awt.font.*; +import java.awt.geom.*; + +public class glJavaFontTest1 { + + + protected class MyCanvas extends GLCanvas { + + + public void drawString(String s,double x,double y) { + + Font font=new Font("timesroman",Font.PLAIN,12); + AffineTransform identity=new AffineTransform(); + FontRenderContext frc=new FontRenderContext(identity,false,false); + GlyphVector g=font.createGlyphVector(frc,s); + Shape shp=g.getOutline(); + FlatteningPathIterator path=new FlatteningPathIterator(shp.getPathIterator(identity),0.05); + + double [] coords=new double[6]; + int type; + + while (!path.isDone()) { + type=path.currentSegment(coords); + switch(type) { + case PathIterator.SEG_MOVETO: + gl.glBegin(GL_LINE_STRIP); + gl.glVertex2d(x+coords[0],y+coords[1]); + break; + case PathIterator.SEG_LINETO: + gl.glVertex2d(x+coords[0],y+coords[1]); + break; + case PathIterator.SEG_CLOSE: + gl.glEnd(); + break; + } + path.next(); + } + } + + public MyCanvas(int w, int h) { + super(w,h); + GLContext.gljNativeDebug = false; + GLContext.gljClassDebug = false; + } + + public void init() { + gl.glMatrixMode(GL_PROJECTION); + gl.glOrtho(-50,50,50,-50,-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.glColor3d(1,1,1); + drawString("Hello world!",-40,0); + + + gl.glPopMatrix(); + glj.gljSwap(); + glj.gljCheckGL(); + glj.gljFree(); + } + } + + protected MyCanvas cvs; + protected JFrame frame; + + public glJavaFontTest1() { + frame = new JFrame( "OpenGL" ); + cvs= new MyCanvas(640,480); + frame.setSize(640,480); + frame.getContentPane().add("Center", cvs); + frame.setVisible(true); + } + + public static void main(java.lang.String[] args) { + try { + glJavaFontTest1 g=new glJavaFontTest1(); + } catch (Throwable exception) { + System.err.println("Exception occurred in main()"); + exception.printStackTrace(System.out); + } + } +} diff --git a/demos/MiscDemos/glutFontBitmapTest.html b/demos/MiscDemos/glutFontBitmapTest.html new file mode 100644 index 0000000..d70bcd9 --- /dev/null +++ b/demos/MiscDemos/glutFontBitmapTest.html @@ -0,0 +1,15 @@ +<HTML>
+<HEAD>
+<TITLE>Göthel Hard- und Software Entwicklungen</TITLE>
+</HEAD>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+<br>
+<hr>
+<applet code="glutFontBitmapTest.class" width=600 height=400>
+<param name=frames value="55">
+</applet>
+<hr>
+</BODY>
+</HTML>
+
+
diff --git a/demos/MiscDemos/glutFontBitmapTest.java b/demos/MiscDemos/glutFontBitmapTest.java new file mode 100644 index 0000000..bb2a2a4 --- /dev/null +++ b/demos/MiscDemos/glutFontBitmapTest.java @@ -0,0 +1,137 @@ +// Test program for GLUT Bitmap font rendering functions +// by Pontus Lidman +// Copyright 2000 MathCore AB +// +// This file/package is licensed under the terms of the LPGL +// with the permission of Pontus Lidman / Mathcore ! +// + +import gl4java.utils.glut.*; +import gl4java.utils.glut.fonts.*; + +import gl4java.awt.*; +import java.applet.*; +import java.awt.*; +import java.awt.Dimension; +import gl4java.GLContext; +import gl4java.GLFunc; + +public class glutFontBitmapTest extends Applet { + + protected GLUTFunc glut = null; + + protected class MyCanvas extends GLCanvas + { + + boolean print_tests=false; + + public MyCanvas(int w, int h) { + super(w,h); + GLContext.gljNativeDebug = false; + GLContext.gljClassDebug = false; + } + + public void init() { + glut = new GLUTFuncLightImplWithFonts(gl, glu); + + 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.glColor3d(0.3,0,0); + + gl.glBegin(GL_POLYGON); + gl.glVertex2d(0,-0.5); + gl.glVertex2d(0.5,0.5); + gl.glVertex2d(-0.5,0.5); + gl.glEnd(); + + gl.glColor3d(1,1,1); + gl.glRasterPos2d(-0.2,-0.2); + glut.glutBitmapString(glut.GLUT_BITMAP_8_BY_13,"8x13 Font"); + gl.glRasterPos2d(-0.2,-0.1); + glut.glutBitmapString(glut.GLUT_BITMAP_9_BY_15,"9x15 Font"); + gl.glRasterPos2d(-0.2,0.0); + glut.glutBitmapString(glut.GLUT_BITMAP_HELVETICA_10,"Helvetica 10 Font"); + gl.glRasterPos2d(-0.2,0.1); + glut.glutBitmapString(glut.GLUT_BITMAP_HELVETICA_12,"Helvetica 12 Font"); + gl.glRasterPos2d(-0.2,0.2); + glut.glutBitmapString(glut.GLUT_BITMAP_HELVETICA_18,"Helvetica 18 Font"); + gl.glRasterPos2d(-0.2,0.3); + glut.glutBitmapString(glut.GLUT_BITMAP_TIMES_ROMAN_10,"Times Roman 10 Font"); + gl.glRasterPos2d(-0.2,0.4); + glut.glutBitmapString(glut.GLUT_BITMAP_TIMES_ROMAN_24,"Times Roman 24 Font"); + + gl.glPopMatrix(); + glj.gljSwap(); + glj.gljCheckGL(); + glj.gljFree(); + } + } + + protected MyCanvas cvs; + + public void init() + { + Dimension d = getSize(); + setLayout(new BorderLayout()); + cvs= new MyCanvas(d.width,d.height); + add("Center", cvs); + } + + public void start() + { + } + + + public void stop() + { + } + + public static void main(java.lang.String[] args) { + try { + Frame mainFrame = new Frame("FontTest"); + + glutFontBitmapTest applet=new glutFontBitmapTest(); + + applet.setSize(400, 400); + applet.init(); + applet.start(); + + mainFrame.add(applet); + + mainFrame.pack(); + mainFrame.setVisible(true); + } catch (Throwable exception) { + System.err.println("Exception occurred in main()"); + exception.printStackTrace(System.out); + } + } +} diff --git a/demos/MiscDemos/glutFontBitmapTest2Applet$glutF b/demos/MiscDemos/glutFontBitmapTest2Applet$glutF Binary files differnew file mode 100644 index 0000000..a23aee0 --- /dev/null +++ b/demos/MiscDemos/glutFontBitmapTest2Applet$glutF diff --git a/demos/MiscDemos/glutFontBitmapTest2Applet.html b/demos/MiscDemos/glutFontBitmapTest2Applet.html new file mode 100644 index 0000000..a10559b --- /dev/null +++ b/demos/MiscDemos/glutFontBitmapTest2Applet.html @@ -0,0 +1,16 @@ +<HTML>
+<HEAD>
+<TITLE>Göthel Hard- und Software Entwicklungen</TITLE>
+</HEAD>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+<B>Try to drag the mouse (press-button and move) with/without the SHIFT key!</B>
+<br>
+<hr>
+<applet code="glutFontBitmapTest2Applet.class" width=600 height=400>
+<param name=frames value="55">
+</applet>
+<hr>
+</BODY>
+</HTML>
+
+
diff --git a/demos/MiscDemos/glutFontBitmapTest2Applet.java b/demos/MiscDemos/glutFontBitmapTest2Applet.java new file mode 100644 index 0000000..0985385 --- /dev/null +++ b/demos/MiscDemos/glutFontBitmapTest2Applet.java @@ -0,0 +1,319 @@ +
+import gl4java.*;
+import gl4java.awt.*;
+import gl4java.utils.textures.*;
+import gl4java.utils.glut.*;
+import gl4java.utils.glut.fonts.*;
+
+import java.awt.*;
+import java.awt.event.*;
+import java.applet.*;
+import java.net.*;
+
+public class glutFontBitmapTest2Applet extends Applet
+{
+ glutFontBitmapTest2 canvas = null;
+
+ public void init()
+ {
+ Dimension d = getSize();
+ setLayout(new BorderLayout());
+ canvas = new glutFontBitmapTest2 (d.width, d.height);
+ add("Center", canvas);
+ }
+
+ public void start()
+ {
+ }
+
+
+ public void stop()
+ {
+ }
+
+ public static void main( String args[] )
+ {
+ Frame mainFrame = new Frame("font test 2");
+
+ glutFontBitmapTest2Applet applet =
+ new glutFontBitmapTest2Applet();
+
+ applet.setSize(400, 400);
+ applet.init();
+ applet.start();
+
+ mainFrame.add(applet);
+
+ mainFrame.pack();
+ mainFrame.setVisible(true);
+ }
+
+ class glutFontBitmapTest2 extends GLCanvas
+ implements MouseListener,MouseMotionListener
+ {
+ float []mPosObjTrans;
+ float []mPosObjRot;
+
+ Point mousePoint;
+ Point oldMousePoint;
+ boolean mouseMoveFlag;
+
+ protected GLUTFunc glut = null;
+
+ int texName[] = {0};
+
+ public glutFontBitmapTest2 (int w, int h)
+ {
+ super(w, h);
+ }
+
+ public void init()
+ {
+ glut = new GLUTFuncLightImplWithFonts(gl, glu);
+
+ // cameraMatrix init
+ mPosObjTrans=new float[16];
+ for(int i=0;i<16;i++)
+ mPosObjTrans[i]=0f;
+ mPosObjTrans[0]=mPosObjTrans[5]=mPosObjTrans[10]=mPosObjTrans[15]=1f;
+
+ mPosObjRot=new float[16];
+ for(int i=0;i<16;i++)
+ mPosObjRot[i]=0f;
+ mPosObjRot[0]=mPosObjRot[5]=mPosObjRot[10]=mPosObjRot[15]=1f;
+
+ TranlateObj(0f,0f,-10f);
+
+ gl.glShadeModel (GL_SMOOTH);
+ gl.glEnable(GL_DEPTH_TEST);
+
+ gl.glClearColor(0.2f, 0.2f, 0.2f, 1.0f);
+ gl.glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
+ glj.gljCheckGL();
+
+ canvas.addMouseListener(this);
+ canvas.addMouseMotionListener(this);
+ mouseMoveFlag=false;
+
+ reshape(getSize().width, getSize().height);
+ }
+
+ public void display()
+ {
+ int i;
+
+ /* Standard GL4Java Init */
+ if( glj.gljMakeCurrent() == false )
+ {
+ System.out.println("problem in use() method");
+ return;
+ }
+
+ // just render it
+ gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ SetCamera();
+
+ DrawScene();
+
+ /* For your animation dutys ;-) */
+ glj.gljSwap();
+ glj.gljCheckGL();
+ glj.gljFree();
+ }
+
+ public void reshape(int w, int h)
+ {
+ gl.glMatrixMode (GL_MODELVIEW);
+ gl.glViewport (0, 0, w, h);
+ gl.glLoadIdentity();
+ SetCamera();
+ }
+
+
+ public void drawGrid(float x0, float y0,
+ float width, float height, float step)
+ {
+ float i,j;
+
+ /* draw grid */
+ gl.glBegin(GL_LINES);
+ for(i=x0;i<width;i+=step)
+ for(j=y0;j<height;j+=step)
+ {
+ if(i==0f && j==0f)
+ gl.glColor3f (1f,0f,0f);
+ else
+ gl.glColor3f (0.6f,0.5f,0.5f);
+ gl.glVertex2f(0f,j);
+ gl.glVertex2f(width,j);
+ gl.glVertex2f(i,height);
+ gl.glVertex2f(i,0f);
+ }
+ gl.glEnd();
+ }
+
+ void DrawScene()
+ {
+ gl.glMatrixMode (GL_MODELVIEW);
+ gl.glLoadIdentity ();
+
+ // kamera setzen
+ gl.glLoadMatrixf(mPosObjTrans);
+ gl.glMultMatrixf(mPosObjRot);
+
+ gl.glPushMatrix();
+ drawGrid(0f, 0f, 10f, 10f, 0.5f);
+ gl.glPopMatrix();
+
+ // obj zeichnen
+ gl.glPushMatrix();
+ gl.glColor3d(0.3,0,0);
+
+ gl.glBegin(GL_POLYGON);
+ gl.glVertex2d(0,-0.5);
+ gl.glVertex2d(0.5,0.5);
+ gl.glVertex2d(-0.5,0.5);
+ gl.glEnd();
+
+ gl.glColor3d(1,1,1);
+ gl.glRasterPos2d(-2.2,-1.2);
+ glut.glutBitmapString(glut.GLUT_BITMAP_8_BY_13,"8x13 Font");
+ gl.glRasterPos2d(-2.2,0.2);
+ glut.glutBitmapString(glut.GLUT_BITMAP_9_BY_15,"9x15 Font");
+ gl.glRasterPos2d(-2.2,1.2);
+ glut.glutBitmapString(glut.GLUT_BITMAP_HELVETICA_10,"Helvetica 10 Font");
+ gl.glRasterPos2d(-2.2,2.2);
+ glut.glutBitmapString(glut.GLUT_BITMAP_HELVETICA_12,"Helvetica 12 Font");
+ gl.glRasterPos2d(-2.2,3.2);
+ glut.glutBitmapString(glut.GLUT_BITMAP_HELVETICA_18,"Helvetica 18 Font");
+ gl.glRasterPos2d(-2.2,4.2);
+ glut.glutBitmapString(glut.GLUT_BITMAP_TIMES_ROMAN_10,"Times Roman 10 Font");
+ gl.glRasterPos2d(-2.2,5.2);
+ glut.glutBitmapString(glut.GLUT_BITMAP_TIMES_ROMAN_24,"Times Roman 24 Font");
+ gl.glPopMatrix();
+
+ }
+
+ void SetCamera()
+ {
+ Dimension dim=getSize();
+ float aspect=(float)dim.width/(float)dim.height;
+
+ gl.glMatrixMode (GL_PROJECTION);
+ gl.glLoadIdentity ();
+ glu.gluPerspective(60f,aspect,.01,100);
+ }
+
+ void RotateObj(float degree,
+ float axisX,
+ float axisY,
+ float axisZ)
+ {
+ if( glj.gljMakeCurrent() == false )
+ {
+ System.out.println("problem in use() method");
+ return;
+ }
+
+ gl.glMatrixMode (GL_MODELVIEW);
+ gl.glLoadIdentity ();
+
+ // kamera setzen
+ gl.glRotatef(degree,axisX,axisY,axisZ);
+ gl.glMultMatrixf(mPosObjRot);
+ gl.glGetFloatv(GL_MODELVIEW_MATRIX,mPosObjRot);
+
+ repaint();
+ }
+
+ void TranlateObj(float x,float y,float z)
+ {
+ if( glj.gljMakeCurrent() == false )
+ {
+ System.out.println("problem in use() method");
+ return;
+ }
+
+ gl.glMatrixMode (GL_MODELVIEW);
+ gl.glLoadIdentity ();
+
+ // kamera setzen
+ gl.glLoadMatrixf(mPosObjTrans);
+ gl.glTranslatef(x,y,z);
+ gl.glGetFloatv(GL_MODELVIEW_MATRIX,mPosObjTrans);
+
+ repaint();
+ }
+
+ // entfernt rotationen aus aktueller matrix
+ double Billboard()
+ {
+ float[] mat=new float[16];
+
+ gl.glGetFloatv(GL_MODELVIEW_MATRIX,mat);
+ mat[0] = mat[5] = mat[10] = 1;
+ mat[1] = mat[2] = mat[4] = mat[6] = mat[8] = mat[9] = 0;
+ gl.glLoadMatrixf(mat);
+
+ return mat[14];
+ }
+
+ // Methods required for the implementation of MouseListener
+ public void mouseEntered( MouseEvent evt )
+ {
+ }
+
+ public void mouseExited( MouseEvent evt )
+ {
+ }
+
+ public void mousePressed( MouseEvent evt )
+ {
+ if(mouseMoveFlag==false)
+ { // start drag
+ mouseMoveFlag=true;
+ mousePoint=evt.getPoint();
+ }
+ }
+
+ public void mouseReleased( MouseEvent evt )
+ {
+ mouseMoveFlag=false;
+ }
+
+ public void mouseClicked( MouseEvent evt )
+ {
+ Component comp = evt.getComponent();
+ }
+
+ public void mouseDragged(MouseEvent e)
+ {
+ if(mouseMoveFlag==true)
+ {
+ oldMousePoint=new Point(mousePoint);
+ mousePoint=e.getPoint();
+
+ Point dif=new Point(mousePoint.x-oldMousePoint.x,
+ mousePoint.y-oldMousePoint.y);
+
+ if(e.isShiftDown()==true)
+ TranlateObj((float)dif.x/6.0f,(float)dif.y/-6.0f,0f);
+ else if(e.isAltDown()==true)
+ {
+ TranlateObj(0f,0f,(float)dif.y/6.0f);
+ RotateObj(dif.x,0f,0f,1f);
+ }
+ else
+ {
+ RotateObj(dif.x,0f,1f,0f);
+ RotateObj(dif.y,1f,0f,0f);
+ }
+ }
+ }
+ public void mouseMoved(MouseEvent e)
+ {
+ }
+
+
+ }
+}
diff --git a/demos/MiscDemos/glutFontBitmapTest2Applet_plugin13.html b/demos/MiscDemos/glutFontBitmapTest2Applet_plugin13.html new file mode 100644 index 0000000..2acee05 --- /dev/null +++ b/demos/MiscDemos/glutFontBitmapTest2Applet_plugin13.html @@ -0,0 +1,48 @@ +<HTML>
+<HEAD>
+<TITLE>Göthel Hard- und Software Entwicklungen</TITLE>
+</HEAD>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+<B>Try to drag the mouse (press-button and move) with/without the SHIFT key!</B>
+<br>
+<hr>
+<!--"CONVERTED_APPLET"-->
+<!-- CONVERTER VERSION 1.3 --> +<SCRIPT LANGUAGE="JavaScript"><!-- + var _info = navigator.userAgent; var _ns = false; + var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0); +//--></SCRIPT> +<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!-- + var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0))); +//--></SCRIPT></COMMENT> + +<SCRIPT LANGUAGE="JavaScript"><!-- + if (_ie == true) document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = 600 HEIGHT = 400 codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0"><NOEMBED><XMP>'); + else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.3" CODE = "glutFontBitmapTest2Applet.class" WIDTH = 600 HEIGHT = 400 frames = "55" scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html"><NOEMBED><XMP>'); +//--></SCRIPT> +<APPLET CODE = "glutFontBitmapTest2Applet.class" WIDTH = 600 HEIGHT = 400></XMP> +<PARAM NAME = CODE VALUE = "glutFontBitmapTest2Applet.class" >
+ +<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3"> +<PARAM NAME="scriptable" VALUE="false"> +<PARAM NAME = frames VALUE ="55">
+ +</APPLET> + +</NOEMBED></EMBED></OBJECT> + + +<!-- +<APPLET CODE = "glutFontBitmapTest2Applet.class" WIDTH = 600 HEIGHT = 400>
+<PARAM NAME = frames VALUE ="55">
+
+
+</APPLET> +--> +<!--"END_CONVERTED_APPLET"-->
+
+<hr>
+</BODY>
+</HTML>
+
+
diff --git a/demos/MiscDemos/glutFontBitmapTest_plugin13.html b/demos/MiscDemos/glutFontBitmapTest_plugin13.html new file mode 100644 index 0000000..2c747d1 --- /dev/null +++ b/demos/MiscDemos/glutFontBitmapTest_plugin13.html @@ -0,0 +1,47 @@ +<HTML>
+<HEAD>
+<TITLE>Göthel Hard- und Software Entwicklungen</TITLE>
+</HEAD>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+<br>
+<hr>
+<!--"CONVERTED_APPLET"-->
+<!-- CONVERTER VERSION 1.3 --> +<SCRIPT LANGUAGE="JavaScript"><!-- + var _info = navigator.userAgent; var _ns = false; + var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0); +//--></SCRIPT> +<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!-- + var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0))); +//--></SCRIPT></COMMENT> + +<SCRIPT LANGUAGE="JavaScript"><!-- + if (_ie == true) document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = 600 HEIGHT = 400 codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0"><NOEMBED><XMP>'); + else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.3" CODE = "glutFontBitmapTest.class" WIDTH = 600 HEIGHT = 400 frames = "55" scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html"><NOEMBED><XMP>'); +//--></SCRIPT> +<APPLET CODE = "glutFontBitmapTest.class" WIDTH = 600 HEIGHT = 400></XMP> +<PARAM NAME = CODE VALUE = "glutFontBitmapTest.class" >
+ +<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3"> +<PARAM NAME="scriptable" VALUE="false"> +<PARAM NAME = frames VALUE ="55">
+ +</APPLET> + +</NOEMBED></EMBED></OBJECT> + + +<!-- +<APPLET CODE = "glutFontBitmapTest.class" WIDTH = 600 HEIGHT = 400>
+<PARAM NAME = frames VALUE ="55">
+
+
+</APPLET> +--> +<!--"END_CONVERTED_APPLET"-->
+
+<hr>
+</BODY>
+</HTML>
+
+
diff --git a/demos/MiscDemos/glutFontStrokeTest.html b/demos/MiscDemos/glutFontStrokeTest.html new file mode 100644 index 0000000..0264ee6 --- /dev/null +++ b/demos/MiscDemos/glutFontStrokeTest.html @@ -0,0 +1,15 @@ +<HTML>
+<HEAD>
+<TITLE>Göthel Hard- und Software Entwicklungen</TITLE>
+</HEAD>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+<br>
+<hr>
+<applet code="glutFontStrokeTest.class" width=600 height=400>
+<param name=frames value="55">
+</applet>
+<hr>
+</BODY>
+</HTML>
+
+
diff --git a/demos/MiscDemos/glutFontStrokeTest.java b/demos/MiscDemos/glutFontStrokeTest.java new file mode 100644 index 0000000..27d95fc --- /dev/null +++ b/demos/MiscDemos/glutFontStrokeTest.java @@ -0,0 +1,128 @@ +// Test program for GLUT Stroke font rendering functions +// by Pontus Lidman +// Copyright 2000 MathCore AB +// +// This file/package is licensed under the terms of the LPGL +// with the permission of Pontus Lidman / Mathcore ! +// + +import gl4java.utils.glut.*; +import gl4java.utils.glut.fonts.*; + +import gl4java.awt.*; +import java.applet.*; +import java.awt.*; +import java.awt.Dimension; +import gl4java.GLContext; +import gl4java.GLFunc; + +public class glutFontStrokeTest extends Applet { + + protected GLUTFunc glut = null; + + protected class MyCanvas extends GLCanvas { + + public MyCanvas(int w, int h) { + super(w,h); + GLContext.gljNativeDebug = false; + GLContext.gljClassDebug = false; + } + + public void init() { + glut = new GLUTFuncLightImplWithFonts(gl, glu); + + gl.glMatrixMode(GL_PROJECTION); + gl.glOrtho(-1000,1000,-1000,1000,-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.glColor3d(0.3,0,0); + + gl.glBegin(GL_POLYGON); + gl.glVertex2d(0,-0.5); + gl.glVertex2d(0.5,0.5); + gl.glVertex2d(-0.5,0.5); + gl.glEnd(); + + gl.glColor3d(1,1,1); + gl.glPushMatrix(); + gl.glTranslated(-900,-100,0); + glut.glutStrokeString(glut.GLUT_STROKE_ROMAN,"Roman Font"); + gl.glPopMatrix(); + gl.glPushMatrix(); + gl.glTranslated(-900,100,0); + glut.glutStrokeString(glut.GLUT_STROKE_MONO_ROMAN,"Mono Roman Font"); + gl.glPopMatrix(); + + gl.glPopMatrix(); + glj.gljSwap(); + glj.gljCheckGL(); + glj.gljFree(); + } + } + + protected MyCanvas cvs; + + public void init() + { + Dimension d = getSize(); + setLayout(new BorderLayout()); + cvs= new MyCanvas(d.width,d.height); + add("Center", cvs); + } + + public void start() + { + } + + + public void stop() + { + } + + public static void main(java.lang.String[] args) { + try { + Frame mainFrame = new Frame("Stroke Test"); + + glutFontStrokeTest applet=new glutFontStrokeTest(); + + applet.setSize(400, 400); + applet.init(); + applet.start(); + + mainFrame.add(applet); + + mainFrame.pack(); + mainFrame.setVisible(true); + } catch (Throwable exception) { + System.err.println("Exception occurred in main()"); + exception.printStackTrace(System.out); + } + } +} diff --git a/demos/MiscDemos/glutFontStrokeTest_plugin13.html b/demos/MiscDemos/glutFontStrokeTest_plugin13.html new file mode 100644 index 0000000..6c74a92 --- /dev/null +++ b/demos/MiscDemos/glutFontStrokeTest_plugin13.html @@ -0,0 +1,47 @@ +<HTML>
+<HEAD>
+<TITLE>Göthel Hard- und Software Entwicklungen</TITLE>
+</HEAD>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+<br>
+<hr>
+<!--"CONVERTED_APPLET"-->
+<!-- CONVERTER VERSION 1.3 --> +<SCRIPT LANGUAGE="JavaScript"><!-- + var _info = navigator.userAgent; var _ns = false; + var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0); +//--></SCRIPT> +<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!-- + var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0))); +//--></SCRIPT></COMMENT> + +<SCRIPT LANGUAGE="JavaScript"><!-- + if (_ie == true) document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = 600 HEIGHT = 400 codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0"><NOEMBED><XMP>'); + else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.3" CODE = "glutFontStrokeTest.class" WIDTH = 600 HEIGHT = 400 frames = "55" scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html"><NOEMBED><XMP>'); +//--></SCRIPT> +<APPLET CODE = "glutFontStrokeTest.class" WIDTH = 600 HEIGHT = 400></XMP> +<PARAM NAME = CODE VALUE = "glutFontStrokeTest.class" >
+ +<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3"> +<PARAM NAME="scriptable" VALUE="false"> +<PARAM NAME = frames VALUE ="55">
+ +</APPLET> + +</NOEMBED></EMBED></OBJECT> + + +<!-- +<APPLET CODE = "glutFontStrokeTest.class" WIDTH = 600 HEIGHT = 400>
+<PARAM NAME = frames VALUE ="55">
+
+
+</APPLET> +--> +<!--"END_CONVERTED_APPLET"-->
+
+<hr>
+</BODY>
+</HTML>
+
+
diff --git a/demos/MiscDemos/index.html b/demos/MiscDemos/index.html new file mode 100644 index 0000000..0c01565 --- /dev/null +++ b/demos/MiscDemos/index.html @@ -0,0 +1,78 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en"> +<html> +<head> + <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> + <meta name="Author" content="Ron Cemer & Sven Goethel"> + <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]"> + <title>Misc Demos</title> +</head> +<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff"> +<p>Here are the demos-II for <B> GL4Java >= 2.4.0.0: </B> <br> +<br> +<p><a href="index_plugin13.html">To use the Java2 Plug-In (Java2, JRE, Plug-In 1.3), click here !</a><br> +<br> +<B>Try to use the right-mouse-button for a pop-up menu within the demos !</B> +<br> +<p> <a href="TriangleRotate.html">TriangleRotate</a> +: TriangleRotate at 500x300 +<p> <a href="DrawColoredPrimitives.html">DrawColoredPrimitives</a> +: DrawColoredPrimitives at 500x300 +<p> <a href="DrawColoredPrimitives2.html">DrawColoredPrimitives2</a> +: DrawColoredPrimitives2 at 500x300 +<p> <a href="nurbs.html">nurbs</a> +: nurbs at 500x300 +<p> <a href="spectex.html">spectex</a> +: spectex at 400x400 +<p> <a href="morph3d.html">morph3d</a> +: morph3d at 400x400 +<p> <a href="gears.html">gears</a> +: gears at 400x400 +<br> +<br> +<p> <a href="accanti.html">accanti</a> +: accanti at 400x400 (GLUT DEMO) +<p> <a href="alpha3D.html">alpha3D</a> +: alpha3D at 400x400 (GLUT DEMO) +<p> <a href="anti.html">anti</a> +: anti at 400x400 (GLUT DEMO) +<p> <a href="depthcue.html">depthcue</a> +: depthcue at 400x400 (GLUT DEMO) +<p> <a href="teaambient.html">teaambient</a> +: teaambient at 400x400 (GLUT DEMO) +<p> <a href="teapots.html">teapots</a> +: teapots at 400x400 (GLUT DEMO) +<br> +<br> +<p> <a href="pngTextureTestApplet.html">pngTextureTestApplet</a> +: png texture test at 600x400 (GLUT DEMO) +<br> +<br> +<br> <a href="stencil.html">Stencil Test</a> +: test/shows geometry with 0 and 8 stencil-bits +<p> <a href="glutFontStrokeTest.html">GLUT Font Stroke 1</a> +: GLUT Font Stroke 1 (GLUT DEMO) +<p> <a href="glutFontBitmapTest.html">GLUT Font Bitmap 1</a> +: GLUT Font Bitmap 1 (GLUT DEMO) +<p> <a href="glutFontBitmapTest2Applet.html">GLUT Font Bitmap 2</a> +: GLUT Font Bitmap 2 (GLUT DEMO) +<br> +<br> +<br> <a href="tess.html">Tessellator Demo 1</a> +: test/shows 2 tesselated geometries +<br> <a href="tesswind.html">Tessellator Demo 2</a> +: test/shows tesselated geometries with different winding rules +<br> <a href="tessdemo.html">Tessellator Demo 3</a> +: test/shows self created tesselated geometries +<br> +<br> +<br> <a href="SharedGLTest2.html">Shared GL-Context</a> +: test/shows the usage of a shared GLContext for Display-Lists +<br> +<br> +<br> <a href="select.html">Selection Demo 1</a> +: test/shows selection +<br> +<br> +<br> +</body> +</html> diff --git a/demos/MiscDemos/index_plugin13.html b/demos/MiscDemos/index_plugin13.html new file mode 100644 index 0000000..082aab8 --- /dev/null +++ b/demos/MiscDemos/index_plugin13.html @@ -0,0 +1,80 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en"> +<html> +<head> + <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> + <meta name="Author" content="Ron Cemer & Sven Goethel"> + <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]"> + <title>Misc Demos</title> +</head> +<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff"> +<p>Here are the demos-II for <B> GL4Java >= 2.4.0.0: & Java2 Plug-In 1.3</B> +<hr> +<br> +<a href="../../Installer/java.policy">The Java2 (sdk, jre, plugin 1.3) policy file example to give GL4Java the necessary permissions (Click here) !</a> +<br> +<hr> +<B>Try to use the right-mouse-button for a pop-up menu within the demos !</B> +<br> +<p> <a href="TriangleRotate_plugin13.html">TriangleRotate</a> +: TriangleRotate at 500x300 +<p> <a href="DrawColoredPrimitives_plugin13.html">DrawColoredPrimitives</a> +: DrawColoredPrimitives at 500x300 +<p> <a href="DrawColoredPrimitives2_plugin13.html">DrawColoredPrimitives2</a> +: DrawColoredPrimitives2 at 500x300 +<p> <a href="nurbs_plugin13.html">nurbs</a> +: nurbs at 500x300 +<p> <a href="spectex_plugin13.html">spectex</a> +: spectex at 400x400 +<p> <a href="morph3d_plugin13.html">morph3d</a> +: morph3d at 400x400 +<p> <a href="gears_plugin13.html">gears</a> +: gears at 400x400 +<br> +<br> +<p> <a href="accanti_plugin13.html">accanti</a> +: accanti at 400x400 (GLUT DEMO) +<p> <a href="alpha3D_plugin13.html">alpha3D</a> +: alpha3D at 400x400 (GLUT DEMO) +<p> <a href="anti_plugin13.html">anti</a> +: anti at 400x400 (GLUT DEMO) +<p> <a href="depthcue_plugin13.html">depthcue</a> +: depthcue at 400x400 (GLUT DEMO) +<p> <a href="teaambient_plugin13.html">teaambient</a> +: teaambient at 400x400 (GLUT DEMO) +<p> <a href="teapots_plugin13.html">teapots</a> +: teapots at 400x400 (GLUT DEMO) +<br> +<br> +<p> <a href="pngTextureTestApplet_plugin13.html">pngTextureTestApplet</a> +: png texture test at 600x400 (GLUT DEMO) +<br> +<br> +<br> <a href="stencil_plugin13.html">Stencil Test</a> +: test/shows geometry with 0 and 8 stencil-bits +<p> <a href="glutFontStrokeTest_plugin13.html">GLUT Font Stroke 1</a> +: GLUT Font Stroke 1 (GLUT DEMO) +<p> <a href="glutFontBitmapTest_plugin13.html">GLUT Font Bitmap 1</a> +: GLUT Font Bitmap 1 (GLUT DEMO) +<p> <a href="glutFontBitmapTest2Applet_plugin13.html">GLUT Font Bitmap 2</a> +: GLUT Font Bitmap 2 (GLUT DEMO) +<br> +<br> +<br> <a href="tess_plugin13.html">Tessellator Demo 1</a> +: test/shows 2 tesselated geometries +<br> <a href="tesswind_plugin13.html">Tessellator Demo 2</a> +: test/shows tesselated geometries with different winding rules +<br> <a href="tessdemo_plugin13.html">Tessellator Demo 3</a> +: test/shows self created tesselated geometries +<br> +<br> +<br> <a href="SharedGLTest2_plugin13.html">Shared GL-Context</a> +: test/shows the usage of a shared GLContext for Display-Lists +<br> +<br> +<br> <a href="select_plugin13.html">Selection Demo 1</a> +: test/shows selection +<br> +<br> +<br> +</body> +</html> diff --git a/demos/MiscDemos/morph3d.html b/demos/MiscDemos/morph3d.html new file mode 100644 index 0000000..b99094a --- /dev/null +++ b/demos/MiscDemos/morph3d.html @@ -0,0 +1,17 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
+ <title>OpenGL Demo - ported by Sven Goethel</title>
+</head>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+Teapots applet
+<br>Originially written by Silicon Graphics
+<br>Ported to Java by Sven Goethel
+<br>
+<applet code="morph3d.class" width=400 height=400>
+</applet>
+<hr>
+</body>
+</html>
diff --git a/demos/MiscDemos/morph3d.java b/demos/MiscDemos/morph3d.java new file mode 100755 index 0000000..7c8a8fe --- /dev/null +++ b/demos/MiscDemos/morph3d.java @@ -0,0 +1,1060 @@ +/*- + * morph3d.c - Shows 3D morphing objects + * + * Converted to GLUT by brianp on 1/1/98 + * + * This program was inspired on a WindowsNT(R)'s screen saver. It was written + * from scratch and it was not based on any other source code. + * + * Porting it to xlock (the final objective of this code (float)Math.since the moment I + * decided to create it) was possible by comparing the original Mesa's gear + * demo with it's ported version, so thanks for Danny Sung for his indirect + * help (look at gear.c in xlock source tree). NOTE: At the moment this code + * was sent to Brian Paul for package inclusion, the XLock Version was not + * available. In fact, I'll wait it to appear on the next Mesa release (If you + * are reading this, it means THIS release) to send it for xlock package + * inclusion). It will probably there be a GLUT version too. + * + * Thanks goes also to Brian Paul for making it possible and inexpensive + * to use OpenGL at home. + * + * Since I'm not a native english speaker, my apologies for any gramatical + * mistake. + * + * My e-mail addresses are + * + * and + * + * Marcelo F. Vianna (Feb-13-1997) + */ + +/* +This document is VERY incomplete, but tries to describe the mathematics used +in the program. At this moment it just describes how the polyhedra are +generated. On futhurer versions, this document will be probabbly improved. + +Since I'm not a native english speaker, my apologies for any gramatical +mistake. + +Marcelo Fernandes Vianna +- Undergraduate in Computer Engeneering at Catholic Pontifical University +- of Rio de Janeiro (PUC-Rio) Brasil. +- e-mail: [email protected] or [email protected] +- Feb-13-1997 + +POLYHEDRA GENERATION + +For the purpose of this program it's not sufficient to know the polyhedra +vertexes coordinates. Since the morphing algorithm applies a nonlinear +transformation over the surfaces (faces) of the polyhedron, each face has +to be divided into smaller ones. The morphing algorithm needs to transform +each vertex of these smaller faces individually. It's a very time consoming +task. + +In order to reduce calculation overload, and (float)Math.since all the macro faces of +the polyhedron are transformed by the same way, the generation is made by +creating only one face of the polyhedron, morphing it and then rotating it +around the polyhedron center. + +What we need to know is the face radius of the polyhedron (the radius of +the inscribed sphere) and the angle between the center of two adjacent +faces u(float)Math.sing the center of the sphere as the angle's vertex. + +The face radius of the regular polyhedra are known values which I decided +to not waste my time calculating. Following is a table of face radius for +the regular polyhedra with edge length = 1: + + TETRAHEDRON : 1/(2*(float)Math.sqrt(2))/(float)Math.sqrt(3) + CUBE : 1/2 + OCTAHEDRON : 1/(float)Math.sqrt(6) + DODECAHEDRON : T^2 * (float)Math.sqrt((T+2)/5) / 2 -> where T=((float)Math.sqrt(5)+1)/2 + ICOSAHEDRON : (3*(float)Math.sqrt(3)+(float)Math.sqrt(15))/12 + +I've not found any reference about the mentioned angles, so I needed to +calculate them, not a trivial task until I figured out how :) +Curiously these angles are the same for the tetrahedron and octahedron. +A way to obtain this value is inscribing the tetrahedron inside the cube +by matching their vertexes. So you'll notice that the remaining unmatched +vertexes are in the same straight line starting in the cube/tetrahedron +center and cros(float)Math.sing the center of each tetrahedron's face. At this point +it's easy to obtain the bigger angle of the isosceles triangle formed by +the center of the cube and two opposite vertexes on the same cube face. +The edges of this triangle have the following lenghts: (float)Math.sqrt(2) for the base +and (float)Math.sqrt(3)/2 for the other two other edges. So the angle we want is: + +-----------------------------------------------------------+ + | 2*ARCSIN((float)Math.sqrt(2)/(float)Math.sqrt(3)) = 109.47122063449069174f degrees | + +-----------------------------------------------------------+ +For the cube this angle is obvious, but just for formality it can be +easily obtained because we also know it's isosceles edge lenghts: +(float)Math.sqrt(2)/2 for the base and 1/2 for the other two edges. So the angle we +want is: + +-----------------------------------------------------------+ + | 2*ARCSIN(((float)Math.sqrt(2)/2)/1) = 90.000000000000000000f degrees | + +-----------------------------------------------------------+ +For the octahedron we use the same idea used for the tetrahedron, but now +we inscribe the cube inside the octahedron so that all cubes's vertexes +matches excatly the center of each octahedron's face. It's now clear that +this angle is the same of the thetrahedron one: + +-----------------------------------------------------------+ + | 2*ARCSIN((float)Math.sqrt(2)/(float)Math.sqrt(3)) = 109.47122063449069174f degrees | + +-----------------------------------------------------------+ +For the dodecahedron it's a little bit harder because it's only relationship +with the cube is useless to us. So we need to solve the problem by another +way. The concept of Face radius also exists on 2D polygons with the name +Edge radius: + Edge Radius For Pentagon (ERp) + ERp = (1/2)/TAN(36 degrees) * VRp = 0.6881909602355867905f + (VRp is the pentagon's vertex radio). + Face Radius For Dodecahedron + FRd = T^2 * (float)Math.sqrt((T+2)/5) / 2 = 1.1135163644116068404f +Why we need ERp? Well, ERp and FRd segments forms a 90 degrees angle, +completing this triangle, the lesser angle is a half of the angle we are +looking for, so this angle is: + +-----------------------------------------------------------+ + | 2*ARCTAN(ERp/FRd) = 63.434948822922009981f degrees | + +-----------------------------------------------------------+ +For the icosahedron we can use the same method used for dodecahedron (well +the method used for dodecahedron may be used for all regular polyhedra) + Edge Radius For Triangle (this one is well known: 1/3 of the triangle height) + ERt = (float)Math.sin(60)/3 = (float)Math.sqrt(3)/6 = 0.2886751345948128655f + Face Radius For Icosahedron + FRi= (3*(float)Math.sqrt(3)+(float)Math.sqrt(15))/12 = 0.7557613140761707538f +So the angle is: + +-----------------------------------------------------------+ + | 2*ARCTAN(ERt/FRi) = 41.810314895778596167f degrees | + +-----------------------------------------------------------+ + +*/ + +import java.applet.*; +import java.awt.*; +import java.awt.event.*; +import java.lang.*; +import java.util.*; +import java.io.*; +import java.util.*; +import gl4java.GLContext; +import gl4java.awt.GLCanvas; +import gl4java.awt.GLAnimCanvas; +import gl4java.applet.SimpleGLAnimApplet1; +import gl4java.utils.textures.*; + +public class morph3d extends SimpleGLAnimApplet1 +{ + static final float Scale =0.3f; + static final float tetraangle = 109.47122063449069174f; + static final float cubeangle = 90.000000000000000000f; + static final float octaangle = 109.47122063449069174f; + static final float dodecaangle = 63.434948822922009981f; + static final float icoangle = 41.810314895778596167f; + + static final float Pi = 3.1415926535897932385f; + static final float SQRT2 = 1.4142135623730951455f; + static final float SQRT3 = 1.7320508075688771932f; + static final float SQRT5 = 2.2360679774997898051f; + static final float SQRT6 = 2.4494897427831778813f; + static final float SQRT15 = 3.8729833462074170214f; + static final float cossec36_2 = 0.8506508083520399322f; + static final float cos72 = 0.3090169943749474241f; + static final float sin72 = 0.9510565162951535721f; + static final float cos36 = 0.8090169943749474241f; + static final float sin36 = 0.5877852522924731292f; + + static final float TAU = (SQRT5+1f)/2.0f; + + + /* Initialize the applet */ + + boolean isAnApplet = true; + + public void init() + { + super.init(); + Dimension d = getSize(); + canvas = new morph3dCanvas(d.width, d.height); + add("Center", canvas); + } + + public static void main( String args[] ) + { + Frame mainFrame = new Frame("morph3d"); + + GLContext.gljNativeDebug = true; + GLContext.gljClassDebug = true; + + morph3d applet = new morph3d(); + + applet.isAnApplet = false; + applet.setSize(400, 400); + applet.init(); + applet.start(); + + mainFrame.add(applet); + + mainFrame.pack(); + mainFrame.setVisible(true); + } + + /* Local GLCanvas extension class */ + + + private class morph3dCanvas extends GLAnimCanvas + implements MouseListener, ActionListener + { + private PopupMenu menu = null; + private boolean menu_showing = false; + private boolean save_suspended = false; + private final String MENUE_0 = "Tetrahedron"; + private final String MENUE_1 = "Hexahedron (Cube)"; + private final String MENUE_2 = "Octahedron"; + private final String MENUE_3 = "Dodecahedron"; + private final String MENUE_4 = "Icosahedron"; + private final String MENUE_5 = "Toggle colored faces"; + private final String MENUE_6 = "Toggle smooth/flat shading"; + private final String MENU_SNAPSHOT = "Snapshot"; + + TGATextureGrabber textgrab = null; + + boolean doSnapshot=false; + + /* Increasing this values produces better image quality, + the price is speed. */ + /* Very low values produces erroneous/incorrect plotting */ + int tetradivisions = 23; + int cubedivisions = 20; + int octadivisions = 21; + int dodecadivisions = 10; + int icodivisions = 15; + + boolean mono=false; + boolean smooth=true; + int WindH, WindW; + float step=0; + float seno; + int object; + int edgedivisions; + float Magnitude; + // float *MaterialColor[20]; + float MaterialColor[][]; + + float front_shininess[] = {60.0f}; + float front_specular[] = { 0.7f, 0.7f, 0.7f, 1.0f }; + float ambient[] = { 0.0f, 0.0f, 0.0f, 1.0f }; + float diffuse[] = { 1.0f, 1.0f, 1.0f, 1.0f }; + float position0[] = { 1.0f, 1.0f, 1.0f, 0.0f }; + float position1[] = {-1.0f,-1.0f, 1.0f, 0.0f }; + float lmodel_ambient[] = { 0.5f, 0.5f, 0.5f, 1.0f }; + float lmodel_twoside[] = {1.0f}; + + float MaterialRed[] = { 0.7f, 0.0f, 0.0f, 1.0f }; + float MaterialGreen[] = { 0.1f, 0.5f, 0.2f, 1.0f }; + float MaterialBlue[] = { 0.0f, 0.0f, 0.7f, 1.0f }; + float MaterialCyan[] = { 0.2f, 0.5f, 0.7f, 1.0f }; + float MaterialYellow[] = { 0.7f, 0.7f, 0.0f, 1.0f }; + float MaterialMagenta[] = { 0.6f, 0.2f, 0.5f, 1.0f }; + float MaterialWhite[] = { 0.7f, 0.7f, 0.7f, 1.0f }; + float MaterialGray[] = { 0.2f, 0.2f, 0.2f, 1.0f }; + + public morph3dCanvas(int w, int h) + { + super(w, h); + setAnimateFps(30.0); + } + + public void preInit() + { + doubleBuffer = true; + stereoView = false; + rgba = true; + } + + + final float VectMulX(float Y1,float Z1,float Y2,float Z2) + { return (Y1)*(Z2)-(Z1)*(Y2); + } + + final float VectMulY(float X1,float Z1,float X2,float Z2) + { return (Z1)*(X2)-(X1)*(Z2); + } + + final float VectMulZ(float X1,float Y1,float X2,float Y2) + { return (X1)*(Y2)-(Y1)*(X2); + } + + final float sqr(float A) + { return (A)*(A); } + + final void TRIANGLE(float Edge, float Amp, int Divisions, float Z) + { + float Xf,Yf,Xa,Yb,Xf2,Yf2; + float Factor,Factor1,Factor2; + float VertX,VertY,VertZ,NeiAX,NeiAY,NeiAZ,NeiBX,NeiBY,NeiBZ; + float Ax,Ay,Bx; + int Ri,Ti; + float Vr=(Edge)*SQRT3/3; + float AmpVr2=(Amp)/sqr(Vr); + float Zf=(Edge)*(Z); + + Ax=(Edge)*(+0.5f/(Divisions)); Ay=(Edge)*(-SQRT3/(2*Divisions)); + Bx=(Edge)*(-0.5f/(Divisions)); + for (Ri=1; Ri<=(Divisions); Ri++) { + gl.glBegin(GL_TRIANGLE_STRIP); + for (Ti=0; Ti<Ri; Ti++) { + Xf=(float)(Ri-Ti)*Ax + (float)Ti*Bx; + Yf=Vr+(float)(Ri-Ti)*Ay + (float)Ti*Ay; + Xa=Xf+0.001f; Yb=Yf+0.001f; + Factor=1-(((Xf2=sqr(Xf))+(Yf2=sqr(Yf)))*AmpVr2); + Factor1=1-((sqr(Xa)+Yf2)*AmpVr2); + Factor2=1-((Xf2+sqr(Yb))*AmpVr2); + VertX=Factor*Xf; VertY=Factor*Yf; VertZ=Factor*Zf; + NeiAX=Factor1*Xa-VertX; NeiAY=Factor1*Yf-VertY; NeiAZ=Factor1*Zf-VertZ; + NeiBX=Factor2*Xf-VertX; NeiBY=Factor2*Yb-VertY; NeiBZ=Factor2*Zf-VertZ; + gl.glNormal3f(VectMulX(NeiAY, NeiAZ, NeiBY, NeiBZ), + VectMulY(NeiAX, NeiAZ, NeiBX, NeiBZ), + VectMulZ(NeiAX, NeiAY, NeiBX, NeiBY)); + gl.glVertex3f(VertX, VertY, VertZ); + + Xf=(float)(Ri-Ti-1)*Ax + (float)Ti*Bx; + Yf=Vr+(float)(Ri-Ti-1)*Ay + (float)Ti*Ay; + Xa=Xf+0.001f; Yb=Yf+0.001f; + Factor=1-(((Xf2=sqr(Xf))+(Yf2=sqr(Yf)))*AmpVr2); + Factor1=1-((sqr(Xa)+Yf2)*AmpVr2); + Factor2=1-((Xf2+sqr(Yb))*AmpVr2); + VertX=Factor*Xf; VertY=Factor*Yf; VertZ=Factor*Zf; + NeiAX=Factor1*Xa-VertX; NeiAY=Factor1*Yf-VertY; NeiAZ=Factor1*Zf-VertZ; + NeiBX=Factor2*Xf-VertX; NeiBY=Factor2*Yb-VertY; NeiBZ=Factor2*Zf-VertZ; + gl.glNormal3f(VectMulX(NeiAY, NeiAZ, NeiBY, NeiBZ), + VectMulY(NeiAX, NeiAZ, NeiBX, NeiBZ), + VectMulZ(NeiAX, NeiAY, NeiBX, NeiBY)); + gl.glVertex3f(VertX, VertY, VertZ); + + } + Xf=(float)Ri*Bx; + Yf=Vr+(float)Ri*Ay; + Xa=Xf+0.001f; Yb=Yf+0.001f; + Factor=1-(((Xf2=sqr(Xf))+(Yf2=sqr(Yf)))*AmpVr2); + Factor1=1-((sqr(Xa)+Yf2)*AmpVr2); + Factor2=1-((Xf2+sqr(Yb))*AmpVr2); + VertX=Factor*Xf; VertY=Factor*Yf; VertZ=Factor*Zf; + NeiAX=Factor1*Xa-VertX; NeiAY=Factor1*Yf-VertY; NeiAZ=Factor1*Zf-VertZ; + NeiBX=Factor2*Xf-VertX; NeiBY=Factor2*Yb-VertY; NeiBZ=Factor2*Zf-VertZ; + gl.glNormal3f(VectMulX(NeiAY, NeiAZ, NeiBY, NeiBZ), + VectMulY(NeiAX, NeiAZ, NeiBX, NeiBZ), + VectMulZ(NeiAX, NeiAY, NeiBX, NeiBY)); + gl.glVertex3f(VertX, VertY, VertZ); + gl.glEnd(); + } + } + + final void SQUARE(float Edge, float Amp, int Divisions, float Z) + { + int Xi,Yi; + float Xf,Yf,Y,Xf2,Yf2,Y2,Xa,Yb; + float Factor,Factor1,Factor2; + float VertX,VertY,VertZ,NeiAX,NeiAY,NeiAZ,NeiBX,NeiBY,NeiBZ; + float Zf=(Edge)*(Z); + float AmpVr2=(Amp)/sqr((Edge)*SQRT2/2); + + for (Yi=0; Yi<(Divisions); Yi++) { + Yf=-((Edge)/2.0f) + ((float)Yi)/(Divisions)*(Edge); + Yf2=sqr(Yf); + Y=Yf+1.0f/(Divisions)*(Edge); + Y2=sqr(Y); + gl.glBegin(GL_QUAD_STRIP); + for (Xi=0; Xi<=(Divisions); Xi++) { + Xf=-((Edge)/2.0f) + ((float)Xi)/(Divisions)*(Edge); + Xf2=sqr(Xf); + + Xa=Xf+0.001f; Yb=Y+0.001f; + Factor=1-((Xf2+Y2)*AmpVr2); + Factor1=1-((sqr(Xa)+Y2)*AmpVr2); + Factor2=1-((Xf2+sqr(Yb))*AmpVr2); + VertX=Factor*Xf; VertY=Factor*Y; VertZ=Factor*Zf; + NeiAX=Factor1*Xa-VertX; NeiAY=Factor1*Y-VertY; NeiAZ=Factor1*Zf-VertZ; + NeiBX=Factor2*Xf-VertX; NeiBY=Factor2*Yb-VertY; NeiBZ=Factor2*Zf-VertZ; + gl.glNormal3f(VectMulX(NeiAY, NeiAZ, NeiBY, NeiBZ), + VectMulY(NeiAX, NeiAZ, NeiBX, NeiBZ), + VectMulZ(NeiAX, NeiAY, NeiBX, NeiBY)); + gl.glVertex3f(VertX, VertY, VertZ); + + Xa=Xf+0.001f; Yb=Yf+0.001f; + Factor=1-((Xf2+Yf2)*AmpVr2); + Factor1=1-((sqr(Xa)+Yf2)*AmpVr2); + Factor2=1-((Xf2+sqr(Yb))*AmpVr2); + VertX=Factor*Xf; VertY=Factor*Yf; VertZ=Factor*Zf; + NeiAX=Factor1*Xa-VertX; NeiAY=Factor1*Yf-VertY; NeiAZ=Factor1*Zf-VertZ; + NeiBX=Factor2*Xf-VertX; NeiBY=Factor2*Yb-VertY; NeiBZ=Factor2*Zf-VertZ; + gl.glNormal3f(VectMulX(NeiAY, NeiAZ, NeiBY, NeiBZ), + VectMulY(NeiAX, NeiAZ, NeiBX, NeiBZ), + VectMulZ(NeiAX, NeiAY, NeiBX, NeiBY)); + gl.glVertex3f(VertX, VertY, VertZ); + } + gl.glEnd(); + } + } + + final void PENTAGON(float Edge, float Amp, int Divisions, float Z) + { + int Ri,Ti,Fi; + float Xf,Yf,Xa,Yb,Xf2,Yf2; + float x[]=new float[6],y[]=new float[6]; + float Factor,Factor1,Factor2; + float VertX,VertY,VertZ,NeiAX,NeiAY,NeiAZ,NeiBX,NeiBY,NeiBZ; + float Zf=(Edge)*(Z); + float AmpVr2=(Amp)/sqr((Edge)*cossec36_2); + + for(Fi=0;Fi<6;Fi++) { + x[Fi]=-(float)Math.cos( Fi*2*Pi/5 + Pi/10 )/(Divisions)*cossec36_2*(Edge); + y[Fi]=(float)Math.sin( Fi*2*Pi/5 + Pi/10 )/(Divisions)*cossec36_2*(Edge); + } + + for (Ri=1; Ri<=(Divisions); Ri++) { + for (Fi=0; Fi<5; Fi++) { + gl.glBegin(GL_TRIANGLE_STRIP); + for (Ti=0; Ti<Ri; Ti++) { + Xf=(float)(Ri-Ti)*x[Fi] + (float)Ti*x[Fi+1]; + Yf=(float)(Ri-Ti)*y[Fi] + (float)Ti*y[Fi+1]; + Xa=Xf+0.001f; Yb=Yf+0.001f; + Factor=1-(((Xf2=sqr(Xf))+(Yf2=sqr(Yf)))*AmpVr2); + Factor1=1-((sqr(Xa)+Yf2)*AmpVr2); + Factor2=1-((Xf2+sqr(Yb))*AmpVr2); + VertX=Factor*Xf; VertY=Factor*Yf; VertZ=Factor*Zf; + NeiAX=Factor1*Xa-VertX; NeiAY=Factor1*Yf-VertY; NeiAZ=Factor1*Zf-VertZ; + NeiBX=Factor2*Xf-VertX; NeiBY=Factor2*Yb-VertY; NeiBZ=Factor2*Zf-VertZ; + gl.glNormal3f(VectMulX(NeiAY, NeiAZ, NeiBY, NeiBZ), + VectMulY(NeiAX, NeiAZ, NeiBX, NeiBZ), + VectMulZ(NeiAX, NeiAY, NeiBX, NeiBY)); + gl.glVertex3f(VertX, VertY, VertZ); + + Xf=(float)(Ri-Ti-1)*x[Fi] + (float)Ti*x[Fi+1]; + Yf=(float)(Ri-Ti-1)*y[Fi] + (float)Ti*y[Fi+1]; + Xa=Xf+0.001f; Yb=Yf+0.001f; + Factor=1-(((Xf2=sqr(Xf))+(Yf2=sqr(Yf)))*AmpVr2); + Factor1=1-((sqr(Xa)+Yf2)*AmpVr2); + Factor2=1-((Xf2+sqr(Yb))*AmpVr2); + VertX=Factor*Xf; VertY=Factor*Yf; VertZ=Factor*Zf; + NeiAX=Factor1*Xa-VertX; NeiAY=Factor1*Yf-VertY; NeiAZ=Factor1*Zf-VertZ; + NeiBX=Factor2*Xf-VertX; NeiBY=Factor2*Yb-VertY; NeiBZ=Factor2*Zf-VertZ; + gl.glNormal3f(VectMulX(NeiAY, NeiAZ, NeiBY, NeiBZ), + VectMulY(NeiAX, NeiAZ, NeiBX, NeiBZ), + VectMulZ(NeiAX, NeiAY, NeiBX, NeiBY)); + gl.glVertex3f(VertX, VertY, VertZ); + + } + Xf=(float)Ri*x[Fi+1]; + Yf=(float)Ri*y[Fi+1]; + Xa=Xf+0.001f; Yb=Yf+0.001f; + Factor=1-(((Xf2=sqr(Xf))+(Yf2=sqr(Yf)))*AmpVr2); + Factor1=1-((sqr(Xa)+Yf2)*AmpVr2); + Factor2=1-((Xf2+sqr(Yb))*AmpVr2); + VertX=Factor*Xf; VertY=Factor*Yf; VertZ=Factor*Zf; + NeiAX=Factor1*Xa-VertX; NeiAY=Factor1*Yf-VertY; NeiAZ=Factor1*Zf-VertZ; + NeiBX=Factor2*Xf-VertX; NeiBY=Factor2*Yb-VertY; NeiBZ=Factor2*Zf-VertZ; + gl.glNormal3f(VectMulX(NeiAY, NeiAZ, NeiBY, NeiBZ), + VectMulY(NeiAX, NeiAZ, NeiBX, NeiBZ), + VectMulZ(NeiAX, NeiAY, NeiBX, NeiBY)); + gl.glVertex3f(VertX, VertY, VertZ); + gl.glEnd(); + } + } + } + + void draw_tetra( ) + { + int list; + + list = gl.glGenLists( 1 ); + gl.glNewList( list, GL_COMPILE ); + TRIANGLE(2,seno,edgedivisions,0.5f/SQRT6); + gl.glEndList(); + + gl.glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[0]); + gl.glCallList(list); + gl.glPushMatrix(); + gl.glRotatef(180,0,0,1); + gl.glRotatef(-tetraangle,1,0,0); + gl.glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[1]); + gl.glCallList(list); + gl.glPopMatrix(); + gl.glPushMatrix(); + gl.glRotatef(180,0,1,0); + gl.glRotatef(-180+tetraangle,0.5f,SQRT3/2,0); + gl.glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[2]); + gl.glCallList(list); + gl.glPopMatrix(); + gl.glRotatef(180,0,1,0); + gl.glRotatef(-180+tetraangle,0.5f,-SQRT3/2,0); + gl.glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[3]); + gl.glCallList(list); + + gl.glDeleteLists(list,1); + } + + void draw_cube() + { + int list; + + list = gl.glGenLists( 1 ); + gl.glNewList( list, GL_COMPILE ); + SQUARE(2.0f, seno, edgedivisions, 0.5f); + gl.glEndList(); + + gl.glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[0]); + gl.glCallList(list); + gl.glRotatef(cubeangle,1,0,0); + gl.glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[1]); + gl.glCallList(list); + gl.glRotatef(cubeangle,1,0,0); + gl.glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[2]); + gl.glCallList(list); + gl.glRotatef(cubeangle,1,0,0); + gl.glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[3]); + gl.glCallList(list); + gl.glRotatef(cubeangle,0,1,0); + gl.glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[4]); + gl.glCallList(list); + gl.glRotatef(2*cubeangle,0,1,0); + gl.glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[5]); + gl.glCallList(list); + + gl.glDeleteLists(list,1); + } + + void draw_octa() + { + int list; + + list = gl.glGenLists( 1 ); + gl.glNewList( list, GL_COMPILE ); + TRIANGLE(2,seno,edgedivisions,1/SQRT6); + gl.glEndList(); + + gl.glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[0]); + gl.glCallList(list); + gl.glPushMatrix(); + gl.glRotatef(180,0,0,1); + gl.glRotatef(-180+octaangle,1,0,0); + gl.glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[1]); + gl.glCallList(list); + gl.glPopMatrix(); + gl.glPushMatrix(); + gl.glRotatef(180,0,1,0); + gl.glRotatef(-octaangle,0.5f,SQRT3/2,0); + gl.glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[2]); + gl.glCallList(list); + gl.glPopMatrix(); + gl.glPushMatrix(); + gl.glRotatef(180,0,1,0); + gl.glRotatef(-octaangle,0.5f,-SQRT3/2,0); + gl.glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[3]); + gl.glCallList(list); + gl.glPopMatrix(); + gl.glRotatef(180,1,0,0); + gl.glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[4]); + gl.glCallList(list); + gl.glPushMatrix(); + gl.glRotatef(180,0,0,1); + gl.glRotatef(-180+octaangle,1,0,0); + gl.glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[5]); + gl.glCallList(list); + gl.glPopMatrix(); + gl.glPushMatrix(); + gl.glRotatef(180,0,1,0); + gl.glRotatef(-octaangle,0.5f,SQRT3/2,0); + gl.glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[6]); + gl.glCallList(list); + gl.glPopMatrix(); + gl.glRotatef(180,0,1,0); + gl.glRotatef(-octaangle,0.5f,-SQRT3/2,0); + gl.glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[7]); + gl.glCallList(list); + + gl.glDeleteLists(list,1); + } + + void draw_dodeca() + { + int list; + + + list = gl.glGenLists( 1 ); + gl.glNewList( list, GL_COMPILE ); + PENTAGON(1,seno,edgedivisions,sqr(TAU) * (float)Math.sqrt((TAU+2)/5) / 2); + gl.glEndList(); + + gl.glPushMatrix(); + gl.glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[0]); + gl.glCallList(list); + gl.glRotatef(180,0,0,1); + gl.glPushMatrix(); + gl.glRotatef(-dodecaangle,1,0,0); + gl.glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[1]); + gl.glCallList(list); + gl.glPopMatrix(); + gl.glPushMatrix(); + gl.glRotatef(-dodecaangle,cos72,sin72,0); + gl.glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[2]); + gl.glCallList(list); + gl.glPopMatrix(); + gl.glPushMatrix(); + gl.glRotatef(-dodecaangle,cos72,-sin72,0); + gl.glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[3]); + gl.glCallList(list); + gl.glPopMatrix(); + gl.glPushMatrix(); + gl.glRotatef(dodecaangle,cos36,-sin36,0); + gl.glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[4]); + gl.glCallList(list); + gl.glPopMatrix(); + gl.glRotatef(dodecaangle,cos36,sin36,0); + gl.glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[5]); + gl.glCallList(list); + gl.glPopMatrix(); + gl.glRotatef(180,1,0,0); + gl.glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[6]); + gl.glCallList(list); + gl.glRotatef(180,0,0,1); + gl.glPushMatrix(); + gl.glRotatef(-dodecaangle,1,0,0); + gl.glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[7]); + gl.glCallList(list); + gl.glPopMatrix(); + gl.glPushMatrix(); + gl.glRotatef(-dodecaangle,cos72,sin72,0); + gl.glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[8]); + gl.glCallList(list); + gl.glPopMatrix(); + gl.glPushMatrix(); + gl.glRotatef(-dodecaangle,cos72,-sin72,0); + gl.glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[9]); + gl.glCallList(list); + gl.glPopMatrix(); + gl.glPushMatrix(); + gl.glRotatef(dodecaangle,cos36,-sin36,0); + gl.glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[10]); + gl.glCallList(list); + gl.glPopMatrix(); + gl.glRotatef(dodecaangle,cos36,sin36,0); + gl.glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[11]); + gl.glCallList(list); + + gl.glDeleteLists(list,1); + } + + void draw_ico() + { + int list; + + list = gl.glGenLists( 1 ); + gl.glNewList( list, GL_COMPILE ); + TRIANGLE(1.5f,seno,edgedivisions,(3*SQRT3+SQRT15)/12); + gl.glEndList(); + + gl.glPushMatrix(); + + gl.glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[0]); + gl.glCallList(list); + gl.glPushMatrix(); + gl.glRotatef(180,0,0,1); + gl.glRotatef(-icoangle,1,0,0); + gl.glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[1]); + gl.glCallList(list); + gl.glPushMatrix(); + gl.glRotatef(180,0,1,0); + gl.glRotatef(-180+icoangle,0.5f,SQRT3/2,0); + gl.glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[2]); + gl.glCallList(list); + gl.glPopMatrix(); + gl.glRotatef(180,0,1,0); + gl.glRotatef(-180+icoangle,0.5f,-SQRT3/2,0); + gl.glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[3]); + gl.glCallList(list); + gl.glPopMatrix(); + gl.glPushMatrix(); + gl.glRotatef(180,0,1,0); + gl.glRotatef(-180+icoangle,0.5f,SQRT3/2,0); + gl.glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[4]); + gl.glCallList(list); + gl.glPushMatrix(); + gl.glRotatef(180,0,1,0); + gl.glRotatef(-180+icoangle,0.5f,SQRT3/2,0); + gl.glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[5]); + gl.glCallList(list); + gl.glPopMatrix(); + gl.glRotatef(180,0,0,1); + gl.glRotatef(-icoangle,1,0,0); + gl.glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[6]); + gl.glCallList(list); + gl.glPopMatrix(); + gl.glRotatef(180,0,1,0); + gl.glRotatef(-180+icoangle,0.5f,-SQRT3/2,0); + gl.glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[7]); + gl.glCallList(list); + gl.glPushMatrix(); + gl.glRotatef(180,0,1,0); + gl.glRotatef(-180+icoangle,0.5f,-SQRT3/2,0); + gl.glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[8]); + gl.glCallList(list); + gl.glPopMatrix(); + gl.glRotatef(180,0,0,1); + gl.glRotatef(-icoangle,1,0,0); + gl.glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[9]); + gl.glCallList(list); + gl.glPopMatrix(); + gl.glRotatef(180,1,0,0); + gl.glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[10]); + gl.glCallList(list); + gl.glPushMatrix(); + gl.glRotatef(180,0,0,1); + gl.glRotatef(-icoangle,1,0,0); + gl.glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[11]); + gl.glCallList(list); + gl.glPushMatrix(); + gl.glRotatef(180,0,1,0); + gl.glRotatef(-180+icoangle,0.5f,SQRT3/2,0); + gl.glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[12]); + gl.glCallList(list); + gl.glPopMatrix(); + gl.glRotatef(180,0,1,0); + gl.glRotatef(-180+icoangle,0.5f,-SQRT3/2,0); + gl.glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[13]); + gl.glCallList(list); + gl.glPopMatrix(); + gl.glPushMatrix(); + gl.glRotatef(180,0,1,0); + gl.glRotatef(-180+icoangle,0.5f,SQRT3/2,0); + gl.glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[14]); + gl.glCallList(list); + gl.glPushMatrix(); + gl.glRotatef(180,0,1,0); + gl.glRotatef(-180+icoangle,0.5f,SQRT3/2,0); + gl.glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[15]); + gl.glCallList(list); + gl.glPopMatrix(); + gl.glRotatef(180,0,0,1); + gl.glRotatef(-icoangle,1,0,0); + gl.glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[16]); + gl.glCallList(list); + gl.glPopMatrix(); + gl.glRotatef(180,0,1,0); + gl.glRotatef(-180+icoangle,0.5f,-SQRT3/2,0); + gl.glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[17]); + gl.glCallList(list); + gl.glPushMatrix(); + gl.glRotatef(180,0,1,0); + gl.glRotatef(-180+icoangle,0.5f,-SQRT3/2,0); + gl.glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[18]); + gl.glCallList(list); + gl.glPopMatrix(); + gl.glRotatef(180,0,0,1); + gl.glRotatef(-icoangle,1,0,0); + gl.glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialColor[19]); + gl.glCallList(list); + + gl.glDeleteLists(list,1); + } + + public void display() + { + if (glj.gljMakeCurrent() == false) return; + + gl.glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); + + gl.glPushMatrix(); + + gl.glTranslatef( 0.0f, 0.0f, -10.0f ); + gl.glScalef( Scale*WindH/WindW, Scale, Scale ); + gl.glTranslatef(2.5f*WindW/WindH*(float)Math.sin(step*1.11f),2.5f*(float)Math.cos(step*1.25f*1.11f),0); + gl.glRotatef(step*100,1,0,0); + gl.glRotatef(step*95,0,1,0); + gl.glRotatef(step*90,0,0,1); + + seno=((float)Math.sin(step)+1.0f/3.0f)*(4.0f/5.0f)*Magnitude; + + switch(object) { + case 1: + draw_tetra(); + break; + case 2: + draw_cube(); + break; + case 3: + draw_octa(); + break; + case 4: + draw_dodeca(); + break; + case 5: + draw_ico(); + break; + } + + gl.glPopMatrix(); + + + if(!isAnApplet && doSnapshot) + { + doSnapshot=false; + textgrab.grabPixels(GL_BACK, + 0, 0, cvsGetWidth(), cvsGetHeight()); + textgrab.write2File("morph3d.tga"); + } + + glj.gljSwap(); + glj.gljCheckGL(); + glj.gljFree(); + + step+=0.05f; + } + + public void reshape(int width, int height) + { + WindW=width; WindH=height; + gl.glViewport(0, 0, WindW, WindH); + gl.glMatrixMode(GL_PROJECTION); + gl.glLoadIdentity(); + gl.glFrustum( -1.0f, 1.0f, -1.0f, 1.0f, 5.0f, 15.0f ); + gl.glMatrixMode(GL_MODELVIEW); + } + + final void pinit() + { + switch(object) { + case 1: + MaterialColor[0]=MaterialRed; + MaterialColor[1]=MaterialGreen; + MaterialColor[2]=MaterialBlue; + MaterialColor[3]=MaterialWhite; + edgedivisions=tetradivisions; + Magnitude=2.5f; + break; + case 2: + MaterialColor[0]=MaterialRed; + MaterialColor[1]=MaterialGreen; + MaterialColor[2]=MaterialCyan; + MaterialColor[3]=MaterialMagenta; + MaterialColor[4]=MaterialYellow; + MaterialColor[5]=MaterialBlue; + edgedivisions=cubedivisions; + Magnitude=2.0f; + break; + case 3: + MaterialColor[0]=MaterialRed; + MaterialColor[1]=MaterialGreen; + MaterialColor[2]=MaterialBlue; + MaterialColor[3]=MaterialWhite; + MaterialColor[4]=MaterialCyan; + MaterialColor[5]=MaterialMagenta; + MaterialColor[6]=MaterialGray; + MaterialColor[7]=MaterialYellow; + edgedivisions=octadivisions; + Magnitude=2.5f; + break; + case 4: + MaterialColor[ 0]=MaterialRed; + MaterialColor[ 1]=MaterialGreen; + MaterialColor[ 2]=MaterialCyan; + MaterialColor[ 3]=MaterialBlue; + MaterialColor[ 4]=MaterialMagenta; + MaterialColor[ 5]=MaterialYellow; + MaterialColor[ 6]=MaterialGreen; + MaterialColor[ 7]=MaterialCyan; + MaterialColor[ 8]=MaterialRed; + MaterialColor[ 9]=MaterialMagenta; + MaterialColor[10]=MaterialBlue; + MaterialColor[11]=MaterialYellow; + edgedivisions=dodecadivisions; + Magnitude=2.0f; + break; + case 5: + MaterialColor[ 0]=MaterialRed; + MaterialColor[ 1]=MaterialGreen; + MaterialColor[ 2]=MaterialBlue; + MaterialColor[ 3]=MaterialCyan; + MaterialColor[ 4]=MaterialYellow; + MaterialColor[ 5]=MaterialMagenta; + MaterialColor[ 6]=MaterialRed; + MaterialColor[ 7]=MaterialGreen; + MaterialColor[ 8]=MaterialBlue; + MaterialColor[ 9]=MaterialWhite; + MaterialColor[10]=MaterialCyan; + MaterialColor[11]=MaterialYellow; + MaterialColor[12]=MaterialMagenta; + MaterialColor[13]=MaterialRed; + MaterialColor[14]=MaterialGreen; + MaterialColor[15]=MaterialBlue; + MaterialColor[16]=MaterialCyan; + MaterialColor[17]=MaterialYellow; + MaterialColor[18]=MaterialMagenta; + MaterialColor[19]=MaterialGray; + edgedivisions=icodivisions; + Magnitude=2.5f; + break; + } + if (mono) { + int loop; + for (loop=0; loop<20; loop++) MaterialColor[loop]=MaterialGray; + } + if (smooth) { + gl.glShadeModel( GL_SMOOTH ); + } else { + gl.glShadeModel( GL_FLAT ); + } + + } + + public void init() + { + textgrab = new TGATextureGrabber(gl); + reshape(getSize().width, getSize().height); + + object=1; + + MaterialColor = new float[20][]; + + gl.glClearDepth(1.0f); + gl.glClearColor( 0.0f, 0.0f, 0.0f, 1.0f ); + gl.glColor3f( 1.0f, 1.0f, 1.0f ); + + gl.glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); + glj.gljSwap(); + + gl.glLightfv(GL_LIGHT0, GL_AMBIENT, ambient); + gl.glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse); + gl.glLightfv(GL_LIGHT0, GL_POSITION, position0); + gl.glLightfv(GL_LIGHT1, GL_AMBIENT, ambient); + gl.glLightfv(GL_LIGHT1, GL_DIFFUSE, diffuse); + gl.glLightfv(GL_LIGHT1, GL_POSITION, position1); + gl.glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient); + gl.glLightModelfv(GL_LIGHT_MODEL_TWO_SIDE, lmodel_twoside); + gl.glEnable(GL_LIGHTING); + gl.glEnable(GL_LIGHT0); + gl.glEnable(GL_LIGHT1); + gl.glEnable(GL_DEPTH_TEST); + gl.glEnable(GL_NORMALIZE); + + gl.glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, front_shininess); + gl.glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, front_specular); + + gl.glHint(GL_FOG_HINT, GL_FASTEST); + gl.glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST); + gl.glHint(GL_POLYGON_SMOOTH_HINT, GL_FASTEST); + + pinit(); + + menu = new PopupMenu("Options"); + menu.add(MENUE_0); + menu.add(MENUE_1); + menu.add(MENUE_2); + menu.add(MENUE_3); + menu.add(MENUE_4); + menu.add(MENUE_5); + menu.add(MENUE_6); + if(!isAnApplet) + menu.add(MENU_SNAPSHOT); + menu.addActionListener(this); + add(menu); + + addMouseListener(this); + + } + + // Methods required for the implementation of MouseListener + public void mouseEntered(MouseEvent evt) + { + } + + public void mouseExited(MouseEvent evt) + { + } + + public void mousePressed(MouseEvent evt) + { + if (!menu_showing) + { + if ((evt.getModifiers() & evt.BUTTON3_MASK) != 0) + { + menu_showing = true; + save_suspended = isSuspended(); + if (!save_suspended) + { + setSuspended(true); + repaint(100); + try + { + Thread.currentThread().sleep(200); + } + catch (Exception e) + { } + } + menu.show(this,evt.getX(),evt.getY()); + } + else + { + // Must be left button. + if (isSuspended()) repaint(); + } + } + else + { + menu_showing = false; + setSuspended(save_suspended); + } + } + + public void mouseReleased(MouseEvent evt) + { + } + + public void mouseClicked(MouseEvent evt) + { + } + + // Method required for the implementation of ActionListener + public void actionPerformed(ActionEvent evt) + { + String c = evt.getActionCommand(); + if (c.equals(MENUE_0)) + { + object=1; + } + else if (c.equals(MENUE_1)) + { + object=2; + } + else if (c.equals(MENUE_2)) + { + object=3; + } + else if (c.equals(MENUE_3)) + { + object=4; + } + else if (c.equals(MENUE_4)) + { + object=5; + } + else if (c.equals(MENUE_5)) + { + mono=!mono; + } + else if (c.equals(MENUE_6)) + { + smooth=!smooth; + } + else if (c.equals(MENU_SNAPSHOT)) + { + doSnapshot=true; + } + if (menu_showing) + { + menu_showing = false; + setSuspended(save_suspended); + } + pinit(); + } + } +} + diff --git a/demos/MiscDemos/morph3d_plugin13.html b/demos/MiscDemos/morph3d_plugin13.html new file mode 100644 index 0000000..1472b89 --- /dev/null +++ b/demos/MiscDemos/morph3d_plugin13.html @@ -0,0 +1,48 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
+ <title>OpenGL Demo - ported by Sven Goethel</title>
+</head>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+Teapots applet
+<br>Originially written by Silicon Graphics
+<br>Ported to Java by Sven Goethel
+<br>
+<!--"CONVERTED_APPLET"-->
+<!-- CONVERTER VERSION 1.3 --> +<SCRIPT LANGUAGE="JavaScript"><!-- + var _info = navigator.userAgent; var _ns = false; + var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0); +//--></SCRIPT> +<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!-- + var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0))); +//--></SCRIPT></COMMENT> + +<SCRIPT LANGUAGE="JavaScript"><!-- + if (_ie == true) document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = 400 HEIGHT = 400 codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0"><NOEMBED><XMP>'); + else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.3" CODE = "morph3d.class" WIDTH = 400 HEIGHT = 400 scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html"><NOEMBED><XMP>'); +//--></SCRIPT> +<APPLET CODE = "morph3d.class" WIDTH = 400 HEIGHT = 400></XMP> +<PARAM NAME = CODE VALUE = "morph3d.class" >
+ +<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3"> +<PARAM NAME="scriptable" VALUE="false"> + +</APPLET> + +</NOEMBED></EMBED></OBJECT> + + +<!-- +<APPLET CODE = "morph3d.class" WIDTH = 400 HEIGHT = 400>
+
+
+</APPLET> +--> +<!--"END_CONVERTED_APPLET"-->
+
+<hr>
+</body>
+</html>
diff --git a/demos/MiscDemos/nurbs.html b/demos/MiscDemos/nurbs.html new file mode 100644 index 0000000..6f0f2fe --- /dev/null +++ b/demos/MiscDemos/nurbs.html @@ -0,0 +1,14 @@ +<HTML>
+<HEAD>
+<TITLE>Göthel Hard- und Software Entwicklungen</TITLE>
+</HEAD>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+<hr>
+<applet code="nurbs.class" width=500 height=300>
+<param name=frames value="55">
+</applet>
+<hr>
+</BODY>
+</HTML>
+
+
diff --git a/demos/MiscDemos/nurbs.java b/demos/MiscDemos/nurbs.java new file mode 100644 index 0000000..52ecd99 --- /dev/null +++ b/demos/MiscDemos/nurbs.java @@ -0,0 +1,314 @@ +/**
+ * @(#) DrawColoredPrimitives2.java
+ * @(#) author: Joe Zimmerman (converted to Java by Sven Goethel)
+ */
+
+/* This program is free software under the license of LGPL */
+
+import java.applet.*;
+import java.awt.*;
+import java.awt.event.*;
+import java.lang.*;
+import java.util.*;
+import java.io.*;
+import java.util.*;
+import gl4java.GLContext;
+import gl4java.awt.GLAnimCanvas;
+import gl4java.applet.SimpleGLAnimApplet1;
+
+public class nurbs extends SimpleGLAnimApplet1
+{
+ public void init()
+ {
+ super.init();
+ Dimension d = getSize();
+ canvas = new gldemo(d.width, d.height);
+ add("Center", canvas);
+ }
+
+ public static void main( String args[] )
+ {
+ Frame mainFrame = new Frame("nurbs");
+
+ nurbs applet = new nurbs();
+
+ applet.setSize(400, 400);
+ applet.init();
+ applet.start();
+
+ mainFrame.add(applet);
+
+ mainFrame.pack();
+ mainFrame.setVisible(true);
+ }
+
+
+ private class gldemo extends GLAnimCanvas
+ implements MouseListener, ActionListener
+ {
+ private PopupMenu menu = null;
+ private boolean menu_showing = false;
+ private boolean save_suspended = false;
+ private final String VIEW_ROTATION = "Toggle Rotation";
+ private final String VIEW_FRONT = "View Front";
+ private final String VIEW_TOP = "View Top";
+ private final String VIEW_BOTTOM = "View Bottom";
+
+ final float M_PI = 3.14159265f;
+ final float M_PI_2 = 1.57079632f;
+ float rotate=0;
+ float rotationStep = 1;
+ boolean rotationOn = true;
+ int view = 0; /* 0 = front, 1 = top, 2 = bottom */
+
+ static final int S_NUMPOINTS = 13;
+ static final int S_ORDER = 3;
+ static final int S_NUMKNOTS = (S_NUMPOINTS + S_ORDER);
+ static final int T_NUMPOINTS = 3;
+ static final int T_ORDER = 3;
+ static final int T_NUMKNOTS = (T_NUMPOINTS + T_ORDER);
+ static final float SQRT2 = 1.41421356237309504880f;
+
+ /* initialized local data */
+
+ float sknots[/*S_NUMKNOTS*/] =
+ {-1.0f, -1.0f, -1.0f, 0.0f, 1.0f, 2.0f, 3.0f, 4.0f,
+ 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 9.0f, 9.0f};
+ float tknots[/*T_NUMKNOTS*/] = {1.0f, 1.0f, 1.0f, 2.0f, 2.0f, 2.0f};
+
+ // float ctlpoints[/*S_NUMPOINTS*/][/*T_NUMPOINTS*/][/*4*/] = {
+ float ctlpoints[] = {
+ 4f,2f,2f,1f, 4f,1.6f,2.5f,1f , 4f,2f,3.0f,1f ,
+ 5f,4f,2f,1f , 5f,4f,2.5f,1f , 5f,4f,3.0f,1f ,
+ 6f,5f,2f,1f , 6f,5f,2.5f,1f , 6f,5f,3.0f,1f ,
+ SQRT2*6f,SQRT2*6f,SQRT2*2f,SQRT2 ,
+ SQRT2*6f,SQRT2*6f,SQRT2*2.5f,SQRT2 ,
+ SQRT2*6f,SQRT2*6f,SQRT2*3.0f,SQRT2 ,
+ 5.2f,6.7f,2f,1f , 5.2f,6.7f,2.5f,1f , 5.2f,6.7f,3.0f,1f ,
+ SQRT2*4f,SQRT2*6f,SQRT2*2f,SQRT2 ,
+ SQRT2*4f,SQRT2*6f,SQRT2*2.5f,SQRT2 ,
+ SQRT2*4f,SQRT2*6f,SQRT2*3.0f,SQRT2 ,
+ 4f,5.2f,2f,1f , 4f,4.6f,2.5f,1f , 4f,5.2f,3.0f,1f ,
+ SQRT2*4f,SQRT2*6f,SQRT2*2f,SQRT2 ,
+ SQRT2*4f,SQRT2*6f,SQRT2*2.5f,SQRT2 ,
+ SQRT2*4f,SQRT2*6f,SQRT2*3.0f,SQRT2 ,
+ 2.8f,6.7f,2f,1f , 2.8f,6.7f,2.5f,1f , 2.8f,6.7f,3.0f,1f ,
+ SQRT2*2f,SQRT2*6f,SQRT2*2f,SQRT2 ,
+ SQRT2*2f,SQRT2*6f,SQRT2*2.5f,SQRT2 ,
+ SQRT2*2f,SQRT2*6f,SQRT2*3.0f,SQRT2 ,
+ 2f,5f,2f,1f , 2f,5f,2.5f,1f , 2f,5f,3.0f,1f ,
+ 3f,4f,2f,1f , 3f,4f,2.5f,1f , 3f,4f,3.0f,1f ,
+ 4f,2f,2f,1f , 4f,1.6f,2.5f,1f , 4f,2f,3.0f,1f
+ };
+
+
+ int theNurb;
+
+ public gldemo(int w, int h)
+ {
+ super(w, h);
+ GLContext.gljNativeDebug = false;
+ GLContext.gljClassDebug = false;
+ setAnimateFps(30.0);
+ }
+
+ public void preInit()
+ {
+ doubleBuffer = true;
+ stereoView = false;
+ }
+
+ public void init()
+ {
+ reshape(getSize().width, getSize().height);
+
+ float mat_ambient[] = { 1.0f, 1.0f, 1.0f, 1.0f };
+ float mat_diffuse[] = { 1.0f, 0.2f, 1.0f, 1.0f };
+ float mat_specular[] = { 1.0f, 1.0f, 1.0f, 1.0f };
+ float mat_shininess[] = { 50.0f };
+
+ float light0_position[] = { 1.0f, 0.1f, 1.0f, 0.0f };
+ float light1_position[] = { -1.0f, 0.1f, 1.0f, 0.0f };
+
+ float lmodel_ambient[] = { 0.3f, 0.3f, 0.3f, 1.0f };
+
+ gl.glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient);
+ gl.glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse);
+ gl.glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
+ gl.glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess);
+ gl.glLightfv(GL_LIGHT0, GL_POSITION, light0_position);
+ gl.glLightfv(GL_LIGHT1, GL_POSITION, light1_position);
+ gl.glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient);
+
+ gl.glEnable(GL_LIGHTING);
+ gl.glEnable(GL_LIGHT0);
+ gl.glEnable(GL_LIGHT1);
+ gl.glDepthFunc(GL_LESS);
+ gl.glEnable(GL_DEPTH_TEST);
+ gl.glEnable(GL_AUTO_NORMAL);
+
+ theNurb = glu.gluNewNurbsRenderer();
+
+ glu.gluNurbsProperty(theNurb, GLU_SAMPLING_TOLERANCE, 25.0f);
+ glu.gluNurbsProperty(theNurb, GLU_DISPLAY_MODE, GLU_FILL);
+ glj.gljCheckGL();
+
+ menu = new PopupMenu("Options");
+ menu.add(VIEW_ROTATION);
+ menu.add(VIEW_FRONT);
+ menu.add(VIEW_TOP);
+ menu.add(VIEW_BOTTOM);
+ menu.addActionListener(this);
+ add(menu);
+
+ addMouseListener(this);
+ }
+
+ public void doCleanup()
+ {
+ removeMouseListener(this);
+ menu.removeActionListener(this);
+ }
+
+ public void reshape(int width, int height)
+ {
+ gl.glMatrixMode(GL_PROJECTION);
+ gl.glLoadIdentity();
+ glu.gluPerspective(90, (float)width/(float)height, 1, 700);
+
+ gl.glMatrixMode(GL_MODELVIEW);
+ gl.glLoadIdentity();
+ gl.glViewport(0,0,width,height);
+ }
+
+ public void display()
+ {
+ if (glj.gljMakeCurrent() == false) return;
+
+ gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ gl.glMatrixMode(GL_MODELVIEW);
+ gl.glLoadIdentity();
+
+ gl.glTranslatef(0, 0, -7.5f);
+
+ gl.glPushMatrix();
+
+ gl.glTranslatef(-5f, -4.5f, -2.5f);
+
+ if(view==1)
+ {
+ gl.glRotatef(90f, 1, 0, 0);
+ } else if(view==2)
+ {
+ gl.glRotatef(-90f, 1, 0, 0);
+ }
+
+ if(rotationOn)
+ {
+ rotate+=rotationStep;
+ if(rotate>=180.0f || rotate<=0.0f)
+ rotationStep*=-1.0f;
+
+ gl.glRotatef(rotate, 0, 1, 0);
+ } else rotate=0;
+
+ glu.gluBeginSurface(theNurb);
+ glu.gluNurbsSurface(theNurb,
+ S_NUMKNOTS, sknots,
+ T_NUMKNOTS, tknots,
+ 4 * T_NUMPOINTS,
+ 4,
+ ctlpoints,
+ S_ORDER, T_ORDER,
+ GL_MAP2_VERTEX_4);
+ glu.gluEndSurface(theNurb);
+
+ gl.glPopMatrix();
+
+ glj.gljSwap();
+ glj.gljCheckGL();
+ glj.gljFree();
+ }
+
+ // Methods required for the implementation of MouseListener
+ public void mouseEntered(MouseEvent evt)
+ {
+ }
+
+ public void mouseExited(MouseEvent evt)
+ {
+ }
+
+ public void mousePressed(MouseEvent evt)
+ {
+ if (!menu_showing)
+ {
+ if ((evt.getModifiers() & evt.BUTTON3_MASK) != 0)
+ {
+ menu_showing = true;
+ save_suspended = isSuspended();
+ if (!save_suspended)
+ {
+ setSuspended(true);
+ repaint(100);
+ try
+ {
+ Thread.currentThread().sleep(200);
+ }
+ catch (Exception e)
+ { }
+ }
+ menu.show(this,evt.getX(),evt.getY());
+ }
+ else
+ {
+ // Must be left button.
+ if (isSuspended()) repaint();
+ }
+ }
+ else
+ {
+ menu_showing = false;
+ setSuspended(save_suspended);
+ }
+ }
+
+ public void mouseReleased(MouseEvent evt)
+ {
+ }
+
+ public void mouseClicked(MouseEvent evt)
+ {
+ }
+
+ // Method required for the implementation of ActionListener
+ public void actionPerformed(ActionEvent evt)
+ {
+ String c = evt.getActionCommand();
+ if (c.equals(VIEW_ROTATION))
+ {
+ rotationOn=!rotationOn;
+ }
+ else if (c.equals(VIEW_FRONT))
+ {
+ view=0;
+ }
+ else if (c.equals(VIEW_TOP))
+ {
+ view=1;
+ }
+ else if (c.equals(VIEW_BOTTOM))
+ {
+ view=2;
+ }
+ if (menu_showing)
+ {
+ menu_showing = false;
+ setSuspended(save_suspended);
+ }
+ }
+
+
+
+ }
+}
diff --git a/demos/MiscDemos/nurbs_plugin13.html b/demos/MiscDemos/nurbs_plugin13.html new file mode 100644 index 0000000..ac13d9e --- /dev/null +++ b/demos/MiscDemos/nurbs_plugin13.html @@ -0,0 +1,46 @@ +<HTML>
+<HEAD>
+<TITLE>Göthel Hard- und Software Entwicklungen</TITLE>
+</HEAD>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+<hr>
+<!--"CONVERTED_APPLET"-->
+<!-- CONVERTER VERSION 1.3 --> +<SCRIPT LANGUAGE="JavaScript"><!-- + var _info = navigator.userAgent; var _ns = false; + var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0); +//--></SCRIPT> +<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!-- + var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0))); +//--></SCRIPT></COMMENT> + +<SCRIPT LANGUAGE="JavaScript"><!-- + if (_ie == true) document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = 500 HEIGHT = 300 codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0"><NOEMBED><XMP>'); + else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.3" CODE = "nurbs.class" WIDTH = 500 HEIGHT = 300 frames = "55" scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html"><NOEMBED><XMP>'); +//--></SCRIPT> +<APPLET CODE = "nurbs.class" WIDTH = 500 HEIGHT = 300></XMP> +<PARAM NAME = CODE VALUE = "nurbs.class" >
+ +<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3"> +<PARAM NAME="scriptable" VALUE="false"> +<PARAM NAME = frames VALUE ="55">
+ +</APPLET> + +</NOEMBED></EMBED></OBJECT> + + +<!-- +<APPLET CODE = "nurbs.class" WIDTH = 500 HEIGHT = 300>
+<PARAM NAME = frames VALUE ="55">
+
+
+</APPLET> +--> +<!--"END_CONVERTED_APPLET"-->
+
+<hr>
+</BODY>
+</HTML>
+
+
diff --git a/demos/MiscDemos/pngTextureTestApplet.html b/demos/MiscDemos/pngTextureTestApplet.html new file mode 100644 index 0000000..4887df3 --- /dev/null +++ b/demos/MiscDemos/pngTextureTestApplet.html @@ -0,0 +1,16 @@ +<HTML>
+<HEAD>
+<TITLE>Göthel Hard- und Software Entwicklungen</TITLE>
+</HEAD>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+<B>Try to drag the mouse (press-button and move) with/without the SHIFT key!</B>
+<br>
+<hr>
+<applet code="pngTextureTestApplet.class" width=600 height=400>
+<param name=frames value="55">
+</applet>
+<hr>
+</BODY>
+</HTML>
+
+
diff --git a/demos/MiscDemos/pngTextureTestApplet.java b/demos/MiscDemos/pngTextureTestApplet.java new file mode 100755 index 0000000..99ea0bb --- /dev/null +++ b/demos/MiscDemos/pngTextureTestApplet.java @@ -0,0 +1,420 @@ +/////////////////////////////////////////////////// +// pngTextureTest in opgl +/////////////////////////////////////////////////// +// progMaxRheiner +/////////////////////////////////////////////////// +// 5.12.1999 +/////////////////////////////////////////////////// + +import gl4java.*; +import gl4java.awt.*; +import gl4java.utils.textures.*; + +import java.awt.*; +import java.awt.event.*; +import java.applet.*; +import java.net.*; + +public class pngTextureTestApplet extends Applet +{ + pngTextureTest canvas = null; + boolean isAnApplet = true; + + public void init() + { + Dimension d = getSize(); + setLayout(new BorderLayout()); + if(isAnApplet) + canvas = new pngTextureTest (d.width, d.height, getCodeBase()); + else + canvas = new pngTextureTest (d.width, d.height, null); + add("Center", canvas); + } + + public static void main( String args[] ) { + pngTextureTestApplet applet = + new pngTextureTestApplet(); + + Frame f = new Frame("pngTextureTestApplet"); + + f.addWindowListener( new WindowAdapter() + { + public void windowClosed(WindowEvent e) + { + System.exit(0); + } + public void windowClosing(WindowEvent e) + { + windowClosed(e); + } + } + ); + + f.setLayout(new BorderLayout()); + f.add("Center", applet); + applet.setSize(500,300); + applet.isAnApplet = false; + applet.init(); + applet.start(); + Dimension ps = applet.getPreferredSize(); + f.setBounds(-100,-100,99,99); + f.setVisible(true); + f.setVisible(false); + Insets i = f.getInsets(); + f.setBounds(0,0, + ps.width+i.left+i.right, + ps.height+i.top+i.bottom); + f.setVisible(true); + } + public void start() + { + } + + + public void stop() + { + } + + class pngTextureTest extends GLCanvas + implements MouseListener,MouseMotionListener + { + float []mPosObjTrans; + float []mPosObjRot; + + Point mousePoint; + Point oldMousePoint; + boolean mouseMoveFlag; + + + int texName[] = {0}; + URL base; + + public pngTextureTest (int w, int h, URL base) + { + super(w, h); + this.base=base; + } + + public void preInit() + { + createOwnWindow = true; + } + + public void init() + { + // texture laden + PngTextureLoader txtLoader1 = new PngTextureLoader(gl, glu); + if(base!=null) + txtLoader1.readTexture(base, "tex/DAISYX.png"); + else { + try { + txtLoader1.readTexture("tex/DAISYX.png"); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + + byte[] pixels1 = txtLoader1.getTexture(); + + if(txtLoader1.isOk()) + { + gl.glEnable(GL_TEXTURE_2D); + + // JAU: let's show us the scaled, + // and the tricky one using glTexSubImage2D + gl.glGenTextures(1,texName); + gl.glBindTexture(GL_TEXTURE_2D,texName[0]); + + gl.glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP); + gl.glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP); + gl.glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); + gl.glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); + + txtLoader1.texImage2DNonScaled(true); + // The Scaled Way + // txtLoader1.texImage2DScaled2Pow2(); + + gl.glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + System.out.println("texture succesfully loaded !"); + System.out.println("texture: "+txtLoader1); + } + // cameraMatrix init + mPosObjTrans=new float[16]; + for(int i=0;i<16;i++) + mPosObjTrans[i]=0f; + mPosObjTrans[0]=mPosObjTrans[5]=mPosObjTrans[10]=mPosObjTrans[15]=1f; + + mPosObjRot=new float[16]; + for(int i=0;i<16;i++) + mPosObjRot[i]=0f; + mPosObjRot[0]=mPosObjRot[5]=mPosObjRot[10]=mPosObjRot[15]=1f; + + TranlateObj(0f,0f,-10f); + + gl.glShadeModel (GL_SMOOTH); + gl.glEnable(GL_DEPTH_TEST); + + gl.glClearColor(0.2f, 0.2f, 0.2f, 1.0f); + gl.glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); + glj.gljCheckGL(); + + canvas.addMouseListener(this); + canvas.addMouseMotionListener(this); + mouseMoveFlag=false; + + reshape(getSize().width, getSize().height); + } + + public void display() + { + int i; + + /* Standard GL4Java Init */ + if( glj.gljMakeCurrent() == false ) + { + System.out.println("problem in use() method"); + return; + } + + // just render it + gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + SetCamera(); + + DrawScene(); + + /* For your animation dutys ;-) */ + glj.gljSwap(); + glj.gljCheckGL(); + glj.gljFree(); + } + + public void reshape(int w, int h) + { + gl.glMatrixMode (GL_MODELVIEW); + gl.glViewport (0, 0, w, h); + gl.glLoadIdentity(); + SetCamera(); + } + + + public void drawGrid(float x0, float y0, + float width, float height, float step) + { + float i,j; + + /* draw grid */ + gl.glBegin(GL_LINES); + for(i=x0;i<width;i+=step) + for(j=y0;j<height;j+=step) + { + if(i==0f && j==0f) + gl.glColor3f (1f,0f,0f); + else + gl.glColor3f (0.6f,0.5f,0.5f); + gl.glVertex2f(0f,j); + gl.glVertex2f(width,j); + gl.glVertex2f(i,height); + gl.glVertex2f(i,0f); + } + gl.glEnd(); + } + + void DrawScene() + { + gl.glMatrixMode (GL_MODELVIEW); + gl.glLoadIdentity (); + + // kamera setzen + gl.glLoadMatrixf(mPosObjTrans); + gl.glMultMatrixf(mPosObjRot); + + gl.glPushMatrix(); + gl.glDisable(GL_TEXTURE_2D); + drawGrid(0f, 0f, 10f, 10f, 0.5f); + gl.glPopMatrix(); + + // obj zeichnen + + gl.glPushMatrix(); + gl.glScalef(2f,2f,2f); + gl.glColor3f(1f,0f,0f); + gl.glDisable(GL_TEXTURE_2D); + DrawObj(); + gl.glPopMatrix(); + + gl.glEnable(GL_BLEND); + gl.glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); + + if(texName[0]!=0) + gl.glEnable(GL_TEXTURE_2D); + + gl.glColor3f(1f,1f,1f); + + gl.glPushMatrix(); + gl.glScalef(3f,3f,3f); + gl.glTranslatef(-1f,0f,1f); + DrawObj(); + gl.glPopMatrix(); + + gl.glPushMatrix(); + gl.glScalef(3f,3f,3f); + gl.glTranslatef(1f,0f,1f); + DrawObj(); + gl.glPopMatrix(); + + gl.glPushMatrix(); + gl.glScalef(3f,3f,3f); + gl.glTranslatef(-2f,1f,1f); + Billboard(); + DrawObj(); + gl.glPopMatrix(); + + gl.glDisable(GL_BLEND); + } + + void DrawObj() + { + gl.glPushMatrix(); + gl.glBegin(GL_QUADS); + gl.glNormal3f(0f,0f,1f); + gl.glTexCoord2f(0f,0f); + gl.glVertex3f(-.5f,-.5f,0f); + + gl.glNormal3f(0f,0f,1f); + gl.glTexCoord2f(0f,1f); + gl.glVertex3f(.5f,-.5f,0f); + + gl.glNormal3f(0f,0f,1f); + gl.glTexCoord2f(1f,1f); + gl.glVertex3f(.5f,.5f,0f); + + gl.glNormal3f(0f,0f,1f); + gl.glTexCoord2f(1f,0f); + gl.glVertex3f(-.5f,.5f,0f); + gl.glEnd(); + gl.glPopMatrix(); + } + + void SetCamera() + { + Dimension dim=getSize(); + float aspect=(float)dim.width/(float)dim.height; + + gl.glMatrixMode (GL_PROJECTION); + gl.glLoadIdentity (); + glu.gluPerspective(60f,aspect,.01,100); + } + + void RotateObj(float degree, + float axisX, + float axisY, + float axisZ) + { + if( glj.gljMakeCurrent() == false ) + { + System.out.println("problem in use() method"); + return; + } + + gl.glMatrixMode (GL_MODELVIEW); + gl.glLoadIdentity (); + + // kamera setzen + gl.glRotatef(degree,axisX,axisY,axisZ); + gl.glMultMatrixf(mPosObjRot); + gl.glGetFloatv(GL_MODELVIEW_MATRIX,mPosObjRot); + + repaint(); + } + + void TranlateObj(float x,float y,float z) + { + if( glj.gljMakeCurrent() == false ) + { + System.out.println("problem in use() method"); + return; + } + + gl.glMatrixMode (GL_MODELVIEW); + gl.glLoadIdentity (); + + // kamera setzen + gl.glLoadMatrixf(mPosObjTrans); + gl.glTranslatef(x,y,z); + gl.glGetFloatv(GL_MODELVIEW_MATRIX,mPosObjTrans); + + repaint(); + } + + // entfernt rotationen aus aktueller matrix + double Billboard() + { + float[] mat=new float[16]; + + gl.glGetFloatv(GL_MODELVIEW_MATRIX,mat); + mat[0] = mat[5] = mat[10] = 1; + mat[1] = mat[2] = mat[4] = mat[6] = mat[8] = mat[9] = 0; + gl.glLoadMatrixf(mat); + + return mat[14]; + } + + // Methods required for the implementation of MouseListener + public void mouseEntered( MouseEvent evt ) + { + } + + public void mouseExited( MouseEvent evt ) + { + } + + public void mousePressed( MouseEvent evt ) + { + if(mouseMoveFlag==false) + { // start drag + mouseMoveFlag=true; + mousePoint=evt.getPoint(); + } + } + + public void mouseReleased( MouseEvent evt ) + { + mouseMoveFlag=false; + } + + public void mouseClicked( MouseEvent evt ) + { + Component comp = evt.getComponent(); + } + + public void mouseDragged(MouseEvent e) + { + if(mouseMoveFlag==true) + { + oldMousePoint=new Point(mousePoint); + mousePoint=e.getPoint(); + + Point dif=new Point(mousePoint.x-oldMousePoint.x, + mousePoint.y-oldMousePoint.y); + + if(e.isShiftDown()==true) + TranlateObj((float)dif.x/6.0f,(float)dif.y/-6.0f,0f); + else if(e.isAltDown()==true) + { + TranlateObj(0f,0f,(float)dif.y/6.0f); + RotateObj(dif.x,0f,0f,1f); + } + else + { + RotateObj(dif.x,0f,1f,0f); + RotateObj(dif.y,1f,0f,0f); + } + } + } + public void mouseMoved(MouseEvent e) + { + } + + + } +} diff --git a/demos/MiscDemos/pngTextureTestApplet_plugin13.html b/demos/MiscDemos/pngTextureTestApplet_plugin13.html new file mode 100644 index 0000000..929700a --- /dev/null +++ b/demos/MiscDemos/pngTextureTestApplet_plugin13.html @@ -0,0 +1,48 @@ +<HTML>
+<HEAD>
+<TITLE>Göthel Hard- und Software Entwicklungen</TITLE>
+</HEAD>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+<B>Try to drag the mouse (press-button and move) with/without the SHIFT key!</B>
+<br>
+<hr>
+<!--"CONVERTED_APPLET"-->
+<!-- CONVERTER VERSION 1.3 --> +<SCRIPT LANGUAGE="JavaScript"><!-- + var _info = navigator.userAgent; var _ns = false; + var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0); +//--></SCRIPT> +<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!-- + var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0))); +//--></SCRIPT></COMMENT> + +<SCRIPT LANGUAGE="JavaScript"><!-- + if (_ie == true) document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = 600 HEIGHT = 400 codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0"><NOEMBED><XMP>'); + else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.3" CODE = "pngTextureTestApplet.class" WIDTH = 600 HEIGHT = 400 frames = "55" scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html"><NOEMBED><XMP>'); +//--></SCRIPT> +<APPLET CODE = "pngTextureTestApplet.class" WIDTH = 600 HEIGHT = 400></XMP> +<PARAM NAME = CODE VALUE = "pngTextureTestApplet.class" >
+ +<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3"> +<PARAM NAME="scriptable" VALUE="false"> +<PARAM NAME = frames VALUE ="55">
+ +</APPLET> + +</NOEMBED></EMBED></OBJECT> + + +<!-- +<APPLET CODE = "pngTextureTestApplet.class" WIDTH = 600 HEIGHT = 400>
+<PARAM NAME = frames VALUE ="55">
+
+
+</APPLET> +--> +<!--"END_CONVERTED_APPLET"-->
+
+<hr>
+</BODY>
+</HTML>
+
+
diff --git a/demos/MiscDemos/select.html b/demos/MiscDemos/select.html new file mode 100644 index 0000000..14b27a6 --- /dev/null +++ b/demos/MiscDemos/select.html @@ -0,0 +1,17 @@ +<HTML> +<HEAD> +<TITLE>Göthel Hard- und Software Entwicklungen</TITLE> +</HEAD> +<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff"> +Press the Left-Mouse Button to change the color! <br> +Press the Middle-Mouse Button to zoom! <br> +Press the Right-Mouse Button to delete! <br> +<br> +<hr> +<applet code="select.class" width=500 height=300> +<param name=frames value="55"> +</applet> +<hr> +</BODY> +</HTML> + diff --git a/demos/MiscDemos/select.java b/demos/MiscDemos/select.java new file mode 100644 index 0000000..a1020c3 --- /dev/null +++ b/demos/MiscDemos/select.java @@ -0,0 +1,596 @@ +/* + * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the name of + * Silicon Graphics may not be used in any adverti(float)Math.sing or + * publicity relating to the software without the specific, prior written + * permission of Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF + * ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +import java.applet.*; +import java.awt.*; +import java.awt.event.*; +import java.lang.*; +import java.util.*; +import java.io.*; +import java.util.*; +import gl4java.GLContext; +import gl4java.awt.GLCanvas; + +import gl4java.utils.glut.*; + +public class select extends Applet +{ + selectCanvas canvas = null; + + /* Initialize the applet */ + + + public void init() + { + Dimension d = getSize(); + setLayout(new BorderLayout()); + canvas = new selectCanvas(d.width, d.height); + add("Center", canvas); + } + + + /* Start the applet */ + + + public void start() + { + } + + + /* Stop the applet */ + + + public void stop() + { + } + + public static void main( String args[] ) { + GLContext.gljNativeDebug = true; + GLContext.gljClassDebug = true; + + select applet = + new select(); + + Frame f = new Frame("select"); + + f.addWindowListener( new WindowAdapter() + { + public void windowClosed(WindowEvent e) + { + System.exit(0); + } + public void windowClosing(WindowEvent e) + { + windowClosed(e); + } + } + ); + + f.setLayout(new BorderLayout()); + f.add("Center", applet); + applet.setSize(500,300); + applet.init(); + applet.start(); + Dimension ps = applet.getPreferredSize(); + f.setBounds(-100,-100,99,99); + f.setVisible(true); + f.setVisible(false); + Insets i = f.getInsets(); + f.setBounds(0,0, + ps.width+i.left+i.right, + ps.height+i.top+i.bottom); + f.setVisible(true); + } + + /* Local GLCanvas extension class */ + + static final int MAXOBJS =10000; + static final int MAXSELECT =100; + static final int MAXFEED =300; + static final int SOLID =1; + static final int LINE =2; + static final int POINT =3; + + protected class object { + float v1[]; + float v2[]; + float v3[]; + float color[]; + + public object() + { + v1=new float[2]; + v2=new float[2]; + v3=new float[2]; + color=new float[3]; + } + } /* objects[MAXOBJS] */ + + + private class selectCanvas extends GLCanvas + implements MouseListener + { + int windW, windH; + + object[] objects=null; + int selectBuf[/*MAXSELECT*/]; + float feedBuf[/*MAXFEED*/]; + int vp[/*4*/]; + float zRotation = 90.0f; + float zoom = 1.0f; + int objectCount; + int numObjects; + boolean linePoly = false; + + public selectCanvas(int w, int h) + { + super(w, h); + } + + public void preInit() + { + doubleBuffer = true; + stereoView = false; + } + + + public void init() + { + int i; + + windW = getSize().width; + windH = getSize().height; + + objects = new object[MAXOBJS]; + for(i=0; i<MAXOBJS; i++) + objects[i]=new object(); + + selectBuf=new int[MAXSELECT]; + feedBuf=new float[MAXFEED]; + vp=new int[4]; + + numObjects = 10; + InitObjects(numObjects); + gl.glGetIntegerv(GL_VIEWPORT, vp); + + addMouseListener(this); + } + + public void InitObjects(int num) + { + int i; + double x, y; + + if (num > MAXOBJS) { + num = MAXOBJS; + } + if (num < 1) { + num = 1; + } + objectCount = num; + + // srand((unsigned int)time(NULL)); + for (i = 0; i < num; i++) { + /* + x = (rand() % 300) - 150; + y = (rand() % 300) - 150; + */ + x = (Math.random() * 300.0) - 150.0; + y = (Math.random() * 300.0) - 150.0; + + objects[i].v1[0] = (float) (x + (Math.random() * 50.0) - 25.0); + objects[i].v2[0] = (float) (x + (Math.random() * 50.0) - 25.0); + objects[i].v3[0] = (float) (x + (Math.random() * 50.0) - 25.0); + objects[i].v1[1] = (float) (y + (Math.random() * 50.0) - 25.0); + objects[i].v2[1] = (float) (y + (Math.random() * 50.0) - 25.0); + objects[i].v3[1] = (float) (y + (Math.random() * 50.0) - 25.0); + objects[i].color[0] = (float) + (((Math.random() * 100.0) + 50.0) / 150.0f); + objects[i].color[1] = (float) + (((Math.random() * 100.0) + 50.0) / 150.0f); + objects[i].color[2] = (float) + (((Math.random() * 100.0) + 50.0) / 150.0f); + } + } + + + public void reshape(int width, int height) + { + + windW = (int)width; + windH = (int)height; + } + + public void Render(int mode) + { + int i; + + for (i = 0; i < objectCount; i++) { + if (mode == GL_SELECT) { + gl.glLoadName(i); + } + gl.glColor3fv(objects[i].color); + gl.glBegin(GL_POLYGON); + gl.glVertex2fv(objects[i].v1); + gl.glVertex2fv(objects[i].v2); + gl.glVertex2fv(objects[i].v3); + gl.glEnd(); + } + } + + public int DoSelect(int x, int y) + { + int hits; + + gl.glSelectBuffer(MAXSELECT, selectBuf); + gl.glRenderMode(GL_SELECT); + gl.glInitNames(); + gl.glPushName(~0); + + gl.glPushMatrix(); + + gl.glViewport(0, 0, windW, windH); + gl.glGetIntegerv(GL_VIEWPORT, vp); + + gl.glMatrixMode(GL_PROJECTION); + gl.glLoadIdentity(); + glu.gluPickMatrix(x, windH-y, 4, 4, vp); + glu.gluOrtho2D(-175, 175, -175, 175); + gl.glMatrixMode(GL_MODELVIEW); + + gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); + gl.glClear(GL_COLOR_BUFFER_BIT); + + gl.glScalef(zoom, zoom, zoom); + gl.glRotatef(zRotation, 0, 0, 1); + + Render(GL_SELECT); + + gl.glPopMatrix(); + + hits = gl.glRenderMode(GL_RENDER); + if (hits <= 0) { + return -1; + } + + return selectBuf[(hits-1)*4+3]; + } + + public void RecolorTri(int h) + { + + objects[h].color[0] = (float) + (((Math.random() * 100.0) + 50.0) / 150.0); + objects[h].color[1] = (float) + (((Math.random() * 100.0) + 50.0) / 150.0); + objects[h].color[2] = (float) + (((Math.random() * 100.0) + 50.0) / 150.0); + } + + public void DeleteTri(int h) + { + + objects[h] = objects[objectCount-1]; + objectCount--; + } + + public void GrowTri(int h) + { + float v[/*2*/]; + int i; + + v = new float[2]; + + v[0] = objects[h].v1[0] + objects[h].v2[0] + objects[h].v3[0]; + v[1] = objects[h].v1[1] + objects[h].v2[1] + objects[h].v3[1]; + v[0] /= 3f; + v[1] /= 3f; + + for (i = 0; i < 3; i++) { + switch (i) { + case 0: + objects[h].v1[0] = 1.5f * (objects[h].v1[0] - v[0]) + v[0]; + objects[h].v1[1] = 1.5f * (objects[h].v1[1] - v[1]) + v[1]; + break; + case 1: + objects[h].v2[0] = 1.5f * (objects[h].v2[0] - v[0]) + v[0]; + objects[h].v2[1] = 1.5f * (objects[h].v2[1] - v[1]) + v[1]; + break; + case 2: + objects[h].v3[0] = 1.5f * (objects[h].v3[0] - v[0]) + v[0]; + objects[h].v3[1] = 1.5f * (objects[h].v3[1] - v[1]) + v[1]; + break; + } + } + } + + // Methods required for the implementation of MouseListener + public void mouseEntered(MouseEvent evt) + { + } + + public void mouseExited(MouseEvent evt) + { + } + + public void mousePressed(MouseEvent evt) + { + } + + public void mouseReleased(MouseEvent evt) + { + } + + public void mouseClicked(MouseEvent evt) + { + int x1 = evt.getX(); + int y1 = evt.getY(); + + /* translate GLUT into GL coordinates */ + // y1 = getSize().height -y1; + + int hit; + + if( glj.gljMakeCurrent() == false ) + { + System.out.println("mouseClicked: problem in GL-use() method"); + return; + } + + hit = DoSelect(x1, y1); + + glj.gljCheckGL(); + glj.gljFree(); + + if (hit != -1) { + if ((evt.getModifiers() & evt.BUTTON1_MASK) != 0) { + RecolorTri(hit); + } + if ((evt.getModifiers() & evt.BUTTON2_MASK) != 0) { + GrowTri(hit); + } + if ((evt.getModifiers() & evt.BUTTON3_MASK) != 0) { + DeleteTri(hit); + } + } + + repaint(); + } + + public void display() + { + + /* Standard GL4Java Init */ + if( glj.gljMakeCurrent() == false ) + { + System.out.println("problem in use() method"); + return; + } + + gl.glPushMatrix(); + + gl.glViewport(0, 0, windW, windH); + gl.glGetIntegerv(GL_VIEWPORT, vp); + + gl.glMatrixMode(GL_PROJECTION); + gl.glLoadIdentity(); + glu.gluOrtho2D(-175, 175, -175, 175); + gl.glMatrixMode(GL_MODELVIEW); + + gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); + gl.glClear(GL_COLOR_BUFFER_BIT); + + gl.glScalef(zoom, zoom, zoom); + gl.glRotatef(zRotation, 0, 0, 1); + + Render(GL_RENDER); + + gl.glPopMatrix(); + + /* For your animation dutys ;-) */ + glj.gljSwap(); + glj.gljCheckGL(); + glj.gljFree(); + } + + public void DrawZoom(int x, int y) + { + + gl.glPushMatrix(); + + gl.glViewport(0, 0, windW, windH); + gl.glGetIntegerv(GL_VIEWPORT, vp); + + gl.glMatrixMode(GL_PROJECTION); + gl.glLoadIdentity(); + glu.gluPickMatrix(x, windH-y, 4, 4, vp); + glu.gluOrtho2D(-175, 175, -175, 175); + gl.glMatrixMode(GL_MODELVIEW); + + gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); + gl.glClear(GL_COLOR_BUFFER_BIT); + + gl.glScalef(zoom, zoom, zoom); + gl.glRotatef(zRotation, 0, 0, 1); + + Render(GL_RENDER); + + gl.glPopMatrix(); + } + + public int DumpFeedbackVert(int i, int n) + { + int index; + + index = i; + if (index+7 > n) { + System.out.println(" ???"); + return n; + } + System.out.println(" ("+feedBuf[index]+" "+ + feedBuf[index+1]+" "+ + feedBuf[index+2]+"), color = ("+ + feedBuf[index+3]+" "+ + feedBuf[index+4]+" "+ + feedBuf[index+5]+")"); + return index + 7; + } + + public void DrawFeedback(int n) + { + int i; + int verts; + + System.out.println("Feedback results ("+n+" floats):"); + for (i = 0; i < n; i++) { + switch ((int)feedBuf[i]) { + case GL_POLYGON_TOKEN: + System.out.print("Polygon"); + i++; + if (i < n) { + verts = (int)feedBuf[i]; + i++; + System.out.print(": "+verts+" vertices"); + } else { + verts = 0; + } + System.out.print("\n"); + while (verts>0) { + i=DumpFeedbackVert(i, n); + verts--; + } + i--; + break; + case GL_LINE_TOKEN: + System.out.print("Line:"); + i++; + i=DumpFeedbackVert(i, n); + i=DumpFeedbackVert(i, n); + i--; + break; + case GL_LINE_RESET_TOKEN: + System.out.print("Line Reset:\n"); + i++; + i=DumpFeedbackVert(i, n); + i=DumpFeedbackVert(i, n); + i--; + break; + default: + System.out.print(feedBuf[i]+"\n"); + break; + } + } + if (i == MAXFEED) { + System.out.print("...\n"); + } + System.out.print("\n"); + } + + public void DoFeedback() + { + int x; + + gl.glFeedbackBuffer(MAXFEED, GL_3D_COLOR, feedBuf); + gl.glRenderMode(GL_FEEDBACK); + + gl.glPushMatrix(); + + gl.glViewport(0, 0, windW, windH); + gl.glGetIntegerv(GL_VIEWPORT, vp); + + gl.glMatrixMode(GL_PROJECTION); + gl.glLoadIdentity(); + glu.gluOrtho2D(-175, 175, -175, 175); + gl.glMatrixMode(GL_MODELVIEW); + + gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); + gl.glClear(GL_COLOR_BUFFER_BIT); + + gl.glScalef(zoom, zoom, zoom); + gl.glRotatef(zRotation, 0, 0, 1); + + Render(GL_FEEDBACK); + + gl.glPopMatrix(); + + x = gl.glRenderMode(GL_RENDER); + if (x == -1) { + x = MAXFEED; + } + + DrawFeedback((int)x); + } + + /* + static void Key2(int key, int x, int y) + { + switch (key) { + case GLUT_KEY_LEFT: + zRotation += 0.5f; + break; + case GLUT_KEY_RIGHT: + zRotation -= 0.5f; + break; + default: + return; + } + + glut.glutPostRedisplay(); + } + + static void Key(unsigned char key, int x, int y) + { + switch (key) { + case 27: + exit(1); + case 'Z': + zoom /= 0.75f; + break; + case 'z': + zoom *= 0.75f; + break; + case 'f': + DoFeedback(); + break; + case 'd': + DrawZoom(x, y); + break; + case 'l': + linePoly = !linePoly; + if (linePoly) { + gl.glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); + } else { + gl.glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); + } + break; + default: + return; + } + + glut.glutPostRedisplay(); + } + */ + + } +} diff --git a/demos/MiscDemos/select_plugin13.html b/demos/MiscDemos/select_plugin13.html new file mode 100644 index 0000000..f4e0e54 --- /dev/null +++ b/demos/MiscDemos/select_plugin13.html @@ -0,0 +1,49 @@ +<HTML> +<HEAD> +<TITLE>Göthel Hard- und Software Entwicklungen</TITLE> +</HEAD> +<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff"> +Press the Left-Mouse Button to change the color! <br> +Press the Middle-Mouse Button to zoom! <br> +Press the Right-Mouse Button to delete! <br> +<br> +<hr> +<!--"CONVERTED_APPLET"--> +<!-- CONVERTER VERSION 1.3 --> +<SCRIPT LANGUAGE="JavaScript"><!-- + var _info = navigator.userAgent; var _ns = false; + var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0); +//--></SCRIPT> +<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!-- + var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0))); +//--></SCRIPT></COMMENT> + +<SCRIPT LANGUAGE="JavaScript"><!-- + if (_ie == true) document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = 500 HEIGHT = 300 codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0"><NOEMBED><XMP>'); + else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.3" CODE = "select.class" WIDTH = 500 HEIGHT = 300 frames = "55" scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html"><NOEMBED><XMP>'); +//--></SCRIPT> +<APPLET CODE = "select.class" WIDTH = 500 HEIGHT = 300></XMP> +<PARAM NAME = CODE VALUE = "select.class" > + +<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3"> +<PARAM NAME="scriptable" VALUE="false"> +<PARAM NAME = frames VALUE ="55"> + +</APPLET> + +</NOEMBED></EMBED></OBJECT> + + +<!-- +<APPLET CODE = "select.class" WIDTH = 500 HEIGHT = 300> +<PARAM NAME = frames VALUE ="55"> + + +</APPLET> +--> +<!--"END_CONVERTED_APPLET"--> + +<hr> +</BODY> +</HTML> + diff --git a/demos/MiscDemos/spectex.html b/demos/MiscDemos/spectex.html new file mode 100644 index 0000000..4ceb658 --- /dev/null +++ b/demos/MiscDemos/spectex.html @@ -0,0 +1,14 @@ +<HTML>
+<HEAD>
+<TITLE>Göthel Hard- und Software Entwicklungen</TITLE>
+</HEAD>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+<hr>
+<applet code="spectex.class" width=400 height=400>
+<param name=frames value="55">
+</applet>
+<hr>
+</BODY>
+</HTML>
+
+
diff --git a/demos/MiscDemos/spectex.java b/demos/MiscDemos/spectex.java new file mode 100644 index 0000000..55d4aae --- /dev/null +++ b/demos/MiscDemos/spectex.java @@ -0,0 +1,336 @@ +/**
+ * @(#) spectex.java
+ * @(#) author: Joe Zimmerman (converted to Java by Sven Goethel)
+ */
+
+/* This program is free software under the license of LGPL */
+
+import java.applet.*;
+import java.awt.*;
+import java.awt.event.*;
+import java.lang.*;
+import java.util.*;
+import java.io.*;
+import java.util.*;
+import gl4java.GLContext;
+import gl4java.awt.GLAnimCanvas;
+import gl4java.applet.SimpleGLAnimApplet1;
+
+public class spectex extends SimpleGLAnimApplet1
+{
+
+ public void init()
+ {
+ super.init();
+ Dimension d = getSize();
+ canvas = new gldemo(d.width, d.height);
+ add("Center", canvas);
+ }
+
+ public static void main( String args[] )
+ {
+ Frame mainFrame = new Frame("spectex");
+
+ spectex applet = new spectex();
+
+ applet.setSize(400, 400);
+ applet.init();
+ applet.start();
+
+ mainFrame.add(applet);
+
+ mainFrame.pack();
+ mainFrame.setVisible(true);
+ }
+
+ private class gldemo extends GLAnimCanvas
+ implements MouseListener, ActionListener
+ {
+ private PopupMenu menu = null;
+ private boolean menu_showing = false;
+ private boolean save_suspended = false;
+ private final String MENUE_0 = "1-pass lighting + texturing";
+ private final String MENUE_1 = "specular lighting";
+ private final String MENUE_2 = "diffuse lighting + texturing";
+ private final String MENUE_3 = "2-pass lighting + texturing";
+ private final String MENUE_4 = "OpenGL 1.2f separate specular";
+
+ final float M_PI = 3.14159265f;
+ final float M_PI_2 = 1.57079632f;
+ int view = 0; /* 0 = front, 1 = top, 2 = bottom */
+
+ int Quadric;
+ int Sphere;
+ float LightPos[/*4*/] = {10.0f, 10.0f, 10.0f, 1.0f};
+ float Delta = 1.0f;
+ int Mode = 0;
+
+ /*static float Blue[4] = {0.0f, 0.0f, 1.0f, 1.0f};*/
+ /*static float Gray[4] = {0.5f, 0.5f, 0.5f, 1.0f};*/
+ float Black[/*4*/] = {0.0f, 0.0f, 0.0f, 1.0f};
+ float White[/*4*/] = {1.0f, 1.0f, 1.0f, 1.0f};
+
+ public gldemo(int w, int h)
+ {
+ super(w, h);
+ GLContext.gljNativeDebug = false;
+ GLContext.gljClassDebug = false;
+ setAnimateFps(30.0);
+ }
+
+ public void preInit()
+ {
+ doubleBuffer = true;
+ stereoView = false;
+ }
+
+ public void init()
+ {
+ gl.glEnable(GL_LIGHTING);
+ gl.glEnable(GL_LIGHT0);
+ gl.glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, 0);
+ gl.glLightModelfv(GL_LIGHT_MODEL_AMBIENT, Black);
+
+ gl.glMaterialfv(GL_FRONT, GL_DIFFUSE, White);
+ gl.glMaterialfv(GL_FRONT, GL_SPECULAR, White);
+ gl.glMaterialf(GL_FRONT, GL_SHININESS, 20.0f);
+
+ /* Actually, these are set again later */
+ gl.glLightfv(GL_LIGHT0, GL_DIFFUSE, White);
+ gl.glLightfv(GL_LIGHT0, GL_SPECULAR, White);
+
+ Quadric = glu.gluNewQuadric();
+ glu.gluQuadricTexture( Quadric, GL_TRUE );
+
+ Sphere= gl.glGenLists(1);
+ gl.glNewList( Sphere, GL_COMPILE );
+ glu.gluSphere( Quadric, 1.0f, 24, 24 );
+ gl.glEndList();
+
+ gl.glEnable(GL_DEPTH_TEST);
+ gl.glEnable(GL_CULL_FACE);
+
+ // byte texImage[64][64][3];
+ byte texImage[] = new byte[64 * 64 * 3];
+ int i,j;
+
+ for (i=0;i<64;i++) {
+ for (j=0;j<64;j++) {
+ int k = ((i>>3)&1) ^ ((j>>3)&1);
+ texImage[i*64*3 + j*3 + 0] = (byte)(255*k);
+ texImage[i*64*3 + j*3 + 1] = (byte)(255*(1-k));
+ texImage[i*64*3 + j*3 + 2] = (byte)(0);
+ }
+ }
+
+ gl.glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+ gl.glTexImage2D( GL_TEXTURE_2D,
+ 0,
+ 3,
+ 64, 64,
+ 0,
+ GL_RGB, GL_UNSIGNED_BYTE,
+ texImage );
+ gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ gl.glEnable(GL_TEXTURE_2D);
+
+ gl.glBlendFunc(GL_ONE, GL_ONE);
+
+ glj.gljCheckGL();
+
+ reshape(getSize().width, getSize().height);
+
+ glj.gljCheckGL();
+
+ menu = new PopupMenu("Options");
+ menu.add(MENUE_0);
+ menu.add(MENUE_1);
+ menu.add(MENUE_2);
+ menu.add(MENUE_3);
+ menu.add(MENUE_4);
+ menu.addActionListener(this);
+ add(menu);
+
+ addMouseListener(this);
+ }
+
+ public void doCleanup()
+ {
+ removeMouseListener(this);
+ menu.removeActionListener(this);
+ }
+
+ public void reshape(int width, int height)
+ {
+ gl.glViewport( 0, 0, width, height );
+ gl.glMatrixMode( GL_PROJECTION );
+ gl.glLoadIdentity();
+ gl.glFrustum( -1.0f, 1.0f, -1.0f, 1.0f, 5.0f, 25.0f );
+ gl.glMatrixMode( GL_MODELVIEW );
+ gl.glLoadIdentity();
+ gl.glTranslatef( 0.0f, 0.0f, -12.0f );
+ }
+
+ public void display()
+ {
+ if (glj.gljMakeCurrent() == false) return;
+
+ gl.glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
+
+ gl.glLightfv(GL_LIGHT0, GL_POSITION, LightPos);
+
+ gl.glPushMatrix();
+ gl.glRotatef(90.0f, 1.0f, 0.0f, 0.0f);
+
+ if (Mode==0) {
+ /* Typical method: diffuse + specular + texture */
+ gl.glEnable(GL_TEXTURE_2D);
+ gl.glLightfv(GL_LIGHT0, GL_DIFFUSE, White); /* enable diffuse */
+ gl.glLightfv(GL_LIGHT0, GL_SPECULAR, White); /* enable specular */
+ //gl.glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SINGLE_COLOR);
+ // glj.gljCheckGL();
+ gl.glCallList(Sphere);
+ }
+ else if (Mode==1) {
+ /* just specular highlight */
+ gl.glDisable(GL_TEXTURE_2D);
+ gl.glLightfv(GL_LIGHT0, GL_DIFFUSE, Black); /* disable diffuse */
+ gl.glLightfv(GL_LIGHT0, GL_SPECULAR, White); /* enable specular */
+ //gl.glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SINGLE_COLOR);
+ gl.glCallList(Sphere);
+ }
+ else if (Mode==2) {
+ /* diffuse textured */
+ gl.glEnable(GL_TEXTURE_2D);
+ gl.glLightfv(GL_LIGHT0, GL_DIFFUSE, White); /* enable diffuse */
+ gl.glLightfv(GL_LIGHT0, GL_SPECULAR, Black); /* disable specular */
+ //gl.glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SINGLE_COLOR);
+ gl.glCallList(Sphere);
+ }
+ else if (Mode==3) {
+ /* 2-pass: diffuse textured then add specular highlight*/
+ gl.glEnable(GL_TEXTURE_2D);
+ gl.glLightfv(GL_LIGHT0, GL_DIFFUSE, White); /* enable diffuse */
+ gl.glLightfv(GL_LIGHT0, GL_SPECULAR, Black); /* disable specular */
+ //gl.glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SINGLE_COLOR);
+ gl.glCallList(Sphere);
+ /* specular highlight */
+ gl.glDepthFunc(GL_EQUAL); /* redraw same pixels */
+ gl.glDisable(GL_TEXTURE_2D);
+ gl.glEnable(GL_BLEND); /* add */
+ gl.glLightfv(GL_LIGHT0, GL_DIFFUSE, Black); /* disable diffuse */
+ gl.glLightfv(GL_LIGHT0, GL_SPECULAR, White); /* enable specular */
+ gl.glCallList(Sphere);
+ gl.glDepthFunc(GL_LESS);
+ gl.glDisable(GL_BLEND);
+ }
+ else if (Mode==4) {
+ /* OpenGL 1.2f's separate diffuse and specular color */
+ gl.glEnable(GL_TEXTURE_2D);
+ gl.glLightfv(GL_LIGHT0, GL_DIFFUSE, White); /* enable diffuse */
+ gl.glLightfv(GL_LIGHT0, GL_SPECULAR, White); /* enable specular */
+ //gl.glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR);
+ gl.glCallList(Sphere);
+ }
+
+ gl.glPopMatrix();
+
+ glj.gljSwap();
+ glj.gljCheckGL();
+ glj.gljFree();
+
+ LightPos[0] += Delta;
+ if (LightPos[0]>15.0f)
+ Delta = -1.0f;
+ else if (LightPos[0]<-15.0f)
+ Delta = 1.0f;
+
+ }
+
+ // Methods required for the implementation of MouseListener
+ public void mouseEntered(MouseEvent evt)
+ {
+ }
+
+ public void mouseExited(MouseEvent evt)
+ {
+ }
+
+ public void mousePressed(MouseEvent evt)
+ {
+ if (!menu_showing)
+ {
+ if ((evt.getModifiers() & evt.BUTTON3_MASK) != 0)
+ {
+ menu_showing = true;
+ save_suspended = isSuspended();
+ if (!save_suspended)
+ {
+ setSuspended(true);
+ repaint(100);
+ try
+ {
+ Thread.currentThread().sleep(200);
+ }
+ catch (Exception e)
+ { }
+ }
+ menu.show(this,evt.getX(),evt.getY());
+ }
+ else
+ {
+ // Must be left button.
+ if (isSuspended()) repaint();
+ }
+ }
+ else
+ {
+ menu_showing = false;
+ setSuspended(save_suspended);
+ }
+ }
+
+ public void mouseReleased(MouseEvent evt)
+ {
+ }
+
+ public void mouseClicked(MouseEvent evt)
+ {
+ }
+
+ // Method required for the implementation of ActionListener
+ public void actionPerformed(ActionEvent evt)
+ {
+ String c = evt.getActionCommand();
+ if (c.equals(MENUE_0))
+ {
+ Mode=0;
+ }
+ else if (c.equals(MENUE_1))
+ {
+ Mode=1;
+ }
+ else if (c.equals(MENUE_2))
+ {
+ Mode=2;
+ }
+ else if (c.equals(MENUE_3))
+ {
+ Mode=3;
+ }
+ else if (c.equals(MENUE_4))
+ {
+ Mode=4;
+ }
+ if (menu_showing)
+ {
+ menu_showing = false;
+ setSuspended(save_suspended);
+ }
+ }
+
+
+
+ }
+}
diff --git a/demos/MiscDemos/spectex_plugin13.html b/demos/MiscDemos/spectex_plugin13.html new file mode 100644 index 0000000..91da5f0 --- /dev/null +++ b/demos/MiscDemos/spectex_plugin13.html @@ -0,0 +1,46 @@ +<HTML>
+<HEAD>
+<TITLE>Göthel Hard- und Software Entwicklungen</TITLE>
+</HEAD>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+<hr>
+<!--"CONVERTED_APPLET"-->
+<!-- CONVERTER VERSION 1.3 --> +<SCRIPT LANGUAGE="JavaScript"><!-- + var _info = navigator.userAgent; var _ns = false; + var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0); +//--></SCRIPT> +<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!-- + var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0))); +//--></SCRIPT></COMMENT> + +<SCRIPT LANGUAGE="JavaScript"><!-- + if (_ie == true) document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = 400 HEIGHT = 400 codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0"><NOEMBED><XMP>'); + else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.3" CODE = "spectex.class" WIDTH = 400 HEIGHT = 400 frames = "55" scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html"><NOEMBED><XMP>'); +//--></SCRIPT> +<APPLET CODE = "spectex.class" WIDTH = 400 HEIGHT = 400></XMP> +<PARAM NAME = CODE VALUE = "spectex.class" >
+ +<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3"> +<PARAM NAME="scriptable" VALUE="false"> +<PARAM NAME = frames VALUE ="55">
+ +</APPLET> + +</NOEMBED></EMBED></OBJECT> + + +<!-- +<APPLET CODE = "spectex.class" WIDTH = 400 HEIGHT = 400>
+<PARAM NAME = frames VALUE ="55">
+
+
+</APPLET> +--> +<!--"END_CONVERTED_APPLET"-->
+
+<hr>
+</BODY>
+</HTML>
+
+
diff --git a/demos/MiscDemos/stencil.html b/demos/MiscDemos/stencil.html new file mode 100644 index 0000000..099ef91 --- /dev/null +++ b/demos/MiscDemos/stencil.html @@ -0,0 +1,20 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
+ <title>Stencil by Silicon Graphics; ported to Java by Ron Cemer</title>
+</head>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+Stencil applet
+<br>Originially written by Silicon Graphics
+<br>
+<B> The left canvas should have 0 stencil-bits !
+<B> The right canvas should have 8 stencil-bits !
+<br>
+<hr>
+<applet code="stencil.class" width=400 height=400>
+</applet>
+<hr>
+</body>
+</html>
diff --git a/demos/MiscDemos/stencil.java b/demos/MiscDemos/stencil.java new file mode 100644 index 0000000..a2d163f --- /dev/null +++ b/demos/MiscDemos/stencil.java @@ -0,0 +1,342 @@ +/**
+ * @(#) stencil.java
+ * @(#) author: Silicon Graphics (converted to Java by Ron Cemer)
+ */
+
+/*
+ * Copyright (c) 1993-1997, Silicon Graphics, Inc.
+ * ALL RIGHTS RESERVED
+ * Permission to use, copy, modify, and distribute this software for
+ * any purpose and without fee is hereby granted, provided that the above
+ * copyright notice appear in all copies and that both the copyright notice
+ * and this permission notice appear in supporting documentation, and that
+ * the name of Silicon Graphics, Inc. not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission.
+ *
+ * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
+ * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
+ * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
+ * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
+ * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
+ * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
+ * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
+ * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
+ * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * US Government Users Restricted Rights
+ * Use, duplication, or disclosure by the Government is subject to
+ * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
+ * (c)(1)(ii) of the Rights in Technical Data and Computer Software
+ * clause at DFARS 252.227-7013 and/or in similar or successor
+ * clauses in the FAR or the DOD or NASA FAR Supplement.
+ * Unpublished-- rights reserved under the copyright laws of the
+ * United States. Contractor/manufacturer is Silicon Graphics,
+ * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
+ *
+ * OpenGL(R) is a registered trademark of Silicon Graphics, Inc.
+ */
+
+/*
+ * This program demonstrates use of the stencil buffer for
+ * masking nonrectangular regions.
+ * Whenever the window is redrawn, a value of 1 is drawn
+ * into a diamond-shaped region in the stencil buffer.
+ * Elsewhere in the stencil buffer, the value is 0.
+ * Then a blue sphere is drawn where the stencil value is 1,
+ * and yellow torii are drawn where the stencil value is not 1.
+ */
+
+import java.applet.*;
+import java.awt.*;
+import java.awt.event.*;
+import java.lang.*;
+import java.util.*;
+import java.io.*;
+import java.util.*;
+import gl4java.GLContext;
+import gl4java.awt.GLCanvas;
+
+public class stencil extends Applet
+{
+ stencilCanvas canvas1 = null;
+ stencilCanvas canvas2 = null;
+
+ Panel cvs = null;
+
+ /* Initialize the applet */
+
+
+ public void init()
+ {
+ Dimension d = getSize();
+ setLayout(new BorderLayout());
+
+ canvas1 = new stencilCanvas(d.width, d.height, 0, false);
+ System.out.println("the left canvas has 0 stencil-bits, self-window");
+ canvas2 = new stencilCanvas(d.width, d.height, 8, true);
+ System.out.println("the right canvas should have 8 stencil-bits, ownWindow");
+
+ cvs = new Panel();
+ cvs.setLayout(new GridLayout(1,2));
+ cvs.add(canvas1);
+ if(canvas2!=null)
+ cvs.add(canvas2);
+ add("Center", cvs);
+ }
+
+
+ public static void main( String args[] )
+ {
+ Frame mainFrame = new Frame("stencil");
+
+ GLContext.gljNativeDebug = true;
+ GLContext.gljClassDebug = true;
+
+ stencil applet = new stencil();
+
+ applet.setSize(400, 400);
+ applet.init();
+ applet.start();
+
+ mainFrame.add(applet);
+
+ mainFrame.pack();
+ mainFrame.setVisible(true);
+ }
+
+ /* Start the applet */
+
+
+ public void start()
+ {
+ }
+
+
+ /* Stop the applet */
+
+
+ public void stop()
+ {
+ }
+
+
+ /* Destroy the applet */
+
+
+
+ /* Local GLCanvas extension class */
+
+
+ private class stencilCanvas extends GLCanvas
+ {
+ private static final float M_PI = 3.14159265359f;
+ private static final int YELLOWMAT = 1, BLUEMAT = 2;
+ private boolean initdone = false;
+
+ public stencilCanvas(int w, int h,
+ int _stencilBits,
+ boolean _createOwnWindow)
+ {
+ super(w, h);
+ stencilBits = _stencilBits;
+ createOwnWindow = _createOwnWindow;
+ }
+
+ public void preInit()
+ {
+ doubleBuffer = true;
+ stereoView = false;
+ }
+
+ public void init()
+ {
+ // Examine some OpenGL properties
+ int [] res=new int[6];
+
+ gl.glGetIntegerv(GL_STENCIL_BITS,res);
+
+ System.out.println("init(): " + this + "\n\t" +
+ "Stencil bits are "+res[0] +"\n\t" +
+ "IsOwnCreatedWindow: "+createOwnWindow);
+
+ float yellow_diffuse[] = { 0.7f, 0.7f, 0.0f, 1.0f };
+ float yellow_specular[] = { 1.0f, 1.0f, 1.0f, 1.0f };
+
+ float blue_diffuse[] = { 0.1f, 0.1f, 0.7f, 1.0f };
+ float blue_specular[] = { 0.1f, 1.0f, 1.0f, 1.0f };
+
+ float position_one[] = { 1.0f, 1.0f, 1.0f, 0.0f };
+
+ gl.glNewList(YELLOWMAT, GL_COMPILE);
+ gl.glMaterialfv(GL_FRONT, GL_DIFFUSE, yellow_diffuse);
+ gl.glMaterialfv(GL_FRONT, GL_SPECULAR, yellow_specular);
+ gl.glMaterialf(GL_FRONT, GL_SHININESS, 64.0f);
+ gl.glEndList();
+
+ gl.glNewList(BLUEMAT, GL_COMPILE);
+ gl.glMaterialfv(GL_FRONT, GL_DIFFUSE, blue_diffuse);
+ gl.glMaterialfv(GL_FRONT, GL_SPECULAR, blue_specular);
+ gl.glMaterialf(GL_FRONT, GL_SHININESS, 45.0f);
+ gl.glEndList();
+
+ gl.glLightfv(GL_LIGHT0, GL_POSITION, position_one);
+
+ gl.glEnable(GL_LIGHT0);
+ gl.glEnable(GL_LIGHTING);
+ gl.glEnable(GL_DEPTH_TEST);
+
+ gl.glClearStencil(0);
+ gl.glEnable(GL_STENCIL_TEST);
+
+ glj.gljCheckGL();
+
+ initdone = true;
+ reshape(getSize().width, getSize().height);
+ }
+
+ public void cvsDispose()
+ {
+ System.out.println("destroy(): " + this);
+ super.cvsDispose();
+ }
+
+ public void reshape(int width, int height)
+ {
+ gl.glViewport(0,0,width,height);
+
+ if (initdone)
+ {
+ /* create a diamond shaped stencil area */
+ gl.glMatrixMode(GL_PROJECTION);
+ gl.glLoadIdentity();
+ if (width <= height)
+ glu.gluOrtho2D
+ (-3.0f,
+ 3.0f,
+ -3.0f*(float)height/(float)width,
+ 3.0f*(float)height/(float)width);
+ else
+ glu.gluOrtho2D
+ (-3.0f*(float)width/(float)height,
+ 3.0f*(float)width/(float)height,
+ -3.0f,
+ 3.0f);
+ gl.glMatrixMode(GL_MODELVIEW);
+ gl.glLoadIdentity();
+
+ gl.glClear(GL_STENCIL_BUFFER_BIT);
+ gl.glStencilFunc(GL_ALWAYS, 1, 1);
+ gl.glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE);
+ gl.glBegin(GL_QUADS);
+ gl.glVertex2f(-1.0f, 0.0f);
+ gl.glVertex2f(0.0f, 1.0f);
+ gl.glVertex2f(1.0f, 0.0f);
+ gl.glVertex2f(0.0f, -1.0f);
+ gl.glEnd();
+ }
+
+ gl.glMatrixMode(GL_PROJECTION);
+ gl.glLoadIdentity();
+ glu.gluPerspective(45.0f, (float)width/(float)height, 3.0f, 7.0f);
+ gl.glMatrixMode(GL_MODELVIEW);
+ gl.glLoadIdentity();
+ gl.glTranslatef(0.0f, 0.0f, -5.0f);
+ }
+
+ public void display()
+ {
+ if (glj.gljMakeCurrent() == false) return;
+
+ /* Draw a sphere in a diamond-shaped section in the
+ * middle of a window with 2 torii.
+ */
+
+ gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ /* draw blue sphere where the stencil is 1 */
+ gl.glStencilFunc(GL_EQUAL, 1, 1);
+ gl.glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
+ gl.glCallList(BLUEMAT);
+
+ int qobj = glu.gluNewQuadric();
+ glu.gluQuadricOrientation(qobj,GLU_OUTSIDE);
+ glu.gluQuadricNormals(qobj,GLU_SMOOTH);
+ glu.gluQuadricTexture(qobj,false);
+ glu.gluSphere(qobj,0.5f,15,15);
+ glu.gluDeleteQuadric(qobj);
+
+ /* draw the tori where the stencil is not 1 */
+ gl.glStencilFunc(GL_NOTEQUAL, 1, 1);
+ gl.glPushMatrix();
+ gl.glRotatef(45.0f, 0.0f, 0.0f, 1.0f);
+ gl.glRotatef(45.0f, 0.0f, 1.0f, 0.0f);
+ gl.glCallList(YELLOWMAT);
+ glutSolidTorus(0.275f, 0.85f, 15, 15);
+ gl.glPushMatrix();
+ gl.glRotatef(90.0f, 1.0f, 0.0f, 0.0f);
+ glutSolidTorus(0.275f, 0.85f, 15, 15);
+ gl.glPopMatrix();
+ gl.glPopMatrix();
+
+ glj.gljSwap();
+ glj.gljCheckGL();
+ glj.gljFree();
+ }
+
+ // Imported from glut.
+ private void glutSolidTorus
+ (float innerRadius,
+ float outerRadius,
+ int nsides,
+ int rings)
+ {
+ doughnut(innerRadius, outerRadius, nsides, rings);
+ }
+
+ // Imported from glut.
+ private void doughnut(float r, float R, int nsides, int rings)
+ {
+ int i, j;
+ float theta, phi, theta1;
+ float cosTheta, sinTheta;
+ float cosTheta1, sinTheta1;
+ float ringDelta, sideDelta;
+
+ ringDelta = 2.0f * M_PI / rings;
+ sideDelta = 2.0f * M_PI / nsides;
+
+ theta = 0.0f;
+ cosTheta = 1.0f;
+ sinTheta = 0.0f;
+ for (i = rings - 1; i >= 0; i--)
+ {
+ theta1 = theta + ringDelta;
+ cosTheta1 = (float)Math.cos(theta1);
+ sinTheta1 = (float)Math.sin(theta1);
+ gl.glBegin(GL_QUAD_STRIP);
+ phi = 0.0f;
+ for (j = nsides; j >= 0; j--)
+ {
+ float cosPhi, sinPhi, dist;
+
+ phi += sideDelta;
+ cosPhi = (float)Math.cos(phi);
+ sinPhi = (float)Math.sin(phi);
+ dist = R + r * cosPhi;
+
+ gl.glNormal3f(cosTheta1 * cosPhi, -sinTheta1 * cosPhi, sinPhi);
+ gl.glVertex3f(cosTheta1 * dist, -sinTheta1 * dist, r * sinPhi);
+ gl.glNormal3f(cosTheta * cosPhi, -sinTheta * cosPhi, sinPhi);
+ gl.glVertex3f(cosTheta * dist, -sinTheta * dist, r * sinPhi);
+ }
+ gl.glEnd();
+ theta = theta1;
+ cosTheta = cosTheta1;
+ sinTheta = sinTheta1;
+ }
+ }
+ }
+}
diff --git a/demos/MiscDemos/stencil_plugin13.html b/demos/MiscDemos/stencil_plugin13.html new file mode 100644 index 0000000..3a654f8 --- /dev/null +++ b/demos/MiscDemos/stencil_plugin13.html @@ -0,0 +1,51 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
+ <title>Stencil by Silicon Graphics; ported to Java by Ron Cemer</title>
+</head>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+Stencil applet
+<br>Originially written by Silicon Graphics
+<br>
+<B> The left canvas should have 0 stencil-bits !
+<B> The right canvas should have 8 stencil-bits !
+<br>
+<hr>
+<!--"CONVERTED_APPLET"-->
+<!-- CONVERTER VERSION 1.3 --> +<SCRIPT LANGUAGE="JavaScript"><!-- + var _info = navigator.userAgent; var _ns = false; + var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0); +//--></SCRIPT> +<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!-- + var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0))); +//--></SCRIPT></COMMENT> + +<SCRIPT LANGUAGE="JavaScript"><!-- + if (_ie == true) document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = 400 HEIGHT = 400 codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0"><NOEMBED><XMP>'); + else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.3" CODE = "stencil.class" WIDTH = 400 HEIGHT = 400 scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html"><NOEMBED><XMP>'); +//--></SCRIPT> +<APPLET CODE = "stencil.class" WIDTH = 400 HEIGHT = 400></XMP> +<PARAM NAME = CODE VALUE = "stencil.class" >
+ +<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3"> +<PARAM NAME="scriptable" VALUE="false"> + +</APPLET> + +</NOEMBED></EMBED></OBJECT> + + +<!-- +<APPLET CODE = "stencil.class" WIDTH = 400 HEIGHT = 400>
+
+
+</APPLET> +--> +<!--"END_CONVERTED_APPLET"-->
+
+<hr>
+</body>
+</html>
diff --git a/demos/MiscDemos/teaambient.html b/demos/MiscDemos/teaambient.html new file mode 100644 index 0000000..2bdbdcd --- /dev/null +++ b/demos/MiscDemos/teaambient.html @@ -0,0 +1,17 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
+ <title>OpenGL Demo - ported by Sven Goethel</title>
+</head>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+Teapots applet
+<br>Originially written by Silicon Graphics
+<br>Ported to Java by Sven Goethel
+<br>
+<applet code="teaambient.class" width=400 height=400>
+</applet>
+<hr>
+</body>
+</html>
diff --git a/demos/MiscDemos/teaambient.java b/demos/MiscDemos/teaambient.java new file mode 100755 index 0000000..aaebf71 --- /dev/null +++ b/demos/MiscDemos/teaambient.java @@ -0,0 +1,182 @@ +/** + * @(#) teaambient.java + * @(#) author: Silicon Graphics, Inc. (converted to Java by Ron Cemer) + */ + +/* + * This program demonstrates lots of material properties. + * A single light source illuminates the objects. + */ + +import java.applet.*; +import java.awt.*; +import java.awt.event.*; +import java.lang.*; +import java.util.*; +import java.io.*; +import java.util.*; +import gl4java.GLContext; +import gl4java.awt.GLCanvas; + +import gl4java.utils.glut.*; + +public class teaambient extends Applet +{ + teaambientCanvas canvas = null; + + + /* Initialize the applet */ + + + public void init() + { + Dimension d = getSize(); + setLayout(new BorderLayout()); + canvas = new teaambientCanvas(d.width, d.height); + add("Center", canvas); + } + + + /* Start the applet */ + + + public void start() + { + } + + + /* Stop the applet */ + + + public void stop() + { + } + + public static void main( String args[] ) + { + Frame mainFrame = new Frame("teaambient"); + + teaambient applet = new teaambient(); + + applet.setSize(400, 600); + applet.init(); + applet.start(); + + mainFrame.add(applet); + + mainFrame.pack(); + mainFrame.setVisible(true); + } + + + /* Local GLCanvas extension class */ + + + private class teaambientCanvas extends GLCanvas + { + GLUTFunc glut = null; + + public teaambientCanvas(int w, int h) + { + super(w, h); + GLContext.gljNativeDebug = false; + GLContext.gljClassDebug = false; + } + + public void preInit() + { + doubleBuffer = true; + stereoView = false; + } + + public void init() + { + System.out.println("init(): " + this); + + glut = new GLUTFuncLightImpl(gl, glu); + + reshape(getSize().width, getSize().height); + + float light_ambient[] = + {0.0f, 0.0f, 0.0f, 1.0f}; + float light_diffuse[] = + {1.0f, 1.0f, 1.0f, 1.0f}; + float light_specular[] = + {1.0f, 1.0f, 1.0f, 1.0f}; + /* light_position is NOT default value */ + float light_position[] = + {1.0f, 0.0f, 0.0f, 0.0f}; + float global_ambient[] = + {0.75f, 0.75f, 0.75f, 1.0f}; + + gl.glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient); + gl.glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse); + gl.glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular); + gl.glLightfv(GL_LIGHT0, GL_POSITION, light_position); + + gl.glLightModelfv(GL_LIGHT_MODEL_AMBIENT, global_ambient); + + gl.glFrontFace(GL_CW); + gl.glEnable(GL_LIGHTING); + gl.glEnable(GL_LIGHT0); + gl.glEnable(GL_AUTO_NORMAL); + gl.glEnable(GL_NORMALIZE); + gl.glDepthFunc(GL_LESS); + gl.glEnable(GL_DEPTH_TEST); + } + + public void display() + { + if (glj.gljMakeCurrent() == false) return; + + float low_ambient[] = + {0.1f, 0.1f, 0.1f, 1.0f}; + float more_ambient[] = + {0.4f, 0.4f, 0.4f, 1.0f}; + float most_ambient[] = + {1.0f, 1.0f, 1.0f, 1.0f}; + + gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + /* material has small ambient reflection */ + gl.glMaterialfv(GL_FRONT, GL_AMBIENT, low_ambient); + gl.glMaterialf(GL_FRONT, GL_SHININESS, 40.0f); + gl.glPushMatrix(); + gl.glTranslatef(0.0f, 2.0f, 0.0f); + glut.glutSolidTeapot(1.0f); + gl.glPopMatrix(); + + /* material has moderate ambient reflection */ + gl.glMaterialfv(GL_FRONT, GL_AMBIENT, more_ambient); + gl.glPushMatrix(); + gl.glTranslatef(0.0f, 0.0f, 0.0f); + glut.glutSolidTeapot(1.0f); + gl.glPopMatrix(); + + /* material has large ambient reflection */ + gl.glMaterialfv(GL_FRONT, GL_AMBIENT, most_ambient); + gl.glPushMatrix(); + gl.glTranslatef(0.0f, -2.0f, 0.0f); + glut.glutSolidTeapot(1.0f); + gl.glPopMatrix(); + glj.gljSwap(); + glj.gljCheckGL(); + glj.gljFree(); + } + + public void reshape(int w, int h) + { + gl.glViewport(0, 0, w, h); + gl.glMatrixMode(GL_PROJECTION); + gl.glLoadIdentity(); + if (w <= h) + gl.glOrtho(-4.0f, 4.0f, -4.0f * (float) h / (float) w, + 4.0f * (float) h / (float) w, -10.0f, 10.0f); + else + gl.glOrtho(-4.0f * (float) w / (float) h, + 4.0f * (float) w / (float) h, -4.0f, 4.0f, -10.0f, 10.0f); + gl.glMatrixMode(GL_MODELVIEW); + } + + } +} diff --git a/demos/MiscDemos/teaambient_plugin13.html b/demos/MiscDemos/teaambient_plugin13.html new file mode 100644 index 0000000..b1ddbb8 --- /dev/null +++ b/demos/MiscDemos/teaambient_plugin13.html @@ -0,0 +1,48 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
+ <title>OpenGL Demo - ported by Sven Goethel</title>
+</head>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+Teapots applet
+<br>Originially written by Silicon Graphics
+<br>Ported to Java by Sven Goethel
+<br>
+<!--"CONVERTED_APPLET"-->
+<!-- CONVERTER VERSION 1.3 --> +<SCRIPT LANGUAGE="JavaScript"><!-- + var _info = navigator.userAgent; var _ns = false; + var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0); +//--></SCRIPT> +<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!-- + var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0))); +//--></SCRIPT></COMMENT> + +<SCRIPT LANGUAGE="JavaScript"><!-- + if (_ie == true) document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = 400 HEIGHT = 400 codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0"><NOEMBED><XMP>'); + else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.3" CODE = "teaambient.class" WIDTH = 400 HEIGHT = 400 scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html"><NOEMBED><XMP>'); +//--></SCRIPT> +<APPLET CODE = "teaambient.class" WIDTH = 400 HEIGHT = 400></XMP> +<PARAM NAME = CODE VALUE = "teaambient.class" >
+ +<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3"> +<PARAM NAME="scriptable" VALUE="false"> + +</APPLET> + +</NOEMBED></EMBED></OBJECT> + + +<!-- +<APPLET CODE = "teaambient.class" WIDTH = 400 HEIGHT = 400>
+
+
+</APPLET> +--> +<!--"END_CONVERTED_APPLET"-->
+
+<hr>
+</body>
+</html>
diff --git a/demos/MiscDemos/teapots.html b/demos/MiscDemos/teapots.html new file mode 100644 index 0000000..834c206 --- /dev/null +++ b/demos/MiscDemos/teapots.html @@ -0,0 +1,17 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
+ <title>Teapots by Silicon Graphics; ported to Java by Ron Cemer</title>
+</head>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+Teapots applet
+<br>Originially written by Silicon Graphics
+<br>Ported to Java by Ron Cemer
+<br>
+<applet code="teapots.class" width=400 height=400>
+</applet>
+<hr>
+</body>
+</html>
diff --git a/demos/MiscDemos/teapots.java b/demos/MiscDemos/teapots.java new file mode 100644 index 0000000..63d42aa --- /dev/null +++ b/demos/MiscDemos/teapots.java @@ -0,0 +1,279 @@ +/**
+ * @(#) teapots.java
+ * @(#) author: Silicon Graphics, Inc. (converted to Java by Ron Cemer)
+ */
+
+/*
+ * This program demonstrates lots of material properties.
+ * A single light source illuminates the objects.
+ */
+
+import java.applet.*;
+import java.awt.*;
+import java.awt.event.*;
+import java.lang.*;
+import java.util.*;
+import java.io.*;
+import java.util.*;
+import gl4java.GLContext;
+import gl4java.awt.GLCanvas;
+
+import gl4java.utils.glut.*;
+
+public class teapots extends Applet
+{
+ teapotsCanvas canvas = null;
+
+
+ /* Initialize the applet */
+
+
+ public void init()
+ {
+ Dimension d = getSize();
+ setLayout(new BorderLayout());
+ canvas = new teapotsCanvas(d.width, d.height);
+ add("Center", canvas);
+ }
+
+
+ /* Start the applet */
+
+
+ public void start()
+ {
+ }
+
+
+ /* Stop the applet */
+
+
+ public void stop()
+ {
+ }
+
+ public static void main( String args[] )
+ {
+ Frame mainFrame = new Frame("teapots");
+
+ teapots applet = new teapots();
+
+ applet.setSize(400, 400);
+ applet.init();
+ applet.start();
+
+ mainFrame.add(applet);
+
+ mainFrame.pack();
+ mainFrame.setVisible(true);
+ }
+
+
+ /* Local GLCanvas extension class */
+
+
+ private class teapotsCanvas extends GLCanvas
+ {
+ int teapotList;
+ GLUTFunc glut = null;
+
+ public teapotsCanvas(int w, int h)
+ {
+ super(w, h);
+ GLContext.gljNativeDebug = false;
+ GLContext.gljClassDebug = false;
+ }
+
+ public void preInit()
+ {
+ doubleBuffer = true;
+ stereoView = false;
+ }
+
+ public void init()
+ {
+ System.out.println("init(): " + this);
+
+ glut = new GLUTFuncLightImpl(gl, glu);
+
+ reshape(getSize().width, getSize().height);
+
+ float ambient[] = {0.0f, 0.0f, 0.0f, 1.0f};
+ float diffuse[] = {1.0f, 1.0f, 1.0f, 1.0f};
+ float specular[] = {1.0f, 1.0f, 1.0f, 1.0f};
+ float position[] = {0.0f, 3.0f, 3.0f, 0.0f};
+
+ float lmodel_ambient[] = {0.2f, 0.2f, 0.2f, 1.0f};
+ float local_view[] = {0.0f};
+
+ gl.glLightfv(GL_LIGHT0, GL_AMBIENT, ambient);
+ gl.glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse);
+ gl.glLightfv(GL_LIGHT0, GL_POSITION, position);
+ gl.glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient);
+ gl.glLightModelfv(GL_LIGHT_MODEL_LOCAL_VIEWER, local_view);
+
+ gl.glFrontFace(GL_CW);
+ gl.glEnable(GL_LIGHTING);
+ gl.glEnable(GL_LIGHT0);
+ gl.glEnable(GL_AUTO_NORMAL);
+ gl.glEnable(GL_NORMALIZE);
+ gl.glEnable(GL_DEPTH_TEST);
+ /* be efficient--make teapot display list */
+ teapotList = gl.glGenLists(1);
+ gl.glNewList(teapotList, GL_COMPILE);
+ glut.glutSolidTeapot(1.0);
+ gl.glEndList();
+
+ glj.gljCheckGL();
+ }
+
+ public void reshape(int width, int height)
+ {
+ gl.glViewport(0,0,width,height);
+ gl.glMatrixMode(GL_PROJECTION);
+ gl.glLoadIdentity();
+ if (width <= height)
+ gl.glOrtho
+ (0.0f,
+ 16.0f,
+ 0.0f,
+ 16.0f*(float)height/(float)width,
+ -10.0f,
+ 10.0f);
+ else
+ gl.glOrtho
+ (0.0f,
+ 16.0f*(float)width/(float)height,
+ 0.0f,
+ 16.0,
+ -10.0f,
+ 10.0f);
+ gl.glMatrixMode(GL_MODELVIEW);
+ }
+
+ public void display()
+ {
+ if (glj.gljMakeCurrent() == false) return;
+
+ /**
+ * First column: emerald, jade, obsidian, pearl, ruby, turquoise
+ * 2nd column: brass, bronze, chrome, copper, gold, silver
+ * 3rd column: black, cyan, green, red, white, yellow plastic
+ * 4th column: black, cyan, green, red, white, yellow rubber
+ */
+ gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ renderTeapot
+ (2.0f, 17.0f, 0.0215f, 0.1745f, 0.0215f,
+ 0.07568f, 0.61424f, 0.07568f, 0.633f, 0.727811f, 0.633f, 0.6f);
+ renderTeapot
+ (2.0f, 14.0f, 0.135f, 0.2225f, 0.1575f,
+ 0.54f, 0.89f, 0.63f, 0.316228f, 0.316228f, 0.316228f, 0.1f);
+ renderTeapot
+ (2.0f, 11.0f, 0.05375f, 0.05f, 0.06625f,
+ 0.18275f, 0.17f, 0.22525f, 0.332741f, 0.328634f, 0.346435f, 0.3f);
+ renderTeapot
+ (2.0f, 8.0f, 0.25f, 0.20725f, 0.20725f,
+ 1f, 0.829f, 0.829f, 0.296648f, 0.296648f, 0.296648f, 0.088f);
+ renderTeapot
+ (2.0f, 5.0f, 0.1745f, 0.01175f, 0.01175f,
+ 0.61424f, 0.04136f, 0.04136f, 0.727811f, 0.626959f, 0.626959f, 0.6f);
+ renderTeapot
+ (2.0f, 2.0f, 0.1f, 0.18725f, 0.1745f,
+ 0.396f, 0.74151f, 0.69102f, 0.297254f, 0.30829f, 0.306678f, 0.1f);
+ renderTeapot
+ (6.0f, 17.0f, 0.329412f, 0.223529f, 0.027451f,
+ 0.780392f, 0.568627f, 0.113725f, 0.992157f, 0.941176f, 0.807843f,
+ 0.21794872f);
+ renderTeapot
+ (6.0f, 14.0f, 0.2125f, 0.1275f, 0.054f,
+ 0.714f, 0.4284f, 0.18144f, 0.393548f, 0.271906f, 0.166721f, 0.2f);
+ renderTeapot
+ (6.0f, 11.0f, 0.25f, 0.25f, 0.25f,
+ 0.4f, 0.4f, 0.4f, 0.774597f, 0.774597f, 0.774597f, 0.6f);
+ renderTeapot
+ (6.0f, 8.0f, 0.19125f, 0.0735f, 0.0225f,
+ 0.7038f, 0.27048f, 0.0828f, 0.256777f, 0.137622f, 0.086014f, 0.1f);
+ renderTeapot
+ (6.0f, 5.0f, 0.24725f, 0.1995f, 0.0745f,
+ 0.75164f, 0.60648f, 0.22648f, 0.628281f, 0.555802f, 0.366065f, 0.4f);
+ renderTeapot
+ (6.0f, 2.0f, 0.19225f, 0.19225f, 0.19225f,
+ 0.50754f, 0.50754f, 0.50754f, 0.508273f, 0.508273f, 0.508273f, 0.4f);
+ renderTeapot
+ (10.0f, 17.0f, 0.0f, 0.0f, 0.0f, 0.01f, 0.01f, 0.01f,
+ 0.50f, 0.50f, 0.50f, .25f);
+ renderTeapot
+ (10.0f, 14.0f, 0.0f, 0.1f, 0.06f, 0.0f, 0.50980392f, 0.50980392f,
+ 0.50196078f, 0.50196078f, 0.50196078f, .25f);
+ renderTeapot
+ (10.0f, 11.0f, 0.0f, 0.0f, 0.0f,
+ 0.1f, 0.35f, 0.1f, 0.45f, 0.55f, 0.45f, .25f);
+ renderTeapot
+ (10.0f, 8.0f, 0.0f, 0.0f, 0.0f, 0.5f, 0.0f, 0.0f,
+ 0.7f, 0.6f, 0.6f, .25f);
+ renderTeapot
+ (10.0f, 5.0f, 0.0f, 0.0f, 0.0f, 0.55f, 0.55f, 0.55f,
+ 0.70f, 0.70f, 0.70f, .25f);
+ renderTeapot
+ (10.0f, 2.0f, 0.0f, 0.0f, 0.0f, 0.5f, 0.5f, 0.0f,
+ 0.60f, 0.60f, 0.50f, .25f);
+ renderTeapot
+ (14.0f, 17.0f, 0.02f, 0.02f, 0.02f, 0.01f, 0.01f, 0.01f,
+ 0.4f, 0.4f, 0.4f, .078125f);
+ renderTeapot
+ (14.0f, 14.0f, 0.0f, 0.05f, 0.05f, 0.4f, 0.5f, 0.5f,
+ 0.04f, 0.7f, 0.7f, .078125f);
+ renderTeapot
+ (14.0f, 11.0f, 0.0f, 0.05f, 0.0f, 0.4f, 0.5f, 0.4f,
+ 0.04f, 0.7f, 0.04f, .078125f);
+ renderTeapot
+ (14.0f, 8.0f, 0.05f, 0.0f, 0.0f, 0.5f, 0.4f, 0.4f,
+ 0.7f, 0.04f, 0.04f, .078125f);
+ renderTeapot
+ (14.0f, 5.0f, 0.05f, 0.05f, 0.05f, 0.5f, 0.5f, 0.5f,
+ 0.7f, 0.7f, 0.7f, .078125f);
+ renderTeapot
+ (14.0f, 2.0f, 0.05f, 0.05f, 0.0f, 0.5f, 0.5f, 0.4f,
+ 0.7f, 0.7f, 0.04f, .078125f);
+ gl.glFlush();
+
+ glj.gljSwap();
+ glj.gljCheckGL();
+ glj.gljFree();
+ }
+
+ /*
+ * Move object into position. Use 3rd through 12th
+ * parameters to specify the material property. Draw a teapot.
+ */
+ private void renderTeapot
+ (float x,
+ float y,
+ float ambr,
+ float ambg,
+ float ambb,
+ float difr,
+ float difg,
+ float difb,
+ float specr,
+ float specg,
+ float specb,
+ float shine)
+ {
+ float mat[] = new float[4];
+
+ gl.glPushMatrix();
+ gl.glTranslatef(x, y, 0.0f);
+ mat[0] = ambr; mat[1] = ambg; mat[2] = ambb; mat[3] = 1.0f;
+ gl.glMaterialfv(GL_FRONT, GL_AMBIENT, mat);
+ mat[0] = difr; mat[1] = difg; mat[2] = difb;
+ gl.glMaterialfv(GL_FRONT, GL_DIFFUSE, mat);
+ mat[0] = specr; mat[1] = specg; mat[2] = specb;
+ gl.glMaterialfv(GL_FRONT, GL_SPECULAR, mat);
+ gl.glMaterialf(GL_FRONT, GL_SHININESS, shine * 128.0f);
+ gl.glCallList(teapotList);
+ gl.glPopMatrix();
+ }
+
+ }
+}
diff --git a/demos/MiscDemos/teapots_plugin13.html b/demos/MiscDemos/teapots_plugin13.html new file mode 100644 index 0000000..19ee75d --- /dev/null +++ b/demos/MiscDemos/teapots_plugin13.html @@ -0,0 +1,48 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
+ <title>Teapots by Silicon Graphics; ported to Java by Ron Cemer</title>
+</head>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+Teapots applet
+<br>Originially written by Silicon Graphics
+<br>Ported to Java by Ron Cemer
+<br>
+<!--"CONVERTED_APPLET"-->
+<!-- CONVERTER VERSION 1.3 --> +<SCRIPT LANGUAGE="JavaScript"><!-- + var _info = navigator.userAgent; var _ns = false; + var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0); +//--></SCRIPT> +<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!-- + var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0))); +//--></SCRIPT></COMMENT> + +<SCRIPT LANGUAGE="JavaScript"><!-- + if (_ie == true) document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = 400 HEIGHT = 400 codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0"><NOEMBED><XMP>'); + else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.3" CODE = "teapots.class" WIDTH = 400 HEIGHT = 400 scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html"><NOEMBED><XMP>'); +//--></SCRIPT> +<APPLET CODE = "teapots.class" WIDTH = 400 HEIGHT = 400></XMP> +<PARAM NAME = CODE VALUE = "teapots.class" >
+ +<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3"> +<PARAM NAME="scriptable" VALUE="false"> + +</APPLET> + +</NOEMBED></EMBED></OBJECT> + + +<!-- +<APPLET CODE = "teapots.class" WIDTH = 400 HEIGHT = 400>
+
+
+</APPLET> +--> +<!--"END_CONVERTED_APPLET"-->
+
+<hr>
+</body>
+</html>
diff --git a/demos/MiscDemos/tess.h b/demos/MiscDemos/tess.h new file mode 100644 index 0000000..998c67b --- /dev/null +++ b/demos/MiscDemos/tess.h @@ -0,0 +1,40 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include <jni.h> +/* Header for class tess */ + +#ifndef _Included_tess +#define _Included_tess +#ifdef __cplusplus +extern "C" { +#endif +/* Inaccessible static: LOCK */ +#undef tess_assert +#define tess_assert 0L +/* Inaccessible static: isInc */ +/* Inaccessible static: incRate */ +#undef tess_TOP_ALIGNMENT +#define tess_TOP_ALIGNMENT 0.0f +#undef tess_CENTER_ALIGNMENT +#define tess_CENTER_ALIGNMENT 0.5f +#undef tess_BOTTOM_ALIGNMENT +#define tess_BOTTOM_ALIGNMENT 1.0f +#undef tess_LEFT_ALIGNMENT +#define tess_LEFT_ALIGNMENT 0.0f +#undef tess_RIGHT_ALIGNMENT +#define tess_RIGHT_ALIGNMENT 1.0f +#undef tess_serialVersionUID +#define tess_serialVersionUID -7644114512714619750LL +#undef tess_serialVersionUID +#define tess_serialVersionUID 4613797578919906343LL +/* Inaccessible static: nameCounter */ +#undef tess_serialVersionUID +#define tess_serialVersionUID -2728009084054400034LL +#undef tess_serialVersionUID +#define tess_serialVersionUID -5836846270535785031LL +/* Inaccessible static: rect */ +/* Inaccessible static: tri */ +/* Inaccessible static: star */ +#ifdef __cplusplus +} +#endif +#endif diff --git a/demos/MiscDemos/tess.html b/demos/MiscDemos/tess.html new file mode 100644 index 0000000..e4496f7 --- /dev/null +++ b/demos/MiscDemos/tess.html @@ -0,0 +1,15 @@ +<HTML> +<HEAD> +<TITLE>Göthel Hard- und Software Entwicklungen</TITLE> +</HEAD> +<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff"> +Press the Right-Mouse Button for a Menu ! +<br> +<hr> +<applet code="tess.class" width=500 height=300> +<param name=frames value="55"> +</applet> +<hr> +</BODY> +</HTML> + diff --git a/demos/MiscDemos/tess.java b/demos/MiscDemos/tess.java new file mode 100644 index 0000000..2cf3a7a --- /dev/null +++ b/demos/MiscDemos/tess.java @@ -0,0 +1,298 @@ +/* + * Copyright (c) 1993-1997, Silicon Graphics, Inc. + * ALL RIGHTS RESERVED + * Permission to use, copy, modify, and distribute this software for + * any purpose and without fee is hereby granted, provided that the above + * copyright notice appear in all copies and that both the copyright notice + * and this permission notice appear in supporting documentation, and that + * the name of Silicon Graphics, Inc. not be used in adverti(float)Math.sing + * or publicity pertaining to distribution of the software without specific, + * written prior permission. + * + * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS" + * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR + * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON + * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, + * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY + * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, + * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF + * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN + * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE + * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE. + * + * US Government Users Restricted Rights + * Use, duplication, or disclosure by the Government is subject to + * restrictions set forth in FAR 52.227f.19(c)(2) or subparagraph + * (c)(1)(ii) of the Rights in Technical Data and Computer Software + * clause at DFARS 252.227f-7013 and/or in similar or successor + * clauses in the FAR or the DOD or NASA FAR Supplement. + * Unpublished-- rights reserved under the copyright laws of the + * United States. Contractor/manufacturer is Silicon Graphics, + * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. + * + * OpenGL(R) is a registered trademark of Silicon Graphics, Inc. + */ + +/* + * tess.c + * This program demonstrates polygon tessellation. + * Two tesselated objects are drawn. The first is a + * rectangle with a triangular hole. The second is a + * smooth shaded, self-intersecting star. + * + * Note the exterior rectangle is drawn with its vertices + * in counter-clockwise order, but its interior clockwise. + * Note the combineCallback is needed for the self-intersecting + * star. Also note that removing the TessProperty for the + * star will make the interior unshaded (WINDING_ODD). + */ + +import gl4java.utils.glut.*; +import gl4java.utils.glut.fonts.*; + +import gl4java.awt.*; +import java.applet.*; +import java.awt.*; +import java.awt.Dimension; +import java.awt.event.*; +import java.lang.*; +import java.util.*; +import gl4java.*; + +public class tess extends Applet { + + MyCanvas canvas = null; + + public void init() + { + Dimension d = getSize(); + setLayout(new BorderLayout()); + canvas = new MyCanvas (d.width, d.height); + add("Center", canvas); + } + + public static void main( String args[] ) + { + Frame mainFrame = new Frame("tessdemo"); + + tess applet = new tess(); + + applet.setSize(400, 400); + applet.init(); + applet.start(); + + mainFrame.add(applet); + + mainFrame.pack(); + mainFrame.setVisible(true); + } + + public void start() + { + } + + + public void stop() + { + } + + public static double rect[/*4*/][/*3*/] = + {{50.0, 50.0, 0.0}, + {200.0, 50.0, 0.0}, + {200.0, 200.0f, 0.0}, + {50.0, 200.0, 0.0}}; + public static double tri[/*3*/][/*3*/] = + {{75.0, 75.0, 0.0}, + {125.0, 175.0, 0.0}, + {175.0, 75.0, 0.0}}; + + public static double star[/*5*/][/*6*/] = + {{250.0, 50.0, 0.0, 1.0, 0.0, 1.0}, + {325.0, 200.0, 0.0, 1.0, 1.0, 0.0}, + {400.0, 50.0, 0.0, 0.0, 1.0, 1.0}, + {250.0, 150.0, 0.0, 1.0, 0.0, 0.0}, + {400.0, 150.0, 0.0, 0.0, 1.0, 0.0}}; + + protected class MyCanvas extends GLCanvas + { + protected GLUTFunc glut = null; + + int startList=-1; + boolean exit = false; + + public MyCanvas(int w, int h) { + super(w,h); + GLContext.gljNativeDebug = false; + GLContext.gljClassDebug = false; + } + + public void init() { + int i; + glut = new GLUTFuncLightImplWithFonts(gl, glu); + + int tobj; + + gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); + + startList = gl.glGenLists(2); + + tobj = glu.gluNewTess(); + glu.gluTessCallback ( tobj, GLU_TESS_VERTEX, gl, + "glVertex3dv", "([D)V", + 3, 0, 0, 0, 0); + glu.gluTessCallback ( tobj, GLU_TESS_BEGIN, this, + "beginCallback", "(I)V", + 0, 0, 0, 0, 0); + glu.gluTessCallback ( tobj, GLU_TESS_END, this, + "endCallback", "()V", + 0, 0, 0, 0, 0); + glu.gluTessCallback ( tobj, GLU_TESS_ERROR, this, + "errorCallback", "(I)V", + 0, 0, 0, 0, 0); + + /* rectangle with triangular hole inside */ + gl.glNewList(startList, GL_COMPILE); + gl.glShadeModel(GL_FLAT); + glu.gluTessBeginPolygon(tobj, (double[])null); + glu.gluTessBeginContour(tobj); + glu.gluTessVertex(tobj, rect[0], rect[0]); + glu.gluTessVertex(tobj, rect[1], rect[1]); + glu.gluTessVertex(tobj, rect[2], rect[2]); + glu.gluTessVertex(tobj, rect[3], rect[3]); + glu.gluTessEndContour(tobj); + glu.gluTessBeginContour(tobj); + glu.gluTessVertex(tobj, tri[0], tri[0]); + glu.gluTessVertex(tobj, tri[1], tri[1]); + glu.gluTessVertex(tobj, tri[2], tri[2]); + glu.gluTessEndContour(tobj); + glu.gluTessEndPolygon(tobj); + gl.glEndList(); + + glu.gluTessCallback ( tobj, GLU_TESS_VERTEX, this, + "vertexCallback", "([D)V", + 6, 0, 0, 0, 0); + glu.gluTessCallback ( tobj, GLU_TESS_BEGIN, this, + "beginCallback", "(I)V", + 0, 0, 0, 0, 0); + glu.gluTessCallback ( tobj, GLU_TESS_END, this, + "endCallback", "()V", + 0, 0, 0, 0, 0); + glu.gluTessCallback ( tobj, GLU_TESS_ERROR, this, + "errorCallback", "(I)V", + 0, 0, 0, 0, 0); + glu.gluTessCallback ( tobj, GLU_TESS_COMBINE, this, + "combineCallback", "([D[D[F[D)V", + 3, 4*6, 4, 6, 0); + + /* smooth shaded, self-intersecting star */ + gl.glNewList(startList + 1, GL_COMPILE); + gl.glShadeModel(GL_SMOOTH); + glu.gluTessProperty(tobj, GLU_TESS_WINDING_RULE, + GLU_TESS_WINDING_POSITIVE); + glu.gluTessBeginPolygon(tobj, (double[])null); + glu.gluTessBeginContour(tobj); + glu.gluTessVertex(tobj, star[0], star[0]); + glu.gluTessVertex(tobj, star[1], star[1]); + glu.gluTessVertex(tobj, star[2], star[2]); + glu.gluTessVertex(tobj, star[3], star[3]); + glu.gluTessVertex(tobj, star[4], star[4]); + glu.gluTessEndContour(tobj); + glu.gluTessEndPolygon(tobj); + gl.glEndList(); + + glu.gluDeleteTess(tobj); + + reshape(getSize().width, getSize().height); + + glj.gljCheckGL(); + } + + public void display() + { + + if(exit) return; + + /* Standard GL4Java Init */ + if( glj.gljMakeCurrent() == false ) + { + System.out.println("problem in use() method"); + return; + } + + gl.glClear(GL_COLOR_BUFFER_BIT); + gl.glColor3f(1.0f, 1.0f, 1.0f); + gl.glCallList(startList); + gl.glCallList(startList + 1); + + /* For your animation dutys ;-) */ + glj.gljSwap(); + glj.gljCheckGL(); + glj.gljFree(); + } + + public void beginCallback(int which) + { + gl.glBegin(which); + } + + public void errorCallback(int errorCode) + { + String str; + + gl.glColor3f( 0.9f, 0.9f, 0.9f ); + gl.glRasterPos2i( 5, 5 ); + + str = glu.gluErrorString( errorCode ); + + glut.glutBitmapString(glut.GLUT_BITMAP_9_BY_15, str); + exit = true; + } + + public void endCallback() + { + gl.glEnd(); + } + + public void vertexCallback(double[/*6*/] vertex) + { + double[] col = new double[3]; + System.arraycopy(vertex, 3, col, 0, 3); + + gl.glColor3dv(col); + gl.glVertex3dv(vertex); + } + + /* combineCallback is used to create a new vertex when edges + * intersect. coordinate location is trivial to calculate, + * but weight[4] may be used to average color, normal, or texture + * coordinate data. In this program, color is weighted. + */ + public void combineCallback(double coords[/*3*/], + double vertex_data[/*4x6*/], + float weight[/*4*/], double[/*6*/] dataOut ) + { + int i; + + dataOut[0] = coords[0]; + dataOut[1] = coords[1]; + dataOut[2] = coords[2]; + for (i = 3; i < 6; i++) + dataOut[i] = weight[0] * vertex_data[0*6+i] + + weight[1] * vertex_data[1*6+i] + + weight[2] * vertex_data[2*6+i] + + weight[3] * vertex_data[3*6+i]; + } + + public void reshape(int w, int h) + { + gl.glViewport( 0, 0, w, h ); + + gl.glMatrixMode( GL_PROJECTION ); + gl.glLoadIdentity(); + glu.gluOrtho2D(0.0f, (double) w, 0.0f, (double) h); + } + + } +} diff --git a/demos/MiscDemos/tess_plugin13.html b/demos/MiscDemos/tess_plugin13.html new file mode 100644 index 0000000..d9b4bc1 --- /dev/null +++ b/demos/MiscDemos/tess_plugin13.html @@ -0,0 +1,47 @@ +<HTML> +<HEAD> +<TITLE>Göthel Hard- und Software Entwicklungen</TITLE> +</HEAD> +<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff"> +Press the Right-Mouse Button for a Menu ! +<br> +<hr> +<!--"CONVERTED_APPLET"--> +<!-- CONVERTER VERSION 1.3 --> +<SCRIPT LANGUAGE="JavaScript"><!-- + var _info = navigator.userAgent; var _ns = false; + var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0); +//--></SCRIPT> +<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!-- + var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0))); +//--></SCRIPT></COMMENT> + +<SCRIPT LANGUAGE="JavaScript"><!-- + if (_ie == true) document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = 500 HEIGHT = 300 codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0"><NOEMBED><XMP>'); + else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.3" CODE = "tess.class" WIDTH = 500 HEIGHT = 300 frames = "55" scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html"><NOEMBED><XMP>'); +//--></SCRIPT> +<APPLET CODE = "tess.class" WIDTH = 500 HEIGHT = 300></XMP> +<PARAM NAME = CODE VALUE = "tess.class" > + +<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3"> +<PARAM NAME="scriptable" VALUE="false"> +<PARAM NAME = frames VALUE ="55"> + +</APPLET> + +</NOEMBED></EMBED></OBJECT> + + +<!-- +<APPLET CODE = "tess.class" WIDTH = 500 HEIGHT = 300> +<PARAM NAME = frames VALUE ="55"> + + +</APPLET> +--> +<!--"END_CONVERTED_APPLET"--> + +<hr> +</BODY> +</HTML> + diff --git a/demos/MiscDemos/tessdemo.html b/demos/MiscDemos/tessdemo.html new file mode 100644 index 0000000..7e07e0b --- /dev/null +++ b/demos/MiscDemos/tessdemo.html @@ -0,0 +1,15 @@ +<HTML> +<HEAD> +<TITLE>Göthel Hard- und Software Entwicklungen</TITLE> +</HEAD> +<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff"> +Press the Right-Mouse Button for a Menu ! +<br> +<hr> +<applet code="tessdemo.class" width=500 height=300> +<param name=frames value="55"> +</applet> +<hr> +</BODY> +</HTML> + diff --git a/demos/MiscDemos/tessdemo.java b/demos/MiscDemos/tessdemo.java new file mode 100755 index 0000000..899b27a --- /dev/null +++ b/demos/MiscDemos/tessdemo.java @@ -0,0 +1,667 @@ +/* $Id$ */ + +/* + * A demo of the GLU polygon tesselation functions written by Bogdan Sikorski. + * This demo isn't built by the Makefile because it needs GLUT. After you've + * installed GLUT you can try this demo. + * Here's the command for IRIX, for example: + cc -g -ansi -prototypes -fullwarn -float -I../include -DSHM tess_demo.c -L../lib -lglut -lMesaGLU -lMesaGL -lm -lX11 -lXext -lXmu -lfpe -lXext -o tess_demo + */ + +/* + * Updated for GLU 1.3f tessellation by Gareth Hughes <[email protected]> + */ + +/* + * $Log$ + * Revision 1.1 2000/11/18 06:53:19 sven + * Initial revision + * + * Revision 1.3f.2.1f 1999/11/16 11:09:09 gareth + * Added combine callback. Converted vertices from ints to floats. + * + * Revision 1.3f 1999/11/04 04:00:42 gareth + * Updated demo for new GLU 1.3f tessellation. Added optimized rendering + * by saving the output of the tessellation into display lists. + * + * Revision 1.2f 1999/09/19 20:09:00 tanner + * + * lots of autoconf updates + * + * Revision 1.1f.1.1f 1999/08/19 00:55:40 jtg + * Imported sources + * + * Revision 3.5f 1999/03/28 18:24:37 brianp + * minor clean-up + * + * Revision 3.4f 1999/02/14 03:37:07 brianp + * fixed callback problem + * + * Revision 3.3f 1998/07/26 01:25:26 brianp + * removed include of gl.h and glu.h + * + * Revision 3.2f 1998/06/29 02:37:30 brianp + * minor changes for Windows (Ted Jump) + * + * Revision 3.1f 1998/06/09 01:53:49 brianp + * main() should return an int + * + * Revision 3.0f 1998/02/14 18:42:29 brianp + * initial rev + * + */ + + +import gl4java.utils.glut.*; +import gl4java.utils.glut.fonts.*; +import gl4java.utils.textures.*; + +import gl4java.awt.*; +import java.applet.*; +import java.awt.*; +import java.awt.Dimension; +import java.awt.event.*; +import java.lang.*; +import java.util.*; +import gl4java.*; + +public class tessdemo extends Applet { + + MyCanvas canvas = null; + boolean isAnApplet = true; + + public void init() + { + Dimension d = getSize(); + setLayout(new BorderLayout()); + canvas = new MyCanvas (d.width, d.height); + add("Center", canvas); + } + + public static void main( String args[] ) + { + Frame mainFrame = new Frame("tessdemo"); + + tessdemo applet = new tessdemo(); + applet.isAnApplet = false; + + applet.setSize(400, 400); + applet.init(); + applet.start(); + + mainFrame.add(applet); + + mainFrame.pack(); + mainFrame.setVisible(true); + + System.out.println(applet.canvas.usage()); + } + + public void start() + { + } + + + public void stop() + { + } + + static final int MAX_POINTS = 256; + static final int MAX_CONTOURS = 32; + static final int MAX_TRIANGLES = 256; + static final String MENU_DONE = "Done"; + static final String MENU_TESS = "Tesselate"; + static final String MENU_CLR = "Clear"; + static final String MENU_SNAPSHOT = "Snapshot"; + static final int MODE_DONE =0; + static final int MODE_CLR =1; + static final int MODE_DEFINE =2; + static final int MODE_TESSELATE =3; + static final int MODE_TESSELATED =4; + + protected class Contour + { + float p[][]; + int point_cnt; + + public Contour() + { + p = new float[MAX_POINTS][2]; + point_cnt = 0; + } + } + + protected class Triangle + { + int no; + float p[][]; + float color[][]; + + public Triangle() + { + no = 0; + p = new float[3][2]; + color = new float[3][3]; + } + } + + protected class MyCanvas extends GLCanvas + implements MouseListener, ActionListener + { + protected GLUTFunc glut = null; + + + private PopupMenu menu = null; + private boolean menu_showing = false; + + int contour_cnt; + int triangle_cnt; + + int mode; + + int list_start; + + float edge_color[]; + + Contour contours[/*MAX_CONTOURS*/]; + + Triangle triangles[/*MAX_TRIANGLES*/]; + + TGATextureGrabber textgrab = null; + + boolean doSnapshot=false; + + public MyCanvas(int w, int h) { + super(w,h); + GLContext.gljNativeDebug = false; + GLContext.gljClassDebug = false; + } + + public void init() { + int i; + glut = new GLUTFuncLightImplWithFonts(gl, glu); + textgrab = new TGATextureGrabber(gl); + contours = new Contour[MAX_CONTOURS]; + for(i=0; i<MAX_CONTOURS; i++) + contours[i] = new Contour(); + triangles = new Triangle[MAX_TRIANGLES]; + for(i=0; i<MAX_TRIANGLES; i++) + triangles[i] = new Triangle(); + edge_color = new float[3]; + + /* clear background to gray */ + gl.glClearColor( 0.4f, 0.4f, 0.4f, 0.0f ); + gl.glShadeModel( GL_FLAT ); + gl.glPolygonMode( GL_FRONT, GL_FILL ); + + contour_cnt = 0; + mode = MODE_DEFINE; + + reshape(getSize().width, getSize().height); + + glj.gljCheckGL(); + + menu = new PopupMenu("Options"); + menu.add(MENU_DONE); + menu.add(MENU_TESS); + menu.add(MENU_CLR); + if(!isAnApplet) + menu.add(MENU_SNAPSHOT); + menu.addActionListener(this); + add(menu); + + addMouseListener(this); + } + + + public void error_callback( int err ) + { + String str; + + gl.glColor3f( 0.9f, 0.9f, 0.9f ); + gl.glRasterPos2i( 5, 5 ); + + str = glu.gluErrorString( err ); + + glut.glutBitmapString(glut.GLUT_BITMAP_9_BY_15, str); + } + + public void begin_callback( int mode ) + { + /* Allow multiple triangles to be output inside the begin/end pair. */ + triangle_cnt = 0; + triangles[triangle_cnt].no = 0; + } + + public void edge_callback( boolean flag ) + { + /* Persist the edge flag across triangles. */ + if ( flag == GL_TRUE ) + { + edge_color[0] = 1.0f; + edge_color[1] = 1.0f; + edge_color[2] = 0.5f; + } + else + { + edge_color[0] = 1.0f; + edge_color[1] = 0.0f; + edge_color[2] = 0.0f; + } + } + + public void end_callback() + { + int i; + + gl.glBegin( GL_LINES ); + + /* Output the three edges of each triangle as lines colored + according to their edge flag. */ + for ( i = 0 ; i < triangle_cnt ; i++ ) + { + gl.glColor3f( triangles[i].color[0][0], + triangles[i].color[0][1], + triangles[i].color[0][2] ); + + gl.glVertex2f( triangles[i].p[0][0], triangles[i].p[0][1] ); + gl.glVertex2f( triangles[i].p[1][0], triangles[i].p[1][1] ); + + gl.glColor3f( triangles[i].color[1][0], + triangles[i].color[1][1], + triangles[i].color[1][2] ); + + gl.glVertex2f( triangles[i].p[1][0], triangles[i].p[1][1] ); + gl.glVertex2f( triangles[i].p[2][0], triangles[i].p[2][1] ); + + gl.glColor3f( triangles[i].color[2][0], + triangles[i].color[2][1], + triangles[i].color[2][2] ); + + gl.glVertex2f( triangles[i].p[2][0], triangles[i].p[2][1] ); + gl.glVertex2f( triangles[i].p[0][0], triangles[i].p[0][1] ); + } + + gl.glEnd(); + } + + public void vertex_callback( float[/*2*/] data ) + { + int no; + + no = triangles[triangle_cnt].no; + + triangles[triangle_cnt].p[no][0] = data[0]; + triangles[triangle_cnt].p[no][1] = data[1]; + + triangles[triangle_cnt].color[no][0] = edge_color[0]; + triangles[triangle_cnt].color[no][1] = edge_color[1]; + triangles[triangle_cnt].color[no][2] = edge_color[2]; + + /* After every three vertices, initialize the next triangle. */ + if ( ++(triangles[triangle_cnt].no) == 3 ) + { + triangle_cnt++; + triangles[triangle_cnt].no = 0; + } + } + + public void combine_callback( double coords[/*3*/], + double vertex_data[/*4xn(=0)*/], + float weight[/*4*/], float[/*m(=2)*/] data ) + { + data[0] = (float) coords[0]; + data[1] = (float) coords[1]; + } + + public void tesse( ) + { + int tobj; + double data[] = new double[3]; + int i, j, point_cnt; + + list_start = gl.glGenLists( 2 ); + + tobj = glu.gluNewTess(); + + if ( tobj != 0 ) + { + glu.gluTessCallback ( tobj, GLU_TESS_BEGIN, gl, + "glBegin", "(I)V", + 0, 0, 0, 0, 0); + glu.gluTessCallback ( tobj, GLU_TESS_VERTEX, gl, + "glVertex2fv", "([F)V", + 2, 0, 0, 0, 0); + glu.gluTessCallback ( tobj, GLU_TESS_END, gl, + "glEnd", "()V", + 0, 0, 0, 0, 0); + glu.gluTessCallback ( tobj, GLU_TESS_ERROR, this, + "error_callback", "(I)V", + 0, 0, 0, 0, 0); + glu.gluTessCallback ( tobj, GLU_TESS_COMBINE, this, + "combine_callback", "([D[D[F[F)V", + 2, 0, 0, 2, 0); + + gl.glNewList( list_start, GL_COMPILE ); + glu.gluBeginPolygon( tobj ); + + for ( j = 0 ; j <= contour_cnt ; j++ ) + { + point_cnt = contours[j].point_cnt; + glu.gluNextContour( tobj, GLU_UNKNOWN ); + + for ( i = 0 ; i < point_cnt ; i++ ) + { + data[0] = (double)( contours[j].p[i][0] ); + data[1] = (double)( contours[j].p[i][1] ); + data[2] = 0.0; + glu.gluTessVertex( tobj, data, contours[j].p[i] ); + } + } + + glu.gluEndPolygon( tobj ); + gl.glEndList(); + + glu.gluTessCallback ( tobj, GLU_TESS_BEGIN, this, + "begin_callback", "(I)V", + 0, 0, 0, 0, 0); + glu.gluTessCallback ( tobj, GLU_TESS_VERTEX, this, + "vertex_callback", "([F)V", + 2, 0, 0, 0, 0); + glu.gluTessCallback ( tobj, GLU_TESS_END, this, + "end_callback", "()V", + 0, 0, 0, 0, 0); + glu.gluTessCallback ( tobj, GLU_TESS_EDGE_FLAG, this, + "edge_callback", "(Z)V", + 0, 0, 0, 0, 0); + + gl.glNewList( list_start + 1, GL_COMPILE ); + glu.gluBeginPolygon( tobj ); + + for ( j = 0 ; j <= contour_cnt ; j++ ) + { + point_cnt = contours[j].point_cnt; + glu.gluNextContour( tobj, GLU_UNKNOWN ); + + for ( i = 0 ; i < point_cnt ; i++ ) + { + data[0] = (double)( contours[j].p[i][0] ); + data[1] = (double)( contours[j].p[i][1] ); + data[2] = 0.0f; + glu.gluTessVertex( tobj, data, contours[j].p[i] ); + } + } + + glu.gluEndPolygon( tobj ); + gl.glEndList(); + + glu.gluDeleteTess( tobj ); + } + } + + public void mouseClicked(MouseEvent evt) + { + if(mode != MODE_DEFINE) + return; + + int x1 = evt.getX(); + int y1 = evt.getY(); + x1 -= x1%10; + y1 -= y1%10; + + float[] P = new float[2]; + int point_cnt; + + /* translate GLUT into GL coordinates */ + + P[0] = x1; + P[1] = getSize().height -y1; + + point_cnt = contours[contour_cnt].point_cnt; + + contours[contour_cnt].p[point_cnt][0] = P[0]; + contours[contour_cnt].p[point_cnt][1] = P[1]; + + contours[contour_cnt].point_cnt++; + repaint(); + } + + public void donePlaceing() + { + int point_cnt; + + point_cnt = contours[contour_cnt].point_cnt; + + if ( point_cnt > 2 ) + { + /* + gl.glBegin( GL_LINES ); + + gl.glVertex2fv( contours[contour_cnt].p[0] ); + gl.glVertex2fv( contours[contour_cnt].p[point_cnt-1] ); + + gl.glEnd(); + */ + contours[contour_cnt].p[point_cnt][0] = -1; + + contour_cnt++; + contours[contour_cnt].point_cnt = 0; + } + } + + public void display() + { + + /* Standard GL4Java Init */ + if( glj.gljMakeCurrent() == false ) + { + System.out.println("problem in use() method"); + return; + } + + int i,j; + int point_cnt; + + gl.glClear( GL_COLOR_BUFFER_BIT ); + + switch ( mode ) + { + case MODE_DONE: + mode=MODE_DEFINE; + donePlaceing(); + repaint(); + break; + + case MODE_CLR: + mode=MODE_DEFINE; + clear(); + repaint(); + break; + + case MODE_DEFINE: + /* draw grid */ + gl.glColor3f( 0.6f, 0.5f, 0.5f ); + + gl.glBegin( GL_LINES ); + + int width = getSize().width; + int height = getSize().height; + for ( i = 0 ; i < width ; i += 10 ) + { + for ( j = 0 ; j < height ; j += 10 ) + { + gl.glVertex2i( 0, j ); + gl.glVertex2i( width, j ); + gl.glVertex2i( i, height ); + gl.glVertex2i( i, 0 ); + } + } + + gl.glEnd( ); + + gl.glColor3f( 1.0f, 1.0f, 0.0f ); + + for ( i = 0 ; i <= contour_cnt ; i++ ) + { + point_cnt = contours[i].point_cnt; + + gl.glBegin( GL_LINES ); + + switch ( point_cnt ) + { + case 0: + break; + case 1: + gl.glVertex2fv( contours[i].p[0] ); + gl.glVertex2fv( contours[i].p[0] ); + break; + case 2: + gl.glVertex2fv( contours[i].p[0] ); + gl.glVertex2fv( contours[i].p[1] ); + break; + default: + --point_cnt; + for ( j = 0 ; j < point_cnt ; j++ ) + { + gl.glVertex2fv( contours[i].p[j] ); + gl.glVertex2fv( contours[i].p[j+1] ); + } + if ( contours[i].p[j+1][0] == -1 ) + { + gl.glVertex2fv( contours[i].p[0] ); + gl.glVertex2fv( contours[i].p[j] ); + } + break; + } + + gl.glEnd(); + } + + // gl.glFinish(); + break; + + case MODE_TESSELATE: + mode=MODE_TESSELATED; + tesse(); + glj.gljCheckGL(); + repaint(); + break; + + case MODE_TESSELATED: + /* draw triangles */ + gl.glColor3f( 0.7f, 0.7f, 0.0f ); + gl.glCallList( list_start ); + + gl.glLineWidth( 2.0f ); + gl.glCallList( list_start + 1 ); + gl.glLineWidth( 1.0f ); + + // gl.glFlush(); + glj.gljCheckGL(); + break; + } + + gl.glColor3f( 1.0f, 1.0f, 0.0f ); + + if(!isAnApplet && doSnapshot) + { + doSnapshot=false; + textgrab.grabPixels(GL_BACK, + 0, 0, cvsGetWidth(), cvsGetHeight()); + textgrab.write2File("tessdemo.tga"); + } + /* For your animation dutys ;-) */ + glj.gljSwap(); + glj.gljCheckGL(); + glj.gljFree(); + } + + public void clear( ) + { + contour_cnt = 0; + contours[0].point_cnt = 0; + triangle_cnt = 0; + + gl.glDeleteLists( list_start, 2 ); + list_start = 0; + } + + public void reshape(int w, int h) + { + gl.glViewport( 0, 0, w, h ); + + gl.glMatrixMode( GL_PROJECTION ); + gl.glLoadIdentity(); + gl.glOrtho( 0.0, (double)w, 0.0, (double)h, -1.0, 1.0 ); + + gl.glMatrixMode( GL_MODELVIEW ); + gl.glLoadIdentity(); + } + + + public String usage( ) + { + return "Use left mouse button to place vertices.\n" + + "Select done from the pop-up menu,\n"+ + "if you are done with placing vertices.\n"+ + "Select tesselate from the pop-up menu.\n"; + } + + + // Methods required for the implementation of MouseListener + public void mouseEntered(MouseEvent evt) + { + } + + public void mouseExited(MouseEvent evt) + { + } + + public void mousePressed(MouseEvent evt) + { + if (!menu_showing) + { + if ((evt.getModifiers() & evt.BUTTON3_MASK) != 0) + { + menu_showing = true; + menu.show(this,evt.getX(),evt.getY()); + } + } + else + { + menu_showing = false; + } + } + + public void mouseReleased(MouseEvent evt) + { + } + + // Method required for the implementation of ActionListener + public void actionPerformed(ActionEvent evt) + { + String c = evt.getActionCommand(); + if (c.equals(MENU_TESS)) + { + mode=MODE_TESSELATE; + } + else if (c.equals(MENU_CLR)) + { + mode=MODE_CLR; + } + else if (c.equals(MENU_DONE)) + { + mode=MODE_DONE; + } + else if (c.equals(MENU_SNAPSHOT)) + { + doSnapshot=true; + } + if (menu_showing) + { + menu_showing = false; + } + repaint(); + } + } +} diff --git a/demos/MiscDemos/tessdemo_plugin13.html b/demos/MiscDemos/tessdemo_plugin13.html new file mode 100644 index 0000000..27e69b2 --- /dev/null +++ b/demos/MiscDemos/tessdemo_plugin13.html @@ -0,0 +1,47 @@ +<HTML> +<HEAD> +<TITLE>Göthel Hard- und Software Entwicklungen</TITLE> +</HEAD> +<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff"> +Press the Right-Mouse Button for a Menu ! +<br> +<hr> +<!--"CONVERTED_APPLET"--> +<!-- CONVERTER VERSION 1.3 --> +<SCRIPT LANGUAGE="JavaScript"><!-- + var _info = navigator.userAgent; var _ns = false; + var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0); +//--></SCRIPT> +<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!-- + var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0))); +//--></SCRIPT></COMMENT> + +<SCRIPT LANGUAGE="JavaScript"><!-- + if (_ie == true) document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = 500 HEIGHT = 300 codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0"><NOEMBED><XMP>'); + else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.3" CODE = "tessdemo.class" WIDTH = 500 HEIGHT = 300 frames = "55" scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html"><NOEMBED><XMP>'); +//--></SCRIPT> +<APPLET CODE = "tessdemo.class" WIDTH = 500 HEIGHT = 300></XMP> +<PARAM NAME = CODE VALUE = "tessdemo.class" > + +<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3"> +<PARAM NAME="scriptable" VALUE="false"> +<PARAM NAME = frames VALUE ="55"> + +</APPLET> + +</NOEMBED></EMBED></OBJECT> + + +<!-- +<APPLET CODE = "tessdemo.class" WIDTH = 500 HEIGHT = 300> +<PARAM NAME = frames VALUE ="55"> + + +</APPLET> +--> +<!--"END_CONVERTED_APPLET"--> + +<hr> +</BODY> +</HTML> + diff --git a/demos/MiscDemos/tesswind.html b/demos/MiscDemos/tesswind.html new file mode 100644 index 0000000..cafaf27 --- /dev/null +++ b/demos/MiscDemos/tesswind.html @@ -0,0 +1,15 @@ +<HTML> +<HEAD> +<TITLE>Göthel Hard- und Software Entwicklungen</TITLE> +</HEAD> +<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff"> +Press the Right-Mouse Button for a Menu ! +<br> +<hr> +<applet code="tesswind.class" width=500 height=500> +<param name=frames value="55"> +</applet> +<hr> +</BODY> +</HTML> + diff --git a/demos/MiscDemos/tesswind.java b/demos/MiscDemos/tesswind.java new file mode 100755 index 0000000..b25ca42 --- /dev/null +++ b/demos/MiscDemos/tesswind.java @@ -0,0 +1,464 @@ +/* + * Copyright (c) 1993-1997, Silicon Graphics, Inc. + * ALL RIGHTS RESERVED + * Permission to use, copy, modify, and distribute this software for + * any purpose and without fee is hereby granted, provided that the above + * copyright notice appear in all copies and that both the copyright notice + * and this permission notice appear in supporting documentation, and that + * the name of Silicon Graphics, Inc. not be used in adverti(float)Math.sing + * or publicity pertaining to distribution of the software without specific, + * written prior permission. + * + * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS" + * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR + * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON + * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, + * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY + * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, + * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF + * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN + * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE + * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE. + * + * US Government Users Restricted Rights + * Use, duplication, or disclosure by the Government is subject to + * restrictions set forth in FAR 52.227f.19(c)(2) or subparagraph + * (c)(1)(ii) of the Rights in Technical Data and Computer Software + * clause at DFARS 252.227f-7013 and/or in similar or successor + * clauses in the FAR or the DOD or NASA FAR Supplement. + * Unpublished-- rights reserved under the copyright laws of the + * United States. Contractor/manufacturer is Silicon Graphics, + * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. + * + * OpenGL(R) is a registered trademark of Silicon Graphics, Inc. + */ + +/* + * tesswind.c + * This program demonstrates the winding rule polygon + * tessellation property. Four tessellated objects are drawn, + * each with very different contours. When the w key is pressed, + * the objects are drawn with a different winding rule. + */ +import gl4java.utils.glut.*; +import gl4java.utils.glut.fonts.*; +import gl4java.utils.textures.*; + +import gl4java.awt.*; +import java.applet.*; +import java.awt.*; +import java.awt.Dimension; +import java.awt.event.*; +import java.lang.*; +import java.util.*; +import gl4java.*; + +public class tesswind extends Applet { + + MyCanvas canvas = null; + boolean isAnApplet = true; + + public void init() + { + Dimension d = getSize(); + setLayout(new BorderLayout()); + canvas = new MyCanvas (d.width, d.height); + add("Center", canvas); + } + + public static void main( String args[] ) + { + Frame mainFrame = new Frame("tessdemo"); + + tesswind applet = new tesswind(); + applet.isAnApplet = false; + + applet.setSize(400, 400); + applet.init(); + applet.start(); + + mainFrame.add(applet); + + mainFrame.pack(); + mainFrame.setVisible(true); + } + + public void start() + { + } + + + public void stop() + { + } + + static final String MENU_1 = "Odd Winding"; + static final String MENU_2 = "Nonzero Winding"; + static final String MENU_3 = "Positive Winding"; + static final String MENU_4 = "Negative Winding"; + static final String MENU_5 = "ABS >= 2 Winding"; + static final String MENU_SNAPSHOT = "Snapshot"; + + public static double rects[/*12*/][/*3*/] = + { { 50.0, 50.0, 0.0}, + { 300.0, 50.0, 0.0}, + { 300.0, 300.0, 0.0}, + { 50.0, 300.0, 0.0}, + { 100.0, 100.0, 0.0}, + { 250.0, 100.0, 0.0}, + { 250.0, 250.0, 0.0}, + { 100.0, 250.0, 0.0}, + { 150.0, 150.0, 0.0}, + { 200.0, 150.0, 0.0}, + { 200.0, 200.0, 0.0}, + { 150.0, 200.0, 0.0} }; + + public static double spiral[/*16*/][/*3*/] = + { { 400.0, 250.0, 0.0}, + { 400.0, 50.0, 0.0}, + { 50.0, 50.0, 0.0}, + { 50.0, 400.0, 0.0}, + { 350.0, 400.0, 0.0}, + { 350.0, 100.0, 0.0}, + { 100.0, 100.0, 0.0}, + { 100.0, 350.0, 0.0}, + { 300.0, 350.0, 0.0}, + { 300.0, 150.0, 0.0}, + { 150.0, 150.0, 0.0}, + { 150.0, 300.0, 0.0}, + { 250.0, 300.0, 0.0}, + { 250.0, 200.0, 0.0}, + { 200.0, 200.0, 0.0}, + { 200.0, 250.0, 0.0} }; + + public static double quad1[/*4*/][/*3*/] = + { {50.0, 150.0, 0.0}, + {350.0, 150.0, 0.0}, + {350.0, 200.0, 0.0}, + {50.0, 200.0, 0.0} }; + + public static double quad2[/*4*/][/*3*/] = + { {100.0, 100.0, 0.0}, + {300.0, 100.0, 0.0}, + {300.0, 350.0, 0.0}, + {100.0, 350.0, 0.0} }; + + public static double tri[/*3*/][/*3*/] = + { {200.0, 50.0, 0.0}, + {250.0, 300.0, 0.0}, + {150.0, 300.0, 0.0} }; + + protected class MyCanvas extends GLCanvas + implements MouseListener, ActionListener + { + protected GLUTFunc glut = null; + + boolean exit = false; + boolean mkNewLists = false; + + int startList=-1; + + private PopupMenu menu = null; + private boolean menu_showing = false; + + TGATextureGrabber textgrab = null; + + boolean doSnapshot=false; + + public MyCanvas(int w, int h) { + super(w,h); + GLContext.gljNativeDebug = false; + GLContext.gljClassDebug = false; + } + + double currentWinding = GLU_TESS_WINDING_ODD; + int currentShape = 0; + int tobj; + int list; + + public void init() { + int i; + glut = new GLUTFuncLightImplWithFonts(gl, glu); + + textgrab = new TGATextureGrabber(gl); + + gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); + gl.glShadeModel(GL_FLAT); + + tobj = glu.gluNewTess(); + + glu.gluTessCallback ( tobj, GLU_TESS_VERTEX, gl, + "glVertex3dv", "([D)V", + 3, 0, 0, 0, 0); + glu.gluTessCallback ( tobj, GLU_TESS_BEGIN, this, + "beginCallback", "(I)V", + 0, 0, 0, 0, 0); + glu.gluTessCallback ( tobj, GLU_TESS_END, this, + "endCallback", "()V", + 0, 0, 0, 0, 0); + glu.gluTessCallback ( tobj, GLU_TESS_ERROR, this, + "errorCallback", "(I)V", + 0, 0, 0, 0, 0); + glu.gluTessCallback ( tobj, GLU_TESS_COMBINE, this, + "combineCallback", "([D[D[F[D)V", + 3, 0, 0, 3, 0); + + + list = gl.glGenLists(4); + makeNewLists(); + + reshape(getSize().width, getSize().height); + + glj.gljCheckGL(); + + menu = new PopupMenu("Options"); + menu.add(MENU_1); + menu.add(MENU_2); + menu.add(MENU_3); + menu.add(MENU_4); + menu.add(MENU_5); + if(!isAnApplet) + menu.add(MENU_SNAPSHOT); + menu.addActionListener(this); + add(menu); + addMouseListener(this); + } + + + /* Make four display lists, + * each with a different tessellated object. + */ + void makeNewLists () + { + int i; + glu.gluTessProperty(tobj, GLU_TESS_WINDING_RULE, + currentWinding); + + gl.glNewList(list, GL_COMPILE); + glu.gluTessBeginPolygon(tobj, (double[])null); + glu.gluTessBeginContour(tobj); + for (i = 0; i < 4; i++) + glu.gluTessVertex(tobj, rects[i], rects[i]); + glu.gluTessEndContour(tobj); + glu.gluTessBeginContour(tobj); + for (i = 4; i < 8; i++) + glu.gluTessVertex(tobj, rects[i], rects[i]); + glu.gluTessEndContour(tobj); + glu.gluTessBeginContour(tobj); + for (i = 8; i < 12; i++) + glu.gluTessVertex(tobj, rects[i], rects[i]); + glu.gluTessEndContour(tobj); + glu.gluTessEndPolygon(tobj); + gl.glEndList(); + + gl.glNewList(list+1, GL_COMPILE); + glu.gluTessBeginPolygon(tobj, (double[])null); + glu.gluTessBeginContour(tobj); + for (i = 0; i < 4; i++) + glu.gluTessVertex(tobj, rects[i], rects[i]); + glu.gluTessEndContour(tobj); + glu.gluTessBeginContour(tobj); + for (i = 7; i >= 4; i--) + glu.gluTessVertex(tobj, rects[i], rects[i]); + glu.gluTessEndContour(tobj); + glu.gluTessBeginContour(tobj); + for (i = 11; i >= 8; i--) + glu.gluTessVertex(tobj, rects[i], rects[i]); + glu.gluTessEndContour(tobj); + glu.gluTessEndPolygon(tobj); + gl.glEndList(); + + gl.glNewList(list+2, GL_COMPILE); + glu.gluTessBeginPolygon(tobj, (double[])null); + glu.gluTessBeginContour(tobj); + for (i = 0; i < 16; i++) + glu.gluTessVertex(tobj, spiral[i], spiral[i]); + glu.gluTessEndContour(tobj); + glu.gluTessEndPolygon(tobj); + gl.glEndList(); + + gl.glNewList(list+3, GL_COMPILE); + glu.gluTessBeginPolygon(tobj, (double[])null); + glu.gluTessBeginContour(tobj); + for (i = 0; i < 4; i++) + glu.gluTessVertex(tobj, quad1[i], quad1[i]); + glu.gluTessEndContour(tobj); + glu.gluTessBeginContour(tobj); + for (i = 0; i < 4; i++) + glu.gluTessVertex(tobj, quad2[i], quad2[i]); + glu.gluTessEndContour(tobj); + glu.gluTessBeginContour(tobj); + for (i = 0; i < 3; i++) + glu.gluTessVertex(tobj, tri[i], tri[i]); + glu.gluTessEndContour(tobj); + glu.gluTessEndPolygon(tobj); + gl.glEndList(); + } + + public void display() + { + + if(exit) return; + + /* Standard GL4Java Init */ + if( glj.gljMakeCurrent() == false ) + { + System.out.println("problem in use() method"); + return; + } + + if(mkNewLists) + { + makeNewLists(); + mkNewLists = false; + } + + gl.glClear(GL_COLOR_BUFFER_BIT); + gl.glColor3f(1.0f, 1.0f, 1.0f); + gl.glPushMatrix(); + gl.glCallList(list); + gl.glTranslatef(0.0f, 500.0f, 0.0f); + gl.glCallList(list+1); + gl.glTranslatef(500.0f, -500.0f, 0.0f); + gl.glCallList(list+2); + gl.glTranslatef(0.0f, 500.0f, 0.0f); + gl.glCallList(list+3); + gl.glPopMatrix(); + + if(!isAnApplet && doSnapshot) + { + doSnapshot=false; + textgrab.grabPixels(GL_BACK, + 0, 0, cvsGetWidth(), cvsGetHeight()); + textgrab.write2File("tesswind.tga"); + } + + /* For your animation dutys ;-) */ + glj.gljSwap(); + glj.gljCheckGL(); + glj.gljFree(); + } + + public void beginCallback(int which) + { + gl.glBegin(which); + } + + public void errorCallback(int errorCode) + { + String str; + + gl.glColor3f( 0.9f, 0.9f, 0.9f ); + gl.glRasterPos2i( 5, 5 ); + + str = glu.gluErrorString( errorCode ); + + glut.glutBitmapString(glut.GLUT_BITMAP_9_BY_15, str); + exit = true; + } + + public void endCallback() + { + gl.glEnd(); + } + + /* combineCallback is used to create a new vertex when edges + * intersect. coordinate location is trivial to calculate, + * but weight[4] may be used to average color, normal, or texture + * coordinate data. + */ + /* ARGSUSED */ + public void combineCallback(double coords[/*3*/], double data[/*4xn*/], + float weight[/*4*/], double[/*3*/] dataOut ) + { + dataOut[0] = coords[0]; + dataOut[1] = coords[1]; + dataOut[2] = coords[2]; + } + + public void reshape(int w, int h) + { + gl.glViewport( 0, 0, w, h ); + + gl.glMatrixMode( GL_PROJECTION ); + gl.glLoadIdentity(); + if (w <= h) + glu.gluOrtho2D(0.0f, 1000.0f, 0.0f, 1000.0f * (double)h/(double)w); + else + glu.gluOrtho2D(0.0f, 1000.0f * (double)w/(double)h, 0.0f, 1000.0f); + gl.glMatrixMode(GL_MODELVIEW); + gl.glLoadIdentity(); + } + + // Methods required for the implementation of MouseListener + public void mouseEntered(MouseEvent evt) + { + } + + public void mouseExited(MouseEvent evt) + { + } + + public void mousePressed(MouseEvent evt) + { + if (!menu_showing) + { + if ((evt.getModifiers() & evt.BUTTON3_MASK) != 0) + { + menu_showing = true; + menu.show(this,evt.getX(),evt.getY()); + } + } + else + { + menu_showing = false; + } + } + + public void mouseClicked(MouseEvent evt) + { + } + + public void mouseReleased(MouseEvent evt) + { + } + + // Method required for the implementation of ActionListener + public void actionPerformed(ActionEvent evt) + { + String c = evt.getActionCommand(); + if (c.equals(MENU_1)) + { + currentWinding = GLU_TESS_WINDING_ODD; + } + else if (c.equals(MENU_2)) + { + currentWinding = GLU_TESS_WINDING_NONZERO; + } + else if (c.equals(MENU_3)) + { + currentWinding = GLU_TESS_WINDING_POSITIVE; + } + else if (c.equals(MENU_4)) + { + currentWinding = GLU_TESS_WINDING_NEGATIVE; + } + else if (c.equals(MENU_5)) + { + currentWinding = GLU_TESS_WINDING_ABS_GEQ_TWO; + } + else if (c.equals(MENU_SNAPSHOT)) + { + doSnapshot=true; + } + if (menu_showing) + { + menu_showing = false; + } + mkNewLists = true; + repaint(); + } + } +} diff --git a/demos/MiscDemos/tesswind_plugin13.html b/demos/MiscDemos/tesswind_plugin13.html new file mode 100644 index 0000000..0786232 --- /dev/null +++ b/demos/MiscDemos/tesswind_plugin13.html @@ -0,0 +1,47 @@ +<HTML> +<HEAD> +<TITLE>Göthel Hard- und Software Entwicklungen</TITLE> +</HEAD> +<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff"> +Press the Right-Mouse Button for a Menu ! +<br> +<hr> +<!--"CONVERTED_APPLET"--> +<!-- CONVERTER VERSION 1.3 --> +<SCRIPT LANGUAGE="JavaScript"><!-- + var _info = navigator.userAgent; var _ns = false; + var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0); +//--></SCRIPT> +<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!-- + var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0))); +//--></SCRIPT></COMMENT> + +<SCRIPT LANGUAGE="JavaScript"><!-- + if (_ie == true) document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = 500 HEIGHT = 500 codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0"><NOEMBED><XMP>'); + else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.3" CODE = "tesswind.class" WIDTH = 500 HEIGHT = 500 frames = "55" scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html"><NOEMBED><XMP>'); +//--></SCRIPT> +<APPLET CODE = "tesswind.class" WIDTH = 500 HEIGHT = 500></XMP> +<PARAM NAME = CODE VALUE = "tesswind.class" > + +<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3"> +<PARAM NAME="scriptable" VALUE="false"> +<PARAM NAME = frames VALUE ="55"> + +</APPLET> + +</NOEMBED></EMBED></OBJECT> + + +<!-- +<APPLET CODE = "tesswind.class" WIDTH = 500 HEIGHT = 500> +<PARAM NAME = frames VALUE ="55"> + + +</APPLET> +--> +<!--"END_CONVERTED_APPLET"--> + +<hr> +</BODY> +</HTML> + diff --git a/demos/MiscDemos/tex/DAISYX.png b/demos/MiscDemos/tex/DAISYX.png Binary files differnew file mode 100644 index 0000000..4892a0b --- /dev/null +++ b/demos/MiscDemos/tex/DAISYX.png diff --git a/demos/MiscDemos/tex/a.tga b/demos/MiscDemos/tex/a.tga Binary files differnew file mode 100644 index 0000000..2bbd4d5 --- /dev/null +++ b/demos/MiscDemos/tex/a.tga diff --git a/demos/MiscDemos/tex/gleeson_head.jpg b/demos/MiscDemos/tex/gleeson_head.jpg Binary files differnew file mode 100644 index 0000000..354cd2f --- /dev/null +++ b/demos/MiscDemos/tex/gleeson_head.jpg diff --git a/demos/MiscDemos/tex/gnu-head-sm.png b/demos/MiscDemos/tex/gnu-head-sm.png Binary files differnew file mode 100755 index 0000000..fc91ff9 --- /dev/null +++ b/demos/MiscDemos/tex/gnu-head-sm.png diff --git a/demos/MiscDemos/tex/jaulogo-300x80.png b/demos/MiscDemos/tex/jaulogo-300x80.png Binary files differnew file mode 100755 index 0000000..4ed48f3 --- /dev/null +++ b/demos/MiscDemos/tex/jaulogo-300x80.png diff --git a/demos/RectRenderSpeed/GL4JCanvas.java b/demos/RectRenderSpeed/GL4JCanvas.java new file mode 100644 index 0000000..7366ee0 --- /dev/null +++ b/demos/RectRenderSpeed/GL4JCanvas.java @@ -0,0 +1,674 @@ + +import java.io.*; + +import gl4java.GLContext; +import gl4java.awt.GLCanvas; + +//---------------------------------------------- +// class definition. +//---------------------------------------------- +public class GL4JCanvas extends gl4java.awt.GLCanvas +{ + private int _canvas_wid_pix; + private int _canvas_hei_pix; + private int _num_colors = 50; + private boolean refresh_gl = false; + +//---------------------------------------------- +// method constructor. +//---------------------------------------------- +public GL4JCanvas (int wid_pix, int hei_pix) +{ + super (wid_pix, hei_pix); + + _canvas_wid_pix = wid_pix; + _canvas_hei_pix = hei_pix; + +} +//---------------------------------------------- +// method preInit +//---------------------------------------------- +public void preInit () +{ + stereoView = false; +} + +public void preSetDblBuffer(boolean dblBuffer) +{ + doubleBuffer = dblBuffer; +} + +//---------------------------------------------- +// method init +//---------------------------------------------- +public void init () +{ +} +//---------------------------------------------- +// method display +//---------------------------------------------- +public void display () +{ + boolean loc_err; + + loc_err = false; + + if(scripting_modes_number>0) + { + int i; + for (i=0; i<scripting_modes_number; i++) + { + System.out.println("trying mode: "+scripting_modes[i]); + if(setRenderMode(scripting_modes[i])==false) + { + System.out.println("render mode: "+scripting_modes[i]+" not supported !"); + continue; + } + gl_display(); + } + cvsDispose(); + System.exit(0); + } + + if(refresh_gl) + { + refresh_gl = false; + gl_display (); + } +} + +public void setRefreshGL(boolean b) +{ + refresh_gl = b; +} + + +public void printTimeDelta(long startTime, int count) +{ + long t1 = System.currentTimeMillis (); + System.out.println ("... elapsed time: " + +((double)(t1-startTime)/1000.0)+" Sec"); + if(count>0) + System.out.println ("... rate: " + +(((double)(t1-startTime))*(1000.0/(double)count)) + +" SPMR (Sec Per Million Rectangles)"); +} + +public double getTimeDeltaSecs(long startTime) +{ + long t1 = System.currentTimeMillis (); + return (double)(t1-startTime)/1000.0; +} + +public static final String modes = new String ( + " 0 - Immediate + FLAT + ColorIndex + glRect\n"+ + " 1 - Immediate + FLAT + ColorIndex + glRectiv\n"+ + " 2 - Immediate + FLAT + ColorIndex + POLYGON + glVertex2i(x2,y2);\n"+ + " 3 - Immediate + FLAT + ColorIndex + QUADS + glVertex2i(x2,y2);\n"+ + " 10 - Immediate + FLAT + RGB + glRect\n"+ + " 11 - Immediate + FLAT + RGB + glRectiv\n"+ + " 12 - Immediate + FLAT + RGB + POLYGON + glVertex2i(x2,y2);\n"+ + " 13 - Immediate + FLAT + RGB + QUADS + glVertex2i(x2,y2);\n"+ + " 20 - Immediate + SMOOTH + ColorIndex + glRect\n"+ + " 21 - Immediate + SMOOTH + ColorIndex + glRectiv\n"+ + " 22 - Immediate + SMOOTH + ColorIndex + POLYGON + glVertex2i(x2,y2);\n"+ + " 23 - Immediate + SMOOTH + ColorIndex + QUADS + glVertex2i(x2,y2);\n"+ + " 30 - Immediate + SMOOTH + RGB + glRect\n"+ + " 31 - Immediate + SMOOTH + RGB + glRectiv\n"+ + " 32 - Immediate + SMOOTH + RGB + POLYGON + glVertex2i(x2,y2);\n"+ + " 33 - Immediate + SMOOTH + RGB + QUADS + glVertex2i(x2,y2);\n"+ + "100 - COMPILED + FLAT + ColorIndex + glRect\n"+ + "101 - COMPILED + FLAT + ColorIndex + glRectiv\n"+ + "102 - COMPILED + FLAT + ColorIndex + POLYGON + glVertex2i(x2,y2);\n"+ + "103 - COMPILED + FLAT + ColorIndex + QUADS + glVertex2i(x2,y2);\n"+ + "110 - COMPILED + FLAT + RGB + glRect\n"+ + "111 - COMPILED + FLAT + RGB + glRectiv\n"+ + "112 - COMPILED + FLAT + RGB + POLYGON + glVertex2i(x2,y2);\n"+ + "113 - COMPILED + FLAT + RGB + QUADS + glVertex2i(x2,y2);\n"+ + "120 - COMPILED + SMOOTH + ColorIndex + glRect\n"+ + "121 - COMPILED + SMOOTH + ColorIndex + glRectiv\n"+ + "122 - COMPILED + SMOOTH + ColorIndex + POLYGON + glVertex2i(x2,y2);\n"+ + "123 - COMPILED + SMOOTH + ColorIndex + QUADS + glVertex2i(x2,y2);\n"+ + "130 - COMPILED + SMOOTH + RGB + glRect\n"+ + "131 - COMPILED + SMOOTH + RGB + glRectiv\n"+ + "132 - COMPILED + SMOOTH + RGB + POLYGON + glVertex2i(x2,y2);\n"+ + "133 - COMPILED + SMOOTH + RGB + GL_QUADS+ glVertex2i(x2,y2);\n"+ + "\n" ); + +public boolean useDisplayList = false; +public boolean useSmoothShading = false; +public boolean useRGB = false; + +public int[] scripting_modes = null; +public int scripting_modes_number = 0; + +public void setScriptModes(int[] modes, int len) +{ + scripting_modes=modes; + scripting_modes_number=len; +} + +/** + * renderMode + * 0 - glRect + * 1 - glRectiv + * 2 - POLYGON + glVertex2i + * 3 - QUADS + glVertex2i + */ +public int renderMode = 0; + +public int dez_mode = 0; + +public boolean setRenderMode(int mode) +{ + useDisplayList = false; + useSmoothShading = false; + useRGB = false; + renderMode = 0; + + if(mode>133 || mode<0) + return false; + + dez_mode=mode; + + if(mode>=100) + { + useDisplayList=true; + mode -= 100; + } + + if(mode>=20) + { + useSmoothShading=true; + mode -= 20; + } + if(mode>=10) + { + useRGB=true; + mode -= 10; + } + + if(renderMode>3) + return false; + + renderMode=mode; + + return true; +} + +public String getGlobalModeDescription() +{ + String str = dez_mode + ": "; + + if(doubleBuffer) + str = str + "DoubleBuffer"; + else + str = str + "FrontBuffer "; + + if(useDisplayList) + str = str + " + COMPILED "; + else + str = str + " + IMMEDIATE"; + + if(useSmoothShading) + str = str + " + Smooth"; + else + str = str + " + Flat "; + + if(useRGB) + str = str + " + RGB "; + else + str = str + " + ColorIndex"; + + switch (renderMode) + { + case 0: str = str + " + glRect"; break; + case 1: str = str + " + glRectiv"; break; + case 2: str = str + " + POLYGON + glVertex2i"; break; + case 3: str = str + " + QUADS + glVertex2i"; break; + } + + return str; +} + +public void gl_display () +{ + boolean debug; + boolean loc_err; + int [] ramp; + float [][] seis_amps = null; + MapAmpToIndex amp_mapper; + long t0, t1; + + debug = false; + + System.out.println(">MODE "+getGlobalModeDescription()); + + t0 = System.currentTimeMillis(); + t1 = System.currentTimeMillis(); + + loc_err = false; + + ramp = MakeRampJ (_num_colors); + if ( ! loc_err) + { + if (debug) + { + for (int loopi = 0; loopi < _num_colors; loopi++) + { + System.out.println ("GL4JCanvas`gl_display- ramp ["+loopi+"] " + +ramp [loopi]); + } + } + } + + // plz_note- prepare seismic data for drawing + if ( ! loc_err) + { + // JAU: seis_amps = GetSeisData (1250, 800); + // seis_amps = GetSeisData (600, 400); + seis_amps = GetSeisData (1250, 800); + if (seis_amps == null) + { + // look_here- error_handling + loc_err = true; + System.out.println + ("GL4JCanvas`gl_display- ERROR- call to " + +" _seis_data.GetSeisData returned "+seis_amps); + } + else + { + if (debug) System.out.println + ("GL4JCanvas`gl_display- call to GetSeisData succeeded"); + } + if (debug) + { + for (int loopi = 0; loopi < seis_amps.length; loopi++) + { + for (int loopj = 0; loopj < seis_amps[0].length; loopj++) + { + if (loopi == 0 || loopi == seis_amps.length - 1) + { + if (loopj >= 80 && loopj < 120) + { + System.out.println + ("GL4JCanvas`gl_display- seis_amps ["+loopi + +"]["+loopj+"] "+seis_amps [loopi][loopj]); + } + } + } + } + } + } + + System.out.println(">Time for fetching Seis-Data: "+ + getTimeDeltaSecs(t1)); + + t1 = System.currentTimeMillis(); + + // plz_note- setup mapper (maps from seismic amplitude to + // plz_note- color table index) + amp_mapper = new MapAmpToIndex (ramp, seis_amps); + + System.out.println(">Time for map color-table: "+ + getTimeDeltaSecs(t1)); + + t1 = System.currentTimeMillis(); + + // plz_note-prepare openGL + if ( ! loc_err) + { + if (glj.gljMakeCurrent () == false) + { + System.out.println ("GL4JCanvas`gl_display- gljMakeCurrent" + +" is false"); + loc_err = true; + } + } + + if ( ! loc_err) + { + if (cvsIsInit () != true) + { + System.out.println ("GL4JCanvas`gl_display- cvsIsInit not true"); + loc_err = true; + } + } + + if ( ! loc_err) + { + if(!doubleBuffer) + gl.glDrawBuffer (GL_FRONT); + + if(!useRGB) + gl.glClearIndex (0.0f); // 1.0 is black + + gl.glClear (GL_COLOR_BUFFER_BIT); + + // set current color index + if(!useRGB) + gl.glIndexi (1); + + gl.glMatrixMode (GL_PROJECTION); + gl.glLoadIdentity (); + + // left, right top, bottom clip planes. + glu.gluOrtho2D (0.0f, (float) (this._canvas_wid_pix), + 0.0f, (float) (this._canvas_hei_pix)); + // look_here- see OpenGL Programming Guide, page 182 + //gl.glMatrixMode (GL_MODELVIEW); + //gl.glLoadIdentity (); + + // plz_note- + int num_trc = seis_amps.length; + int num_sam = seis_amps [0].length; + if (debug) + { + System.out.println ("GL4JCanvas`gl_display- num_trc "+num_trc); + System.out.println ("GL4JCanvas`gl_display- num_sam "+num_sam); + } + + int rect_wid = (int) Math.ceil + ((double)((double) (this._canvas_wid_pix) / (double) (num_trc))); + rect_wid++; + int rect_hei = (int) Math.ceil + ((double)((double) (this._canvas_hei_pix)/ (double) (num_sam))); + rect_hei++; + if (debug) + { + System.out.println ("GL4JCanvas`gl_display- rect_wid "+rect_wid); + System.out.println ("GL4JCanvas`gl_display- rect_hei "+rect_hei); + } + + int x1, y1, x2, y2; + int[] v1 = new int[3]; + int[] v2 = new int[3]; + int ramp_index; + int color_index; + + double ratio; + int count = 0; + int rectList = -1; + + { + // JAU + if(useDisplayList) + { + rectList = gl.glGenLists(1); + gl.glNewList(rectList, GL_COMPILE); + } + + if(useSmoothShading) + gl.glShadeModel(GL_SMOOTH); + else + gl.glShadeModel(GL_FLAT); + + if(renderMode==3) + gl.glBegin(GL_QUADS); + + + // plz_note- for each column or trace + for (int loop_i = 0; loop_i < num_trc; loop_i++) + { + // plz_note- for each row or seismic amplitude + for (int loop_j = 0; loop_j < num_sam; loop_j++) + { + // plz_note- compute vertices. + ratio = (double)(loop_i) / (double)(num_trc); + x1 = (int)(ratio * (double)(this._canvas_wid_pix)); + x2 = x1 + rect_wid; + + ratio = (double)(loop_j) / (double)(num_sam); + y1 = this._canvas_hei_pix - + (int)(ratio * (double)(this._canvas_hei_pix)); + y2 = y1 + rect_hei; + + // plz_note- set current color index + ramp_index = amp_mapper.GetColorIndex + (seis_amps [loop_i][loop_j]); + color_index = ramp [ramp_index]; + if (debug && ((loop_i == 0 || loop_i == num_trc - 1) + && loop_j >= 80 && loop_j< 180)) + { + System.out.print (" `gl_display-" + +" trc "+loop_i+", sam "+loop_j + +", amp "+seis_amps [loop_i][loop_j]); + System.out.print (", ramp_index "+ramp_index); + System.out.println (", color_index "+color_index); + } + + if(!useRGB) + gl.glIndexi (color_index); + + if(renderMode==0) + { + gl.glRecti (x1, y1, x2, y2); + } else if(renderMode==1) + { + v1[0]=x1; v1[1]=y1; + v2[0]=x2; v2[1]=y2; + gl.glRectiv (v1, v2); + } else { + if(renderMode==2) + gl.glBegin(GL_POLYGON); + if(renderMode>=2) + { + gl.glVertex2i(x1,y1); + gl.glVertex2i(x2,y1); + gl.glVertex2i(x2,y2); + gl.glVertex2i(x1,y2); + } + if(renderMode==2) + gl.glEnd(); + } + + count++; + } + } + if(renderMode==3) + gl.glEnd( /* GL_QUADS */ ); + + // JAU + if(useDisplayList) + { + gl.glEndList(); + } + else if(doubleBuffer) + glj.gljSwap (); + + } + + if(useDisplayList) + { + System.out.println (">`gl_display(displayList)- rectangles put in displayList: " +count); + System.out.println (">relative time: (display-list only)"); + printTimeDelta(t1, count); + System.out.println (">absolute time: (display-list and calculations)"); + printTimeDelta(t0, count); + } else { + System.out.println (">`gl_display(immediate)- rectangles rendered: " +count); + System.out.println (">relative time: (immediate only)"); + printTimeDelta(t1, count); + System.out.println (">absolute time: (immediate and calculations)"); + printTimeDelta(t0, count); + } + + t1 = System.currentTimeMillis(); + + if(useDisplayList) + { + gl.glCallList(rectList); + + if(doubleBuffer) + glj.gljSwap (); + + printTimeDelta(t0, count); + + System.out.println (">relative time: (display-list called)"); + printTimeDelta(t1, count); + System.out.println (">absolute time: (display-list compiled+called+calculations)"); + printTimeDelta(t0, count); + + gl.glDeleteLists(rectList, 1); + } + + gl.glFlush (); + gl.glFinish (); + + glj.gljFree (); + } + +} +//---------------------------------------------- +// method reshape. +//---------------------------------------------- +public void reshape (int wid, int hei) +{ +} +//---------------------------------------------- +// method +// what the color is does not matter now. +//---------------------------------------------- +public int [] MakeRampJ (int num_colors) +{ + boolean debug = false; + + if (debug) System.out.println ("GL4JCanvas`MakeRampJ- begin"); + + int [] rtn_array = new int [num_colors]; + + for (int loopi = 0; loopi < num_colors; loopi++) + { + rtn_array [loopi] = loopi; + } + + if (debug) System.out.println ("GL4JCanvas`MakeRampJ- end"); + return rtn_array; +} +//---------------------------------------------- +// method +// what the data is does not matter now. +//---------------------------------------------- +public float [][] GetSeisData (int wid, int hei) +{ + boolean debug; + + debug = false; + if (debug) System.out.println ("GL4JCanvas`GetSeisData- begin"); + + float [][] rtn_array = new float [wid][]; + + for (int loopi = 0; loopi < wid; loopi++) + { + rtn_array [loopi] = new float [hei]; + } + + for (int loopi = 0; loopi < wid; loopi++) + for (int loopj = 0; loopj < hei; loopj++) + rtn_array [loopi][loopj] = (float) (Math.random ()) * 100.0f; + + if (debug) System.out.println ("GL4JCanvas`GetSeisData- end"); + return rtn_array; +} + +//---------------------------------------------- +// end of class GL4JCanvas +//---------------------------------------------- +} + +//---------------------------------------------- +// begin class definition +//---------------------------------------------- +class MapAmpToIndex extends Object +{ + + private boolean InitDone = false; + private int [] _color_ramp; + private float _max_amp = (float) 0.0; + private float _min_amp = (float) 0.0; + +//---------------------------------------------- +// method MapAmpToIndex +//---------------------------------------------- +MapAmpToIndex (int [] ramp, float [][] data) +{ + boolean debug; + + debug = false; + InitDone = true; + + if (debug) System.out.println ("MapAmpToIndex`MapAmpToIndex- begin"); + + // plz_note- set the color index data store + _color_ramp = new int [ramp.length]; + System.arraycopy (ramp, 0, _color_ramp, 0, ramp.length); + if (debug) + { + System.out.println ("MapAmpToIndex`MapAmpToIndex- _color_ramp:"); + for (int loopi = 0; loopi < _color_ramp.length; loopi++) + { + System.out.println ("MapAmpToIndex`MapAmpToIndex- _color_ramp [" + +loopi+"] "+_color_ramp [loopi]); + } + } + + // plz_note- set the max, min amplitudes for scaling + for (int loopi = 0; loopi < data.length; loopi++) + { + for (int loopj = 0; loopj < data [0].length; loopj++) + { + if (data [loopi][loopj] > _max_amp) + _max_amp = data [loopi][loopj]; + if (data [loopi][loopj] < _min_amp) + _min_amp = data [loopi][loopj]; + } + } + if (debug) + { + System.out.println ("MapAmpToIndex`MapAmpToIndex- _max_amp " + +_max_amp); + System.out.println ("MapAmpToIndex`MapAmpToIndex- _min_amp " + +_min_amp); + } + + if (debug) System.out.println ("MapAmpToIndex`MapAmpToIndex- end"); +} + +//---------------------------------------------- +// method GetColorIndex +//---------------------------------------------- +int GetColorIndex (float this_amp) +{ + boolean debug; + int index; + int max_index; + float amp_range; + + debug = false; + if (debug) System.out.println ("MapAmpToIndex`GetColorIndex- begin"); + index = 0; + + //if ( ! init) + { + max_index = _color_ramp.length - 1; + amp_range = _max_amp - _min_amp; + } + + index = (int) + (((float)(max_index)) * + ((this_amp - _min_amp) / (_max_amp - _min_amp))); + + if (debug) System.out.println ("MapAmpToIndex`GetColorIndex- end"); + return index; +} + +//---------------------------------------------- +// end of class MapAmpToIndex +//---------------------------------------------- + +} + + +//---------------------------------------------- +// end of file +//---------------------------------------------- diff --git a/demos/RectRenderSpeed/GL4JTests2.java b/demos/RectRenderSpeed/GL4JTests2.java new file mode 100644 index 0000000..8352c96 --- /dev/null +++ b/demos/RectRenderSpeed/GL4JTests2.java @@ -0,0 +1,149 @@ + +import GL4JCanvas; + +import java.awt.*; +import java.awt.event.*; + +//---------------------------------------------- +// class definition. +//---------------------------------------------- +public class GL4JTests2 implements ActionListener +{ + private GL4JCanvas _glcanvas; + TextField tf_renderMode; + +//---------------------------------------------- +// method constructor. +//---------------------------------------------- +public GL4JTests2 (String [] args) +{ + boolean debug = true; + Frame outer_frame; + Frame inner_frame; + Panel inner_panel; + Container outer_container; + Container inner_container; + Button button; + int modes[]=new int[args.length]; + int mode_number=0; + boolean dblBuffer=false; + + if(args.length>0) + { + int i; + for (i=0; i<args.length; i++) + { + if(args[i].equals("help")) + { + System.out.println( + "Arguments:\n"+ + "\thelp - print this help\n"+ + "\tdbl - use doublebuffer\n"+ + "\t<mode> - render mode, where mode is one of the following integer values :\n"+ GL4JCanvas.modes); + } else if(args[i].equals("dbl")) + { + dblBuffer=true; + } else { + try { + modes[mode_number] = + Integer.valueOf(args[i]).intValue(); + mode_number++; + } catch (Exception ex) { + System.out.println("wrong mode: "+args[i]); + return; + } + } + } + } else { + System.out.println ("GL4JTests`constructor- begin\n modes:\n"+ + _glcanvas.modes); + } + + // build outer most frame and container. + outer_frame = new Frame ("The GL4Java Canvas Window"); + + // create a new canvas from GL4Java... + // _glcanvas = new GL4JCanvas (1250, 800); + // JAU: I have just a little screen at my place now :-) ! + _glcanvas = new GL4JCanvas (640, 480); + outer_frame.add ("Center",_glcanvas); + + _glcanvas.preSetDblBuffer(dblBuffer); + + Panel renderPanel = new Panel(); + + if(mode_number==0) + { + // interactive mode + // + button = new Button ("Paint"); + button.setActionCommand ("Button Pressed"); + button.addActionListener (this); + renderPanel.add(button); + tf_renderMode = new TextField("0"); + renderPanel.add(tf_renderMode); + outer_frame.add ("South", renderPanel); + + } + + outer_frame.pack (); + outer_frame.setVisible (true); + + if(mode_number>0) + { + // scripting mode + // + _glcanvas.setScriptModes(modes, mode_number); + _glcanvas.setRefreshGL(true); + _glcanvas.repaint(); + + } + +} + + +//---------------------------------------------- +// method actionPerformed. +//---------------------------------------------- +public void actionPerformed (ActionEvent event) +{ + + String action_command; + + /* + * Let's do the repaint thread save ... + */ + int mode=0; + try { + mode = Integer.valueOf(tf_renderMode.getText()).intValue(); + } catch (Exception ex) { + System.out.println("wrong mode: "+tf_renderMode.getText()); + return; + } + if(_glcanvas.setRenderMode(mode)==false) + { + System.out.println("render mode not supported !"); + System.out.println("use one of the following:\n"+ + _glcanvas.modes); + return; + } + _glcanvas.setRefreshGL(true); + _glcanvas.repaint(); + +} +//---------------------------------------------- +// method main. +//---------------------------------------------- +public static void main (String[] args) +{ + boolean debug = true; + + GL4JTests2 gl4JTests1 = new GL4JTests2 (args); + //GL4JTests2 gl4JTests2 = new GL4JTests2 (args); + +} + +//---------------------------------------------- +// end of class GL4JTests. +//---------------------------------------------- +} diff --git a/demos/RectRenderSpeed/GL4JTests2.sh b/demos/RectRenderSpeed/GL4JTests2.sh new file mode 100755 index 0000000..405f1f4 --- /dev/null +++ b/demos/RectRenderSpeed/GL4JTests2.sh @@ -0,0 +1,12 @@ +#! /bin/sh + +# +# run +# +echo args: $* + +# +# run java with increased memory, classpath arg +# +java -ms64m -mx64m GL4JTests2 $* + diff --git a/demos/RectRenderSpeed/perfomance-Linux-300MHzPII-Mesa b/demos/RectRenderSpeed/perfomance-Linux-300MHzPII-Mesa new file mode 100644 index 0000000..a17bfbb --- /dev/null +++ b/demos/RectRenderSpeed/perfomance-Linux-300MHzPII-Mesa @@ -0,0 +1 @@ +I used platform:
RivaTNT2 with MesaNVidia driver und Linux glibc2 !
120 MB RAM !
300 MhZ PII !
Running under Java117NativeThreads+TYA & ShellScript GL4JTests2.sh !
args: help 0 1 2 3 100 101 102 103
Arguments:
help - print this help
dbl - use doublebuffer
<mode> - render mode, where mode is one of the following integer values :
0 - Immediate + FLAT + ColorIndex + glRect
1 - Immediate + FLAT + ColorIndex + glRectiv
2 - Immediate + FLAT + ColorIndex + POLYGON + glVertex2i(x2,y2);
3 - Immediate + FLAT + ColorIndex + QUADS + glVertex2i(x2,y2);
10 - Immediate + FLAT + RGB + glRect
11 - Immediate + FLAT + RGB + glRectiv
12 - Immediate + FLAT + RGB + POLYGON + glVertex2i(x2,y2);
13 - Immediate + FLAT + RGB + QUADS + glVertex2i(x2,y2);
20 - Immediate + SMOOTH + ColorIndex + glRect
21 - Immediate + SMOOTH + ColorIndex + glRectiv
22 - Immediate + SMOOTH + ColorIndex + POLYGON + glVertex2i(x2,y2);
23 - Immediate + SMOOTH + ColorIndex + QUADS + glVertex2i(x2,y2);
30 - Immediate + SMOOTH + RGB + glRect
31 - Immediate + SMOOTH + RGB + glRectiv
32 - Immediate + SMOOTH + RGB + POLYGON + glVertex2i(x2,y2);
33 - Immediate + SMOOTH + RGB + QUADS + glVertex2i(x2,y2);
100 - COMPILED + FLAT + ColorIndex + glRect
101 - COMPILED + FLAT + ColorIndex + glRectiv
102 - COMPILED + FLAT + ColorIndex + POLYGON + glVertex2i(x2,y2);
103 - COMPILED + FLAT + ColorIndex + QUADS + glVertex2i(x2,y2);
110 - COMPILED + FLAT + RGB + glRect
111 - COMPILED + FLAT + RGB + glRectiv
112 - COMPILED + FLAT + RGB + POLYGON + glVertex2i(x2,y2);
113 - COMPILED + FLAT + RGB + QUADS + glVertex2i(x2,y2);
120 - COMPILED + SMOOTH + ColorIndex + glRect
121 - COMPILED + SMOOTH + ColorIndex + glRectiv
122 - COMPILED + SMOOTH + ColorIndex + POLYGON + glVertex2i(x2,y2);
123 - COMPILED + SMOOTH + ColorIndex + QUADS + glVertex2i(x2,y2);
130 - COMPILED + SMOOTH + RGB + glRect
131 - COMPILED + SMOOTH + RGB + glRectiv
132 - COMPILED + SMOOTH + RGB + POLYGON + glVertex2i(x2,y2);
133 - COMPILED + SMOOTH + RGB + GL_QUADS+ glVertex2i(x2,y2);
trying mode: 0
>MODE 0: FrontBuffer + IMMEDIATE + Flat + ColorIndex + glRect
>Time for fetching Seis-Data: 8.238
>Time for map color-table: 0.632
>`gl_display(immediate)- rectangles rendered: 1000000
>relative time: (immediate only)
... elapsed time: 24.793 Sec
... rate: 24.793 SPMR (Sec Per Million Rectangles)
>absolute time: (immediate and calculations)
... elapsed time: 33.695 Sec
... rate: 33.695 SPMR (Sec Per Million Rectangles)
trying mode: 1
>MODE 1: FrontBuffer + IMMEDIATE + Flat + ColorIndex + glRectiv
>Time for fetching Seis-Data: 8.69
>Time for map color-table: 1.095
>`gl_display(immediate)- rectangles rendered: 1000000
>relative time: (immediate only)
... elapsed time: 35.262 Sec
... rate: 35.262 SPMR (Sec Per Million Rectangles)
>absolute time: (immediate and calculations)
... elapsed time: 45.095 Sec
... rate: 45.095 SPMR (Sec Per Million Rectangles)
trying mode: 2
>MODE 2: FrontBuffer + IMMEDIATE + Flat + ColorIndex + POLYGON + glVertex2i
>Time for fetching Seis-Data: 7.502
>Time for map color-table: 1.272
>`gl_display(immediate)- rectangles rendered: 1000000
>relative time: (immediate only)
... elapsed time: 44.177 Sec
... rate: 44.177 SPMR (Sec Per Million Rectangles)
>absolute time: (immediate and calculations)
... elapsed time: 53.002 Sec
... rate: 53.002 SPMR (Sec Per Million Rectangles)
trying mode: 3
>MODE 3: FrontBuffer + IMMEDIATE + Flat + ColorIndex + QUADS + glVertex2i
>Time for fetching Seis-Data: 7.626
>Time for map color-table: 1.227
>`gl_display(immediate)- rectangles rendered: 1000000
>relative time: (immediate only)
... elapsed time: 31.222 Sec
... rate: 31.222 SPMR (Sec Per Million Rectangles)
>absolute time: (immediate and calculations)
... elapsed time: 40.135 Sec
... rate: 40.135 SPMR (Sec Per Million Rectangles)
trying mode: 100
>MODE 100: FrontBuffer + COMPILED + Flat + ColorIndex + glRect
>Time for fetching Seis-Data: 8.431
>Time for map color-table: 0.435
>`gl_display(displayList)- rectangles put in displayList: 1000000
>relative time: (display-list only)
... elapsed time: 15.316 Sec
... rate: 15.316 SPMR (Sec Per Million Rectangles)
>absolute time: (display-list and calculations)
... elapsed time: 24.43 Sec
... rate: 24.43 SPMR (Sec Per Million Rectangles)
... elapsed time: 24.477 Sec
... rate: 24.477 SPMR (Sec Per Million Rectangles)
>relative time: (display-list called)
... elapsed time: 0.065 Sec
... rate: 0.065 SPMR (Sec Per Million Rectangles)
>absolute time: (display-list compiled+called+calculations)
... elapsed time: 24.555 Sec
... rate: 24.555 SPMR (Sec Per Million Rectangles)
trying mode: 101
>MODE 101: FrontBuffer + COMPILED + Flat + ColorIndex + glRectiv
>Time for fetching Seis-Data: 8.556
>Time for map color-table: 0.405
>`gl_display(displayList)- rectangles put in displayList: 1000000
>relative time: (display-list only)
... elapsed time: 23.98 Sec
... rate: 23.98 SPMR (Sec Per Million Rectangles)
>absolute time: (display-list and calculations)
... elapsed time: 32.969 Sec
... rate: 32.969 SPMR (Sec Per Million Rectangles)
... elapsed time: 32.97 Sec
... rate: 32.97 SPMR (Sec Per Million Rectangles)
>relative time: (display-list called)
... elapsed time: 0.0 Sec
... rate: 0.0 SPMR (Sec Per Million Rectangles)
>absolute time: (display-list compiled+called+calculations)
... elapsed time: 32.971 Sec
... rate: 32.971 SPMR (Sec Per Million Rectangles)
trying mode: 102
>MODE 102: FrontBuffer + COMPILED + Flat + ColorIndex + POLYGON + glVertex2i
>Time for fetching Seis-Data: 8.849
>Time for map color-table: 0.433
>`gl_display(displayList)- rectangles put in displayList: 1000000
>relative time: (display-list only)
... elapsed time: 36.812 Sec
... rate: 36.812 SPMR (Sec Per Million Rectangles)
>absolute time: (display-list and calculations)
... elapsed time: 46.114 Sec
... rate: 46.114 SPMR (Sec Per Million Rectangles)
... elapsed time: 46.115 Sec
... rate: 46.115 SPMR (Sec Per Million Rectangles)
>relative time: (display-list called)
... elapsed time: 0.0 Sec
... rate: 0.0 SPMR (Sec Per Million Rectangles)
>absolute time: (display-list compiled+called+calculations)
... elapsed time: 46.116 Sec
... rate: 46.116 SPMR (Sec Per Million Rectangles)
trying mode: 103
>MODE 103: FrontBuffer + COMPILED + Flat + ColorIndex + QUADS + glVertex2i
>Time for fetching Seis-Data: 8.511
>Time for map color-table: 0.426
>`gl_display(displayList)- rectangles put in displayList: 1000000
>relative time: (display-list only)
... elapsed time: 23.532 Sec
... rate: 23.532 SPMR (Sec Per Million Rectangles)
>absolute time: (display-list and calculations)
... elapsed time: 32.524 Sec
... rate: 32.524 SPMR (Sec Per Million Rectangles)
... elapsed time: 32.55 Sec
... rate: 32.55 SPMR (Sec Per Million Rectangles)
>relative time: (display-list called)
... elapsed time: 0.038 Sec
... rate: 0.038 SPMR (Sec Per Million Rectangles)
>absolute time: (display-list compiled+called+calculations)
... elapsed time: 32.626 Sec
... rate: 32.626 SPMR (Sec Per Million Rectangles)
\ No newline at end of file diff --git a/demos/RectRenderSpeed/perfomance-Linux-300MHzPII-MesaRivaTNT2.txt b/demos/RectRenderSpeed/perfomance-Linux-300MHzPII-MesaRivaTNT2.txt new file mode 100644 index 0000000..af0e9e7 --- /dev/null +++ b/demos/RectRenderSpeed/perfomance-Linux-300MHzPII-MesaRivaTNT2.txt @@ -0,0 +1,167 @@ +I used platform: + +RivaTNT2 with MesaNVidia driver und Linux glibc2 ! +120 MB RAM ! +300 MhZ PII ! + +Running under Java117NativeThreads+TYA & ShellScript GL4JTests2.sh ! + +args: help 0 1 2 3 100 101 102 103 +Arguments: + help - print this help + dbl - use doublebuffer + <mode> - render mode, where mode is one of the following integer values : + 0 - Immediate + FLAT + ColorIndex + glRect + 1 - Immediate + FLAT + ColorIndex + glRectiv + 2 - Immediate + FLAT + ColorIndex + POLYGON + glVertex2i(x2,y2); + 3 - Immediate + FLAT + ColorIndex + QUADS + glVertex2i(x2,y2); + 10 - Immediate + FLAT + RGB + glRect + 11 - Immediate + FLAT + RGB + glRectiv + 12 - Immediate + FLAT + RGB + POLYGON + glVertex2i(x2,y2); + 13 - Immediate + FLAT + RGB + QUADS + glVertex2i(x2,y2); + 20 - Immediate + SMOOTH + ColorIndex + glRect + 21 - Immediate + SMOOTH + ColorIndex + glRectiv + 22 - Immediate + SMOOTH + ColorIndex + POLYGON + glVertex2i(x2,y2); + 23 - Immediate + SMOOTH + ColorIndex + QUADS + glVertex2i(x2,y2); + 30 - Immediate + SMOOTH + RGB + glRect + 31 - Immediate + SMOOTH + RGB + glRectiv + 32 - Immediate + SMOOTH + RGB + POLYGON + glVertex2i(x2,y2); + 33 - Immediate + SMOOTH + RGB + QUADS + glVertex2i(x2,y2); +100 - COMPILED + FLAT + ColorIndex + glRect +101 - COMPILED + FLAT + ColorIndex + glRectiv +102 - COMPILED + FLAT + ColorIndex + POLYGON + glVertex2i(x2,y2); +103 - COMPILED + FLAT + ColorIndex + QUADS + glVertex2i(x2,y2); +110 - COMPILED + FLAT + RGB + glRect +111 - COMPILED + FLAT + RGB + glRectiv +112 - COMPILED + FLAT + RGB + POLYGON + glVertex2i(x2,y2); +113 - COMPILED + FLAT + RGB + QUADS + glVertex2i(x2,y2); +120 - COMPILED + SMOOTH + ColorIndex + glRect +121 - COMPILED + SMOOTH + ColorIndex + glRectiv +122 - COMPILED + SMOOTH + ColorIndex + POLYGON + glVertex2i(x2,y2); +123 - COMPILED + SMOOTH + ColorIndex + QUADS + glVertex2i(x2,y2); +130 - COMPILED + SMOOTH + RGB + glRect +131 - COMPILED + SMOOTH + RGB + glRectiv +132 - COMPILED + SMOOTH + RGB + POLYGON + glVertex2i(x2,y2); +133 - COMPILED + SMOOTH + RGB + GL_QUADS+ glVertex2i(x2,y2); + + +trying mode: 0 +>MODE 0: FrontBuffer + IMMEDIATE + Flat + ColorIndex + glRect +>Time for fetching Seis-Data: 8.238 +>Time for map color-table: 0.632 +>`gl_display(immediate)- rectangles rendered: 1000000 +>relative time: (immediate only) +... elapsed time: 24.793 Sec +... rate: 24.793 SPMR (Sec Per Million Rectangles) +>absolute time: (immediate and calculations) +... elapsed time: 33.695 Sec +... rate: 33.695 SPMR (Sec Per Million Rectangles) +trying mode: 1 +>MODE 1: FrontBuffer + IMMEDIATE + Flat + ColorIndex + glRectiv +>Time for fetching Seis-Data: 8.69 +>Time for map color-table: 1.095 +>`gl_display(immediate)- rectangles rendered: 1000000 +>relative time: (immediate only) +... elapsed time: 35.262 Sec +... rate: 35.262 SPMR (Sec Per Million Rectangles) +>absolute time: (immediate and calculations) +... elapsed time: 45.095 Sec +... rate: 45.095 SPMR (Sec Per Million Rectangles) +trying mode: 2 +>MODE 2: FrontBuffer + IMMEDIATE + Flat + ColorIndex + POLYGON + glVertex2i +>Time for fetching Seis-Data: 7.502 +>Time for map color-table: 1.272 +>`gl_display(immediate)- rectangles rendered: 1000000 +>relative time: (immediate only) +... elapsed time: 44.177 Sec +... rate: 44.177 SPMR (Sec Per Million Rectangles) +>absolute time: (immediate and calculations) +... elapsed time: 53.002 Sec +... rate: 53.002 SPMR (Sec Per Million Rectangles) +trying mode: 3 +>MODE 3: FrontBuffer + IMMEDIATE + Flat + ColorIndex + QUADS + glVertex2i +>Time for fetching Seis-Data: 7.626 +>Time for map color-table: 1.227 +>`gl_display(immediate)- rectangles rendered: 1000000 +>relative time: (immediate only) +... elapsed time: 31.222 Sec +... rate: 31.222 SPMR (Sec Per Million Rectangles) +>absolute time: (immediate and calculations) +... elapsed time: 40.135 Sec +... rate: 40.135 SPMR (Sec Per Million Rectangles) +trying mode: 100 +>MODE 100: FrontBuffer + COMPILED + Flat + ColorIndex + glRect +>Time for fetching Seis-Data: 8.431 +>Time for map color-table: 0.435 +>`gl_display(displayList)- rectangles put in displayList: 1000000 +>relative time: (display-list only) +... elapsed time: 15.316 Sec +... rate: 15.316 SPMR (Sec Per Million Rectangles) +>absolute time: (display-list and calculations) +... elapsed time: 24.43 Sec +... rate: 24.43 SPMR (Sec Per Million Rectangles) +... elapsed time: 24.477 Sec +... rate: 24.477 SPMR (Sec Per Million Rectangles) +>relative time: (display-list called) +... elapsed time: 0.065 Sec +... rate: 0.065 SPMR (Sec Per Million Rectangles) +>absolute time: (display-list compiled+called+calculations) +... elapsed time: 24.555 Sec +... rate: 24.555 SPMR (Sec Per Million Rectangles) +trying mode: 101 +>MODE 101: FrontBuffer + COMPILED + Flat + ColorIndex + glRectiv +>Time for fetching Seis-Data: 8.556 +>Time for map color-table: 0.405 +>`gl_display(displayList)- rectangles put in displayList: 1000000 +>relative time: (display-list only) +... elapsed time: 23.98 Sec +... rate: 23.98 SPMR (Sec Per Million Rectangles) +>absolute time: (display-list and calculations) +... elapsed time: 32.969 Sec +... rate: 32.969 SPMR (Sec Per Million Rectangles) +... elapsed time: 32.97 Sec +... rate: 32.97 SPMR (Sec Per Million Rectangles) +>relative time: (display-list called) +... elapsed time: 0.0 Sec +... rate: 0.0 SPMR (Sec Per Million Rectangles) +>absolute time: (display-list compiled+called+calculations) +... elapsed time: 32.971 Sec +... rate: 32.971 SPMR (Sec Per Million Rectangles) +trying mode: 102 +>MODE 102: FrontBuffer + COMPILED + Flat + ColorIndex + POLYGON + glVertex2i +>Time for fetching Seis-Data: 8.849 +>Time for map color-table: 0.433 +>`gl_display(displayList)- rectangles put in displayList: 1000000 +>relative time: (display-list only) +... elapsed time: 36.812 Sec +... rate: 36.812 SPMR (Sec Per Million Rectangles) +>absolute time: (display-list and calculations) +... elapsed time: 46.114 Sec +... rate: 46.114 SPMR (Sec Per Million Rectangles) +... elapsed time: 46.115 Sec +... rate: 46.115 SPMR (Sec Per Million Rectangles) +>relative time: (display-list called) +... elapsed time: 0.0 Sec +... rate: 0.0 SPMR (Sec Per Million Rectangles) +>absolute time: (display-list compiled+called+calculations) +... elapsed time: 46.116 Sec +... rate: 46.116 SPMR (Sec Per Million Rectangles) +trying mode: 103 +>MODE 103: FrontBuffer + COMPILED + Flat + ColorIndex + QUADS + glVertex2i +>Time for fetching Seis-Data: 8.511 +>Time for map color-table: 0.426 +>`gl_display(displayList)- rectangles put in displayList: 1000000 +>relative time: (display-list only) +... elapsed time: 23.532 Sec +... rate: 23.532 SPMR (Sec Per Million Rectangles) +>absolute time: (display-list and calculations) +... elapsed time: 32.524 Sec +... rate: 32.524 SPMR (Sec Per Million Rectangles) +... elapsed time: 32.55 Sec +... rate: 32.55 SPMR (Sec Per Million Rectangles) +>relative time: (display-list called) +... elapsed time: 0.038 Sec +... rate: 0.038 SPMR (Sec Per Million Rectangles) +>absolute time: (display-list compiled+called+calculations) +... elapsed time: 32.626 Sec +... rate: 32.626 SPMR (Sec Per Million Rectangles) diff --git a/demos/RectRenderSpeed/perfomance-Linux-350MHzPII-Mesa b/demos/RectRenderSpeed/perfomance-Linux-350MHzPII-Mesa new file mode 100644 index 0000000..042252f --- /dev/null +++ b/demos/RectRenderSpeed/perfomance-Linux-350MHzPII-Mesa @@ -0,0 +1 @@ +I used platform:
RivaTNT2 with MesaNVidia driver und Linux glibc2 !
120 MB RAM !
350 MhZ PII !
Running under Java117NativeThreads+TYA & ShellScript GL4JTests2.sh !
args: help 0 1 2 3 100 101 102 103
args: help 0 1 2 3 100 101 102 103
Arguments:
help - print this help
dbl - use doublebuffer
<mode> - render mode, where mode is one of the following integer values :
0 - Immediate + FLAT + ColorIndex + glRect
1 - Immediate + FLAT + ColorIndex + glRectiv
2 - Immediate + FLAT + ColorIndex + POLYGON + glVertex2i(x2,y2);
3 - Immediate + FLAT + ColorIndex + QUADS + glVertex2i(x2,y2);
10 - Immediate + FLAT + RGB + glRect
11 - Immediate + FLAT + RGB + glRectiv
12 - Immediate + FLAT + RGB + POLYGON + glVertex2i(x2,y2);
13 - Immediate + FLAT + RGB + QUADS + glVertex2i(x2,y2);
20 - Immediate + SMOOTH + ColorIndex + glRect
21 - Immediate + SMOOTH + ColorIndex + glRectiv
22 - Immediate + SMOOTH + ColorIndex + POLYGON + glVertex2i(x2,y2);
23 - Immediate + SMOOTH + ColorIndex + QUADS + glVertex2i(x2,y2);
30 - Immediate + SMOOTH + RGB + glRect
31 - Immediate + SMOOTH + RGB + glRectiv
32 - Immediate + SMOOTH + RGB + POLYGON + glVertex2i(x2,y2);
33 - Immediate + SMOOTH + RGB + QUADS + glVertex2i(x2,y2);
100 - COMPILED + FLAT + ColorIndex + glRect
101 - COMPILED + FLAT + ColorIndex + glRectiv
102 - COMPILED + FLAT + ColorIndex + POLYGON + glVertex2i(x2,y2);
103 - COMPILED + FLAT + ColorIndex + QUADS + glVertex2i(x2,y2);
110 - COMPILED + FLAT + RGB + glRect
111 - COMPILED + FLAT + RGB + glRectiv
112 - COMPILED + FLAT + RGB + POLYGON + glVertex2i(x2,y2);
113 - COMPILED + FLAT + RGB + QUADS + glVertex2i(x2,y2);
120 - COMPILED + SMOOTH + ColorIndex + glRect
121 - COMPILED + SMOOTH + ColorIndex + glRectiv
122 - COMPILED + SMOOTH + ColorIndex + POLYGON + glVertex2i(x2,y2);
123 - COMPILED + SMOOTH + ColorIndex + QUADS + glVertex2i(x2,y2);
130 - COMPILED + SMOOTH + RGB + glRect
131 - COMPILED + SMOOTH + RGB + glRectiv
132 - COMPILED + SMOOTH + RGB + POLYGON + glVertex2i(x2,y2);
133 - COMPILED + SMOOTH + RGB + GL_QUADS+ glVertex2i(x2,y2);
trying mode: 0
>MODE 0: FrontBuffer + IMMEDIATE + Flat + ColorIndex + glRect
>Time for fetching Seis-Data: 6.723
>Time for map color-table: 0.417
>`gl_display(immediate)- rectangles rendered: 1000000
>relative time: (immediate only)
... elapsed time: 34.165 Sec
... rate: 34.165 SPMR (Sec Per Million Rectangles)
>absolute time: (immediate and calculations)
... elapsed time: 41.367 Sec
... rate: 41.367 SPMR (Sec Per Million Rectangles)
trying mode: 1
>MODE 1: FrontBuffer + IMMEDIATE + Flat + ColorIndex + glRectiv
>Time for fetching Seis-Data: 6.323
>Time for map color-table: 0.39
>`gl_display(immediate)- rectangles rendered: 1000000
>relative time: (immediate only)
... elapsed time: 45.265 Sec
... rate: 45.265 SPMR (Sec Per Million Rectangles)
>absolute time: (immediate and calculations)
... elapsed time: 52.034 Sec
... rate: 52.034 SPMR (Sec Per Million Rectangles)
trying mode: 2
>MODE 2: FrontBuffer + IMMEDIATE + Flat + ColorIndex + POLYGON + glVertex2i
>Time for fetching Seis-Data: 6.878
>Time for map color-table: 0.4
>`gl_display(immediate)- rectangles rendered: 1000000
>relative time: (immediate only)
... elapsed time: 46.561 Sec
... rate: 46.561 SPMR (Sec Per Million Rectangles)
>absolute time: (immediate and calculations)
... elapsed time: 53.894 Sec
... rate: 53.894 SPMR (Sec Per Million Rectangles)
trying mode: 3
>MODE 3: FrontBuffer + IMMEDIATE + Flat + ColorIndex + QUADS + glVertex2i
>Time for fetching Seis-Data: 6.831
>Time for map color-table: 0.404
>`gl_display(immediate)- rectangles rendered: 1000000
>relative time: (immediate only)
... elapsed time: 32.039 Sec
... rate: 32.039 SPMR (Sec Per Million Rectangles)
>absolute time: (immediate and calculations)
... elapsed time: 39.329 Sec
... rate: 39.329 SPMR (Sec Per Million Rectangles)
trying mode: 100
>MODE 100: FrontBuffer + COMPILED + Flat + ColorIndex + glRect
>Time for fetching Seis-Data: 6.777
>Time for map color-table: 0.4
>`gl_display(displayList)- rectangles put in displayList: 1000000
>relative time: (display-list only)
... elapsed time: 10.559 Sec
... rate: 10.559 SPMR (Sec Per Million Rectangles)
>absolute time: (display-list and calculations)
... elapsed time: 17.897 Sec
... rate: 17.897 SPMR (Sec Per Million Rectangles)
... elapsed time: 43.379 Sec
... rate: 43.379 SPMR (Sec Per Million Rectangles)
>relative time: (display-list called)
... elapsed time: 25.516 Sec
... rate: 25.516 SPMR (Sec Per Million Rectangles)
>absolute time: (display-list compiled+called+calculations)
... elapsed time: 43.455 Sec
... rate: 43.455 SPMR (Sec Per Million Rectangles)
trying mode: 101
>MODE 101: FrontBuffer + COMPILED + Flat + ColorIndex + glRectiv
>Time for fetching Seis-Data: 6.37
>Time for map color-table: 0.4
>`gl_display(displayList)- rectangles put in displayList: 1000000
>relative time: (display-list only)
... elapsed time: 15.623 Sec
... rate: 15.623 SPMR (Sec Per Million Rectangles)
>absolute time: (display-list and calculations)
... elapsed time: 22.467 Sec
... rate: 22.467 SPMR (Sec Per Million Rectangles)
... elapsed time: 42.516 Sec
... rate: 42.516 SPMR (Sec Per Million Rectangles)
>relative time: (display-list called)
... elapsed time: 20.062 Sec
... rate: 20.062 SPMR (Sec Per Million Rectangles)
>absolute time: (display-list compiled+called+calculations)
... elapsed time: 42.594 Sec
... rate: 42.594 SPMR (Sec Per Million Rectangles)
trying mode: 102
>MODE 102: FrontBuffer + COMPILED + Flat + ColorIndex + POLYGON + glVertex2i
>Time for fetching Seis-Data: 6.319
>Time for map color-table: 0.401
>`gl_display(displayList)- rectangles put in displayList: 1000000
>relative time: (display-list only)
... elapsed time: 26.708 Sec
... rate: 26.708 SPMR (Sec Per Million Rectangles)
>absolute time: (display-list and calculations)
... elapsed time: 33.641 Sec
... rate: 33.641 SPMR (Sec Per Million Rectangles)
... elapsed time: 67.779 Sec
... rate: 67.779 SPMR (Sec Per Million Rectangles)
>relative time: (display-list called)
... elapsed time: 34.544 Sec
... rate: 34.544 SPMR (Sec Per Million Rectangles)
>absolute time: (display-list compiled+called+calculations)
... elapsed time: 68.186 Sec
... rate: 68.186 SPMR (Sec Per Million Rectangles)
trying mode: 103
>MODE 103: FrontBuffer + COMPILED + Flat + ColorIndex + QUADS + glVertex2i
>Time for fetching Seis-Data: 6.671
>Time for map color-table: 0.409
>`gl_display(displayList)- rectangles put in displayList: 1000000
>relative time: (display-list only)
... elapsed time: 17.646 Sec
... rate: 17.646 SPMR (Sec Per Million Rectangles)
>absolute time: (display-list and calculations)
... elapsed time: 25.173 Sec
... rate: 25.173 SPMR (Sec Per Million Rectangles)
... elapsed time: 58.663 Sec
... rate: 58.663 SPMR (Sec Per Million Rectangles)
>relative time: (display-list called)
... elapsed time: 33.524 Sec
... rate: 33.524 SPMR (Sec Per Million Rectangles)
>absolute time: (display-list compiled+called+calculations)
... elapsed time: 58.752 Sec
... rate: 58.752 SPMR (Sec Per Million Rectangles)
\ No newline at end of file diff --git a/demos/RectRenderSpeed/perfomance-Linux-350MHzPII-MesaRivaTNT2.txt b/demos/RectRenderSpeed/perfomance-Linux-350MHzPII-MesaRivaTNT2.txt new file mode 100644 index 0000000..370ee97 --- /dev/null +++ b/demos/RectRenderSpeed/perfomance-Linux-350MHzPII-MesaRivaTNT2.txt @@ -0,0 +1,168 @@ +I used platform: + +RivaTNT2 with MesaNVidia driver und Linux glibc2 ! +120 MB RAM ! +350 MhZ PII ! + +Running under Java117NativeThreads+TYA & ShellScript GL4JTests2.sh ! + +args: help 0 1 2 3 100 101 102 103 +args: help 0 1 2 3 100 101 102 103 +Arguments: + help - print this help + dbl - use doublebuffer + <mode> - render mode, where mode is one of the following integer values : + 0 - Immediate + FLAT + ColorIndex + glRect + 1 - Immediate + FLAT + ColorIndex + glRectiv + 2 - Immediate + FLAT + ColorIndex + POLYGON + glVertex2i(x2,y2); + 3 - Immediate + FLAT + ColorIndex + QUADS + glVertex2i(x2,y2); + 10 - Immediate + FLAT + RGB + glRect + 11 - Immediate + FLAT + RGB + glRectiv + 12 - Immediate + FLAT + RGB + POLYGON + glVertex2i(x2,y2); + 13 - Immediate + FLAT + RGB + QUADS + glVertex2i(x2,y2); + 20 - Immediate + SMOOTH + ColorIndex + glRect + 21 - Immediate + SMOOTH + ColorIndex + glRectiv + 22 - Immediate + SMOOTH + ColorIndex + POLYGON + glVertex2i(x2,y2); + 23 - Immediate + SMOOTH + ColorIndex + QUADS + glVertex2i(x2,y2); + 30 - Immediate + SMOOTH + RGB + glRect + 31 - Immediate + SMOOTH + RGB + glRectiv + 32 - Immediate + SMOOTH + RGB + POLYGON + glVertex2i(x2,y2); + 33 - Immediate + SMOOTH + RGB + QUADS + glVertex2i(x2,y2); +100 - COMPILED + FLAT + ColorIndex + glRect +101 - COMPILED + FLAT + ColorIndex + glRectiv +102 - COMPILED + FLAT + ColorIndex + POLYGON + glVertex2i(x2,y2); +103 - COMPILED + FLAT + ColorIndex + QUADS + glVertex2i(x2,y2); +110 - COMPILED + FLAT + RGB + glRect +111 - COMPILED + FLAT + RGB + glRectiv +112 - COMPILED + FLAT + RGB + POLYGON + glVertex2i(x2,y2); +113 - COMPILED + FLAT + RGB + QUADS + glVertex2i(x2,y2); +120 - COMPILED + SMOOTH + ColorIndex + glRect +121 - COMPILED + SMOOTH + ColorIndex + glRectiv +122 - COMPILED + SMOOTH + ColorIndex + POLYGON + glVertex2i(x2,y2); +123 - COMPILED + SMOOTH + ColorIndex + QUADS + glVertex2i(x2,y2); +130 - COMPILED + SMOOTH + RGB + glRect +131 - COMPILED + SMOOTH + RGB + glRectiv +132 - COMPILED + SMOOTH + RGB + POLYGON + glVertex2i(x2,y2); +133 - COMPILED + SMOOTH + RGB + GL_QUADS+ glVertex2i(x2,y2); + + +trying mode: 0 +>MODE 0: FrontBuffer + IMMEDIATE + Flat + ColorIndex + glRect +>Time for fetching Seis-Data: 6.723 +>Time for map color-table: 0.417 +>`gl_display(immediate)- rectangles rendered: 1000000 +>relative time: (immediate only) +... elapsed time: 34.165 Sec +... rate: 34.165 SPMR (Sec Per Million Rectangles) +>absolute time: (immediate and calculations) +... elapsed time: 41.367 Sec +... rate: 41.367 SPMR (Sec Per Million Rectangles) +trying mode: 1 +>MODE 1: FrontBuffer + IMMEDIATE + Flat + ColorIndex + glRectiv +>Time for fetching Seis-Data: 6.323 +>Time for map color-table: 0.39 +>`gl_display(immediate)- rectangles rendered: 1000000 +>relative time: (immediate only) +... elapsed time: 45.265 Sec +... rate: 45.265 SPMR (Sec Per Million Rectangles) +>absolute time: (immediate and calculations) +... elapsed time: 52.034 Sec +... rate: 52.034 SPMR (Sec Per Million Rectangles) +trying mode: 2 +>MODE 2: FrontBuffer + IMMEDIATE + Flat + ColorIndex + POLYGON + glVertex2i +>Time for fetching Seis-Data: 6.878 +>Time for map color-table: 0.4 +>`gl_display(immediate)- rectangles rendered: 1000000 +>relative time: (immediate only) +... elapsed time: 46.561 Sec +... rate: 46.561 SPMR (Sec Per Million Rectangles) +>absolute time: (immediate and calculations) +... elapsed time: 53.894 Sec +... rate: 53.894 SPMR (Sec Per Million Rectangles) +trying mode: 3 +>MODE 3: FrontBuffer + IMMEDIATE + Flat + ColorIndex + QUADS + glVertex2i +>Time for fetching Seis-Data: 6.831 +>Time for map color-table: 0.404 +>`gl_display(immediate)- rectangles rendered: 1000000 +>relative time: (immediate only) +... elapsed time: 32.039 Sec +... rate: 32.039 SPMR (Sec Per Million Rectangles) +>absolute time: (immediate and calculations) +... elapsed time: 39.329 Sec +... rate: 39.329 SPMR (Sec Per Million Rectangles) +trying mode: 100 +>MODE 100: FrontBuffer + COMPILED + Flat + ColorIndex + glRect +>Time for fetching Seis-Data: 6.777 +>Time for map color-table: 0.4 +>`gl_display(displayList)- rectangles put in displayList: 1000000 +>relative time: (display-list only) +... elapsed time: 10.559 Sec +... rate: 10.559 SPMR (Sec Per Million Rectangles) +>absolute time: (display-list and calculations) +... elapsed time: 17.897 Sec +... rate: 17.897 SPMR (Sec Per Million Rectangles) +... elapsed time: 43.379 Sec +... rate: 43.379 SPMR (Sec Per Million Rectangles) +>relative time: (display-list called) +... elapsed time: 25.516 Sec +... rate: 25.516 SPMR (Sec Per Million Rectangles) +>absolute time: (display-list compiled+called+calculations) +... elapsed time: 43.455 Sec +... rate: 43.455 SPMR (Sec Per Million Rectangles) +trying mode: 101 +>MODE 101: FrontBuffer + COMPILED + Flat + ColorIndex + glRectiv +>Time for fetching Seis-Data: 6.37 +>Time for map color-table: 0.4 +>`gl_display(displayList)- rectangles put in displayList: 1000000 +>relative time: (display-list only) +... elapsed time: 15.623 Sec +... rate: 15.623 SPMR (Sec Per Million Rectangles) +>absolute time: (display-list and calculations) +... elapsed time: 22.467 Sec +... rate: 22.467 SPMR (Sec Per Million Rectangles) +... elapsed time: 42.516 Sec +... rate: 42.516 SPMR (Sec Per Million Rectangles) +>relative time: (display-list called) +... elapsed time: 20.062 Sec +... rate: 20.062 SPMR (Sec Per Million Rectangles) +>absolute time: (display-list compiled+called+calculations) +... elapsed time: 42.594 Sec +... rate: 42.594 SPMR (Sec Per Million Rectangles) +trying mode: 102 +>MODE 102: FrontBuffer + COMPILED + Flat + ColorIndex + POLYGON + glVertex2i +>Time for fetching Seis-Data: 6.319 +>Time for map color-table: 0.401 +>`gl_display(displayList)- rectangles put in displayList: 1000000 +>relative time: (display-list only) +... elapsed time: 26.708 Sec +... rate: 26.708 SPMR (Sec Per Million Rectangles) +>absolute time: (display-list and calculations) +... elapsed time: 33.641 Sec +... rate: 33.641 SPMR (Sec Per Million Rectangles) +... elapsed time: 67.779 Sec +... rate: 67.779 SPMR (Sec Per Million Rectangles) +>relative time: (display-list called) +... elapsed time: 34.544 Sec +... rate: 34.544 SPMR (Sec Per Million Rectangles) +>absolute time: (display-list compiled+called+calculations) +... elapsed time: 68.186 Sec +... rate: 68.186 SPMR (Sec Per Million Rectangles) +trying mode: 103 +>MODE 103: FrontBuffer + COMPILED + Flat + ColorIndex + QUADS + glVertex2i +>Time for fetching Seis-Data: 6.671 +>Time for map color-table: 0.409 +>`gl_display(displayList)- rectangles put in displayList: 1000000 +>relative time: (display-list only) +... elapsed time: 17.646 Sec +... rate: 17.646 SPMR (Sec Per Million Rectangles) +>absolute time: (display-list and calculations) +... elapsed time: 25.173 Sec +... rate: 25.173 SPMR (Sec Per Million Rectangles) +... elapsed time: 58.663 Sec +... rate: 58.663 SPMR (Sec Per Million Rectangles) +>relative time: (display-list called) +... elapsed time: 33.524 Sec +... rate: 33.524 SPMR (Sec Per Million Rectangles) +>absolute time: (display-list compiled+called+calculations) +... elapsed time: 58.752 Sec +... rate: 58.752 SPMR (Sec Per Million Rectangles) diff --git a/demos/RectRenderSpeed/perfomance-Win32-400MHzPII-Matr b/demos/RectRenderSpeed/perfomance-Win32-400MHzPII-Matr new file mode 100644 index 0000000..71ae1bc --- /dev/null +++ b/demos/RectRenderSpeed/perfomance-Win32-400MHzPII-Matr @@ -0,0 +1 @@ +I used platform:
Matrox G200 with new driver !
Windows NT 4.0 SP5 !
329 MB RAM !
400 MhZ PII !
Running under Java2 & Cygwin32-Bash & ShellScript GL4JTests2.sh !
args: help 0 1 2 3 100 101 102 103
Arguments:
help - print this help
dbl - use doublebuffer
<mode> - render mode, where mode is one of the following integer values :
0 - Immediate + FLAT + ColorIndex + glRect
1 - Immediate + FLAT + ColorIndex + glRectiv
2 - Immediate + FLAT + ColorIndex + POLYGON + glVertex2i(x2,y2);
3 - Immediate + FLAT + ColorIndex + QUADS + glVertex2i(x2,y2);
10 - Immediate + FLAT + RGB + glRect
11 - Immediate + FLAT + RGB + glRectiv
12 - Immediate + FLAT + RGB + POLYGON + glVertex2i(x2,y2);
13 - Immediate + FLAT + RGB + QUADS + glVertex2i(x2,y2);
20 - Immediate + SMOOTH + ColorIndex + glRect
21 - Immediate + SMOOTH + ColorIndex + glRectiv
22 - Immediate + SMOOTH + ColorIndex + POLYGON + glVertex2i(x2,y2);
23 - Immediate + SMOOTH + ColorIndex + QUADS + glVertex2i(x2,y2);
30 - Immediate + SMOOTH + RGB + glRect
31 - Immediate + SMOOTH + RGB + glRectiv
32 - Immediate + SMOOTH + RGB + POLYGON + glVertex2i(x2,y2);
33 - Immediate + SMOOTH + RGB + QUADS + glVertex2i(x2,y2);
100 - COMPILED + FLAT + ColorIndex + glRect
101 - COMPILED + FLAT + ColorIndex + glRectiv
102 - COMPILED + FLAT + ColorIndex + POLYGON + glVertex2i(x2,y2);
103 - COMPILED + FLAT + ColorIndex + QUADS + glVertex2i(x2,y2);
110 - COMPILED + FLAT + RGB + glRect
111 - COMPILED + FLAT + RGB + glRectiv
112 - COMPILED + FLAT + RGB + POLYGON + glVertex2i(x2,y2);
113 - COMPILED + FLAT + RGB + QUADS + glVertex2i(x2,y2);
120 - COMPILED + SMOOTH + ColorIndex + glRect
121 - COMPILED + SMOOTH + ColorIndex + glRectiv
122 - COMPILED + SMOOTH + ColorIndex + POLYGON + glVertex2i(x2,y2);
123 - COMPILED + SMOOTH + ColorIndex + QUADS + glVertex2i(x2,y2);
130 - COMPILED + SMOOTH + RGB + glRect
131 - COMPILED + SMOOTH + RGB + glRectiv
132 - COMPILED + SMOOTH + RGB + POLYGON + glVertex2i(x2,y2);
133 - COMPILED + SMOOTH + RGB + GL_QUADS+ glVertex2i(x2,y2);
trying mode: 0
>MODE 0: FrontBuffer + IMMEDIATE + Flat + ColorIndex + glRect
>Time for fetching Seis-Data: 0.631
>Time for map color-table: 0.05
>`gl_display(immediate)- rectangles rendered: 1000000
>relative time: (immediate only)
... elapsed time: 60.858 Sec
... rate: 60.858000000000004 SPMR (Sec Per Million Rectangles)
>absolute time: (immediate and calculations)
... elapsed time: 61.549 Sec
... rate: 61.549 SPMR (Sec Per Million Rectangles)
trying mode: 1
>MODE 1: FrontBuffer + IMMEDIATE + Flat + ColorIndex + glRectiv
>Time for fetching Seis-Data: 0.631
>Time for map color-table: 0.04
>`gl_display(immediate)- rectangles rendered: 1000000
>relative time: (immediate only)
... elapsed time: 67.547 Sec
... rate: 67.547 SPMR (Sec Per Million Rectangles)
>absolute time: (immediate and calculations)
... elapsed time: 68.218 Sec
... rate: 68.218 SPMR (Sec Per Million Rectangles)
trying mode: 2
>MODE 2: FrontBuffer + IMMEDIATE + Flat + ColorIndex + POLYGON + glVertex2i
>Time for fetching Seis-Data: 0.631
>Time for map color-table: 0.05
>`gl_display(immediate)- rectangles rendered: 1000000
>relative time: (immediate only)
... elapsed time: 8.782 Sec
... rate: 8.782 SPMR (Sec Per Million Rectangles)
>absolute time: (immediate and calculations)
... elapsed time: 9.473 Sec
... rate: 9.473 SPMR (Sec Per Million Rectangles)
trying mode: 3
>MODE 3: FrontBuffer + IMMEDIATE + Flat + ColorIndex + QUADS + glVertex2i
>Time for fetching Seis-Data: 0.631
>Time for map color-table: 0.04
>`gl_display(immediate)- rectangles rendered: 1000000
>relative time: (immediate only)
... elapsed time: 7.051 Sec
... rate: 7.051 SPMR (Sec Per Million Rectangles)
>absolute time: (immediate and calculations)
... elapsed time: 7.722 Sec
... rate: 7.722 SPMR (Sec Per Million Rectangles)
trying mode: 100
>MODE 100: FrontBuffer + COMPILED + Flat + ColorIndex + glRect
>Time for fetching Seis-Data: 0.63
>Time for map color-table: 0.051
>`gl_display(displayList)- rectangles put in displayList: 1000000
>relative time: (display-list only)
... elapsed time: 2.894 Sec
... rate: 2.894 SPMR (Sec Per Million Rectangles)
>absolute time: (display-list and calculations)
... elapsed time: 3.575 Sec
... rate: 3.575 SPMR (Sec Per Million Rectangles)
... elapsed time: 56.571 Sec
... rate: 56.571 SPMR (Sec Per Million Rectangles)
>relative time: (display-list called)
... elapsed time: 52.996 Sec
... rate: 52.996 SPMR (Sec Per Million Rectangles)
>absolute time: (display-list compiled+called+calculations)
... elapsed time: 56.571 Sec
... rate: 56.571 SPMR (Sec Per Million Rectangles)
trying mode: 101
>MODE 101: FrontBuffer + COMPILED + Flat + ColorIndex + glRectiv
>Time for fetching Seis-Data: 0.631
>Time for map color-table: 0.04
>`gl_display(displayList)- rectangles put in displayList: 1000000
>relative time: (display-list only)
... elapsed time: 4.867 Sec
... rate: 4.867 SPMR (Sec Per Million Rectangles)
>absolute time: (display-list and calculations)
... elapsed time: 5.548 Sec
... rate: 5.548 SPMR (Sec Per Million Rectangles)
... elapsed time: 59.245 Sec
... rate: 59.245000000000005 SPMR (Sec Per Million Rectangles)
>relative time: (display-list called)
... elapsed time: 53.707 Sec
... rate: 53.707 SPMR (Sec Per Million Rectangles)
>absolute time: (display-list compiled+called+calculations)
... elapsed time: 59.255 Sec
... rate: 59.255 SPMR (Sec Per Million Rectangles)
trying mode: 102
>MODE 102: FrontBuffer + COMPILED + Flat + ColorIndex + POLYGON + glVertex2i
>Time for fetching Seis-Data: 0.641
>Time for map color-table: 0.05
>`gl_display(displayList)- rectangles put in displayList: 1000000
>relative time: (display-list only)
... elapsed time: 25.947 Sec
... rate: 25.947 SPMR (Sec Per Million Rectangles)
>absolute time: (display-list and calculations)
... elapsed time: 26.899 Sec
... rate: 26.899 SPMR (Sec Per Million Rectangles)
... elapsed time: 34.35 Sec
... rate: 34.35 SPMR (Sec Per Million Rectangles)
>relative time: (display-list called)
... elapsed time: 7.391 Sec
... rate: 7.391 SPMR (Sec Per Million Rectangles)
>absolute time: (display-list compiled+called+calculations)
... elapsed time: 34.35 Sec
... rate: 34.35 SPMR (Sec Per Million Rectangles)
trying mode: 103
>MODE 103: FrontBuffer + COMPILED + Flat + ColorIndex + QUADS + glVertex2i
>Time for fetching Seis-Data: 0.791
>Time for map color-table: 0.05
>`gl_display(displayList)- rectangles put in displayList: 1000000
>relative time: (display-list only)
... elapsed time: 7.671 Sec
... rate: 7.671 SPMR (Sec Per Million Rectangles)
>absolute time: (display-list and calculations)
... elapsed time: 10.796 Sec
... rate: 10.796 SPMR (Sec Per Million Rectangles)
... elapsed time: 16.314 Sec
... rate: 16.314 SPMR (Sec Per Million Rectangles)
>relative time: (display-list called)
... elapsed time: 5.498 Sec
... rate: 5.498 SPMR (Sec Per Million Rectangles)
>absolute time: (display-list compiled+called+calculations)
... elapsed time: 16.334 Sec
... rate: 16.334 SPMR (Sec Per Million Rectangles)
args: help 112 113
Arguments:
help - print this help
dbl - use doublebuffer
<mode> - render mode, where mode is one of the following integer values :
0 - Immediate + FLAT + ColorIndex + glRect
1 - Immediate + FLAT + ColorIndex + glRectiv
2 - Immediate + FLAT + ColorIndex + POLYGON + glVertex2i(x2,y2);
3 - Immediate + FLAT + ColorIndex + QUADS + glVertex2i(x2,y2);
10 - Immediate + FLAT + RGB + glRect
11 - Immediate + FLAT + RGB + glRectiv
12 - Immediate + FLAT + RGB + POLYGON + glVertex2i(x2,y2);
13 - Immediate + FLAT + RGB + QUADS + glVertex2i(x2,y2);
20 - Immediate + SMOOTH + ColorIndex + glRect
21 - Immediate + SMOOTH + ColorIndex + glRectiv
22 - Immediate + SMOOTH + ColorIndex + POLYGON + glVertex2i(x2,y2);
23 - Immediate + SMOOTH + ColorIndex + QUADS + glVertex2i(x2,y2);
30 - Immediate + SMOOTH + RGB + glRect
31 - Immediate + SMOOTH + RGB + glRectiv
32 - Immediate + SMOOTH + RGB + POLYGON + glVertex2i(x2,y2);
33 - Immediate + SMOOTH + RGB + QUADS + glVertex2i(x2,y2);
100 - COMPILED + FLAT + ColorIndex + glRect
101 - COMPILED + FLAT + ColorIndex + glRectiv
102 - COMPILED + FLAT + ColorIndex + POLYGON + glVertex2i(x2,y2);
103 - COMPILED + FLAT + ColorIndex + QUADS + glVertex2i(x2,y2);
110 - COMPILED + FLAT + RGB + glRect
111 - COMPILED + FLAT + RGB + glRectiv
112 - COMPILED + FLAT + RGB + POLYGON + glVertex2i(x2,y2);
113 - COMPILED + FLAT + RGB + QUADS + glVertex2i(x2,y2);
120 - COMPILED + SMOOTH + ColorIndex + glRect
121 - COMPILED + SMOOTH + ColorIndex + glRectiv
122 - COMPILED + SMOOTH + ColorIndex + POLYGON + glVertex2i(x2,y2);
123 - COMPILED + SMOOTH + ColorIndex + QUADS + glVertex2i(x2,y2);
130 - COMPILED + SMOOTH + RGB + glRect
131 - COMPILED + SMOOTH + RGB + glRectiv
132 - COMPILED + SMOOTH + RGB + POLYGON + glVertex2i(x2,y2);
133 - COMPILED + SMOOTH + RGB + GL_QUADS+ glVertex2i(x2,y2);
trying mode: 112
>MODE 112: FrontBuffer + COMPILED + Flat + RGB + POLYGON + glVertex2i
>Time for fetching Seis-Data: 0.641
>Time for map color-table: 0.05
>`gl_display(displayList)- rectangles put in displayList: 1000000
>relative time: (display-list only)
... elapsed time: 8.372 Sec
... rate: 8.372 SPMR (Sec Per Million Rectangles)
>absolute time: (display-list and calculations)
... elapsed time: 9.073 Sec
... rate: 9.073 SPMR (Sec Per Million Rectangles)
... elapsed time: 15.563 Sec
... rate: 15.563 SPMR (Sec Per Million Rectangles)
>relative time: (display-list called)
... elapsed time: 6.49 Sec
... rate: 6.49 SPMR (Sec Per Million Rectangles)
>absolute time: (display-list compiled+called+calculations)
... elapsed time: 15.563 Sec
... rate: 15.563 SPMR (Sec Per Million Rectangles)
trying mode: 113
>MODE 113: FrontBuffer + COMPILED + Flat + RGB + QUADS + glVertex2i
>Time for fetching Seis-Data: 0.631
>Time for map color-table: 0.05
>`gl_display(displayList)- rectangles put in displayList: 1000000
>relative time: (display-list only)
... elapsed time: 6.159 Sec
... rate: 6.159 SPMR (Sec Per Million Rectangles)
>absolute time: (display-list and calculations)
... elapsed time: 6.84 Sec
... rate: 6.84 SPMR (Sec Per Million Rectangles)
... elapsed time: 12.147 Sec
... rate: 12.147 SPMR (Sec Per Million Rectangles)
>relative time: (display-list called)
... elapsed time: 5.317 Sec
... rate: 5.317 SPMR (Sec Per Million Rectangles)
>absolute time: (display-list compiled+called+calculations)
... elapsed time: 12.157 Sec
... rate: 12.157 SPMR (Sec Per Million Rectangles)
\ No newline at end of file diff --git a/demos/RectRenderSpeed/perfomance-Win32-400MHzPII-MatroxG200.txt b/demos/RectRenderSpeed/perfomance-Win32-400MHzPII-MatroxG200.txt new file mode 100644 index 0000000..4cba0c7 --- /dev/null +++ b/demos/RectRenderSpeed/perfomance-Win32-400MHzPII-MatroxG200.txt @@ -0,0 +1,247 @@ +I used platform:
+
+Matrox G200 with new driver !
+Windows NT 4.0 SP5 !
+329 MB RAM !
+400 MhZ PII !
+
+Running under Java2 & Cygwin32-Bash & ShellScript GL4JTests2.sh !
+
+
+args: help 0 1 2 3 100 101 102 103
+Arguments:
+ help - print this help
+ dbl - use doublebuffer
+ <mode> - render mode, where mode is one of the following integer values :
+ 0 - Immediate + FLAT + ColorIndex + glRect
+ 1 - Immediate + FLAT + ColorIndex + glRectiv
+ 2 - Immediate + FLAT + ColorIndex + POLYGON + glVertex2i(x2,y2);
+ 3 - Immediate + FLAT + ColorIndex + QUADS + glVertex2i(x2,y2);
+ 10 - Immediate + FLAT + RGB + glRect
+ 11 - Immediate + FLAT + RGB + glRectiv
+ 12 - Immediate + FLAT + RGB + POLYGON + glVertex2i(x2,y2);
+ 13 - Immediate + FLAT + RGB + QUADS + glVertex2i(x2,y2);
+ 20 - Immediate + SMOOTH + ColorIndex + glRect
+ 21 - Immediate + SMOOTH + ColorIndex + glRectiv
+ 22 - Immediate + SMOOTH + ColorIndex + POLYGON + glVertex2i(x2,y2);
+ 23 - Immediate + SMOOTH + ColorIndex + QUADS + glVertex2i(x2,y2);
+ 30 - Immediate + SMOOTH + RGB + glRect
+ 31 - Immediate + SMOOTH + RGB + glRectiv
+ 32 - Immediate + SMOOTH + RGB + POLYGON + glVertex2i(x2,y2);
+ 33 - Immediate + SMOOTH + RGB + QUADS + glVertex2i(x2,y2);
+100 - COMPILED + FLAT + ColorIndex + glRect
+101 - COMPILED + FLAT + ColorIndex + glRectiv
+102 - COMPILED + FLAT + ColorIndex + POLYGON + glVertex2i(x2,y2);
+103 - COMPILED + FLAT + ColorIndex + QUADS + glVertex2i(x2,y2);
+110 - COMPILED + FLAT + RGB + glRect
+111 - COMPILED + FLAT + RGB + glRectiv
+112 - COMPILED + FLAT + RGB + POLYGON + glVertex2i(x2,y2);
+113 - COMPILED + FLAT + RGB + QUADS + glVertex2i(x2,y2);
+120 - COMPILED + SMOOTH + ColorIndex + glRect
+121 - COMPILED + SMOOTH + ColorIndex + glRectiv
+122 - COMPILED + SMOOTH + ColorIndex + POLYGON + glVertex2i(x2,y2);
+123 - COMPILED + SMOOTH + ColorIndex + QUADS + glVertex2i(x2,y2);
+130 - COMPILED + SMOOTH + RGB + glRect
+131 - COMPILED + SMOOTH + RGB + glRectiv
+132 - COMPILED + SMOOTH + RGB + POLYGON + glVertex2i(x2,y2);
+133 - COMPILED + SMOOTH + RGB + GL_QUADS+ glVertex2i(x2,y2);
+
+
+trying mode: 0
+>MODE 0: FrontBuffer + IMMEDIATE + Flat + ColorIndex + glRect
+>Time for fetching Seis-Data: 0.631
+>Time for map color-table: 0.05
+>`gl_display(immediate)- rectangles rendered: 1000000
+>relative time: (immediate only)
+... elapsed time: 60.858 Sec
+... rate: 60.858000000000004 SPMR (Sec Per Million Rectangles)
+>absolute time: (immediate and calculations)
+... elapsed time: 61.549 Sec
+... rate: 61.549 SPMR (Sec Per Million Rectangles)
+trying mode: 1
+>MODE 1: FrontBuffer + IMMEDIATE + Flat + ColorIndex + glRectiv
+>Time for fetching Seis-Data: 0.631
+>Time for map color-table: 0.04
+>`gl_display(immediate)- rectangles rendered: 1000000
+>relative time: (immediate only)
+... elapsed time: 67.547 Sec
+... rate: 67.547 SPMR (Sec Per Million Rectangles)
+>absolute time: (immediate and calculations)
+... elapsed time: 68.218 Sec
+... rate: 68.218 SPMR (Sec Per Million Rectangles)
+trying mode: 2
+>MODE 2: FrontBuffer + IMMEDIATE + Flat + ColorIndex + POLYGON + glVertex2i
+>Time for fetching Seis-Data: 0.631
+>Time for map color-table: 0.05
+>`gl_display(immediate)- rectangles rendered: 1000000
+>relative time: (immediate only)
+... elapsed time: 8.782 Sec
+... rate: 8.782 SPMR (Sec Per Million Rectangles)
+>absolute time: (immediate and calculations)
+... elapsed time: 9.473 Sec
+... rate: 9.473 SPMR (Sec Per Million Rectangles)
+trying mode: 3
+>MODE 3: FrontBuffer + IMMEDIATE + Flat + ColorIndex + QUADS + glVertex2i
+>Time for fetching Seis-Data: 0.631
+>Time for map color-table: 0.04
+>`gl_display(immediate)- rectangles rendered: 1000000
+>relative time: (immediate only)
+... elapsed time: 7.051 Sec
+... rate: 7.051 SPMR (Sec Per Million Rectangles)
+>absolute time: (immediate and calculations)
+... elapsed time: 7.722 Sec
+... rate: 7.722 SPMR (Sec Per Million Rectangles)
+trying mode: 100
+>MODE 100: FrontBuffer + COMPILED + Flat + ColorIndex + glRect
+>Time for fetching Seis-Data: 0.63
+>Time for map color-table: 0.051
+>`gl_display(displayList)- rectangles put in displayList: 1000000
+>relative time: (display-list only)
+... elapsed time: 2.894 Sec
+... rate: 2.894 SPMR (Sec Per Million Rectangles)
+>absolute time: (display-list and calculations)
+... elapsed time: 3.575 Sec
+... rate: 3.575 SPMR (Sec Per Million Rectangles)
+... elapsed time: 56.571 Sec
+... rate: 56.571 SPMR (Sec Per Million Rectangles)
+>relative time: (display-list called)
+... elapsed time: 52.996 Sec
+... rate: 52.996 SPMR (Sec Per Million Rectangles)
+>absolute time: (display-list compiled+called+calculations)
+... elapsed time: 56.571 Sec
+... rate: 56.571 SPMR (Sec Per Million Rectangles)
+trying mode: 101
+>MODE 101: FrontBuffer + COMPILED + Flat + ColorIndex + glRectiv
+>Time for fetching Seis-Data: 0.631
+>Time for map color-table: 0.04
+>`gl_display(displayList)- rectangles put in displayList: 1000000
+>relative time: (display-list only)
+... elapsed time: 4.867 Sec
+... rate: 4.867 SPMR (Sec Per Million Rectangles)
+>absolute time: (display-list and calculations)
+... elapsed time: 5.548 Sec
+... rate: 5.548 SPMR (Sec Per Million Rectangles)
+... elapsed time: 59.245 Sec
+... rate: 59.245000000000005 SPMR (Sec Per Million Rectangles)
+>relative time: (display-list called)
+... elapsed time: 53.707 Sec
+... rate: 53.707 SPMR (Sec Per Million Rectangles)
+>absolute time: (display-list compiled+called+calculations)
+... elapsed time: 59.255 Sec
+... rate: 59.255 SPMR (Sec Per Million Rectangles)
+trying mode: 102
+>MODE 102: FrontBuffer + COMPILED + Flat + ColorIndex + POLYGON + glVertex2i
+>Time for fetching Seis-Data: 0.641
+>Time for map color-table: 0.05
+>`gl_display(displayList)- rectangles put in displayList: 1000000
+>relative time: (display-list only)
+... elapsed time: 25.947 Sec
+... rate: 25.947 SPMR (Sec Per Million Rectangles)
+>absolute time: (display-list and calculations)
+... elapsed time: 26.899 Sec
+... rate: 26.899 SPMR (Sec Per Million Rectangles)
+... elapsed time: 34.35 Sec
+... rate: 34.35 SPMR (Sec Per Million Rectangles)
+>relative time: (display-list called)
+... elapsed time: 7.391 Sec
+... rate: 7.391 SPMR (Sec Per Million Rectangles)
+>absolute time: (display-list compiled+called+calculations)
+... elapsed time: 34.35 Sec
+... rate: 34.35 SPMR (Sec Per Million Rectangles)
+trying mode: 103
+>MODE 103: FrontBuffer + COMPILED + Flat + ColorIndex + QUADS + glVertex2i
+>Time for fetching Seis-Data: 0.791
+>Time for map color-table: 0.05
+>`gl_display(displayList)- rectangles put in displayList: 1000000
+>relative time: (display-list only)
+... elapsed time: 7.671 Sec
+... rate: 7.671 SPMR (Sec Per Million Rectangles)
+>absolute time: (display-list and calculations)
+... elapsed time: 10.796 Sec
+... rate: 10.796 SPMR (Sec Per Million Rectangles)
+... elapsed time: 16.314 Sec
+... rate: 16.314 SPMR (Sec Per Million Rectangles)
+>relative time: (display-list called)
+... elapsed time: 5.498 Sec
+... rate: 5.498 SPMR (Sec Per Million Rectangles)
+>absolute time: (display-list compiled+called+calculations)
+... elapsed time: 16.334 Sec
+... rate: 16.334 SPMR (Sec Per Million Rectangles)
+
+args: help 112 113
+Arguments:
+ help - print this help
+ dbl - use doublebuffer
+ <mode> - render mode, where mode is one of the following integer values :
+ 0 - Immediate + FLAT + ColorIndex + glRect
+ 1 - Immediate + FLAT + ColorIndex + glRectiv
+ 2 - Immediate + FLAT + ColorIndex + POLYGON + glVertex2i(x2,y2);
+ 3 - Immediate + FLAT + ColorIndex + QUADS + glVertex2i(x2,y2);
+ 10 - Immediate + FLAT + RGB + glRect
+ 11 - Immediate + FLAT + RGB + glRectiv
+ 12 - Immediate + FLAT + RGB + POLYGON + glVertex2i(x2,y2);
+ 13 - Immediate + FLAT + RGB + QUADS + glVertex2i(x2,y2);
+ 20 - Immediate + SMOOTH + ColorIndex + glRect
+ 21 - Immediate + SMOOTH + ColorIndex + glRectiv
+ 22 - Immediate + SMOOTH + ColorIndex + POLYGON + glVertex2i(x2,y2);
+ 23 - Immediate + SMOOTH + ColorIndex + QUADS + glVertex2i(x2,y2);
+ 30 - Immediate + SMOOTH + RGB + glRect
+ 31 - Immediate + SMOOTH + RGB + glRectiv
+ 32 - Immediate + SMOOTH + RGB + POLYGON + glVertex2i(x2,y2);
+ 33 - Immediate + SMOOTH + RGB + QUADS + glVertex2i(x2,y2);
+100 - COMPILED + FLAT + ColorIndex + glRect
+101 - COMPILED + FLAT + ColorIndex + glRectiv
+102 - COMPILED + FLAT + ColorIndex + POLYGON + glVertex2i(x2,y2);
+103 - COMPILED + FLAT + ColorIndex + QUADS + glVertex2i(x2,y2);
+110 - COMPILED + FLAT + RGB + glRect
+111 - COMPILED + FLAT + RGB + glRectiv
+112 - COMPILED + FLAT + RGB + POLYGON + glVertex2i(x2,y2);
+113 - COMPILED + FLAT + RGB + QUADS + glVertex2i(x2,y2);
+120 - COMPILED + SMOOTH + ColorIndex + glRect
+121 - COMPILED + SMOOTH + ColorIndex + glRectiv
+122 - COMPILED + SMOOTH + ColorIndex + POLYGON + glVertex2i(x2,y2);
+123 - COMPILED + SMOOTH + ColorIndex + QUADS + glVertex2i(x2,y2);
+130 - COMPILED + SMOOTH + RGB + glRect
+131 - COMPILED + SMOOTH + RGB + glRectiv
+132 - COMPILED + SMOOTH + RGB + POLYGON + glVertex2i(x2,y2);
+133 - COMPILED + SMOOTH + RGB + GL_QUADS+ glVertex2i(x2,y2);
+
+
+trying mode: 112
+>MODE 112: FrontBuffer + COMPILED + Flat + RGB + POLYGON + glVertex2i
+>Time for fetching Seis-Data: 0.641
+>Time for map color-table: 0.05
+>`gl_display(displayList)- rectangles put in displayList: 1000000
+>relative time: (display-list only)
+... elapsed time: 8.372 Sec
+... rate: 8.372 SPMR (Sec Per Million Rectangles)
+>absolute time: (display-list and calculations)
+... elapsed time: 9.073 Sec
+... rate: 9.073 SPMR (Sec Per Million Rectangles)
+... elapsed time: 15.563 Sec
+... rate: 15.563 SPMR (Sec Per Million Rectangles)
+>relative time: (display-list called)
+... elapsed time: 6.49 Sec
+... rate: 6.49 SPMR (Sec Per Million Rectangles)
+>absolute time: (display-list compiled+called+calculations)
+... elapsed time: 15.563 Sec
+... rate: 15.563 SPMR (Sec Per Million Rectangles)
+trying mode: 113
+>MODE 113: FrontBuffer + COMPILED + Flat + RGB + QUADS + glVertex2i
+>Time for fetching Seis-Data: 0.631
+>Time for map color-table: 0.05
+>`gl_display(displayList)- rectangles put in displayList: 1000000
+>relative time: (display-list only)
+... elapsed time: 6.159 Sec
+... rate: 6.159 SPMR (Sec Per Million Rectangles)
+>absolute time: (display-list and calculations)
+... elapsed time: 6.84 Sec
+... rate: 6.84 SPMR (Sec Per Million Rectangles)
+... elapsed time: 12.147 Sec
+... rate: 12.147 SPMR (Sec Per Million Rectangles)
+>relative time: (display-list called)
+... elapsed time: 5.317 Sec
+... rate: 5.317 SPMR (Sec Per Million Rectangles)
+>absolute time: (display-list compiled+called+calculations)
+... elapsed time: 12.157 Sec
+... rate: 12.157 SPMR (Sec Per Million Rectangles)
diff --git a/demos/RonsDemos/DemoTex1.java b/demos/RonsDemos/DemoTex1.java new file mode 100644 index 0000000..60477f9 --- /dev/null +++ b/demos/RonsDemos/DemoTex1.java @@ -0,0 +1,4158 @@ +/**
+ * @(#) DemoTex1.java
+ * @(#) author: Ronald B. Cemer
+ * @(#) version: 1.0
+ */
+
+import java.io.*;
+import gl4java.GLEnum;
+
+public class DemoTex1 implements HardCodedTexture, GLEnum
+{
+ private static final int width = 64;
+ private static final int height = 64;
+ private static final byte bits[] =
+ {
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x18,(byte)0x08,(byte)0x08,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x10,(byte)0x08,(byte)0x08,
+ (byte)0x18,(byte)0x10,(byte)0x10,
+ (byte)0x20,(byte)0x18,(byte)0x18,
+ (byte)0x29,(byte)0x20,(byte)0x20,
+ (byte)0x18,(byte)0x18,(byte)0x18,
+ (byte)0x10,(byte)0x10,(byte)0x10,
+ (byte)0x08,(byte)0x08,(byte)0x08,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x10,(byte)0x00,(byte)0x00,
+ (byte)0x18,(byte)0x08,(byte)0x08,
+ (byte)0x20,(byte)0x10,(byte)0x10,
+ (byte)0x29,(byte)0x18,(byte)0x18,
+ (byte)0x20,(byte)0x18,(byte)0x18,
+ (byte)0x31,(byte)0x18,(byte)0x18,
+ (byte)0x10,(byte)0x08,(byte)0x08,
+ (byte)0x18,(byte)0x08,(byte)0x10,
+ (byte)0x4a,(byte)0x39,(byte)0x41,
+ (byte)0x5a,(byte)0x4a,(byte)0x52,
+ (byte)0x7b,(byte)0x62,(byte)0x62,
+ (byte)0x7b,(byte)0x62,(byte)0x62,
+ (byte)0x83,(byte)0x73,(byte)0x6a,
+ (byte)0x6a,(byte)0x62,(byte)0x52,
+ (byte)0x6a,(byte)0x62,(byte)0x5a,
+ (byte)0x5a,(byte)0x52,(byte)0x4a,
+ (byte)0x39,(byte)0x31,(byte)0x31,
+ (byte)0x10,(byte)0x10,(byte)0x10,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x18,(byte)0x08,(byte)0x00,
+ (byte)0x18,(byte)0x08,(byte)0x08,
+ (byte)0x10,(byte)0x08,(byte)0x08,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x10,(byte)0x10,(byte)0x08,
+ (byte)0x10,(byte)0x10,(byte)0x08,
+ (byte)0x20,(byte)0x20,(byte)0x20,
+ (byte)0x10,(byte)0x10,(byte)0x10,
+ (byte)0x08,(byte)0x08,(byte)0x08,
+ (byte)0x10,(byte)0x08,(byte)0x08,
+ (byte)0x5a,(byte)0x39,(byte)0x4a,
+ (byte)0x62,(byte)0x39,(byte)0x4a,
+ (byte)0x73,(byte)0x41,(byte)0x5a,
+ (byte)0x7b,(byte)0x41,(byte)0x52,
+ (byte)0x8b,(byte)0x41,(byte)0x5a,
+ (byte)0x83,(byte)0x39,(byte)0x4a,
+ (byte)0x73,(byte)0x41,(byte)0x41,
+ (byte)0x6a,(byte)0x52,(byte)0x41,
+ (byte)0x6a,(byte)0x5a,(byte)0x4a,
+ (byte)0x6a,(byte)0x62,(byte)0x4a,
+ (byte)0x39,(byte)0x39,(byte)0x29,
+ (byte)0x20,(byte)0x18,(byte)0x18,
+ (byte)0x10,(byte)0x10,(byte)0x10,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x10,(byte)0x08,(byte)0x08,
+ (byte)0x18,(byte)0x10,(byte)0x10,
+ (byte)0x20,(byte)0x18,(byte)0x18,
+ (byte)0x18,(byte)0x18,(byte)0x20,
+ (byte)0x31,(byte)0x31,(byte)0x39,
+ (byte)0x41,(byte)0x41,(byte)0x4a,
+ (byte)0x4a,(byte)0x41,(byte)0x4a,
+ (byte)0x31,(byte)0x31,(byte)0x39,
+ (byte)0x39,(byte)0x39,(byte)0x39,
+ (byte)0x4a,(byte)0x39,(byte)0x31,
+ (byte)0x5a,(byte)0x31,(byte)0x31,
+ (byte)0x5a,(byte)0x31,(byte)0x41,
+ (byte)0x62,(byte)0x20,(byte)0x39,
+ (byte)0x6a,(byte)0x18,(byte)0x39,
+ (byte)0x6a,(byte)0x31,(byte)0x41,
+ (byte)0x5a,(byte)0x29,(byte)0x39,
+ (byte)0x41,(byte)0x10,(byte)0x18,
+ (byte)0x4a,(byte)0x20,(byte)0x31,
+ (byte)0x4a,(byte)0x31,(byte)0x41,
+ (byte)0x52,(byte)0x31,(byte)0x41,
+ (byte)0x62,(byte)0x41,(byte)0x4a,
+ (byte)0x5a,(byte)0x29,(byte)0x31,
+ (byte)0x39,(byte)0x20,(byte)0x18,
+ (byte)0x39,(byte)0x39,(byte)0x29,
+ (byte)0x52,(byte)0x52,(byte)0x41,
+ (byte)0x41,(byte)0x39,(byte)0x39,
+ (byte)0x20,(byte)0x18,(byte)0x10,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x18,(byte)0x10,(byte)0x10,
+ (byte)0x31,(byte)0x29,(byte)0x39,
+ (byte)0x29,(byte)0x29,(byte)0x39,
+ (byte)0x18,(byte)0x18,(byte)0x20,
+ (byte)0x20,(byte)0x20,(byte)0x29,
+ (byte)0x4a,(byte)0x4a,(byte)0x52,
+ (byte)0x73,(byte)0x7b,(byte)0x8b,
+ (byte)0x4a,(byte)0x4a,(byte)0x52,
+ (byte)0x41,(byte)0x39,(byte)0x39,
+ (byte)0x29,(byte)0x20,(byte)0x18,
+ (byte)0x62,(byte)0x41,(byte)0x52,
+ (byte)0x94,(byte)0x62,(byte)0x83,
+ (byte)0x9c,(byte)0x62,(byte)0x83,
+ (byte)0x8b,(byte)0x5a,(byte)0x83,
+ (byte)0x8b,(byte)0x62,(byte)0x94,
+ (byte)0x9c,(byte)0x83,(byte)0xb4,
+ (byte)0x9c,(byte)0x8b,(byte)0xbd,
+ (byte)0x83,(byte)0x6a,(byte)0x94,
+ (byte)0x83,(byte)0x6a,(byte)0x83,
+ (byte)0x8b,(byte)0x62,(byte)0x8b,
+ (byte)0x7b,(byte)0x6a,(byte)0x94,
+ (byte)0x83,(byte)0x6a,(byte)0x94,
+ (byte)0x94,(byte)0x94,(byte)0xb4,
+ (byte)0xa4,(byte)0x7b,(byte)0xac,
+ (byte)0x83,(byte)0x41,(byte)0x73,
+ (byte)0x41,(byte)0x18,(byte)0x29,
+ (byte)0x31,(byte)0x29,(byte)0x20,
+ (byte)0x5a,(byte)0x52,(byte)0x4a,
+ (byte)0x39,(byte)0x31,(byte)0x29,
+ (byte)0x20,(byte)0x18,(byte)0x10,
+ (byte)0x10,(byte)0x10,(byte)0x08,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x10,(byte)0x08,(byte)0x08,
+ (byte)0x20,(byte)0x18,(byte)0x29,
+ (byte)0x31,(byte)0x31,(byte)0x39,
+ (byte)0x29,(byte)0x29,(byte)0x31,
+ (byte)0x10,(byte)0x10,(byte)0x18,
+ (byte)0x10,(byte)0x10,(byte)0x08,
+ (byte)0x08,(byte)0x08,(byte)0x00,
+ (byte)0x52,(byte)0x41,(byte)0x52,
+ (byte)0x7b,(byte)0x6a,(byte)0x8b,
+ (byte)0x6a,(byte)0x6a,(byte)0x73,
+ (byte)0x41,(byte)0x41,(byte)0x4a,
+ (byte)0x41,(byte)0x29,(byte)0x41,
+ (byte)0x41,(byte)0x31,(byte)0x4a,
+ (byte)0x73,(byte)0x62,(byte)0x8b,
+ (byte)0x9c,(byte)0x9c,(byte)0xde,
+ (byte)0x7b,(byte)0xa4,(byte)0xde,
+ (byte)0x6a,(byte)0xac,(byte)0xde,
+ (byte)0x6a,(byte)0xa4,(byte)0xde,
+ (byte)0x62,(byte)0xa4,(byte)0xde,
+ (byte)0x6a,(byte)0xa4,(byte)0xde,
+ (byte)0x73,(byte)0xac,(byte)0xe6,
+ (byte)0x73,(byte)0xa4,(byte)0xde,
+ (byte)0x73,(byte)0xa4,(byte)0xd5,
+ (byte)0x73,(byte)0x9c,(byte)0xcd,
+ (byte)0x7b,(byte)0xac,(byte)0xde,
+ (byte)0x83,(byte)0xb4,(byte)0xe6,
+ (byte)0x9c,(byte)0xac,(byte)0xde,
+ (byte)0x94,(byte)0x62,(byte)0x8b,
+ (byte)0x39,(byte)0x18,(byte)0x18,
+ (byte)0x10,(byte)0x08,(byte)0x08,
+ (byte)0x20,(byte)0x20,(byte)0x20,
+ (byte)0x20,(byte)0x18,(byte)0x10,
+ (byte)0x18,(byte)0x18,(byte)0x10,
+ (byte)0x29,(byte)0x20,(byte)0x18,
+ (byte)0x08,(byte)0x08,(byte)0x08,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x10,(byte)0x00,(byte)0x00,
+ (byte)0x31,(byte)0x20,(byte)0x29,
+ (byte)0x29,(byte)0x20,(byte)0x29,
+ (byte)0x20,(byte)0x18,(byte)0x18,
+ (byte)0x18,(byte)0x10,(byte)0x08,
+ (byte)0x20,(byte)0x18,(byte)0x08,
+ (byte)0x31,(byte)0x20,(byte)0x18,
+ (byte)0x6a,(byte)0x41,(byte)0x52,
+ (byte)0xac,(byte)0x94,(byte)0xbd,
+ (byte)0xbd,(byte)0xbd,(byte)0xee,
+ (byte)0xa4,(byte)0x8b,(byte)0xb4,
+ (byte)0x8b,(byte)0x73,(byte)0x94,
+ (byte)0xa4,(byte)0x8b,(byte)0xbd,
+ (byte)0x94,(byte)0x94,(byte)0xc5,
+ (byte)0x8b,(byte)0xa4,(byte)0xd5,
+ (byte)0x83,(byte)0xac,(byte)0xde,
+ (byte)0x73,(byte)0xa4,(byte)0xde,
+ (byte)0x6a,(byte)0x9c,(byte)0xd5,
+ (byte)0x62,(byte)0x94,(byte)0xd5,
+ (byte)0x52,(byte)0x8b,(byte)0xc5,
+ (byte)0x4a,(byte)0x83,(byte)0xc5,
+ (byte)0x4a,(byte)0x83,(byte)0xc5,
+ (byte)0x52,(byte)0x8b,(byte)0xc5,
+ (byte)0x52,(byte)0x8b,(byte)0xcd,
+ (byte)0x52,(byte)0x94,(byte)0xcd,
+ (byte)0x5a,(byte)0x94,(byte)0xcd,
+ (byte)0x62,(byte)0x9c,(byte)0xd5,
+ (byte)0x73,(byte)0xac,(byte)0xe6,
+ (byte)0x9c,(byte)0x94,(byte)0xcd,
+ (byte)0x7b,(byte)0x41,(byte)0x62,
+ (byte)0x5a,(byte)0x39,(byte)0x39,
+ (byte)0x39,(byte)0x39,(byte)0x29,
+ (byte)0x29,(byte)0x20,(byte)0x20,
+ (byte)0x10,(byte)0x10,(byte)0x10,
+ (byte)0x18,(byte)0x18,(byte)0x10,
+ (byte)0x29,(byte)0x29,(byte)0x20,
+ (byte)0x10,(byte)0x10,(byte)0x08,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x29,(byte)0x18,(byte)0x10,
+ (byte)0x39,(byte)0x29,(byte)0x29,
+ (byte)0x31,(byte)0x20,(byte)0x18,
+ (byte)0x18,(byte)0x18,(byte)0x08,
+ (byte)0x41,(byte)0x39,(byte)0x29,
+ (byte)0x94,(byte)0x73,(byte)0x8b,
+ (byte)0xbd,(byte)0xa4,(byte)0xcd,
+ (byte)0xcd,(byte)0xcd,(byte)0xf6,
+ (byte)0xcd,(byte)0xd5,(byte)0xff,
+ (byte)0xc5,(byte)0xcd,(byte)0xf6,
+ (byte)0xcd,(byte)0xc5,(byte)0xee,
+ (byte)0xc5,(byte)0xd5,(byte)0xff,
+ (byte)0xb4,(byte)0xcd,(byte)0xf6,
+ (byte)0xa4,(byte)0xc5,(byte)0xee,
+ (byte)0x94,(byte)0xbd,(byte)0xe6,
+ (byte)0x83,(byte)0xac,(byte)0xde,
+ (byte)0x7b,(byte)0xa4,(byte)0xde,
+ (byte)0x7b,(byte)0xa4,(byte)0xde,
+ (byte)0x62,(byte)0x94,(byte)0xcd,
+ (byte)0x5a,(byte)0x8b,(byte)0xc5,
+ (byte)0x52,(byte)0x83,(byte)0xc5,
+ (byte)0x4a,(byte)0x83,(byte)0xc5,
+ (byte)0x41,(byte)0x7b,(byte)0xbd,
+ (byte)0x41,(byte)0x7b,(byte)0xbd,
+ (byte)0x41,(byte)0x7b,(byte)0xbd,
+ (byte)0x4a,(byte)0x83,(byte)0xc5,
+ (byte)0x4a,(byte)0x83,(byte)0xc5,
+ (byte)0x52,(byte)0x8b,(byte)0xcd,
+ (byte)0x62,(byte)0x9c,(byte)0xd5,
+ (byte)0x7b,(byte)0x9c,(byte)0xd5,
+ (byte)0x94,(byte)0x5a,(byte)0x8b,
+ (byte)0x6a,(byte)0x31,(byte)0x31,
+ (byte)0x41,(byte)0x39,(byte)0x29,
+ (byte)0x39,(byte)0x31,(byte)0x31,
+ (byte)0x41,(byte)0x41,(byte)0x41,
+ (byte)0x18,(byte)0x18,(byte)0x10,
+ (byte)0x20,(byte)0x18,(byte)0x10,
+ (byte)0x20,(byte)0x18,(byte)0x10,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x10,(byte)0x08,(byte)0x00,
+ (byte)0x39,(byte)0x20,(byte)0x20,
+ (byte)0x41,(byte)0x31,(byte)0x31,
+ (byte)0x18,(byte)0x18,(byte)0x08,
+ (byte)0x29,(byte)0x20,(byte)0x10,
+ (byte)0x5a,(byte)0x41,(byte)0x41,
+ (byte)0x9c,(byte)0x73,(byte)0x9c,
+ (byte)0xac,(byte)0xa4,(byte)0xc5,
+ (byte)0xac,(byte)0xb4,(byte)0xd5,
+ (byte)0xbd,(byte)0xc5,(byte)0xee,
+ (byte)0xcd,(byte)0xd5,(byte)0xff,
+ (byte)0xcd,(byte)0xd5,(byte)0xf6,
+ (byte)0xc5,(byte)0xd5,(byte)0xf6,
+ (byte)0xb4,(byte)0xcd,(byte)0xf6,
+ (byte)0xac,(byte)0xc5,(byte)0xee,
+ (byte)0xac,(byte)0xc5,(byte)0xee,
+ (byte)0x9c,(byte)0xb4,(byte)0xe6,
+ (byte)0x8b,(byte)0xb4,(byte)0xde,
+ (byte)0x94,(byte)0xb4,(byte)0xe6,
+ (byte)0x83,(byte)0xa4,(byte)0xde,
+ (byte)0x6a,(byte)0x94,(byte)0xd5,
+ (byte)0x5a,(byte)0x8b,(byte)0xcd,
+ (byte)0x5a,(byte)0x8b,(byte)0xc5,
+ (byte)0x5a,(byte)0x83,(byte)0xc5,
+ (byte)0x41,(byte)0x73,(byte)0xbd,
+ (byte)0x39,(byte)0x6a,(byte)0xb4,
+ (byte)0x41,(byte)0x73,(byte)0xb4,
+ (byte)0x41,(byte)0x73,(byte)0xbd,
+ (byte)0x39,(byte)0x73,(byte)0xb4,
+ (byte)0x41,(byte)0x7b,(byte)0xbd,
+ (byte)0x4a,(byte)0x83,(byte)0xc5,
+ (byte)0x52,(byte)0x94,(byte)0xcd,
+ (byte)0x73,(byte)0xa4,(byte)0xde,
+ (byte)0x9c,(byte)0x62,(byte)0x9c,
+ (byte)0x7b,(byte)0x31,(byte)0x52,
+ (byte)0x5a,(byte)0x4a,(byte)0x52,
+ (byte)0x4a,(byte)0x4a,(byte)0x41,
+ (byte)0x41,(byte)0x39,(byte)0x39,
+ (byte)0x10,(byte)0x10,(byte)0x08,
+ (byte)0x18,(byte)0x10,(byte)0x08,
+ (byte)0x18,(byte)0x10,(byte)0x08,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x29,(byte)0x18,(byte)0x18,
+ (byte)0x39,(byte)0x20,(byte)0x20,
+ (byte)0x41,(byte)0x31,(byte)0x41,
+ (byte)0x31,(byte)0x31,(byte)0x20,
+ (byte)0x41,(byte)0x41,(byte)0x20,
+ (byte)0x5a,(byte)0x39,(byte)0x41,
+ (byte)0x9c,(byte)0x83,(byte)0xa4,
+ (byte)0xc5,(byte)0xcd,(byte)0xee,
+ (byte)0xac,(byte)0xac,(byte)0xcd,
+ (byte)0xbd,(byte)0xbd,(byte)0xde,
+ (byte)0xd5,(byte)0xd5,(byte)0xff,
+ (byte)0xcd,(byte)0xd5,(byte)0xff,
+ (byte)0xc5,(byte)0xcd,(byte)0xf6,
+ (byte)0xb4,(byte)0xcd,(byte)0xf6,
+ (byte)0xac,(byte)0xc5,(byte)0xee,
+ (byte)0xa4,(byte)0xc5,(byte)0xee,
+ (byte)0x94,(byte)0xb4,(byte)0xe6,
+ (byte)0x8b,(byte)0xac,(byte)0xde,
+ (byte)0x8b,(byte)0xac,(byte)0xde,
+ (byte)0x8b,(byte)0xac,(byte)0xde,
+ (byte)0x83,(byte)0xa4,(byte)0xde,
+ (byte)0x73,(byte)0x9c,(byte)0xd5,
+ (byte)0x6a,(byte)0x94,(byte)0xcd,
+ (byte)0x5a,(byte)0x83,(byte)0xc5,
+ (byte)0x5a,(byte)0x83,(byte)0xc5,
+ (byte)0x5a,(byte)0x8b,(byte)0xc5,
+ (byte)0x4a,(byte)0x7b,(byte)0xbd,
+ (byte)0x41,(byte)0x6a,(byte)0xb4,
+ (byte)0x39,(byte)0x73,(byte)0xb4,
+ (byte)0x39,(byte)0x6a,(byte)0xb4,
+ (byte)0x39,(byte)0x73,(byte)0xb4,
+ (byte)0x39,(byte)0x73,(byte)0xb4,
+ (byte)0x41,(byte)0x7b,(byte)0xbd,
+ (byte)0x52,(byte)0x8b,(byte)0xcd,
+ (byte)0x6a,(byte)0x94,(byte)0xd5,
+ (byte)0x8b,(byte)0x6a,(byte)0xa4,
+ (byte)0x7b,(byte)0x4a,(byte)0x73,
+ (byte)0x52,(byte)0x41,(byte)0x4a,
+ (byte)0x41,(byte)0x39,(byte)0x39,
+ (byte)0x29,(byte)0x29,(byte)0x20,
+ (byte)0x18,(byte)0x18,(byte)0x10,
+ (byte)0x39,(byte)0x29,(byte)0x20,
+ (byte)0x29,(byte)0x20,(byte)0x10,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x10,(byte)0x00,(byte)0x08,
+ (byte)0x29,(byte)0x10,(byte)0x10,
+ (byte)0x31,(byte)0x29,(byte)0x29,
+ (byte)0x4a,(byte)0x4a,(byte)0x41,
+ (byte)0x41,(byte)0x4a,(byte)0x4a,
+ (byte)0x4a,(byte)0x4a,(byte)0x5a,
+ (byte)0x41,(byte)0x41,(byte)0x62,
+ (byte)0xb4,(byte)0xbd,(byte)0xe6,
+ (byte)0xd5,(byte)0xde,(byte)0xff,
+ (byte)0xd5,(byte)0xde,(byte)0xff,
+ (byte)0xd5,(byte)0xde,(byte)0xff,
+ (byte)0xcd,(byte)0xd5,(byte)0xff,
+ (byte)0xcd,(byte)0xd5,(byte)0xf6,
+ (byte)0xc5,(byte)0xd5,(byte)0xf6,
+ (byte)0xc5,(byte)0xcd,(byte)0xf6,
+ (byte)0xb4,(byte)0xcd,(byte)0xf6,
+ (byte)0xac,(byte)0xc5,(byte)0xee,
+ (byte)0x9c,(byte)0xbd,(byte)0xe6,
+ (byte)0x9c,(byte)0xb4,(byte)0xe6,
+ (byte)0x94,(byte)0xb4,(byte)0xe6,
+ (byte)0x94,(byte)0xb4,(byte)0xe6,
+ (byte)0x83,(byte)0xac,(byte)0xde,
+ (byte)0x6a,(byte)0x94,(byte)0xd5,
+ (byte)0x5a,(byte)0x8b,(byte)0xcd,
+ (byte)0x5a,(byte)0x8b,(byte)0xc5,
+ (byte)0x5a,(byte)0x83,(byte)0xc5,
+ (byte)0x52,(byte)0x7b,(byte)0xbd,
+ (byte)0x4a,(byte)0x7b,(byte)0xbd,
+ (byte)0x41,(byte)0x6a,(byte)0xb4,
+ (byte)0x31,(byte)0x62,(byte)0xa4,
+ (byte)0x31,(byte)0x62,(byte)0xa4,
+ (byte)0x39,(byte)0x6a,(byte)0xb4,
+ (byte)0x39,(byte)0x6a,(byte)0xac,
+ (byte)0x31,(byte)0x6a,(byte)0xb4,
+ (byte)0x41,(byte)0x7b,(byte)0xbd,
+ (byte)0x4a,(byte)0x8b,(byte)0xcd,
+ (byte)0x62,(byte)0x9c,(byte)0xd5,
+ (byte)0x7b,(byte)0x83,(byte)0xb4,
+ (byte)0x7b,(byte)0x5a,(byte)0x7b,
+ (byte)0x29,(byte)0x18,(byte)0x20,
+ (byte)0x20,(byte)0x10,(byte)0x10,
+ (byte)0x10,(byte)0x08,(byte)0x08,
+ (byte)0x41,(byte)0x41,(byte)0x39,
+ (byte)0x39,(byte)0x31,(byte)0x31,
+ (byte)0x10,(byte)0x10,(byte)0x08,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x10,(byte)0x08,(byte)0x08,
+ (byte)0x20,(byte)0x18,(byte)0x10,
+ (byte)0x39,(byte)0x31,(byte)0x29,
+ (byte)0x5a,(byte)0x52,(byte)0x5a,
+ (byte)0x4a,(byte)0x52,(byte)0x6a,
+ (byte)0x31,(byte)0x39,(byte)0x62,
+ (byte)0x29,(byte)0x29,(byte)0x41,
+ (byte)0x6a,(byte)0x73,(byte)0x8b,
+ (byte)0xcd,(byte)0xd5,(byte)0xff,
+ (byte)0xcd,(byte)0xd5,(byte)0xf6,
+ (byte)0xcd,(byte)0xd5,(byte)0xf6,
+ (byte)0xcd,(byte)0xd5,(byte)0xff,
+ (byte)0xcd,(byte)0xd5,(byte)0xff,
+ (byte)0xcd,(byte)0xd5,(byte)0xf6,
+ (byte)0xcd,(byte)0xd5,(byte)0xf6,
+ (byte)0xc5,(byte)0xcd,(byte)0xf6,
+ (byte)0xac,(byte)0xc5,(byte)0xee,
+ (byte)0xac,(byte)0xc5,(byte)0xee,
+ (byte)0xb4,(byte)0xc5,(byte)0xee,
+ (byte)0xa4,(byte)0xc5,(byte)0xee,
+ (byte)0x8b,(byte)0xb4,(byte)0xde,
+ (byte)0x7b,(byte)0xa4,(byte)0xde,
+ (byte)0x73,(byte)0x9c,(byte)0xd5,
+ (byte)0x62,(byte)0x94,(byte)0xcd,
+ (byte)0x5a,(byte)0x8b,(byte)0xc5,
+ (byte)0x52,(byte)0x83,(byte)0xc5,
+ (byte)0x41,(byte)0x7b,(byte)0xbd,
+ (byte)0x39,(byte)0x6a,(byte)0xb4,
+ (byte)0x39,(byte)0x6a,(byte)0xb4,
+ (byte)0x41,(byte)0x73,(byte)0xb4,
+ (byte)0x39,(byte)0x6a,(byte)0xac,
+ (byte)0x31,(byte)0x62,(byte)0xa4,
+ (byte)0x39,(byte)0x6a,(byte)0xac,
+ (byte)0x39,(byte)0x6a,(byte)0xac,
+ (byte)0x31,(byte)0x62,(byte)0xac,
+ (byte)0x31,(byte)0x6a,(byte)0xb4,
+ (byte)0x41,(byte)0x7b,(byte)0xbd,
+ (byte)0x52,(byte)0x8b,(byte)0xcd,
+ (byte)0x6a,(byte)0xa4,(byte)0xde,
+ (byte)0x9c,(byte)0xb4,(byte)0xe6,
+ (byte)0x6a,(byte)0x5a,(byte)0x73,
+ (byte)0x20,(byte)0x20,(byte)0x29,
+ (byte)0x20,(byte)0x18,(byte)0x20,
+ (byte)0x18,(byte)0x10,(byte)0x10,
+ (byte)0x18,(byte)0x10,(byte)0x10,
+ (byte)0x18,(byte)0x10,(byte)0x08,
+ (byte)0x20,(byte)0x18,(byte)0x10,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x20,(byte)0x10,(byte)0x18,
+ (byte)0x29,(byte)0x20,(byte)0x20,
+ (byte)0x39,(byte)0x31,(byte)0x29,
+ (byte)0x52,(byte)0x41,(byte)0x39,
+ (byte)0x39,(byte)0x39,(byte)0x5a,
+ (byte)0x39,(byte)0x41,(byte)0x73,
+ (byte)0x31,(byte)0x39,(byte)0x5a,
+ (byte)0x29,(byte)0x29,(byte)0x41,
+ (byte)0x94,(byte)0xa4,(byte)0xc5,
+ (byte)0xd5,(byte)0xde,(byte)0xff,
+ (byte)0xcd,(byte)0xd5,(byte)0xf6,
+ (byte)0xcd,(byte)0xd5,(byte)0xf6,
+ (byte)0xcd,(byte)0xd5,(byte)0xff,
+ (byte)0xd5,(byte)0xde,(byte)0xff,
+ (byte)0xcd,(byte)0xd5,(byte)0xff,
+ (byte)0xcd,(byte)0xd5,(byte)0xff,
+ (byte)0xc5,(byte)0xcd,(byte)0xf6,
+ (byte)0xbd,(byte)0xcd,(byte)0xf6,
+ (byte)0xbd,(byte)0xcd,(byte)0xf6,
+ (byte)0xb4,(byte)0xcd,(byte)0xf6,
+ (byte)0x9c,(byte)0xbd,(byte)0xee,
+ (byte)0x8b,(byte)0xb4,(byte)0xe6,
+ (byte)0x7b,(byte)0xac,(byte)0xde,
+ (byte)0x73,(byte)0x9c,(byte)0xd5,
+ (byte)0x62,(byte)0x94,(byte)0xcd,
+ (byte)0x52,(byte)0x83,(byte)0xc5,
+ (byte)0x4a,(byte)0x83,(byte)0xc5,
+ (byte)0x41,(byte)0x7b,(byte)0xbd,
+ (byte)0x41,(byte)0x7b,(byte)0xbd,
+ (byte)0x41,(byte)0x7b,(byte)0xbd,
+ (byte)0x39,(byte)0x73,(byte)0xb4,
+ (byte)0x39,(byte)0x73,(byte)0xb4,
+ (byte)0x39,(byte)0x73,(byte)0xb4,
+ (byte)0x39,(byte)0x6a,(byte)0xb4,
+ (byte)0x31,(byte)0x6a,(byte)0xac,
+ (byte)0x31,(byte)0x62,(byte)0xac,
+ (byte)0x31,(byte)0x62,(byte)0xac,
+ (byte)0x31,(byte)0x6a,(byte)0xb4,
+ (byte)0x41,(byte)0x7b,(byte)0xbd,
+ (byte)0x5a,(byte)0x94,(byte)0xcd,
+ (byte)0x7b,(byte)0xac,(byte)0xde,
+ (byte)0x94,(byte)0xac,(byte)0xde,
+ (byte)0xa4,(byte)0xb4,(byte)0xde,
+ (byte)0x73,(byte)0x73,(byte)0x8b,
+ (byte)0x10,(byte)0x08,(byte)0x10,
+ (byte)0x18,(byte)0x10,(byte)0x10,
+ (byte)0x08,(byte)0x08,(byte)0x00,
+ (byte)0x10,(byte)0x08,(byte)0x00,
+ (byte)0x10,(byte)0x08,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x08,
+ (byte)0x20,(byte)0x10,(byte)0x10,
+ (byte)0x39,(byte)0x39,(byte)0x29,
+ (byte)0x4a,(byte)0x4a,(byte)0x39,
+ (byte)0x18,(byte)0x18,(byte)0x20,
+ (byte)0x20,(byte)0x20,(byte)0x39,
+ (byte)0x41,(byte)0x4a,(byte)0x73,
+ (byte)0x31,(byte)0x31,(byte)0x5a,
+ (byte)0x31,(byte)0x39,(byte)0x52,
+ (byte)0xb4,(byte)0xbd,(byte)0xe6,
+ (byte)0xcd,(byte)0xd5,(byte)0xff,
+ (byte)0xcd,(byte)0xd5,(byte)0xf6,
+ (byte)0xcd,(byte)0xd5,(byte)0xf6,
+ (byte)0xcd,(byte)0xd5,(byte)0xf6,
+ (byte)0xcd,(byte)0xd5,(byte)0xff,
+ (byte)0xcd,(byte)0xd5,(byte)0xff,
+ (byte)0xcd,(byte)0xd5,(byte)0xff,
+ (byte)0xcd,(byte)0xd5,(byte)0xff,
+ (byte)0xcd,(byte)0xd5,(byte)0xf6,
+ (byte)0xc5,(byte)0xd5,(byte)0xf6,
+ (byte)0xbd,(byte)0xcd,(byte)0xf6,
+ (byte)0xac,(byte)0xb4,(byte)0xe6,
+ (byte)0x94,(byte)0x9c,(byte)0xcd,
+ (byte)0x83,(byte)0x9c,(byte)0xd5,
+ (byte)0x62,(byte)0x9c,(byte)0xd5,
+ (byte)0x5a,(byte)0x94,(byte)0xcd,
+ (byte)0x52,(byte)0x8b,(byte)0xcd,
+ (byte)0x52,(byte)0x8b,(byte)0xcd,
+ (byte)0x52,(byte)0x8b,(byte)0xc5,
+ (byte)0x4a,(byte)0x83,(byte)0xc5,
+ (byte)0x41,(byte)0x83,(byte)0xc5,
+ (byte)0x41,(byte)0x7b,(byte)0xbd,
+ (byte)0x41,(byte)0x7b,(byte)0xbd,
+ (byte)0x39,(byte)0x73,(byte)0xb4,
+ (byte)0x31,(byte)0x6a,(byte)0xb4,
+ (byte)0x31,(byte)0x6a,(byte)0xac,
+ (byte)0x31,(byte)0x62,(byte)0xac,
+ (byte)0x31,(byte)0x62,(byte)0xac,
+ (byte)0x29,(byte)0x62,(byte)0xac,
+ (byte)0x39,(byte)0x73,(byte)0xb4,
+ (byte)0x4a,(byte)0x83,(byte)0xc5,
+ (byte)0x6a,(byte)0x9c,(byte)0xd5,
+ (byte)0x83,(byte)0xb4,(byte)0xe6,
+ (byte)0x9c,(byte)0xc5,(byte)0xee,
+ (byte)0xbd,(byte)0xc5,(byte)0xf6,
+ (byte)0x73,(byte)0x62,(byte)0x83,
+ (byte)0x20,(byte)0x10,(byte)0x18,
+ (byte)0x18,(byte)0x08,(byte)0x08,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x10,(byte)0x08,(byte)0x00,
+ (byte)0x08,(byte)0x08,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x18,(byte)0x08,(byte)0x08,
+ (byte)0x18,(byte)0x18,(byte)0x10,
+ (byte)0x4a,(byte)0x4a,(byte)0x41,
+ (byte)0x31,(byte)0x31,(byte)0x4a,
+ (byte)0x18,(byte)0x20,(byte)0x31,
+ (byte)0x18,(byte)0x18,(byte)0x29,
+ (byte)0x39,(byte)0x41,(byte)0x6a,
+ (byte)0x29,(byte)0x31,(byte)0x52,
+ (byte)0x4a,(byte)0x52,(byte)0x6a,
+ (byte)0xc5,(byte)0xcd,(byte)0xf6,
+ (byte)0xcd,(byte)0xd5,(byte)0xf6,
+ (byte)0xc5,(byte)0xd5,(byte)0xf6,
+ (byte)0xcd,(byte)0xd5,(byte)0xf6,
+ (byte)0xcd,(byte)0xd5,(byte)0xf6,
+ (byte)0xcd,(byte)0xd5,(byte)0xf6,
+ (byte)0xd5,(byte)0xd5,(byte)0xff,
+ (byte)0xd5,(byte)0xd5,(byte)0xff,
+ (byte)0xc5,(byte)0xcd,(byte)0xee,
+ (byte)0xcd,(byte)0xd5,(byte)0xff,
+ (byte)0xc5,(byte)0xac,(byte)0xde,
+ (byte)0x94,(byte)0x62,(byte)0x94,
+ (byte)0x6a,(byte)0x41,(byte)0x6a,
+ (byte)0x5a,(byte)0x39,(byte)0x5a,
+ (byte)0x83,(byte)0x94,(byte)0xcd,
+ (byte)0x7b,(byte)0xac,(byte)0xe6,
+ (byte)0x7b,(byte)0xac,(byte)0xde,
+ (byte)0x73,(byte)0xa4,(byte)0xde,
+ (byte)0x6a,(byte)0xa4,(byte)0xd5,
+ (byte)0x62,(byte)0x9c,(byte)0xd5,
+ (byte)0x52,(byte)0x94,(byte)0xcd,
+ (byte)0x52,(byte)0x8b,(byte)0xcd,
+ (byte)0x4a,(byte)0x8b,(byte)0xc5,
+ (byte)0x4a,(byte)0x83,(byte)0xc5,
+ (byte)0x41,(byte)0x83,(byte)0xbd,
+ (byte)0x41,(byte)0x7b,(byte)0xbd,
+ (byte)0x39,(byte)0x7b,(byte)0xbd,
+ (byte)0x39,(byte)0x73,(byte)0xb4,
+ (byte)0x31,(byte)0x6a,(byte)0xb4,
+ (byte)0x31,(byte)0x6a,(byte)0xac,
+ (byte)0x31,(byte)0x6a,(byte)0xb4,
+ (byte)0x41,(byte)0x83,(byte)0xbd,
+ (byte)0x5a,(byte)0x94,(byte)0xcd,
+ (byte)0x83,(byte)0xac,(byte)0xe6,
+ (byte)0x94,(byte)0xb4,(byte)0xe6,
+ (byte)0xb4,(byte)0xcd,(byte)0xf6,
+ (byte)0xbd,(byte)0xb4,(byte)0xe6,
+ (byte)0x52,(byte)0x41,(byte)0x4a,
+ (byte)0x29,(byte)0x10,(byte)0x10,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x10,(byte)0x10,(byte)0x08,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x18,(byte)0x08,(byte)0x08,
+ (byte)0x29,(byte)0x20,(byte)0x10,
+ (byte)0x4a,(byte)0x41,(byte)0x39,
+ (byte)0x31,(byte)0x31,(byte)0x4a,
+ (byte)0x20,(byte)0x29,(byte)0x4a,
+ (byte)0x20,(byte)0x29,(byte)0x41,
+ (byte)0x18,(byte)0x20,(byte)0x31,
+ (byte)0x29,(byte)0x31,(byte)0x52,
+ (byte)0x29,(byte)0x39,(byte)0x5a,
+ (byte)0x62,(byte)0x6a,(byte)0x83,
+ (byte)0xd5,(byte)0xde,(byte)0xff,
+ (byte)0xd5,(byte)0xde,(byte)0xff,
+ (byte)0xcd,(byte)0xd5,(byte)0xff,
+ (byte)0xd5,(byte)0xd5,(byte)0xff,
+ (byte)0xcd,(byte)0xd5,(byte)0xff,
+ (byte)0xcd,(byte)0xd5,(byte)0xff,
+ (byte)0xcd,(byte)0xd5,(byte)0xf6,
+ (byte)0xa4,(byte)0xa4,(byte)0xc5,
+ (byte)0xac,(byte)0xb4,(byte)0xd5,
+ (byte)0xcd,(byte)0xde,(byte)0xff,
+ (byte)0xbd,(byte)0xcd,(byte)0xf6,
+ (byte)0x7b,(byte)0x8b,(byte)0xa4,
+ (byte)0x29,(byte)0x29,(byte)0x29,
+ (byte)0x4a,(byte)0x4a,(byte)0x62,
+ (byte)0x94,(byte)0x83,(byte)0xb4,
+ (byte)0x8b,(byte)0x62,(byte)0x94,
+ (byte)0x9c,(byte)0x9c,(byte)0xcd,
+ (byte)0x94,(byte)0xa4,(byte)0xde,
+ (byte)0x83,(byte)0xa4,(byte)0xde,
+ (byte)0x73,(byte)0xac,(byte)0xde,
+ (byte)0x62,(byte)0x9c,(byte)0xd5,
+ (byte)0x62,(byte)0x9c,(byte)0xd5,
+ (byte)0x5a,(byte)0x94,(byte)0xd5,
+ (byte)0x5a,(byte)0x94,(byte)0xcd,
+ (byte)0x52,(byte)0x94,(byte)0xcd,
+ (byte)0x52,(byte)0x8b,(byte)0xcd,
+ (byte)0x4a,(byte)0x8b,(byte)0xc5,
+ (byte)0x4a,(byte)0x83,(byte)0xc5,
+ (byte)0x41,(byte)0x7b,(byte)0xbd,
+ (byte)0x41,(byte)0x7b,(byte)0xbd,
+ (byte)0x39,(byte)0x73,(byte)0xbd,
+ (byte)0x41,(byte)0x7b,(byte)0xbd,
+ (byte)0x52,(byte)0x8b,(byte)0xcd,
+ (byte)0x83,(byte)0xac,(byte)0xde,
+ (byte)0x8b,(byte)0xb4,(byte)0xe6,
+ (byte)0xa4,(byte)0xc5,(byte)0xee,
+ (byte)0xc5,(byte)0xd5,(byte)0xff,
+ (byte)0xb4,(byte)0x94,(byte)0xbd,
+ (byte)0x5a,(byte)0x41,(byte)0x4a,
+ (byte)0x18,(byte)0x08,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x10,(byte)0x08,(byte)0x08,
+ (byte)0x18,(byte)0x10,(byte)0x10,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x08,
+ (byte)0x18,(byte)0x10,(byte)0x08,
+ (byte)0x4a,(byte)0x4a,(byte)0x31,
+ (byte)0x62,(byte)0x4a,(byte)0x4a,
+ (byte)0x29,(byte)0x29,(byte)0x41,
+ (byte)0x29,(byte)0x29,(byte)0x41,
+ (byte)0x31,(byte)0x29,(byte)0x4a,
+ (byte)0x20,(byte)0x20,(byte)0x41,
+ (byte)0x18,(byte)0x20,(byte)0x31,
+ (byte)0x20,(byte)0x29,(byte)0x4a,
+ (byte)0x6a,(byte)0x6a,(byte)0x8b,
+ (byte)0xac,(byte)0xb4,(byte)0xd5,
+ (byte)0xa4,(byte)0xa4,(byte)0xc5,
+ (byte)0x9c,(byte)0xa4,(byte)0xcd,
+ (byte)0xa4,(byte)0xac,(byte)0xcd,
+ (byte)0xbd,(byte)0xc5,(byte)0xe6,
+ (byte)0xc5,(byte)0xcd,(byte)0xf6,
+ (byte)0xcd,(byte)0xd5,(byte)0xff,
+ (byte)0xa4,(byte)0xa4,(byte)0xc5,
+ (byte)0xc5,(byte)0xc5,(byte)0xee,
+ (byte)0xc5,(byte)0xb4,(byte)0xe6,
+ (byte)0xbd,(byte)0x9c,(byte)0xc5,
+ (byte)0x8b,(byte)0x7b,(byte)0x9c,
+ (byte)0x31,(byte)0x39,(byte)0x31,
+ (byte)0x5a,(byte)0x29,(byte)0x41,
+ (byte)0x8b,(byte)0x31,(byte)0x4a,
+ (byte)0x83,(byte)0x29,(byte)0x4a,
+ (byte)0x94,(byte)0x39,(byte)0x6a,
+ (byte)0x94,(byte)0x39,(byte)0x4a,
+ (byte)0x94,(byte)0x4a,(byte)0x6a,
+ (byte)0x8b,(byte)0x7b,(byte)0xac,
+ (byte)0x7b,(byte)0xac,(byte)0xde,
+ (byte)0x7b,(byte)0xa4,(byte)0xde,
+ (byte)0x7b,(byte)0xa4,(byte)0xde,
+ (byte)0x73,(byte)0x9c,(byte)0xde,
+ (byte)0x73,(byte)0x94,(byte)0xd5,
+ (byte)0x6a,(byte)0x9c,(byte)0xd5,
+ (byte)0x62,(byte)0x9c,(byte)0xd5,
+ (byte)0x62,(byte)0x94,(byte)0xd5,
+ (byte)0x5a,(byte)0x94,(byte)0xcd,
+ (byte)0x52,(byte)0x94,(byte)0xcd,
+ (byte)0x52,(byte)0x8b,(byte)0xcd,
+ (byte)0x4a,(byte)0x83,(byte)0xc5,
+ (byte)0x4a,(byte)0x8b,(byte)0xc5,
+ (byte)0x7b,(byte)0xac,(byte)0xde,
+ (byte)0x94,(byte)0xb4,(byte)0xe6,
+ (byte)0xa4,(byte)0xc5,(byte)0xee,
+ (byte)0xbd,(byte)0xcd,(byte)0xf6,
+ (byte)0xcd,(byte)0xcd,(byte)0xf6,
+ (byte)0xbd,(byte)0xac,(byte)0xcd,
+ (byte)0x52,(byte)0x39,(byte)0x41,
+ (byte)0x10,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x20,(byte)0x18,(byte)0x18,
+ (byte)0x08,(byte)0x08,(byte)0x08,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x20,(byte)0x08,(byte)0x10,
+ (byte)0x31,(byte)0x29,(byte)0x18,
+ (byte)0x6a,(byte)0x62,(byte)0x4a,
+ (byte)0x31,(byte)0x29,(byte)0x39,
+ (byte)0x08,(byte)0x08,(byte)0x10,
+ (byte)0x18,(byte)0x08,(byte)0x18,
+ (byte)0x29,(byte)0x29,(byte)0x4a,
+ (byte)0x20,(byte)0x29,(byte)0x41,
+ (byte)0x10,(byte)0x10,(byte)0x18,
+ (byte)0x18,(byte)0x18,(byte)0x29,
+ (byte)0x41,(byte)0x41,(byte)0x5a,
+ (byte)0x31,(byte)0x39,(byte)0x5a,
+ (byte)0x31,(byte)0x39,(byte)0x52,
+ (byte)0x29,(byte)0x31,(byte)0x4a,
+ (byte)0x31,(byte)0x39,(byte)0x52,
+ (byte)0x39,(byte)0x39,(byte)0x5a,
+ (byte)0x4a,(byte)0x52,(byte)0x6a,
+ (byte)0x73,(byte)0x73,(byte)0x8b,
+ (byte)0xac,(byte)0x83,(byte)0xac,
+ (byte)0xbd,(byte)0x8b,(byte)0xbd,
+ (byte)0x7b,(byte)0x41,(byte)0x5a,
+ (byte)0x4a,(byte)0x20,(byte)0x29,
+ (byte)0x5a,(byte)0x4a,(byte)0x62,
+ (byte)0x29,(byte)0x29,(byte)0x20,
+ (byte)0x41,(byte)0x31,(byte)0x29,
+ (byte)0x6a,(byte)0x4a,(byte)0x4a,
+ (byte)0x94,(byte)0x5a,(byte)0x7b,
+ (byte)0x73,(byte)0x29,(byte)0x41,
+ (byte)0x4a,(byte)0x20,(byte)0x29,
+ (byte)0x62,(byte)0x41,(byte)0x5a,
+ (byte)0x94,(byte)0x73,(byte)0xa4,
+ (byte)0x9c,(byte)0xbd,(byte)0xee,
+ (byte)0xa4,(byte)0xa4,(byte)0xcd,
+ (byte)0x9c,(byte)0x52,(byte)0x83,
+ (byte)0x9c,(byte)0x52,(byte)0x8b,
+ (byte)0x9c,(byte)0x4a,(byte)0x8b,
+ (byte)0x73,(byte)0x5a,(byte)0x8b,
+ (byte)0x7b,(byte)0xa4,(byte)0xde,
+ (byte)0x7b,(byte)0xac,(byte)0xde,
+ (byte)0x7b,(byte)0xac,(byte)0xde,
+ (byte)0x7b,(byte)0xac,(byte)0xde,
+ (byte)0x7b,(byte)0xa4,(byte)0xde,
+ (byte)0x73,(byte)0xa4,(byte)0xde,
+ (byte)0x62,(byte)0x94,(byte)0xcd,
+ (byte)0x73,(byte)0xa4,(byte)0xde,
+ (byte)0xa4,(byte)0xbd,(byte)0xee,
+ (byte)0xa4,(byte)0xc5,(byte)0xee,
+ (byte)0xbd,(byte)0xcd,(byte)0xf6,
+ (byte)0xcd,(byte)0xd5,(byte)0xf6,
+ (byte)0xde,(byte)0xde,(byte)0xff,
+ (byte)0x8b,(byte)0x7b,(byte)0x8b,
+ (byte)0x20,(byte)0x18,(byte)0x10,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x18,(byte)0x10,(byte)0x10,
+ (byte)0x20,(byte)0x18,(byte)0x10,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x20,(byte)0x10,(byte)0x10,
+ (byte)0x31,(byte)0x10,(byte)0x10,
+ (byte)0x41,(byte)0x39,(byte)0x20,
+ (byte)0x41,(byte)0x41,(byte)0x29,
+ (byte)0x08,(byte)0x08,(byte)0x10,
+ (byte)0x08,(byte)0x00,(byte)0x08,
+ (byte)0x29,(byte)0x20,(byte)0x39,
+ (byte)0x29,(byte)0x31,(byte)0x52,
+ (byte)0x20,(byte)0x20,(byte)0x39,
+ (byte)0x18,(byte)0x18,(byte)0x18,
+ (byte)0x10,(byte)0x08,(byte)0x10,
+ (byte)0x18,(byte)0x10,(byte)0x20,
+ (byte)0x20,(byte)0x29,(byte)0x41,
+ (byte)0x31,(byte)0x39,(byte)0x62,
+ (byte)0x31,(byte)0x41,(byte)0x62,
+ (byte)0x31,(byte)0x39,(byte)0x62,
+ (byte)0x29,(byte)0x31,(byte)0x52,
+ (byte)0x29,(byte)0x29,(byte)0x41,
+ (byte)0x4a,(byte)0x39,(byte)0x5a,
+ (byte)0x73,(byte)0x41,(byte)0x52,
+ (byte)0x52,(byte)0x41,(byte)0x39,
+ (byte)0x41,(byte)0x39,(byte)0x20,
+ (byte)0x10,(byte)0x10,(byte)0x08,
+ (byte)0x39,(byte)0x41,(byte)0x4a,
+ (byte)0x62,(byte)0x5a,(byte)0x73,
+ (byte)0x39,(byte)0x31,(byte)0x31,
+ (byte)0x39,(byte)0x31,(byte)0x29,
+ (byte)0x31,(byte)0x18,(byte)0x18,
+ (byte)0x4a,(byte)0x41,(byte)0x41,
+ (byte)0x52,(byte)0x4a,(byte)0x5a,
+ (byte)0x41,(byte)0x41,(byte)0x4a,
+ (byte)0x7b,(byte)0x6a,(byte)0x83,
+ (byte)0x94,(byte)0x6a,(byte)0x9c,
+ (byte)0x8b,(byte)0x52,(byte)0x73,
+ (byte)0x73,(byte)0x4a,(byte)0x4a,
+ (byte)0x5a,(byte)0x29,(byte)0x31,
+ (byte)0x8b,(byte)0x41,(byte)0x6a,
+ (byte)0x7b,(byte)0x52,(byte)0x73,
+ (byte)0x9c,(byte)0x83,(byte)0xb4,
+ (byte)0x94,(byte)0xac,(byte)0xd5,
+ (byte)0x8b,(byte)0xb4,(byte)0xe6,
+ (byte)0x8b,(byte)0xb4,(byte)0xe6,
+ (byte)0x8b,(byte)0xb4,(byte)0xe6,
+ (byte)0x94,(byte)0xb4,(byte)0xe6,
+ (byte)0x9c,(byte)0xbd,(byte)0xe6,
+ (byte)0x94,(byte)0xb4,(byte)0xe6,
+ (byte)0xac,(byte)0xbd,(byte)0xee,
+ (byte)0xac,(byte)0xc5,(byte)0xee,
+ (byte)0xc5,(byte)0xcd,(byte)0xf6,
+ (byte)0xc5,(byte)0xcd,(byte)0xf6,
+ (byte)0xde,(byte)0xde,(byte)0xff,
+ (byte)0xb4,(byte)0xac,(byte)0xc5,
+ (byte)0x4a,(byte)0x41,(byte)0x41,
+ (byte)0x18,(byte)0x10,(byte)0x08,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x10,(byte)0x08,(byte)0x08,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x39,(byte)0x20,(byte)0x29,
+ (byte)0x4a,(byte)0x29,(byte)0x29,
+ (byte)0x4a,(byte)0x41,(byte)0x31,
+ (byte)0x10,(byte)0x08,(byte)0x08,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x29,(byte)0x10,(byte)0x29,
+ (byte)0x31,(byte)0x31,(byte)0x52,
+ (byte)0x20,(byte)0x29,(byte)0x41,
+ (byte)0x31,(byte)0x31,(byte)0x41,
+ (byte)0x41,(byte)0x39,(byte)0x41,
+ (byte)0x20,(byte)0x20,(byte)0x29,
+ (byte)0x08,(byte)0x10,(byte)0x18,
+ (byte)0x18,(byte)0x18,(byte)0x31,
+ (byte)0x18,(byte)0x20,(byte)0x31,
+ (byte)0x29,(byte)0x31,(byte)0x4a,
+ (byte)0x39,(byte)0x41,(byte)0x6a,
+ (byte)0x39,(byte)0x4a,(byte)0x6a,
+ (byte)0x39,(byte)0x41,(byte)0x6a,
+ (byte)0x52,(byte)0x52,(byte)0x5a,
+ (byte)0x39,(byte)0x41,(byte)0x20,
+ (byte)0x20,(byte)0x20,(byte)0x10,
+ (byte)0x20,(byte)0x20,(byte)0x10,
+ (byte)0x10,(byte)0x10,(byte)0x08,
+ (byte)0x18,(byte)0x18,(byte)0x18,
+ (byte)0x73,(byte)0x73,(byte)0x83,
+ (byte)0x4a,(byte)0x41,(byte)0x52,
+ (byte)0x20,(byte)0x20,(byte)0x29,
+ (byte)0x10,(byte)0x00,(byte)0x00,
+ (byte)0x62,(byte)0x41,(byte)0x52,
+ (byte)0x94,(byte)0x52,(byte)0x73,
+ (byte)0x62,(byte)0x39,(byte)0x4a,
+ (byte)0x94,(byte)0x62,(byte)0x8b,
+ (byte)0x83,(byte)0x41,(byte)0x6a,
+ (byte)0x39,(byte)0x10,(byte)0x10,
+ (byte)0x4a,(byte)0x39,(byte)0x31,
+ (byte)0x4a,(byte)0x41,(byte)0x39,
+ (byte)0x62,(byte)0x5a,(byte)0x62,
+ (byte)0x31,(byte)0x29,(byte)0x31,
+ (byte)0x4a,(byte)0x39,(byte)0x4a,
+ (byte)0x9c,(byte)0xac,(byte)0xd5,
+ (byte)0xa4,(byte)0xc5,(byte)0xee,
+ (byte)0x9c,(byte)0xbd,(byte)0xee,
+ (byte)0x9c,(byte)0xbd,(byte)0xee,
+ (byte)0x9c,(byte)0xbd,(byte)0xe6,
+ (byte)0x9c,(byte)0xbd,(byte)0xee,
+ (byte)0xac,(byte)0xc5,(byte)0xee,
+ (byte)0xb4,(byte)0xc5,(byte)0xee,
+ (byte)0xb4,(byte)0xc5,(byte)0xee,
+ (byte)0xc5,(byte)0xcd,(byte)0xf6,
+ (byte)0xc5,(byte)0xd5,(byte)0xf6,
+ (byte)0xde,(byte)0xd5,(byte)0xf6,
+ (byte)0xcd,(byte)0xc5,(byte)0xde,
+ (byte)0x8b,(byte)0x8b,(byte)0x9c,
+ (byte)0x41,(byte)0x41,(byte)0x39,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x08,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x10,(byte)0x08,(byte)0x10,
+ (byte)0x62,(byte)0x29,(byte)0x41,
+ (byte)0x73,(byte)0x4a,(byte)0x52,
+ (byte)0x20,(byte)0x18,(byte)0x10,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x18,(byte)0x10,(byte)0x18,
+ (byte)0x31,(byte)0x29,(byte)0x4a,
+ (byte)0x20,(byte)0x29,(byte)0x4a,
+ (byte)0x29,(byte)0x31,(byte)0x4a,
+ (byte)0x20,(byte)0x29,(byte)0x41,
+ (byte)0x20,(byte)0x29,(byte)0x31,
+ (byte)0x29,(byte)0x31,(byte)0x41,
+ (byte)0x18,(byte)0x20,(byte)0x39,
+ (byte)0x20,(byte)0x29,(byte)0x41,
+ (byte)0x29,(byte)0x29,(byte)0x4a,
+ (byte)0x20,(byte)0x29,(byte)0x41,
+ (byte)0x18,(byte)0x20,(byte)0x31,
+ (byte)0x29,(byte)0x29,(byte)0x41,
+ (byte)0x39,(byte)0x41,(byte)0x6a,
+ (byte)0x4a,(byte)0x52,(byte)0x5a,
+ (byte)0x29,(byte)0x31,(byte)0x20,
+ (byte)0x31,(byte)0x29,(byte)0x10,
+ (byte)0x29,(byte)0x20,(byte)0x10,
+ (byte)0x10,(byte)0x08,(byte)0x08,
+ (byte)0x29,(byte)0x18,(byte)0x20,
+ (byte)0x4a,(byte)0x4a,(byte)0x52,
+ (byte)0x18,(byte)0x10,(byte)0x10,
+ (byte)0x10,(byte)0x10,(byte)0x08,
+ (byte)0x41,(byte)0x20,(byte)0x31,
+ (byte)0x94,(byte)0x31,(byte)0x5a,
+ (byte)0x7b,(byte)0x08,(byte)0x20,
+ (byte)0x6a,(byte)0x29,(byte)0x39,
+ (byte)0x62,(byte)0x29,(byte)0x41,
+ (byte)0x31,(byte)0x18,(byte)0x20,
+ (byte)0x18,(byte)0x18,(byte)0x18,
+ (byte)0x20,(byte)0x20,(byte)0x18,
+ (byte)0x39,(byte)0x31,(byte)0x29,
+ (byte)0x41,(byte)0x31,(byte)0x31,
+ (byte)0x18,(byte)0x18,(byte)0x20,
+ (byte)0x41,(byte)0x41,(byte)0x4a,
+ (byte)0xbd,(byte)0xc5,(byte)0xee,
+ (byte)0xbd,(byte)0xcd,(byte)0xf6,
+ (byte)0xb4,(byte)0xcd,(byte)0xf6,
+ (byte)0xbd,(byte)0xcd,(byte)0xf6,
+ (byte)0xbd,(byte)0xcd,(byte)0xf6,
+ (byte)0xbd,(byte)0xcd,(byte)0xf6,
+ (byte)0xb4,(byte)0xcd,(byte)0xee,
+ (byte)0xbd,(byte)0xcd,(byte)0xee,
+ (byte)0xbd,(byte)0xcd,(byte)0xee,
+ (byte)0xcd,(byte)0xd5,(byte)0xf6,
+ (byte)0xcd,(byte)0xd5,(byte)0xf6,
+ (byte)0xde,(byte)0xd5,(byte)0xf6,
+ (byte)0xd5,(byte)0xcd,(byte)0xee,
+ (byte)0x9c,(byte)0x9c,(byte)0xac,
+ (byte)0x5a,(byte)0x5a,(byte)0x5a,
+ (byte)0x10,(byte)0x10,(byte)0x08,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x4a,(byte)0x20,(byte)0x39,
+ (byte)0x9c,(byte)0x4a,(byte)0x73,
+ (byte)0x4a,(byte)0x39,(byte)0x29,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x08,(byte)0x10,
+ (byte)0x29,(byte)0x20,(byte)0x39,
+ (byte)0x29,(byte)0x29,(byte)0x4a,
+ (byte)0x29,(byte)0x29,(byte)0x41,
+ (byte)0x29,(byte)0x31,(byte)0x4a,
+ (byte)0x08,(byte)0x18,(byte)0x29,
+ (byte)0x18,(byte)0x20,(byte)0x39,
+ (byte)0x29,(byte)0x31,(byte)0x41,
+ (byte)0x29,(byte)0x29,(byte)0x4a,
+ (byte)0x31,(byte)0x31,(byte)0x5a,
+ (byte)0x31,(byte)0x20,(byte)0x39,
+ (byte)0x31,(byte)0x29,(byte)0x4a,
+ (byte)0x20,(byte)0x29,(byte)0x41,
+ (byte)0x18,(byte)0x18,(byte)0x31,
+ (byte)0x18,(byte)0x18,(byte)0x29,
+ (byte)0x52,(byte)0x4a,(byte)0x62,
+ (byte)0x52,(byte)0x4a,(byte)0x39,
+ (byte)0x31,(byte)0x29,(byte)0x29,
+ (byte)0x29,(byte)0x18,(byte)0x18,
+ (byte)0x20,(byte)0x10,(byte)0x18,
+ (byte)0x10,(byte)0x10,(byte)0x18,
+ (byte)0x18,(byte)0x18,(byte)0x29,
+ (byte)0x10,(byte)0x10,(byte)0x18,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x20,(byte)0x18,(byte)0x10,
+ (byte)0x73,(byte)0x41,(byte)0x4a,
+ (byte)0x83,(byte)0x4a,(byte)0x4a,
+ (byte)0x39,(byte)0x29,(byte)0x18,
+ (byte)0x10,(byte)0x08,(byte)0x00,
+ (byte)0x20,(byte)0x18,(byte)0x18,
+ (byte)0x31,(byte)0x31,(byte)0x29,
+ (byte)0x62,(byte)0x62,(byte)0x5a,
+ (byte)0x41,(byte)0x41,(byte)0x39,
+ (byte)0x29,(byte)0x20,(byte)0x20,
+ (byte)0x10,(byte)0x10,(byte)0x10,
+ (byte)0x31,(byte)0x29,(byte)0x31,
+ (byte)0x8b,(byte)0x62,(byte)0x8b,
+ (byte)0xbd,(byte)0xac,(byte)0xde,
+ (byte)0xcd,(byte)0xd5,(byte)0xf6,
+ (byte)0xc5,(byte)0xcd,(byte)0xf6,
+ (byte)0xbd,(byte)0xcd,(byte)0xf6,
+ (byte)0xc5,(byte)0xcd,(byte)0xf6,
+ (byte)0xc5,(byte)0xd5,(byte)0xf6,
+ (byte)0xcd,(byte)0xd5,(byte)0xf6,
+ (byte)0xcd,(byte)0xcd,(byte)0xf6,
+ (byte)0xcd,(byte)0xd5,(byte)0xf6,
+ (byte)0xcd,(byte)0xd5,(byte)0xf6,
+ (byte)0xde,(byte)0xd5,(byte)0xf6,
+ (byte)0xd5,(byte)0xd5,(byte)0xf6,
+ (byte)0xac,(byte)0xac,(byte)0xbd,
+ (byte)0x73,(byte)0x73,(byte)0x62,
+ (byte)0x20,(byte)0x20,(byte)0x18,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x6a,(byte)0x29,(byte)0x52,
+ (byte)0xac,(byte)0x62,(byte)0x8b,
+ (byte)0x29,(byte)0x20,(byte)0x10,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x18,(byte)0x10,(byte)0x20,
+ (byte)0x29,(byte)0x29,(byte)0x41,
+ (byte)0x31,(byte)0x39,(byte)0x52,
+ (byte)0x18,(byte)0x20,(byte)0x31,
+ (byte)0x08,(byte)0x18,(byte)0x31,
+ (byte)0x29,(byte)0x31,(byte)0x4a,
+ (byte)0x29,(byte)0x29,(byte)0x41,
+ (byte)0x29,(byte)0x31,(byte)0x52,
+ (byte)0x39,(byte)0x29,(byte)0x4a,
+ (byte)0x18,(byte)0x08,(byte)0x10,
+ (byte)0x10,(byte)0x10,(byte)0x18,
+ (byte)0x20,(byte)0x29,(byte)0x41,
+ (byte)0x29,(byte)0x29,(byte)0x4a,
+ (byte)0x29,(byte)0x29,(byte)0x39,
+ (byte)0x62,(byte)0x52,(byte)0x41,
+ (byte)0x52,(byte)0x4a,(byte)0x41,
+ (byte)0x31,(byte)0x29,(byte)0x39,
+ (byte)0x4a,(byte)0x39,(byte)0x41,
+ (byte)0x31,(byte)0x20,(byte)0x20,
+ (byte)0x31,(byte)0x31,(byte)0x39,
+ (byte)0x18,(byte)0x18,(byte)0x29,
+ (byte)0x10,(byte)0x08,(byte)0x08,
+ (byte)0x10,(byte)0x08,(byte)0x08,
+ (byte)0x20,(byte)0x18,(byte)0x20,
+ (byte)0x73,(byte)0x6a,(byte)0x6a,
+ (byte)0x83,(byte)0x7b,(byte)0x73,
+ (byte)0x6a,(byte)0x5a,(byte)0x4a,
+ (byte)0x52,(byte)0x4a,(byte)0x39,
+ (byte)0x31,(byte)0x29,(byte)0x20,
+ (byte)0x18,(byte)0x18,(byte)0x10,
+ (byte)0x41,(byte)0x41,(byte)0x39,
+ (byte)0x18,(byte)0x18,(byte)0x10,
+ (byte)0x20,(byte)0x18,(byte)0x18,
+ (byte)0x18,(byte)0x08,(byte)0x10,
+ (byte)0x10,(byte)0x08,(byte)0x10,
+ (byte)0x52,(byte)0x41,(byte)0x41,
+ (byte)0xb4,(byte)0x8b,(byte)0xb4,
+ (byte)0xd5,(byte)0xd5,(byte)0xf6,
+ (byte)0xd5,(byte)0xd5,(byte)0xf6,
+ (byte)0xd5,(byte)0xd5,(byte)0xf6,
+ (byte)0xcd,(byte)0xd5,(byte)0xf6,
+ (byte)0xc5,(byte)0xcd,(byte)0xf6,
+ (byte)0xc5,(byte)0xd5,(byte)0xf6,
+ (byte)0xcd,(byte)0xd5,(byte)0xf6,
+ (byte)0xcd,(byte)0xd5,(byte)0xf6,
+ (byte)0xd5,(byte)0xd5,(byte)0xf6,
+ (byte)0xde,(byte)0xd5,(byte)0xee,
+ (byte)0xd5,(byte)0xd5,(byte)0xf6,
+ (byte)0xac,(byte)0xac,(byte)0xbd,
+ (byte)0xa4,(byte)0x9c,(byte)0x94,
+ (byte)0x39,(byte)0x29,(byte)0x20,
+ (byte)0x10,(byte)0x10,(byte)0x08,
+ (byte)0x08,(byte)0x08,(byte)0x00,
+ (byte)0x10,(byte)0x08,(byte)0x08,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x08,
+ (byte)0x8b,(byte)0x39,(byte)0x6a,
+ (byte)0x9c,(byte)0x5a,(byte)0x8b,
+ (byte)0x10,(byte)0x08,(byte)0x08,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x08,
+ (byte)0x20,(byte)0x10,(byte)0x18,
+ (byte)0x31,(byte)0x31,(byte)0x4a,
+ (byte)0x31,(byte)0x31,(byte)0x41,
+ (byte)0x18,(byte)0x20,(byte)0x31,
+ (byte)0x18,(byte)0x18,(byte)0x31,
+ (byte)0x31,(byte)0x31,(byte)0x4a,
+ (byte)0x20,(byte)0x29,(byte)0x41,
+ (byte)0x29,(byte)0x31,(byte)0x52,
+ (byte)0x31,(byte)0x20,(byte)0x39,
+ (byte)0x10,(byte)0x00,(byte)0x08,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x18,(byte)0x20,(byte)0x29,
+ (byte)0x39,(byte)0x31,(byte)0x5a,
+ (byte)0x41,(byte)0x39,(byte)0x4a,
+ (byte)0x5a,(byte)0x5a,(byte)0x41,
+ (byte)0x41,(byte)0x39,(byte)0x31,
+ (byte)0x18,(byte)0x18,(byte)0x10,
+ (byte)0x31,(byte)0x20,(byte)0x20,
+ (byte)0x41,(byte)0x29,(byte)0x20,
+ (byte)0x39,(byte)0x29,(byte)0x31,
+ (byte)0x29,(byte)0x20,(byte)0x29,
+ (byte)0x10,(byte)0x08,(byte)0x00,
+ (byte)0x10,(byte)0x08,(byte)0x10,
+ (byte)0x18,(byte)0x10,(byte)0x10,
+ (byte)0x52,(byte)0x41,(byte)0x39,
+ (byte)0x73,(byte)0x6a,(byte)0x62,
+ (byte)0x7b,(byte)0x73,(byte)0x62,
+ (byte)0x4a,(byte)0x41,(byte)0x31,
+ (byte)0x08,(byte)0x08,(byte)0x00,
+ (byte)0x10,(byte)0x08,(byte)0x00,
+ (byte)0x18,(byte)0x10,(byte)0x08,
+ (byte)0x20,(byte)0x18,(byte)0x10,
+ (byte)0x20,(byte)0x18,(byte)0x18,
+ (byte)0x29,(byte)0x10,(byte)0x18,
+ (byte)0x31,(byte)0x08,(byte)0x10,
+ (byte)0x4a,(byte)0x39,(byte)0x39,
+ (byte)0xa4,(byte)0x94,(byte)0xa4,
+ (byte)0xc5,(byte)0xc5,(byte)0xe6,
+ (byte)0xde,(byte)0xd5,(byte)0xf6,
+ (byte)0xde,(byte)0xd5,(byte)0xf6,
+ (byte)0xde,(byte)0xd5,(byte)0xf6,
+ (byte)0xd5,(byte)0xd5,(byte)0xf6,
+ (byte)0xd5,(byte)0xd5,(byte)0xf6,
+ (byte)0xcd,(byte)0xd5,(byte)0xf6,
+ (byte)0xcd,(byte)0xd5,(byte)0xf6,
+ (byte)0xd5,(byte)0xd5,(byte)0xee,
+ (byte)0xde,(byte)0xd5,(byte)0xf6,
+ (byte)0xde,(byte)0xd5,(byte)0xf6,
+ (byte)0xac,(byte)0xac,(byte)0xbd,
+ (byte)0xb4,(byte)0xac,(byte)0xb4,
+ (byte)0x6a,(byte)0x52,(byte)0x4a,
+ (byte)0x08,(byte)0x08,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x10,(byte)0x08,(byte)0x08,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x20,(byte)0x08,(byte)0x18,
+ (byte)0x9c,(byte)0x39,(byte)0x73,
+ (byte)0x6a,(byte)0x39,(byte)0x5a,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x08,(byte)0x08,
+ (byte)0x08,(byte)0x08,(byte)0x10,
+ (byte)0x18,(byte)0x08,(byte)0x18,
+ (byte)0x31,(byte)0x29,(byte)0x39,
+ (byte)0x29,(byte)0x29,(byte)0x29,
+ (byte)0x18,(byte)0x18,(byte)0x29,
+ (byte)0x29,(byte)0x29,(byte)0x31,
+ (byte)0x31,(byte)0x39,(byte)0x4a,
+ (byte)0x29,(byte)0x29,(byte)0x41,
+ (byte)0x31,(byte)0x29,(byte)0x41,
+ (byte)0x20,(byte)0x20,(byte)0x31,
+ (byte)0x10,(byte)0x08,(byte)0x18,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x08,(byte)0x18,
+ (byte)0x39,(byte)0x29,(byte)0x31,
+ (byte)0x62,(byte)0x52,(byte)0x39,
+ (byte)0x62,(byte)0x62,(byte)0x4a,
+ (byte)0x20,(byte)0x20,(byte)0x20,
+ (byte)0x10,(byte)0x10,(byte)0x10,
+ (byte)0x31,(byte)0x18,(byte)0x10,
+ (byte)0x31,(byte)0x18,(byte)0x10,
+ (byte)0x31,(byte)0x29,(byte)0x29,
+ (byte)0x39,(byte)0x39,(byte)0x52,
+ (byte)0x20,(byte)0x18,(byte)0x18,
+ (byte)0x10,(byte)0x10,(byte)0x10,
+ (byte)0x29,(byte)0x20,(byte)0x20,
+ (byte)0x83,(byte)0x7b,(byte)0x73,
+ (byte)0x8b,(byte)0x83,(byte)0x7b,
+ (byte)0x41,(byte)0x39,(byte)0x31,
+ (byte)0x41,(byte)0x41,(byte)0x31,
+ (byte)0x10,(byte)0x10,(byte)0x08,
+ (byte)0x20,(byte)0x10,(byte)0x10,
+ (byte)0x29,(byte)0x20,(byte)0x18,
+ (byte)0x10,(byte)0x10,(byte)0x08,
+ (byte)0x08,(byte)0x08,(byte)0x08,
+ (byte)0x08,(byte)0x08,(byte)0x08,
+ (byte)0x31,(byte)0x10,(byte)0x10,
+ (byte)0x39,(byte)0x20,(byte)0x20,
+ (byte)0x62,(byte)0x52,(byte)0x62,
+ (byte)0x94,(byte)0x94,(byte)0xac,
+ (byte)0xb4,(byte)0xb4,(byte)0xcd,
+ (byte)0xd5,(byte)0xcd,(byte)0xee,
+ (byte)0xde,(byte)0xde,(byte)0xf6,
+ (byte)0xde,(byte)0xd5,(byte)0xf6,
+ (byte)0xde,(byte)0xd5,(byte)0xee,
+ (byte)0xde,(byte)0xd5,(byte)0xee,
+ (byte)0xd5,(byte)0xcd,(byte)0xee,
+ (byte)0xde,(byte)0xd5,(byte)0xee,
+ (byte)0xde,(byte)0xde,(byte)0xf6,
+ (byte)0xd5,(byte)0xd5,(byte)0xee,
+ (byte)0xb4,(byte)0xac,(byte)0xbd,
+ (byte)0xbd,(byte)0xb4,(byte)0xc5,
+ (byte)0xac,(byte)0x9c,(byte)0xac,
+ (byte)0x29,(byte)0x20,(byte)0x18,
+ (byte)0x08,(byte)0x08,(byte)0x08,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x31,(byte)0x08,(byte)0x18,
+ (byte)0x94,(byte)0x29,(byte)0x5a,
+ (byte)0x4a,(byte)0x29,(byte)0x41,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x10,(byte)0x10,(byte)0x29,
+ (byte)0x08,(byte)0x10,(byte)0x18,
+ (byte)0x18,(byte)0x08,(byte)0x18,
+ (byte)0x39,(byte)0x20,(byte)0x29,
+ (byte)0x31,(byte)0x31,(byte)0x29,
+ (byte)0x20,(byte)0x18,(byte)0x18,
+ (byte)0x31,(byte)0x29,(byte)0x29,
+ (byte)0x31,(byte)0x29,(byte)0x4a,
+ (byte)0x31,(byte)0x18,(byte)0x31,
+ (byte)0x18,(byte)0x08,(byte)0x18,
+ (byte)0x00,(byte)0x00,(byte)0x08,
+ (byte)0x10,(byte)0x10,(byte)0x18,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x41,(byte)0x41,(byte)0x31,
+ (byte)0x62,(byte)0x5a,(byte)0x39,
+ (byte)0x52,(byte)0x52,(byte)0x39,
+ (byte)0x29,(byte)0x29,(byte)0x18,
+ (byte)0x10,(byte)0x10,(byte)0x08,
+ (byte)0x39,(byte)0x20,(byte)0x20,
+ (byte)0x52,(byte)0x39,(byte)0x39,
+ (byte)0x18,(byte)0x10,(byte)0x10,
+ (byte)0x10,(byte)0x10,(byte)0x18,
+ (byte)0x29,(byte)0x18,(byte)0x20,
+ (byte)0x31,(byte)0x18,(byte)0x18,
+ (byte)0x4a,(byte)0x29,(byte)0x20,
+ (byte)0x7b,(byte)0x62,(byte)0x5a,
+ (byte)0x73,(byte)0x6a,(byte)0x52,
+ (byte)0x4a,(byte)0x4a,(byte)0x39,
+ (byte)0x4a,(byte)0x41,(byte)0x39,
+ (byte)0x29,(byte)0x20,(byte)0x18,
+ (byte)0x39,(byte)0x29,(byte)0x20,
+ (byte)0x10,(byte)0x08,(byte)0x08,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x20,(byte)0x20,(byte)0x18,
+ (byte)0x41,(byte)0x41,(byte)0x31,
+ (byte)0x62,(byte)0x6a,(byte)0x6a,
+ (byte)0x94,(byte)0x94,(byte)0x9c,
+ (byte)0xa4,(byte)0xa4,(byte)0xa4,
+ (byte)0xac,(byte)0xa4,(byte)0xb4,
+ (byte)0xcd,(byte)0xc5,(byte)0xde,
+ (byte)0xde,(byte)0xd5,(byte)0xf6,
+ (byte)0xde,(byte)0xde,(byte)0xf6,
+ (byte)0xde,(byte)0xde,(byte)0xf6,
+ (byte)0xde,(byte)0xd5,(byte)0xf6,
+ (byte)0xde,(byte)0xd5,(byte)0xf6,
+ (byte)0xde,(byte)0xde,(byte)0xf6,
+ (byte)0xd5,(byte)0xcd,(byte)0xee,
+ (byte)0xb4,(byte)0xac,(byte)0xbd,
+ (byte)0xb4,(byte)0xa4,(byte)0xb4,
+ (byte)0xcd,(byte)0xbd,(byte)0xde,
+ (byte)0x52,(byte)0x31,(byte)0x39,
+ (byte)0x20,(byte)0x20,(byte)0x20,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x39,(byte)0x08,(byte)0x18,
+ (byte)0x8b,(byte)0x20,(byte)0x41,
+ (byte)0x39,(byte)0x18,(byte)0x29,
+ (byte)0x00,(byte)0x00,(byte)0x08,
+ (byte)0x08,(byte)0x08,(byte)0x18,
+ (byte)0x00,(byte)0x08,(byte)0x08,
+ (byte)0x20,(byte)0x08,(byte)0x10,
+ (byte)0x41,(byte)0x20,(byte)0x29,
+ (byte)0x52,(byte)0x4a,(byte)0x4a,
+ (byte)0x41,(byte)0x39,(byte)0x39,
+ (byte)0x41,(byte)0x31,(byte)0x31,
+ (byte)0x31,(byte)0x18,(byte)0x29,
+ (byte)0x18,(byte)0x08,(byte)0x18,
+ (byte)0x08,(byte)0x08,(byte)0x10,
+ (byte)0x08,(byte)0x08,(byte)0x10,
+ (byte)0x00,(byte)0x00,(byte)0x08,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x31,(byte)0x29,(byte)0x18,
+ (byte)0x5a,(byte)0x52,(byte)0x31,
+ (byte)0x4a,(byte)0x39,(byte)0x31,
+ (byte)0x20,(byte)0x10,(byte)0x08,
+ (byte)0x20,(byte)0x18,(byte)0x08,
+ (byte)0x29,(byte)0x18,(byte)0x10,
+ (byte)0x10,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x18,(byte)0x08,(byte)0x08,
+ (byte)0x29,(byte)0x10,(byte)0x08,
+ (byte)0x39,(byte)0x18,(byte)0x10,
+ (byte)0x31,(byte)0x20,(byte)0x20,
+ (byte)0x41,(byte)0x41,(byte)0x31,
+ (byte)0x10,(byte)0x10,(byte)0x10,
+ (byte)0x18,(byte)0x18,(byte)0x10,
+ (byte)0x10,(byte)0x08,(byte)0x08,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x10,(byte)0x10,(byte)0x10,
+ (byte)0x31,(byte)0x31,(byte)0x29,
+ (byte)0x31,(byte)0x29,(byte)0x20,
+ (byte)0x9c,(byte)0x8b,(byte)0x7b,
+ (byte)0xb4,(byte)0xac,(byte)0xac,
+ (byte)0xa4,(byte)0x9c,(byte)0xac,
+ (byte)0xac,(byte)0xac,(byte)0xbd,
+ (byte)0xc5,(byte)0xc5,(byte)0xd5,
+ (byte)0xd5,(byte)0xd5,(byte)0xee,
+ (byte)0xde,(byte)0xde,(byte)0xf6,
+ (byte)0xde,(byte)0xd5,(byte)0xf6,
+ (byte)0xde,(byte)0xd5,(byte)0xf6,
+ (byte)0xde,(byte)0xd5,(byte)0xee,
+ (byte)0xd5,(byte)0xcd,(byte)0xde,
+ (byte)0xbd,(byte)0xac,(byte)0xc5,
+ (byte)0xa4,(byte)0x7b,(byte)0x8b,
+ (byte)0xcd,(byte)0xbd,(byte)0xd5,
+ (byte)0x5a,(byte)0x29,(byte)0x31,
+ (byte)0x08,(byte)0x08,(byte)0x08,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x4a,(byte)0x08,(byte)0x10,
+ (byte)0x8b,(byte)0x20,(byte)0x41,
+ (byte)0x41,(byte)0x20,(byte)0x31,
+ (byte)0x00,(byte)0x08,(byte)0x10,
+ (byte)0x08,(byte)0x08,(byte)0x08,
+ (byte)0x00,(byte)0x08,(byte)0x08,
+ (byte)0x18,(byte)0x08,(byte)0x10,
+ (byte)0x29,(byte)0x10,(byte)0x20,
+ (byte)0x29,(byte)0x20,(byte)0x20,
+ (byte)0x39,(byte)0x31,(byte)0x31,
+ (byte)0x29,(byte)0x10,(byte)0x18,
+ (byte)0x29,(byte)0x08,(byte)0x10,
+ (byte)0x08,(byte)0x08,(byte)0x08,
+ (byte)0x08,(byte)0x08,(byte)0x10,
+ (byte)0x18,(byte)0x18,(byte)0x31,
+ (byte)0x08,(byte)0x08,(byte)0x10,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x08,
+ (byte)0x29,(byte)0x18,(byte)0x10,
+ (byte)0x73,(byte)0x4a,(byte)0x41,
+ (byte)0x94,(byte)0x52,(byte)0x73,
+ (byte)0x6a,(byte)0x39,(byte)0x5a,
+ (byte)0x31,(byte)0x18,(byte)0x20,
+ (byte)0x18,(byte)0x08,(byte)0x00,
+ (byte)0x18,(byte)0x00,(byte)0x00,
+ (byte)0x18,(byte)0x10,(byte)0x18,
+ (byte)0x10,(byte)0x08,(byte)0x10,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x20,(byte)0x08,(byte)0x00,
+ (byte)0x20,(byte)0x08,(byte)0x08,
+ (byte)0x20,(byte)0x18,(byte)0x29,
+ (byte)0x52,(byte)0x41,(byte)0x39,
+ (byte)0x39,(byte)0x29,(byte)0x18,
+ (byte)0x20,(byte)0x18,(byte)0x10,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x18,(byte)0x10,(byte)0x08,
+ (byte)0x08,(byte)0x08,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x18,(byte)0x18,(byte)0x10,
+ (byte)0x20,(byte)0x29,(byte)0x18,
+ (byte)0x31,(byte)0x20,(byte)0x18,
+ (byte)0xb4,(byte)0x9c,(byte)0xac,
+ (byte)0xd5,(byte)0xd5,(byte)0xee,
+ (byte)0xb4,(byte)0xa4,(byte)0xb4,
+ (byte)0xa4,(byte)0x8b,(byte)0x9c,
+ (byte)0xbd,(byte)0xb4,(byte)0xc5,
+ (byte)0xcd,(byte)0xc5,(byte)0xde,
+ (byte)0xd5,(byte)0xcd,(byte)0xcd,
+ (byte)0xde,(byte)0xd5,(byte)0xee,
+ (byte)0xde,(byte)0xd5,(byte)0xf6,
+ (byte)0xd5,(byte)0xcd,(byte)0xd5,
+ (byte)0xcd,(byte)0xc5,(byte)0xc5,
+ (byte)0xc5,(byte)0xac,(byte)0xbd,
+ (byte)0xa4,(byte)0x7b,(byte)0x83,
+ (byte)0xbd,(byte)0xac,(byte)0xbd,
+ (byte)0x52,(byte)0x31,(byte)0x31,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x08,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x4a,(byte)0x00,(byte)0x08,
+ (byte)0x94,(byte)0x31,(byte)0x4a,
+ (byte)0x52,(byte)0x39,(byte)0x52,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x08,(byte)0x08,
+ (byte)0x00,(byte)0x00,(byte)0x08,
+ (byte)0x08,(byte)0x08,(byte)0x08,
+ (byte)0x18,(byte)0x08,(byte)0x10,
+ (byte)0x08,(byte)0x08,(byte)0x10,
+ (byte)0x18,(byte)0x10,(byte)0x18,
+ (byte)0x29,(byte)0x00,(byte)0x18,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x08,(byte)0x08,
+ (byte)0x00,(byte)0x08,(byte)0x08,
+ (byte)0x08,(byte)0x08,(byte)0x18,
+ (byte)0x08,(byte)0x08,(byte)0x10,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x18,(byte)0x00,(byte)0x08,
+ (byte)0x9c,(byte)0x5a,(byte)0x8b,
+ (byte)0xb4,(byte)0x62,(byte)0xa4,
+ (byte)0xa4,(byte)0x5a,(byte)0x8b,
+ (byte)0x8b,(byte)0x39,(byte)0x6a,
+ (byte)0x6a,(byte)0x29,(byte)0x41,
+ (byte)0x6a,(byte)0x31,(byte)0x41,
+ (byte)0x41,(byte)0x20,(byte)0x31,
+ (byte)0x10,(byte)0x08,(byte)0x10,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x18,(byte)0x08,(byte)0x00,
+ (byte)0x10,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x08,
+ (byte)0x52,(byte)0x39,(byte)0x29,
+ (byte)0x52,(byte)0x41,(byte)0x10,
+ (byte)0x41,(byte)0x31,(byte)0x29,
+ (byte)0x18,(byte)0x10,(byte)0x08,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x10,(byte)0x10,(byte)0x08,
+ (byte)0x39,(byte)0x39,(byte)0x31,
+ (byte)0x18,(byte)0x18,(byte)0x18,
+ (byte)0x41,(byte)0x18,(byte)0x18,
+ (byte)0xac,(byte)0x7b,(byte)0x8b,
+ (byte)0xde,(byte)0xde,(byte)0xff,
+ (byte)0xac,(byte)0x9c,(byte)0xa4,
+ (byte)0xa4,(byte)0x62,(byte)0x73,
+ (byte)0xbd,(byte)0xa4,(byte)0xbd,
+ (byte)0xc5,(byte)0xbd,(byte)0xbd,
+ (byte)0xcd,(byte)0xbd,(byte)0x9c,
+ (byte)0xd5,(byte)0xc5,(byte)0xac,
+ (byte)0xcd,(byte)0xc5,(byte)0xb4,
+ (byte)0xd5,(byte)0xc5,(byte)0xa4,
+ (byte)0xd5,(byte)0xc5,(byte)0xa4,
+ (byte)0xbd,(byte)0xa4,(byte)0xa4,
+ (byte)0x9c,(byte)0x8b,(byte)0x8b,
+ (byte)0x9c,(byte)0x8b,(byte)0x94,
+ (byte)0x5a,(byte)0x39,(byte)0x41,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x18,(byte)0x10,(byte)0x08,
+ (byte)0x08,(byte)0x08,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x4a,(byte)0x00,(byte)0x08,
+ (byte)0x9c,(byte)0x4a,(byte)0x5a,
+ (byte)0x5a,(byte)0x39,(byte)0x5a,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x08,(byte)0x08,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x08,
+ (byte)0x08,(byte)0x00,(byte)0x08,
+ (byte)0x18,(byte)0x18,(byte)0x29,
+ (byte)0x18,(byte)0x10,(byte)0x18,
+ (byte)0x10,(byte)0x00,(byte)0x08,
+ (byte)0x00,(byte)0x00,(byte)0x08,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x08,(byte)0x08,
+ (byte)0x08,(byte)0x08,(byte)0x08,
+ (byte)0x08,(byte)0x08,(byte)0x08,
+ (byte)0x08,(byte)0x00,(byte)0x08,
+ (byte)0x20,(byte)0x10,(byte)0x18,
+ (byte)0x8b,(byte)0x62,(byte)0x83,
+ (byte)0x9c,(byte)0x41,(byte)0x6a,
+ (byte)0x83,(byte)0x18,(byte)0x41,
+ (byte)0x73,(byte)0x08,(byte)0x18,
+ (byte)0x7b,(byte)0x18,(byte)0x39,
+ (byte)0x8b,(byte)0x29,(byte)0x52,
+ (byte)0x8b,(byte)0x39,(byte)0x62,
+ (byte)0x29,(byte)0x10,(byte)0x18,
+ (byte)0x08,(byte)0x00,(byte)0x08,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x08,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x39,(byte)0x20,(byte)0x08,
+ (byte)0x4a,(byte)0x39,(byte)0x10,
+ (byte)0x29,(byte)0x20,(byte)0x18,
+ (byte)0x10,(byte)0x08,(byte)0x08,
+ (byte)0x18,(byte)0x10,(byte)0x08,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x18,(byte)0x18,(byte)0x18,
+ (byte)0x10,(byte)0x08,(byte)0x08,
+ (byte)0x18,(byte)0x10,(byte)0x08,
+ (byte)0x62,(byte)0x29,(byte)0x31,
+ (byte)0xc5,(byte)0xa4,(byte)0xcd,
+ (byte)0x94,(byte)0x83,(byte)0x8b,
+ (byte)0x83,(byte)0x73,(byte)0x6a,
+ (byte)0xbd,(byte)0xa4,(byte)0xb4,
+ (byte)0xc5,(byte)0xb4,(byte)0xac,
+ (byte)0xcd,(byte)0xb4,(byte)0x83,
+ (byte)0xcd,(byte)0xbd,(byte)0x8b,
+ (byte)0xc5,(byte)0xb4,(byte)0x8b,
+ (byte)0xcd,(byte)0xbd,(byte)0x9c,
+ (byte)0xc5,(byte)0xb4,(byte)0x7b,
+ (byte)0xcd,(byte)0xc5,(byte)0xc5,
+ (byte)0x8b,(byte)0x7b,(byte)0x73,
+ (byte)0x8b,(byte)0x62,(byte)0x73,
+ (byte)0x5a,(byte)0x31,(byte)0x41,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x20,(byte)0x18,(byte)0x10,
+ (byte)0x08,(byte)0x08,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x4a,(byte)0x08,(byte)0x10,
+ (byte)0xa4,(byte)0x52,(byte)0x6a,
+ (byte)0x4a,(byte)0x29,(byte)0x41,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x08,
+ (byte)0x10,(byte)0x00,(byte)0x08,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x10,(byte)0x18,(byte)0x31,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x08,
+ (byte)0x08,(byte)0x00,(byte)0x08,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x52,(byte)0x29,(byte)0x4a,
+ (byte)0xcd,(byte)0x94,(byte)0xd5,
+ (byte)0x9c,(byte)0x41,(byte)0x6a,
+ (byte)0x7b,(byte)0x10,(byte)0x08,
+ (byte)0x6a,(byte)0x10,(byte)0x00,
+ (byte)0x6a,(byte)0x08,(byte)0x18,
+ (byte)0x73,(byte)0x10,(byte)0x31,
+ (byte)0x4a,(byte)0x10,(byte)0x20,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x08,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x08,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x18,(byte)0x08,(byte)0x08,
+ (byte)0x39,(byte)0x29,(byte)0x10,
+ (byte)0x18,(byte)0x10,(byte)0x08,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x18,(byte)0x10,(byte)0x08,
+ (byte)0x39,(byte)0x29,(byte)0x20,
+ (byte)0x18,(byte)0x10,(byte)0x08,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x08,(byte)0x08,
+ (byte)0x10,(byte)0x10,(byte)0x10,
+ (byte)0x4a,(byte)0x18,(byte)0x20,
+ (byte)0x9c,(byte)0x5a,(byte)0x7b,
+ (byte)0x83,(byte)0x52,(byte)0x62,
+ (byte)0x6a,(byte)0x52,(byte)0x41,
+ (byte)0xbd,(byte)0xb4,(byte)0xa4,
+ (byte)0xde,(byte)0xd5,(byte)0xd5,
+ (byte)0xc5,(byte)0xac,(byte)0x8b,
+ (byte)0xc5,(byte)0xac,(byte)0x8b,
+ (byte)0xd5,(byte)0xc5,(byte)0xbd,
+ (byte)0xc5,(byte)0xac,(byte)0x8b,
+ (byte)0xc5,(byte)0xac,(byte)0x94,
+ (byte)0xde,(byte)0xd5,(byte)0xcd,
+ (byte)0x94,(byte)0x83,(byte)0x73,
+ (byte)0x83,(byte)0x4a,(byte)0x52,
+ (byte)0x52,(byte)0x31,(byte)0x31,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x18,(byte)0x08,(byte)0x08,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x52,(byte)0x10,(byte)0x18,
+ (byte)0xa4,(byte)0x4a,(byte)0x5a,
+ (byte)0x52,(byte)0x31,(byte)0x4a,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x08,(byte)0x10,
+ (byte)0x4a,(byte)0x20,(byte)0x39,
+ (byte)0x18,(byte)0x10,(byte)0x18,
+ (byte)0x10,(byte)0x18,(byte)0x29,
+ (byte)0x08,(byte)0x08,(byte)0x10,
+ (byte)0x4a,(byte)0x18,(byte)0x31,
+ (byte)0x20,(byte)0x18,(byte)0x20,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x10,(byte)0x00,(byte)0x08,
+ (byte)0x20,(byte)0x08,(byte)0x10,
+ (byte)0x31,(byte)0x18,(byte)0x20,
+ (byte)0x20,(byte)0x00,(byte)0x08,
+ (byte)0x73,(byte)0x4a,(byte)0x6a,
+ (byte)0xac,(byte)0x52,(byte)0x94,
+ (byte)0x8b,(byte)0x20,(byte)0x4a,
+ (byte)0x83,(byte)0x20,(byte)0x08,
+ (byte)0x62,(byte)0x18,(byte)0x00,
+ (byte)0x6a,(byte)0x10,(byte)0x31,
+ (byte)0x73,(byte)0x18,(byte)0x41,
+ (byte)0x5a,(byte)0x20,(byte)0x31,
+ (byte)0x08,(byte)0x00,(byte)0x08,
+ (byte)0x00,(byte)0x00,(byte)0x08,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x08,
+ (byte)0x08,(byte)0x00,(byte)0x08,
+ (byte)0x39,(byte)0x10,(byte)0x18,
+ (byte)0x31,(byte)0x10,(byte)0x08,
+ (byte)0x31,(byte)0x10,(byte)0x18,
+ (byte)0x83,(byte)0x41,(byte)0x73,
+ (byte)0x8b,(byte)0x52,(byte)0x73,
+ (byte)0x73,(byte)0x41,(byte)0x41,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x08,(byte)0x08,
+ (byte)0x08,(byte)0x08,(byte)0x08,
+ (byte)0x08,(byte)0x08,(byte)0x08,
+ (byte)0x18,(byte)0x10,(byte)0x10,
+ (byte)0x20,(byte)0x10,(byte)0x10,
+ (byte)0x20,(byte)0x10,(byte)0x10,
+ (byte)0x8b,(byte)0x6a,(byte)0x52,
+ (byte)0xbd,(byte)0xac,(byte)0x83,
+ (byte)0xc5,(byte)0xac,(byte)0x73,
+ (byte)0xc5,(byte)0xac,(byte)0x8b,
+ (byte)0xcd,(byte)0xc5,(byte)0xc5,
+ (byte)0xc5,(byte)0xbd,(byte)0x9c,
+ (byte)0xcd,(byte)0xc5,(byte)0xbd,
+ (byte)0xc5,(byte)0xb4,(byte)0xa4,
+ (byte)0xcd,(byte)0xb4,(byte)0x83,
+ (byte)0xac,(byte)0x94,(byte)0x73,
+ (byte)0x39,(byte)0x20,(byte)0x20,
+ (byte)0x39,(byte)0x20,(byte)0x20,
+ (byte)0x08,(byte)0x08,(byte)0x08,
+ (byte)0x10,(byte)0x08,(byte)0x00,
+ (byte)0x10,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x52,(byte)0x10,(byte)0x18,
+ (byte)0x94,(byte)0x31,(byte)0x41,
+ (byte)0x73,(byte)0x39,(byte)0x62,
+ (byte)0x31,(byte)0x10,(byte)0x18,
+ (byte)0x4a,(byte)0x20,(byte)0x31,
+ (byte)0x10,(byte)0x10,(byte)0x10,
+ (byte)0x4a,(byte)0x39,(byte)0x4a,
+ (byte)0x6a,(byte)0x62,(byte)0x8b,
+ (byte)0x29,(byte)0x29,(byte)0x41,
+ (byte)0x62,(byte)0x62,(byte)0x83,
+ (byte)0x73,(byte)0x62,(byte)0x8b,
+ (byte)0x31,(byte)0x31,(byte)0x39,
+ (byte)0x31,(byte)0x18,(byte)0x20,
+ (byte)0x83,(byte)0x39,(byte)0x6a,
+ (byte)0x83,(byte)0x31,(byte)0x62,
+ (byte)0x9c,(byte)0x5a,(byte)0x8b,
+ (byte)0x94,(byte)0x4a,(byte)0x7b,
+ (byte)0x83,(byte)0x4a,(byte)0x6a,
+ (byte)0xa4,(byte)0x52,(byte)0x83,
+ (byte)0x8b,(byte)0x20,(byte)0x52,
+ (byte)0x7b,(byte)0x10,(byte)0x31,
+ (byte)0x6a,(byte)0x08,(byte)0x20,
+ (byte)0x73,(byte)0x10,(byte)0x31,
+ (byte)0x5a,(byte)0x20,(byte)0x31,
+ (byte)0x39,(byte)0x31,(byte)0x18,
+ (byte)0x20,(byte)0x18,(byte)0x10,
+ (byte)0x08,(byte)0x00,(byte)0x08,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x08,
+ (byte)0x10,(byte)0x10,(byte)0x20,
+ (byte)0x5a,(byte)0x18,(byte)0x29,
+ (byte)0x94,(byte)0x29,(byte)0x4a,
+ (byte)0x7b,(byte)0x31,(byte)0x4a,
+ (byte)0x73,(byte)0x29,(byte)0x41,
+ (byte)0xac,(byte)0x5a,(byte)0x7b,
+ (byte)0xc5,(byte)0x94,(byte)0x8b,
+ (byte)0xac,(byte)0x83,(byte)0x9c,
+ (byte)0x39,(byte)0x20,(byte)0x20,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x08,(byte)0x08,
+ (byte)0x08,(byte)0x08,(byte)0x08,
+ (byte)0x08,(byte)0x08,(byte)0x08,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x08,(byte)0x00,
+ (byte)0x5a,(byte)0x41,(byte)0x31,
+ (byte)0xa4,(byte)0x94,(byte)0x5a,
+ (byte)0xac,(byte)0x8b,(byte)0x31,
+ (byte)0xa4,(byte)0x8b,(byte)0x52,
+ (byte)0xc5,(byte)0xbd,(byte)0xb4,
+ (byte)0x8b,(byte)0x7b,(byte)0x41,
+ (byte)0xc5,(byte)0xb4,(byte)0xac,
+ (byte)0xb4,(byte)0x9c,(byte)0x73,
+ (byte)0xbd,(byte)0xa4,(byte)0x5a,
+ (byte)0xbd,(byte)0x9c,(byte)0x83,
+ (byte)0x20,(byte)0x10,(byte)0x10,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x08,(byte)0x08,
+ (byte)0x20,(byte)0x10,(byte)0x10,
+ (byte)0x18,(byte)0x08,(byte)0x08,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x52,(byte)0x10,(byte)0x20,
+ (byte)0x8b,(byte)0x29,(byte)0x39,
+ (byte)0x8b,(byte)0x39,(byte)0x6a,
+ (byte)0x83,(byte)0x41,(byte)0x62,
+ (byte)0x94,(byte)0x41,(byte)0x73,
+ (byte)0x4a,(byte)0x31,(byte)0x41,
+ (byte)0x6a,(byte)0x6a,(byte)0x83,
+ (byte)0x9c,(byte)0x9c,(byte)0xcd,
+ (byte)0x8b,(byte)0x9c,(byte)0xc5,
+ (byte)0x9c,(byte)0xa4,(byte)0xcd,
+ (byte)0xa4,(byte)0xac,(byte)0xd5,
+ (byte)0x8b,(byte)0x8b,(byte)0xa4,
+ (byte)0x8b,(byte)0x41,(byte)0x73,
+ (byte)0xac,(byte)0x52,(byte)0x94,
+ (byte)0xb4,(byte)0x5a,(byte)0xa4,
+ (byte)0xa4,(byte)0x41,(byte)0x83,
+ (byte)0xb4,(byte)0x6a,(byte)0xa4,
+ (byte)0xac,(byte)0x7b,(byte)0xa4,
+ (byte)0xb4,(byte)0x73,(byte)0xa4,
+ (byte)0xa4,(byte)0x4a,(byte)0x8b,
+ (byte)0x94,(byte)0x31,(byte)0x73,
+ (byte)0x94,(byte)0x39,(byte)0x73,
+ (byte)0x73,(byte)0x18,(byte)0x39,
+ (byte)0x4a,(byte)0x08,(byte)0x18,
+ (byte)0x10,(byte)0x10,(byte)0x08,
+ (byte)0x10,(byte)0x10,(byte)0x08,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x08,
+ (byte)0x18,(byte)0x10,(byte)0x18,
+ (byte)0x83,(byte)0x31,(byte)0x39,
+ (byte)0xb4,(byte)0x73,(byte)0x39,
+ (byte)0xbd,(byte)0x6a,(byte)0x73,
+ (byte)0x94,(byte)0x62,(byte)0x7b,
+ (byte)0xa4,(byte)0x62,(byte)0x5a,
+ (byte)0xbd,(byte)0x7b,(byte)0x5a,
+ (byte)0xc5,(byte)0x8b,(byte)0xb4,
+ (byte)0x62,(byte)0x41,(byte)0x4a,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x18,(byte)0x18,(byte)0x10,
+ (byte)0x18,(byte)0x18,(byte)0x10,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x08,(byte)0x08,
+ (byte)0x10,(byte)0x10,(byte)0x00,
+ (byte)0x4a,(byte)0x41,(byte)0x10,
+ (byte)0x73,(byte)0x62,(byte)0x20,
+ (byte)0x7b,(byte)0x6a,(byte)0x41,
+ (byte)0x9c,(byte)0x94,(byte)0x83,
+ (byte)0xa4,(byte)0x94,(byte)0x73,
+ (byte)0xb4,(byte)0xa4,(byte)0x9c,
+ (byte)0x83,(byte)0x6a,(byte)0x29,
+ (byte)0xac,(byte)0x8b,(byte)0x41,
+ (byte)0x4a,(byte)0x41,(byte)0x20,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x29,(byte)0x10,(byte)0x18,
+ (byte)0x20,(byte)0x10,(byte)0x10,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x4a,(byte)0x08,(byte)0x20,
+ (byte)0x7b,(byte)0x18,(byte)0x29,
+ (byte)0x83,(byte)0x31,(byte)0x5a,
+ (byte)0xa4,(byte)0x5a,(byte)0x94,
+ (byte)0xac,(byte)0x52,(byte)0x94,
+ (byte)0x9c,(byte)0x52,(byte)0x8b,
+ (byte)0x9c,(byte)0x9c,(byte)0xbd,
+ (byte)0xa4,(byte)0xac,(byte)0xd5,
+ (byte)0x9c,(byte)0xa4,(byte)0xcd,
+ (byte)0xa4,(byte)0xac,(byte)0xd5,
+ (byte)0xac,(byte)0xb4,(byte)0xd5,
+ (byte)0xb4,(byte)0x9c,(byte)0xcd,
+ (byte)0xa4,(byte)0x41,(byte)0x83,
+ (byte)0xa4,(byte)0x39,(byte)0x6a,
+ (byte)0xb4,(byte)0x62,(byte)0x39,
+ (byte)0xa4,(byte)0x41,(byte)0x5a,
+ (byte)0xb4,(byte)0x73,(byte)0xb4,
+ (byte)0xc5,(byte)0x8b,(byte)0xc5,
+ (byte)0xb4,(byte)0x6a,(byte)0x9c,
+ (byte)0x83,(byte)0x20,(byte)0x4a,
+ (byte)0x94,(byte)0x31,(byte)0x62,
+ (byte)0xc5,(byte)0x94,(byte)0xb4,
+ (byte)0x83,(byte)0x41,(byte)0x5a,
+ (byte)0x29,(byte)0x08,(byte)0x08,
+ (byte)0x10,(byte)0x08,(byte)0x00,
+ (byte)0x10,(byte)0x10,(byte)0x08,
+ (byte)0x08,(byte)0x10,(byte)0x08,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x08,(byte)0x08,
+ (byte)0x41,(byte)0x31,(byte)0x20,
+ (byte)0x7b,(byte)0x5a,(byte)0x29,
+ (byte)0x6a,(byte)0x41,(byte)0x29,
+ (byte)0x4a,(byte)0x31,(byte)0x29,
+ (byte)0x5a,(byte)0x39,(byte)0x39,
+ (byte)0x94,(byte)0x6a,(byte)0x83,
+ (byte)0x6a,(byte)0x4a,(byte)0x52,
+ (byte)0x29,(byte)0x10,(byte)0x10,
+ (byte)0x20,(byte)0x18,(byte)0x10,
+ (byte)0x39,(byte)0x31,(byte)0x29,
+ (byte)0x08,(byte)0x08,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x10,(byte)0x08,(byte)0x10,
+ (byte)0x62,(byte)0x29,(byte)0x41,
+ (byte)0x5a,(byte)0x20,(byte)0x29,
+ (byte)0x39,(byte)0x31,(byte)0x10,
+ (byte)0x62,(byte)0x5a,(byte)0x39,
+ (byte)0xa4,(byte)0x94,(byte)0x6a,
+ (byte)0x83,(byte)0x73,(byte)0x39,
+ (byte)0xac,(byte)0xa4,(byte)0x7b,
+ (byte)0x73,(byte)0x62,(byte)0x39,
+ (byte)0x83,(byte)0x73,(byte)0x4a,
+ (byte)0x52,(byte)0x4a,(byte)0x10,
+ (byte)0x18,(byte)0x18,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x31,(byte)0x18,(byte)0x20,
+ (byte)0x29,(byte)0x18,(byte)0x20,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x29,(byte)0x08,(byte)0x10,
+ (byte)0x7b,(byte)0x18,(byte)0x39,
+ (byte)0xa4,(byte)0x62,(byte)0x8b,
+ (byte)0xac,(byte)0x5a,(byte)0x9c,
+ (byte)0xa4,(byte)0x4a,(byte)0x8b,
+ (byte)0xa4,(byte)0x41,(byte)0x8b,
+ (byte)0xb4,(byte)0x83,(byte)0xb4,
+ (byte)0xac,(byte)0xb4,(byte)0xd5,
+ (byte)0xa4,(byte)0xac,(byte)0xd5,
+ (byte)0xa4,(byte)0xac,(byte)0xd5,
+ (byte)0xac,(byte)0xb4,(byte)0xde,
+ (byte)0xbd,(byte)0xa4,(byte)0xd5,
+ (byte)0xb4,(byte)0x5a,(byte)0x9c,
+ (byte)0xac,(byte)0x4a,(byte)0x4a,
+ (byte)0xbd,(byte)0x73,(byte)0x20,
+ (byte)0xa4,(byte)0x52,(byte)0x52,
+ (byte)0xbd,(byte)0x7b,(byte)0xbd,
+ (byte)0xac,(byte)0x52,(byte)0x9c,
+ (byte)0x9c,(byte)0x41,(byte)0x73,
+ (byte)0x73,(byte)0x08,(byte)0x20,
+ (byte)0x8b,(byte)0x29,(byte)0x4a,
+ (byte)0xb4,(byte)0x6a,(byte)0x94,
+ (byte)0x9c,(byte)0x6a,(byte)0x83,
+ (byte)0x7b,(byte)0x6a,(byte)0x6a,
+ (byte)0x52,(byte)0x4a,(byte)0x41,
+ (byte)0x6a,(byte)0x62,(byte)0x5a,
+ (byte)0x39,(byte)0x39,(byte)0x31,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x31,(byte)0x29,(byte)0x20,
+ (byte)0x20,(byte)0x20,(byte)0x10,
+ (byte)0x20,(byte)0x18,(byte)0x10,
+ (byte)0x10,(byte)0x08,(byte)0x00,
+ (byte)0x4a,(byte)0x41,(byte)0x31,
+ (byte)0x29,(byte)0x20,(byte)0x18,
+ (byte)0x18,(byte)0x08,(byte)0x08,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x31,(byte)0x20,(byte)0x18,
+ (byte)0x39,(byte)0x29,(byte)0x29,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x10,(byte)0x08,(byte)0x08,
+ (byte)0x41,(byte)0x18,(byte)0x18,
+ (byte)0x62,(byte)0x31,(byte)0x31,
+ (byte)0x18,(byte)0x10,(byte)0x00,
+ (byte)0x4a,(byte)0x4a,(byte)0x20,
+ (byte)0xac,(byte)0x9c,(byte)0x62,
+ (byte)0xa4,(byte)0x94,(byte)0x73,
+ (byte)0x9c,(byte)0x8b,(byte)0x6a,
+ (byte)0x94,(byte)0x83,(byte)0x5a,
+ (byte)0x8b,(byte)0x7b,(byte)0x5a,
+ (byte)0x52,(byte)0x41,(byte)0x18,
+ (byte)0x20,(byte)0x18,(byte)0x10,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x5a,(byte)0x31,(byte)0x4a,
+ (byte)0x18,(byte)0x10,(byte)0x10,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x18,(byte)0x08,(byte)0x08,
+ (byte)0x7b,(byte)0x18,(byte)0x39,
+ (byte)0xb4,(byte)0x6a,(byte)0xa4,
+ (byte)0xac,(byte)0x62,(byte)0x9c,
+ (byte)0xac,(byte)0x52,(byte)0x62,
+ (byte)0xa4,(byte)0x4a,(byte)0x5a,
+ (byte)0xac,(byte)0x5a,(byte)0x94,
+ (byte)0xbd,(byte)0xb4,(byte)0xde,
+ (byte)0xac,(byte)0xb4,(byte)0xd5,
+ (byte)0xac,(byte)0xb4,(byte)0xde,
+ (byte)0xb4,(byte)0xb4,(byte)0xd5,
+ (byte)0xc5,(byte)0xc5,(byte)0xe6,
+ (byte)0xb4,(byte)0x73,(byte)0xac,
+ (byte)0x94,(byte)0x29,(byte)0x5a,
+ (byte)0xb4,(byte)0x6a,(byte)0x7b,
+ (byte)0xc5,(byte)0x9c,(byte)0xcd,
+ (byte)0xc5,(byte)0x94,(byte)0xac,
+ (byte)0xc5,(byte)0x94,(byte)0xb4,
+ (byte)0x9c,(byte)0x41,(byte)0x7b,
+ (byte)0x94,(byte)0x31,(byte)0x52,
+ (byte)0x94,(byte)0x31,(byte)0x41,
+ (byte)0x94,(byte)0x39,(byte)0x62,
+ (byte)0x94,(byte)0x73,(byte)0x7b,
+ (byte)0x73,(byte)0x6a,(byte)0x62,
+ (byte)0x5a,(byte)0x5a,(byte)0x52,
+ (byte)0x94,(byte)0x8b,(byte)0x94,
+ (byte)0x41,(byte)0x39,(byte)0x39,
+ (byte)0x08,(byte)0x08,(byte)0x00,
+ (byte)0x08,(byte)0x08,(byte)0x08,
+ (byte)0x08,(byte)0x08,(byte)0x08,
+ (byte)0x39,(byte)0x31,(byte)0x29,
+ (byte)0x4a,(byte)0x41,(byte)0x39,
+ (byte)0x4a,(byte)0x41,(byte)0x39,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x10,(byte)0x10,(byte)0x10,
+ (byte)0x10,(byte)0x08,(byte)0x08,
+ (byte)0x18,(byte)0x08,(byte)0x08,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x08,(byte)0x08,
+ (byte)0x10,(byte)0x10,(byte)0x08,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x10,(byte)0x08,
+ (byte)0x08,(byte)0x08,(byte)0x00,
+ (byte)0x29,(byte)0x20,(byte)0x10,
+ (byte)0xac,(byte)0x9c,(byte)0x62,
+ (byte)0xac,(byte)0x9c,(byte)0x52,
+ (byte)0xc5,(byte)0xb4,(byte)0x9c,
+ (byte)0xb4,(byte)0xa4,(byte)0x83,
+ (byte)0xac,(byte)0x9c,(byte)0x6a,
+ (byte)0x29,(byte)0x29,(byte)0x10,
+ (byte)0x41,(byte)0x20,(byte)0x20,
+ (byte)0x52,(byte)0x20,(byte)0x39,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x08,(byte)0x00,
+ (byte)0x62,(byte)0x39,(byte)0x52,
+ (byte)0x08,(byte)0x08,(byte)0x08,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x10,(byte)0x08,(byte)0x08,
+ (byte)0x73,(byte)0x20,(byte)0x39,
+ (byte)0x9c,(byte)0x41,(byte)0x7b,
+ (byte)0xbd,(byte)0x83,(byte)0xc5,
+ (byte)0xb4,(byte)0x6a,(byte)0x5a,
+ (byte)0xb4,(byte)0x6a,(byte)0x29,
+ (byte)0xb4,(byte)0x6a,(byte)0x9c,
+ (byte)0xcd,(byte)0xbd,(byte)0xe6,
+ (byte)0xb4,(byte)0xb4,(byte)0xde,
+ (byte)0xac,(byte)0xb4,(byte)0xde,
+ (byte)0xb4,(byte)0xb4,(byte)0xde,
+ (byte)0xbd,(byte)0xbd,(byte)0xde,
+ (byte)0xb4,(byte)0x6a,(byte)0xac,
+ (byte)0x94,(byte)0x29,(byte)0x62,
+ (byte)0x9c,(byte)0x31,(byte)0x83,
+ (byte)0xb4,(byte)0x6a,(byte)0xac,
+ (byte)0xd5,(byte)0xb4,(byte)0x7b,
+ (byte)0xcd,(byte)0xa4,(byte)0x4a,
+ (byte)0xb4,(byte)0x73,(byte)0x9c,
+ (byte)0x9c,(byte)0x41,(byte)0x52,
+ (byte)0x73,(byte)0x10,(byte)0x00,
+ (byte)0x7b,(byte)0x29,(byte)0x39,
+ (byte)0xc5,(byte)0xbd,(byte)0xc5,
+ (byte)0x7b,(byte)0x73,(byte)0x6a,
+ (byte)0x6a,(byte)0x62,(byte)0x62,
+ (byte)0xa4,(byte)0x9c,(byte)0x9c,
+ (byte)0x5a,(byte)0x5a,(byte)0x5a,
+ (byte)0x08,(byte)0x08,(byte)0x08,
+ (byte)0x08,(byte)0x08,(byte)0x08,
+ (byte)0x08,(byte)0x00,(byte)0x08,
+ (byte)0x4a,(byte)0x41,(byte)0x39,
+ (byte)0x41,(byte)0x41,(byte)0x31,
+ (byte)0x31,(byte)0x31,(byte)0x20,
+ (byte)0x08,(byte)0x08,(byte)0x08,
+ (byte)0x00,(byte)0x08,(byte)0x00,
+ (byte)0x18,(byte)0x00,(byte)0x08,
+ (byte)0x39,(byte)0x08,(byte)0x08,
+ (byte)0x08,(byte)0x00,(byte)0x08,
+ (byte)0x29,(byte)0x41,(byte)0x41,
+ (byte)0x62,(byte)0x4a,(byte)0x31,
+ (byte)0x10,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x08,(byte)0x00,
+ (byte)0x08,(byte)0x08,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x4a,(byte)0x41,(byte)0x31,
+ (byte)0xac,(byte)0x9c,(byte)0x62,
+ (byte)0xac,(byte)0x9c,(byte)0x62,
+ (byte)0xcd,(byte)0xc5,(byte)0x94,
+ (byte)0xbd,(byte)0xac,(byte)0x7b,
+ (byte)0xac,(byte)0x9c,(byte)0x62,
+ (byte)0x41,(byte)0x41,(byte)0x20,
+ (byte)0x52,(byte)0x29,(byte)0x29,
+ (byte)0x52,(byte)0x18,(byte)0x29,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x08,(byte)0x08,
+ (byte)0x31,(byte)0x29,(byte)0x29,
+ (byte)0x6a,(byte)0x41,(byte)0x5a,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x5a,(byte)0x18,(byte)0x29,
+ (byte)0xa4,(byte)0x4a,(byte)0x7b,
+ (byte)0xbd,(byte)0x83,(byte)0xbd,
+ (byte)0xa4,(byte)0x5a,(byte)0x7b,
+ (byte)0xa4,(byte)0x52,(byte)0x18,
+ (byte)0x9c,(byte)0x39,(byte)0x5a,
+ (byte)0xb4,(byte)0x8b,(byte)0xbd,
+ (byte)0xb4,(byte)0xbd,(byte)0xe6,
+ (byte)0xb4,(byte)0xbd,(byte)0xde,
+ (byte)0xb4,(byte)0xbd,(byte)0xde,
+ (byte)0xb4,(byte)0xb4,(byte)0xd5,
+ (byte)0xb4,(byte)0x8b,(byte)0xb4,
+ (byte)0x9c,(byte)0x4a,(byte)0x7b,
+ (byte)0x9c,(byte)0x41,(byte)0x7b,
+ (byte)0xc5,(byte)0x9c,(byte)0xcd,
+ (byte)0xcd,(byte)0xac,(byte)0x6a,
+ (byte)0xc5,(byte)0x7b,(byte)0x08,
+ (byte)0xc5,(byte)0x8b,(byte)0x83,
+ (byte)0xa4,(byte)0x4a,(byte)0x7b,
+ (byte)0x7b,(byte)0x20,(byte)0x41,
+ (byte)0x5a,(byte)0x31,(byte)0x29,
+ (byte)0xa4,(byte)0x94,(byte)0x8b,
+ (byte)0x83,(byte)0x7b,(byte)0x6a,
+ (byte)0x7b,(byte)0x6a,(byte)0x6a,
+ (byte)0x29,(byte)0x29,(byte)0x20,
+ (byte)0x29,(byte)0x29,(byte)0x20,
+ (byte)0x08,(byte)0x08,(byte)0x08,
+ (byte)0x10,(byte)0x08,(byte)0x08,
+ (byte)0x18,(byte)0x00,(byte)0x08,
+ (byte)0x20,(byte)0x18,(byte)0x18,
+ (byte)0x83,(byte)0x7b,(byte)0x6a,
+ (byte)0x4a,(byte)0x4a,(byte)0x39,
+ (byte)0x18,(byte)0x20,(byte)0x10,
+ (byte)0x08,(byte)0x08,(byte)0x08,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x20,(byte)0x08,(byte)0x00,
+ (byte)0x10,(byte)0x10,(byte)0x10,
+ (byte)0x7b,(byte)0x6a,(byte)0x52,
+ (byte)0x73,(byte)0x4a,(byte)0x39,
+ (byte)0x20,(byte)0x18,(byte)0x08,
+ (byte)0x4a,(byte)0x4a,(byte)0x10,
+ (byte)0x41,(byte)0x41,(byte)0x10,
+ (byte)0x29,(byte)0x29,(byte)0x08,
+ (byte)0x31,(byte)0x31,(byte)0x18,
+ (byte)0x08,(byte)0x08,(byte)0x00,
+ (byte)0x18,(byte)0x18,(byte)0x08,
+ (byte)0x8b,(byte)0x7b,(byte)0x41,
+ (byte)0xa4,(byte)0x94,(byte)0x4a,
+ (byte)0xac,(byte)0x9c,(byte)0x5a,
+ (byte)0xc5,(byte)0xbd,(byte)0x83,
+ (byte)0xac,(byte)0xa4,(byte)0x6a,
+ (byte)0x9c,(byte)0x8b,(byte)0x52,
+ (byte)0x20,(byte)0x18,(byte)0x10,
+ (byte)0x29,(byte)0x10,(byte)0x10,
+ (byte)0x10,(byte)0x08,(byte)0x08,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x08,(byte)0x00,
+ (byte)0x52,(byte)0x39,(byte)0x4a,
+ (byte)0x5a,(byte)0x39,(byte)0x52,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x39,(byte)0x10,(byte)0x20,
+ (byte)0x8b,(byte)0x31,(byte)0x5a,
+ (byte)0xa4,(byte)0x52,(byte)0x83,
+ (byte)0xbd,(byte)0x7b,(byte)0xb4,
+ (byte)0xb4,(byte)0x7b,(byte)0x94,
+ (byte)0xa4,(byte)0x4a,(byte)0x6a,
+ (byte)0x9c,(byte)0x41,(byte)0x83,
+ (byte)0xbd,(byte)0xac,(byte)0xd5,
+ (byte)0xb4,(byte)0xbd,(byte)0xde,
+ (byte)0xb4,(byte)0xbd,(byte)0xde,
+ (byte)0x8b,(byte)0x83,(byte)0xa4,
+ (byte)0x7b,(byte)0x5a,(byte)0x6a,
+ (byte)0xa4,(byte)0x5a,(byte)0x83,
+ (byte)0x94,(byte)0x41,(byte)0x73,
+ (byte)0xb4,(byte)0x73,(byte)0xa4,
+ (byte)0xcd,(byte)0xa4,(byte)0x52,
+ (byte)0xb4,(byte)0x62,(byte)0x00,
+ (byte)0xa4,(byte)0x5a,(byte)0x62,
+ (byte)0x94,(byte)0x31,(byte)0x6a,
+ (byte)0x6a,(byte)0x10,(byte)0x29,
+ (byte)0x41,(byte)0x20,(byte)0x10,
+ (byte)0x83,(byte)0x73,(byte)0x6a,
+ (byte)0x62,(byte)0x52,(byte)0x52,
+ (byte)0x41,(byte)0x39,(byte)0x31,
+ (byte)0x4a,(byte)0x4a,(byte)0x41,
+ (byte)0x29,(byte)0x29,(byte)0x20,
+ (byte)0x10,(byte)0x10,(byte)0x08,
+ (byte)0x08,(byte)0x10,(byte)0x08,
+ (byte)0x10,(byte)0x08,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x29,(byte)0x20,(byte)0x10,
+ (byte)0x29,(byte)0x29,(byte)0x18,
+ (byte)0x20,(byte)0x20,(byte)0x18,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x29,(byte)0x18,(byte)0x10,
+ (byte)0x18,(byte)0x08,(byte)0x08,
+ (byte)0x39,(byte)0x31,(byte)0x18,
+ (byte)0x7b,(byte)0x73,(byte)0x31,
+ (byte)0x5a,(byte)0x5a,(byte)0x20,
+ (byte)0x4a,(byte)0x41,(byte)0x10,
+ (byte)0x29,(byte)0x29,(byte)0x08,
+ (byte)0x18,(byte)0x18,(byte)0x08,
+ (byte)0x73,(byte)0x6a,(byte)0x39,
+ (byte)0x9c,(byte)0x83,(byte)0x41,
+ (byte)0x8b,(byte)0x6a,(byte)0x31,
+ (byte)0xbd,(byte)0xac,(byte)0x6a,
+ (byte)0xac,(byte)0x9c,(byte)0x5a,
+ (byte)0xac,(byte)0x94,(byte)0x52,
+ (byte)0x6a,(byte)0x62,(byte)0x4a,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x10,(byte)0x08,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x08,(byte)0x00,
+ (byte)0x7b,(byte)0x52,(byte)0x62,
+ (byte)0x31,(byte)0x18,(byte)0x20,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x18,(byte)0x10,(byte)0x10,
+ (byte)0x8b,(byte)0x39,(byte)0x5a,
+ (byte)0x8b,(byte)0x29,(byte)0x5a,
+ (byte)0xac,(byte)0x5a,(byte)0x94,
+ (byte)0xc5,(byte)0x8b,(byte)0xc5,
+ (byte)0xa4,(byte)0x52,(byte)0x94,
+ (byte)0x9c,(byte)0x39,(byte)0x73,
+ (byte)0xac,(byte)0x83,(byte)0xac,
+ (byte)0x83,(byte)0x73,(byte)0x8b,
+ (byte)0x83,(byte)0x7b,(byte)0x94,
+ (byte)0x62,(byte)0x4a,(byte)0x5a,
+ (byte)0x5a,(byte)0x41,(byte)0x4a,
+ (byte)0x5a,(byte)0x31,(byte)0x41,
+ (byte)0x94,(byte)0x62,(byte)0x8b,
+ (byte)0xc5,(byte)0x8b,(byte)0xc5,
+ (byte)0xcd,(byte)0x9c,(byte)0x8b,
+ (byte)0xa4,(byte)0x52,(byte)0x18,
+ (byte)0x8b,(byte)0x31,(byte)0x4a,
+ (byte)0xac,(byte)0x73,(byte)0x94,
+ (byte)0x6a,(byte)0x20,(byte)0x31,
+ (byte)0x18,(byte)0x00,(byte)0x00,
+ (byte)0x10,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x39,(byte)0x39,(byte)0x31,
+ (byte)0x7b,(byte)0x73,(byte)0x7b,
+ (byte)0x41,(byte)0x39,(byte)0x39,
+ (byte)0x08,(byte)0x10,(byte)0x08,
+ (byte)0x08,(byte)0x08,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x29,(byte)0x20,(byte)0x18,
+ (byte)0x20,(byte)0x20,(byte)0x18,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x39,(byte)0x31,(byte)0x18,
+ (byte)0x5a,(byte)0x4a,(byte)0x29,
+ (byte)0x31,(byte)0x29,(byte)0x10,
+ (byte)0x39,(byte)0x31,(byte)0x10,
+ (byte)0x20,(byte)0x18,(byte)0x08,
+ (byte)0x83,(byte)0x6a,(byte)0x39,
+ (byte)0xbd,(byte)0xac,(byte)0x73,
+ (byte)0xa4,(byte)0x94,(byte)0x52,
+ (byte)0xa4,(byte)0x94,(byte)0x5a,
+ (byte)0xb4,(byte)0xa4,(byte)0x73,
+ (byte)0x94,(byte)0x7b,(byte)0x41,
+ (byte)0xa4,(byte)0x8b,(byte)0x41,
+ (byte)0x31,(byte)0x29,(byte)0x18,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x08,(byte)0x08,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x29,(byte)0x20,(byte)0x20,
+ (byte)0x83,(byte)0x52,(byte)0x52,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x5a,(byte)0x31,(byte)0x41,
+ (byte)0x94,(byte)0x39,(byte)0x62,
+ (byte)0x94,(byte)0x31,(byte)0x62,
+ (byte)0xc5,(byte)0x9c,(byte)0xb4,
+ (byte)0xb4,(byte)0x6a,(byte)0xac,
+ (byte)0x94,(byte)0x31,(byte)0x73,
+ (byte)0x9c,(byte)0x52,(byte)0x7b,
+ (byte)0x62,(byte)0x41,(byte)0x52,
+ (byte)0x52,(byte)0x39,(byte)0x4a,
+ (byte)0x5a,(byte)0x41,(byte)0x52,
+ (byte)0x4a,(byte)0x39,(byte)0x4a,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x5a,(byte)0x39,(byte)0x52,
+ (byte)0xcd,(byte)0x9c,(byte)0xd5,
+ (byte)0xcd,(byte)0xb4,(byte)0xe6,
+ (byte)0xbd,(byte)0x94,(byte)0xb4,
+ (byte)0xb4,(byte)0x83,(byte)0xa4,
+ (byte)0xa4,(byte)0x73,(byte)0x94,
+ (byte)0xbd,(byte)0x9c,(byte)0xbd,
+ (byte)0x4a,(byte)0x20,(byte)0x20,
+ (byte)0x10,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x10,(byte)0x18,(byte)0x10,
+ (byte)0x18,(byte)0x18,(byte)0x10,
+ (byte)0x08,(byte)0x08,(byte)0x08,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x08,(byte)0x00,
+ (byte)0x08,(byte)0x08,(byte)0x08,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x20,(byte)0x20,(byte)0x08,
+ (byte)0x18,(byte)0x18,(byte)0x00,
+ (byte)0x39,(byte)0x29,(byte)0x18,
+ (byte)0x73,(byte)0x62,(byte)0x41,
+ (byte)0x94,(byte)0x83,(byte)0x6a,
+ (byte)0x7b,(byte)0x73,(byte)0x41,
+ (byte)0xa4,(byte)0x94,(byte)0x62,
+ (byte)0x94,(byte)0x8b,(byte)0x52,
+ (byte)0xac,(byte)0x9c,(byte)0x5a,
+ (byte)0x94,(byte)0x7b,(byte)0x39,
+ (byte)0x83,(byte)0x7b,(byte)0x39,
+ (byte)0x10,(byte)0x18,(byte)0x08,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x10,(byte)0x08,(byte)0x08,
+ (byte)0x6a,(byte)0x4a,(byte)0x4a,
+ (byte)0x62,(byte)0x39,(byte)0x39,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x20,(byte)0x10,(byte)0x10,
+ (byte)0x94,(byte)0x4a,(byte)0x6a,
+ (byte)0x8b,(byte)0x20,(byte)0x4a,
+ (byte)0xc5,(byte)0x94,(byte)0x94,
+ (byte)0xcd,(byte)0xac,(byte)0x83,
+ (byte)0xbd,(byte)0x7b,(byte)0xbd,
+ (byte)0x9c,(byte)0x4a,(byte)0x7b,
+ (byte)0x73,(byte)0x4a,(byte)0x62,
+ (byte)0x52,(byte)0x39,(byte)0x4a,
+ (byte)0x41,(byte)0x31,(byte)0x41,
+ (byte)0x10,(byte)0x10,(byte)0x10,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x52,(byte)0x29,(byte)0x41,
+ (byte)0xcd,(byte)0xa4,(byte)0xde,
+ (byte)0xcd,(byte)0xb4,(byte)0xe6,
+ (byte)0xc5,(byte)0xac,(byte)0xd5,
+ (byte)0xcd,(byte)0xc5,(byte)0xee,
+ (byte)0x94,(byte)0x4a,(byte)0x62,
+ (byte)0x83,(byte)0x41,(byte)0x62,
+ (byte)0x8b,(byte)0x6a,(byte)0x7b,
+ (byte)0x10,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x10,(byte)0x08,(byte)0x08,
+ (byte)0x10,(byte)0x10,(byte)0x08,
+ (byte)0x00,(byte)0x00,(byte)0x08,
+ (byte)0x00,(byte)0x00,(byte)0x08,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x10,(byte)0x08,(byte)0x00,
+ (byte)0x29,(byte)0x20,(byte)0x08,
+ (byte)0x6a,(byte)0x5a,(byte)0x31,
+ (byte)0xd5,(byte)0xc5,(byte)0x94,
+ (byte)0x9c,(byte)0x8b,(byte)0x5a,
+ (byte)0x9c,(byte)0x8b,(byte)0x5a,
+ (byte)0x73,(byte)0x6a,(byte)0x31,
+ (byte)0x4a,(byte)0x4a,(byte)0x10,
+ (byte)0xa4,(byte)0x94,(byte)0x5a,
+ (byte)0xc5,(byte)0xb4,(byte)0x73,
+ (byte)0x62,(byte)0x5a,(byte)0x31,
+ (byte)0x18,(byte)0x18,(byte)0x08,
+ (byte)0x10,(byte)0x10,(byte)0x08,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x39,(byte)0x31,(byte)0x31,
+ (byte)0x94,(byte)0x5a,(byte)0x5a,
+ (byte)0x20,(byte)0x08,(byte)0x08,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x52,(byte)0x31,(byte)0x39,
+ (byte)0x9c,(byte)0x4a,(byte)0x6a,
+ (byte)0x9c,(byte)0x39,(byte)0x62,
+ (byte)0xcd,(byte)0x94,(byte)0x41,
+ (byte)0xcd,(byte)0xb4,(byte)0xa4,
+ (byte)0xac,(byte)0x62,(byte)0xa4,
+ (byte)0x7b,(byte)0x4a,(byte)0x6a,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x20,(byte)0x08,(byte)0x10,
+ (byte)0xac,(byte)0x73,(byte)0xac,
+ (byte)0xcd,(byte)0xbd,(byte)0xee,
+ (byte)0xa4,(byte)0x83,(byte)0x9c,
+ (byte)0xac,(byte)0x83,(byte)0xac,
+ (byte)0xb4,(byte)0x8b,(byte)0xac,
+ (byte)0x31,(byte)0x00,(byte)0x08,
+ (byte)0x52,(byte)0x39,(byte)0x41,
+ (byte)0x39,(byte)0x29,(byte)0x29,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x41,(byte)0x10,(byte)0x31,
+ (byte)0x31,(byte)0x18,(byte)0x31,
+ (byte)0x10,(byte)0x10,(byte)0x20,
+ (byte)0x10,(byte)0x10,(byte)0x18,
+ (byte)0x08,(byte)0x00,(byte)0x08,
+ (byte)0x00,(byte)0x00,(byte)0x08,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x31,(byte)0x20,(byte)0x08,
+ (byte)0x29,(byte)0x18,(byte)0x08,
+ (byte)0x20,(byte)0x10,(byte)0x08,
+ (byte)0x52,(byte)0x41,(byte)0x10,
+ (byte)0x7b,(byte)0x6a,(byte)0x41,
+ (byte)0x8b,(byte)0x7b,(byte)0x52,
+ (byte)0x8b,(byte)0x7b,(byte)0x62,
+ (byte)0x29,(byte)0x20,(byte)0x00,
+ (byte)0x8b,(byte)0x7b,(byte)0x41,
+ (byte)0x6a,(byte)0x62,(byte)0x31,
+ (byte)0xa4,(byte)0x94,(byte)0x5a,
+ (byte)0x4a,(byte)0x41,(byte)0x20,
+ (byte)0x29,(byte)0x29,(byte)0x10,
+ (byte)0x10,(byte)0x18,(byte)0x08,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x20,(byte)0x18,(byte)0x10,
+ (byte)0x7b,(byte)0x5a,(byte)0x52,
+ (byte)0x7b,(byte)0x41,(byte)0x39,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x10,(byte)0x08,(byte)0x00,
+ (byte)0x8b,(byte)0x4a,(byte)0x62,
+ (byte)0x9c,(byte)0x39,(byte)0x62,
+ (byte)0xbd,(byte)0x73,(byte)0x73,
+ (byte)0xcd,(byte)0x94,(byte)0x29,
+ (byte)0xc5,(byte)0x8b,(byte)0x7b,
+ (byte)0xc5,(byte)0x94,(byte)0xcd,
+ (byte)0x62,(byte)0x39,(byte)0x52,
+ (byte)0x10,(byte)0x00,(byte)0x08,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x6a,(byte)0x39,(byte)0x5a,
+ (byte)0xd5,(byte)0xbd,(byte)0xee,
+ (byte)0x83,(byte)0x5a,(byte)0x73,
+ (byte)0x7b,(byte)0x41,(byte)0x62,
+ (byte)0x62,(byte)0x39,(byte)0x52,
+ (byte)0x18,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x08,(byte)0x00,
+ (byte)0x18,(byte)0x10,(byte)0x08,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x10,(byte)0x08,(byte)0x10,
+ (byte)0x18,(byte)0x10,(byte)0x20,
+ (byte)0x10,(byte)0x18,(byte)0x29,
+ (byte)0x18,(byte)0x18,(byte)0x29,
+ (byte)0x08,(byte)0x00,(byte)0x08,
+ (byte)0x08,(byte)0x08,(byte)0x08,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x08,(byte)0x00,
+ (byte)0x18,(byte)0x18,(byte)0x08,
+ (byte)0x29,(byte)0x18,(byte)0x08,
+ (byte)0x39,(byte)0x29,(byte)0x10,
+ (byte)0x29,(byte)0x20,(byte)0x00,
+ (byte)0x39,(byte)0x31,(byte)0x18,
+ (byte)0xa4,(byte)0x94,(byte)0x6a,
+ (byte)0x39,(byte)0x39,(byte)0x18,
+ (byte)0x52,(byte)0x52,(byte)0x31,
+ (byte)0xa4,(byte)0x94,(byte)0x62,
+ (byte)0x8b,(byte)0x7b,(byte)0x5a,
+ (byte)0x62,(byte)0x52,(byte)0x41,
+ (byte)0x31,(byte)0x31,(byte)0x10,
+ (byte)0x52,(byte)0x4a,(byte)0x10,
+ (byte)0x10,(byte)0x10,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x20,(byte)0x18,(byte)0x18,
+ (byte)0x83,(byte)0x52,(byte)0x4a,
+ (byte)0x29,(byte)0x10,(byte)0x10,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x5a,(byte)0x39,(byte)0x4a,
+ (byte)0xa4,(byte)0x4a,(byte)0x6a,
+ (byte)0xa4,(byte)0x5a,(byte)0x62,
+ (byte)0xbd,(byte)0x73,(byte)0x4a,
+ (byte)0xc5,(byte)0x7b,(byte)0x10,
+ (byte)0xc5,(byte)0x94,(byte)0xa4,
+ (byte)0xc5,(byte)0x94,(byte)0xd5,
+ (byte)0xa4,(byte)0x7b,(byte)0xac,
+ (byte)0x29,(byte)0x10,(byte)0x20,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x29,(byte)0x10,(byte)0x20,
+ (byte)0x62,(byte)0x41,(byte)0x5a,
+ (byte)0x31,(byte)0x08,(byte)0x18,
+ (byte)0x62,(byte)0x41,(byte)0x5a,
+ (byte)0x18,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x10,(byte)0x08,(byte)0x08,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x10,(byte)0x08,(byte)0x00,
+ (byte)0x10,(byte)0x18,(byte)0x00,
+ (byte)0x31,(byte)0x20,(byte)0x08,
+ (byte)0x29,(byte)0x20,(byte)0x08,
+ (byte)0x39,(byte)0x31,(byte)0x10,
+ (byte)0x41,(byte)0x41,(byte)0x20,
+ (byte)0x62,(byte)0x5a,(byte)0x39,
+ (byte)0x9c,(byte)0x8b,(byte)0x62,
+ (byte)0x9c,(byte)0x83,(byte)0x52,
+ (byte)0xac,(byte)0x9c,(byte)0x73,
+ (byte)0x39,(byte)0x29,(byte)0x10,
+ (byte)0x4a,(byte)0x41,(byte)0x10,
+ (byte)0x52,(byte)0x52,(byte)0x18,
+ (byte)0x10,(byte)0x10,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x39,(byte)0x20,(byte)0x20,
+ (byte)0x6a,(byte)0x31,(byte)0x39,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x08,(byte)0x08,
+ (byte)0x73,(byte)0x39,(byte)0x52,
+ (byte)0x83,(byte)0x10,(byte)0x20,
+ (byte)0x9c,(byte)0x41,(byte)0x52,
+ (byte)0xac,(byte)0x62,(byte)0x4a,
+ (byte)0xb4,(byte)0x73,(byte)0x41,
+ (byte)0xcd,(byte)0xbd,(byte)0xde,
+ (byte)0xcd,(byte)0xb4,(byte)0xe6,
+ (byte)0xac,(byte)0x83,(byte)0xb4,
+ (byte)0x4a,(byte)0x20,(byte)0x39,
+ (byte)0x10,(byte)0x00,(byte)0x08,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x31,(byte)0x18,(byte)0x29,
+ (byte)0x10,(byte)0x00,(byte)0x08,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x10,(byte)0x00,(byte)0x08,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x18,(byte)0x10,(byte)0x00,
+ (byte)0x08,(byte)0x10,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x52,(byte)0x41,(byte)0x29,
+ (byte)0x6a,(byte)0x52,(byte)0x31,
+ (byte)0x41,(byte)0x39,(byte)0x20,
+ (byte)0x62,(byte)0x52,(byte)0x31,
+ (byte)0x62,(byte)0x52,(byte)0x31,
+ (byte)0xac,(byte)0x9c,(byte)0x6a,
+ (byte)0x6a,(byte)0x62,(byte)0x41,
+ (byte)0x20,(byte)0x18,(byte)0x00,
+ (byte)0x5a,(byte)0x5a,(byte)0x20,
+ (byte)0x41,(byte)0x41,(byte)0x10,
+ (byte)0x18,(byte)0x08,(byte)0x08,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x7b,(byte)0x41,(byte)0x52,
+ (byte)0x18,(byte)0x08,(byte)0x10,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x20,(byte)0x18,(byte)0x18,
+ (byte)0x7b,(byte)0x41,(byte)0x4a,
+ (byte)0x83,(byte)0x20,(byte)0x39,
+ (byte)0xa4,(byte)0x52,(byte)0x8b,
+ (byte)0x8b,(byte)0x29,(byte)0x29,
+ (byte)0xb4,(byte)0x7b,(byte)0x94,
+ (byte)0xcd,(byte)0xbd,(byte)0xe6,
+ (byte)0xcd,(byte)0xb4,(byte)0xe6,
+ (byte)0xcd,(byte)0xbd,(byte)0xee,
+ (byte)0x52,(byte)0x31,(byte)0x4a,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x10,(byte)0x00,(byte)0x08,
+ (byte)0x18,(byte)0x00,(byte)0x08,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x29,(byte)0x18,(byte)0x18,
+ (byte)0xb4,(byte)0x9c,(byte)0x7b,
+ (byte)0x94,(byte)0x7b,(byte)0x52,
+ (byte)0x29,(byte)0x20,(byte)0x08,
+ (byte)0x20,(byte)0x20,(byte)0x08,
+ (byte)0x31,(byte)0x29,(byte)0x08,
+ (byte)0x5a,(byte)0x4a,(byte)0x20,
+ (byte)0x10,(byte)0x10,(byte)0x00,
+ (byte)0x31,(byte)0x31,(byte)0x10,
+ (byte)0x52,(byte)0x4a,(byte)0x20,
+ (byte)0x4a,(byte)0x39,(byte)0x20,
+ (byte)0x18,(byte)0x18,(byte)0x10,
+ (byte)0x52,(byte)0x39,(byte)0x41,
+ (byte)0x62,(byte)0x39,(byte)0x4a,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x62,(byte)0x62,(byte)0x62,
+ (byte)0x94,(byte)0x62,(byte)0x6a,
+ (byte)0x7b,(byte)0x18,(byte)0x39,
+ (byte)0x8b,(byte)0x29,(byte)0x52,
+ (byte)0xbd,(byte)0x8b,(byte)0xac,
+ (byte)0xc5,(byte)0xac,(byte)0xd5,
+ (byte)0xa4,(byte)0x7b,(byte)0x9c,
+ (byte)0x94,(byte)0x62,(byte)0x83,
+ (byte)0x39,(byte)0x10,(byte)0x20,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x31,(byte)0x20,(byte)0x18,
+ (byte)0x52,(byte)0x41,(byte)0x31,
+ (byte)0x29,(byte)0x18,(byte)0x10,
+ (byte)0x20,(byte)0x18,(byte)0x08,
+ (byte)0x31,(byte)0x20,(byte)0x08,
+ (byte)0x20,(byte)0x18,(byte)0x08,
+ (byte)0x20,(byte)0x18,(byte)0x08,
+ (byte)0x39,(byte)0x39,(byte)0x10,
+ (byte)0x5a,(byte)0x52,(byte)0x31,
+ (byte)0x62,(byte)0x52,(byte)0x41,
+ (byte)0x39,(byte)0x39,(byte)0x31,
+ (byte)0x10,(byte)0x08,(byte)0x08,
+ (byte)0x73,(byte)0x41,(byte)0x52,
+ (byte)0x10,(byte)0x08,(byte)0x08,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x08,(byte)0x08,
+ (byte)0x8b,(byte)0x83,(byte)0x83,
+ (byte)0x94,(byte)0x6a,(byte)0x7b,
+ (byte)0x62,(byte)0x20,(byte)0x20,
+ (byte)0x8b,(byte)0x4a,(byte)0x6a,
+ (byte)0xb4,(byte)0x83,(byte)0xa4,
+ (byte)0xbd,(byte)0x94,(byte)0xbd,
+ (byte)0xa4,(byte)0x7b,(byte)0xa4,
+ (byte)0x6a,(byte)0x41,(byte)0x5a,
+ (byte)0x52,(byte)0x29,(byte)0x41,
+ (byte)0x18,(byte)0x08,(byte)0x18,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x10,(byte)0x00,(byte)0x00,
+ (byte)0x10,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x31,(byte)0x29,(byte)0x10,
+ (byte)0x29,(byte)0x18,(byte)0x08,
+ (byte)0x18,(byte)0x08,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x10,(byte)0x08,(byte)0x00,
+ (byte)0x29,(byte)0x18,(byte)0x10,
+ (byte)0x52,(byte)0x4a,(byte)0x41,
+ (byte)0x08,(byte)0x08,(byte)0x08,
+ (byte)0x5a,(byte)0x31,(byte)0x31,
+ (byte)0x20,(byte)0x10,(byte)0x18,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x29,(byte)0x31,(byte)0x29,
+ (byte)0x94,(byte)0x94,(byte)0x94,
+ (byte)0x9c,(byte)0x8b,(byte)0x8b,
+ (byte)0x4a,(byte)0x18,(byte)0x10,
+ (byte)0x83,(byte)0x52,(byte)0x6a,
+ (byte)0xa4,(byte)0x5a,(byte)0x83,
+ (byte)0xa4,(byte)0x73,(byte)0x94,
+ (byte)0x83,(byte)0x5a,(byte)0x73,
+ (byte)0x31,(byte)0x08,(byte)0x18,
+ (byte)0x10,(byte)0x00,(byte)0x08,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x10,(byte)0x00,(byte)0x00,
+ (byte)0x10,(byte)0x00,(byte)0x00,
+ (byte)0x18,(byte)0x00,(byte)0x08,
+ (byte)0x29,(byte)0x08,(byte)0x10,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x10,(byte)0x00,(byte)0x08,
+ (byte)0x39,(byte)0x10,(byte)0x10,
+ (byte)0x20,(byte)0x08,(byte)0x08,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x10,(byte)0x00,(byte)0x00,
+ (byte)0x18,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x20,(byte)0x18,(byte)0x08,
+ (byte)0x10,(byte)0x10,(byte)0x00,
+ (byte)0x20,(byte)0x20,(byte)0x08,
+ (byte)0x41,(byte)0x29,(byte)0x10,
+ (byte)0x10,(byte)0x08,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x08,(byte)0x08,
+ (byte)0x39,(byte)0x31,(byte)0x20,
+ (byte)0x10,(byte)0x08,(byte)0x10,
+ (byte)0x31,(byte)0x20,(byte)0x18,
+ (byte)0x39,(byte)0x20,(byte)0x29,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x20,(byte)0x20,(byte)0x20,
+ (byte)0x62,(byte)0x62,(byte)0x52,
+ (byte)0x6a,(byte)0x62,(byte)0x41,
+ (byte)0x41,(byte)0x29,(byte)0x18,
+ (byte)0x62,(byte)0x39,(byte)0x52,
+ (byte)0x83,(byte)0x4a,(byte)0x62,
+ (byte)0x39,(byte)0x10,(byte)0x20,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x10,(byte)0x00,(byte)0x00,
+ (byte)0x10,(byte)0x00,(byte)0x00,
+ (byte)0x18,(byte)0x00,(byte)0x08,
+ (byte)0x5a,(byte)0x18,(byte)0x29,
+ (byte)0x31,(byte)0x08,(byte)0x08,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x10,(byte)0x00,(byte)0x08,
+ (byte)0x18,(byte)0x00,(byte)0x08,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x10,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x10,(byte)0x10,(byte)0x00,
+ (byte)0x08,(byte)0x08,(byte)0x00,
+ (byte)0x10,(byte)0x10,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x10,(byte)0x08,(byte)0x08,
+ (byte)0x20,(byte)0x08,(byte)0x08,
+ (byte)0x39,(byte)0x20,(byte)0x20,
+ (byte)0x41,(byte)0x20,(byte)0x29,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x31,(byte)0x31,(byte)0x31,
+ (byte)0x62,(byte)0x62,(byte)0x52,
+ (byte)0x8b,(byte)0x83,(byte)0x83,
+ (byte)0x29,(byte)0x18,(byte)0x18,
+ (byte)0x41,(byte)0x29,(byte)0x31,
+ (byte)0x62,(byte)0x39,(byte)0x52,
+ (byte)0x39,(byte)0x20,(byte)0x29,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x10,(byte)0x00,(byte)0x00,
+ (byte)0x10,(byte)0x00,(byte)0x00,
+ (byte)0x20,(byte)0x00,(byte)0x08,
+ (byte)0x41,(byte)0x08,(byte)0x18,
+ (byte)0x29,(byte)0x00,(byte)0x08,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x10,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x20,(byte)0x08,(byte)0x08,
+ (byte)0x41,(byte)0x29,(byte)0x29,
+ (byte)0x41,(byte)0x20,(byte)0x31,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x4a,(byte)0x41,(byte)0x4a,
+ (byte)0xac,(byte)0xa4,(byte)0xac,
+ (byte)0x73,(byte)0x6a,(byte)0x62,
+ (byte)0x10,(byte)0x08,(byte)0x00,
+ (byte)0x10,(byte)0x00,(byte)0x00,
+ (byte)0x39,(byte)0x29,(byte)0x29,
+ (byte)0x29,(byte)0x18,(byte)0x18,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x10,(byte)0x00,(byte)0x00,
+ (byte)0x31,(byte)0x08,(byte)0x18,
+ (byte)0x4a,(byte)0x10,(byte)0x10,
+ (byte)0x18,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x10,(byte)0x00,(byte)0x00,
+ (byte)0x31,(byte)0x08,(byte)0x10,
+ (byte)0x29,(byte)0x08,(byte)0x10,
+ (byte)0x10,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x18,(byte)0x08,(byte)0x08,
+ (byte)0x41,(byte)0x31,(byte)0x29,
+ (byte)0x41,(byte)0x29,(byte)0x29,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x41,(byte)0x41,(byte)0x41,
+ (byte)0x7b,(byte)0x6a,(byte)0x6a,
+ (byte)0x62,(byte)0x5a,(byte)0x52,
+ (byte)0x10,(byte)0x08,(byte)0x08,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x10,(byte)0x08,(byte)0x08,
+ (byte)0x18,(byte)0x10,(byte)0x10,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x10,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x08,(byte)0x08,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x39,(byte)0x29,(byte)0x20,
+ (byte)0x39,(byte)0x20,(byte)0x20,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x4a,(byte)0x4a,(byte)0x4a,
+ (byte)0x5a,(byte)0x5a,(byte)0x52,
+ (byte)0x41,(byte)0x39,(byte)0x31,
+ (byte)0x20,(byte)0x20,(byte)0x20,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x10,(byte)0x08,(byte)0x08,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x18,(byte)0x10,(byte)0x08,
+ (byte)0x41,(byte)0x29,(byte)0x18,
+ (byte)0x20,(byte)0x18,(byte)0x18,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x20,(byte)0x20,(byte)0x20,
+ (byte)0x39,(byte)0x39,(byte)0x31,
+ (byte)0x41,(byte)0x41,(byte)0x39,
+ (byte)0x52,(byte)0x52,(byte)0x4a,
+ (byte)0x20,(byte)0x20,(byte)0x20,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x08,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x08,
+ (byte)0x18,(byte)0x00,(byte)0x10,
+ (byte)0x10,(byte)0x00,(byte)0x08,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x08,(byte)0x08,
+ (byte)0x10,(byte)0x18,(byte)0x10,
+ (byte)0x29,(byte)0x18,(byte)0x10,
+ (byte)0x39,(byte)0x20,(byte)0x10,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x10,(byte)0x10,(byte)0x10,
+ (byte)0x29,(byte)0x29,(byte)0x20,
+ (byte)0x41,(byte)0x41,(byte)0x41,
+ (byte)0x29,(byte)0x29,(byte)0x20,
+ (byte)0x10,(byte)0x10,(byte)0x08,
+ (byte)0x18,(byte)0x08,(byte)0x10,
+ (byte)0x29,(byte)0x08,(byte)0x20,
+ (byte)0x29,(byte)0x10,(byte)0x29,
+ (byte)0x18,(byte)0x10,(byte)0x20,
+ (byte)0x10,(byte)0x10,(byte)0x18,
+ (byte)0x08,(byte)0x08,(byte)0x10,
+ (byte)0x08,(byte)0x00,(byte)0x08,
+ (byte)0x08,(byte)0x08,(byte)0x10,
+ (byte)0x00,(byte)0x00,(byte)0x08,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x08,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x10,(byte)0x10,(byte)0x08,
+ (byte)0x18,(byte)0x18,(byte)0x10,
+ (byte)0x18,(byte)0x18,(byte)0x10,
+ (byte)0x29,(byte)0x20,(byte)0x10,
+ (byte)0x31,(byte)0x18,(byte)0x08,
+ (byte)0x18,(byte)0x08,(byte)0x08,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x08,(byte)0x08,
+ (byte)0x10,(byte)0x10,(byte)0x10,
+ (byte)0x10,(byte)0x10,(byte)0x08,
+ (byte)0x08,(byte)0x08,(byte)0x08,
+ (byte)0x18,(byte)0x10,(byte)0x10,
+ (byte)0x18,(byte)0x10,(byte)0x10,
+ (byte)0x10,(byte)0x08,(byte)0x10,
+ (byte)0x10,(byte)0x10,(byte)0x18,
+ (byte)0x10,(byte)0x10,(byte)0x20,
+ (byte)0x10,(byte)0x10,(byte)0x18,
+ (byte)0x10,(byte)0x10,(byte)0x18,
+ (byte)0x08,(byte)0x00,(byte)0x08,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x08,
+ (byte)0x00,(byte)0x00,(byte)0x08,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x20,(byte)0x20,(byte)0x18,
+ (byte)0x29,(byte)0x29,(byte)0x20,
+ (byte)0x31,(byte)0x31,(byte)0x20,
+ (byte)0x39,(byte)0x31,(byte)0x20,
+ (byte)0x41,(byte)0x31,(byte)0x29,
+ (byte)0x41,(byte)0x31,(byte)0x18,
+ (byte)0x20,(byte)0x10,(byte)0x08,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x08,
+ (byte)0x08,(byte)0x08,(byte)0x08,
+ (byte)0x08,(byte)0x08,(byte)0x08,
+ (byte)0x08,(byte)0x08,(byte)0x08,
+ (byte)0x08,(byte)0x10,(byte)0x08,
+ (byte)0x10,(byte)0x10,(byte)0x08,
+ (byte)0x08,(byte)0x08,(byte)0x08,
+ (byte)0x08,(byte)0x08,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x20,(byte)0x20,(byte)0x18,
+ (byte)0x4a,(byte)0x41,(byte)0x31,
+ (byte)0x4a,(byte)0x4a,(byte)0x39,
+ (byte)0x4a,(byte)0x41,(byte)0x39,
+ (byte)0x4a,(byte)0x41,(byte)0x31,
+ (byte)0x39,(byte)0x29,(byte)0x20,
+ (byte)0x29,(byte)0x18,(byte)0x10,
+ (byte)0x18,(byte)0x08,(byte)0x08,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x08,(byte)0x00,(byte)0x08,
+ (byte)0x10,(byte)0x00,(byte)0x08,
+ (byte)0x18,(byte)0x08,(byte)0x08,
+ (byte)0x29,(byte)0x18,(byte)0x18,
+ (byte)0x20,(byte)0x18,(byte)0x18,
+ (byte)0x10,(byte)0x10,(byte)0x08,
+ (byte)0x18,(byte)0x10,(byte)0x10,
+ (byte)0x20,(byte)0x18,(byte)0x18,
+ (byte)0x41,(byte)0x41,(byte)0x31,
+ (byte)0x52,(byte)0x4a,(byte)0x39,
+ (byte)0x39,(byte)0x29,(byte)0x20,
+ (byte)0x29,(byte)0x18,(byte)0x10,
+ (byte)0x20,(byte)0x10,(byte)0x10,
+ (byte)0x10,(byte)0x08,(byte)0x08,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x18,(byte)0x08,(byte)0x10,
+ (byte)0x10,(byte)0x10,(byte)0x10,
+ (byte)0x08,(byte)0x08,(byte)0x08,
+ (byte)0x08,(byte)0x08,(byte)0x00,
+ (byte)0x10,(byte)0x10,(byte)0x10,
+ (byte)0x20,(byte)0x18,(byte)0x18,
+ (byte)0x10,(byte)0x08,(byte)0x08,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,
+ };
+
+ public DemoTex1()
+ {
+ }
+
+ public void dispose()
+ {
+ }
+
+ /* GL_RGBA, etc. arg #3 in glTexImage2D() */
+ public int getComponents()
+ {
+ return(GL_RGB);
+ }
+
+ /* arg #4 in glTexImage2D() */
+ public int getWidth()
+ {
+ return(width);
+ }
+
+ /* arg #5 in glTexImage2D() */
+ public int getHeight()
+ {
+ return(height);
+ }
+
+ /* GL_RGBA, etc. arg #7 in glTexImage2D() */
+ public int getFormat()
+ {
+ return(GL_RGB);
+ }
+
+ /* GL_UNSIGNED_BYTE, etc. arg #8 in glTexImage2D() */
+ public int getType()
+ {
+ return(GL_UNSIGNED_BYTE);
+ }
+
+ /* arg #9 in glTexImage2D() */
+ public byte[] getBits()
+ {
+ return(bits);
+ }
+}
+
diff --git a/demos/RonsDemos/FullScreenGears.java b/demos/RonsDemos/FullScreenGears.java new file mode 100644 index 0000000..e0d6151 --- /dev/null +++ b/demos/RonsDemos/FullScreenGears.java @@ -0,0 +1,18 @@ +import java.applet.*; +import java.awt.*; +import java.awt.event.*; + +public class FullScreenGears { + public static void main(String[] args) { + final Applet a = new gears(); /*from ronsdemos*/ + final Window w = new Window(new Frame()); + w.setLayout(new BorderLayout()); + w.add("Center",a); + a.init(); + a.start(); + Toolkit tk = Toolkit.getDefaultToolkit(); + Dimension screensize = tk.getScreenSize(); + w.setBounds(0,0,screensize.width,screensize.height); + w.setVisible(true); + } +} diff --git a/demos/RonsDemos/GL4JDemos.pvk b/demos/RonsDemos/GL4JDemos.pvk Binary files differnew file mode 100644 index 0000000..46cc77a --- /dev/null +++ b/demos/RonsDemos/GL4JDemos.pvk diff --git a/demos/RonsDemos/GL4JDemos.spc b/demos/RonsDemos/GL4JDemos.spc Binary files differnew file mode 100644 index 0000000..643bed1 --- /dev/null +++ b/demos/RonsDemos/GL4JDemos.spc diff --git a/demos/RonsDemos/HardCodedTexture.java b/demos/RonsDemos/HardCodedTexture.java new file mode 100644 index 0000000..6395c8a --- /dev/null +++ b/demos/RonsDemos/HardCodedTexture.java @@ -0,0 +1,31 @@ +/**
+ * @(#) HardCodedTexture.java
+ * @(#) author: Ronald B. Cemer
+ * @(#) version: 1.0
+ */
+
+import java.io.*;
+
+public interface HardCodedTexture
+{
+ public void dispose();
+
+ /* GL_RGBA, etc. arg #3 in glTexImage2D() */
+ public int getComponents();
+
+ /* arg #4 in glTexImage2D() */
+ public int getWidth();
+
+ /* arg #5 in glTexImage2D() */
+ public int getHeight();
+
+ /* GL_RGBA, etc. arg #7 in glTexImage2D() */
+ public int getFormat();
+
+ /* GL_UNSIGNED_BYTE, etc. arg #8 in glTexImage2D() */
+ public int getType();
+
+ /* arg #9 in glTexImage2D() */
+ public byte[] getBits();
+}
+
diff --git a/demos/RonsDemos/MatrixFuncs.java b/demos/RonsDemos/MatrixFuncs.java new file mode 100644 index 0000000..75493a2 --- /dev/null +++ b/demos/RonsDemos/MatrixFuncs.java @@ -0,0 +1,200 @@ +/**
+ * @(#) MatrixFuncs.java
+ * @(#) author: Ronald B. Cemer
+ * @(#) version: 1.0
+ */
+
+import java.io.*;
+
+public class MatrixFuncs
+{
+ public static final float M_PI = 3.14159265359f;
+
+ // Given the angle in degs, create a 4x4 matrix
+ // in mtx which rotates around the X axis.
+ public void rotateAroundX(float degs, float mtx[])
+ {
+ float rads, rsin, rcos;
+
+ rads = degs*(M_PI/180.0f);
+ rsin = (float)Math.sin(rads);
+ rcos = (float)Math.cos(rads);
+ mtx[0] = 1.0f;
+ mtx[1] = 0.0f;
+ mtx[2] = 0.0f;
+ mtx[3] = 0.0f;
+ mtx[4] = 0.0f;
+ mtx[5] = rcos;
+ mtx[6] = rsin;
+ mtx[7] = 0.0f;
+ mtx[8] = 0.0f;
+ mtx[9] = -rsin;
+ mtx[10] = rcos;
+ mtx[11] = 0.0f;
+ mtx[12] = 0.0f;
+ mtx[13] = 0.0f;
+ mtx[14] = 0.0f;
+ mtx[15] = 1.0f;
+ }
+
+ // Given the angle in degs, create a 4x4 matrix
+ // in mtx which rotates around the Y axis.
+ public void rotateAroundY(float degs, float mtx[])
+ {
+ float rads, rsin, rcos;
+
+ rads = degs*(M_PI/180.0f);
+ rsin = (float)Math.sin(rads);
+ rcos = (float)Math.cos(rads);
+ mtx[0] = rcos;
+ mtx[1] = 0.0f;
+ mtx[2] = -rsin;
+ mtx[3] = 0.0f;
+ mtx[4] = 0.0f;
+ mtx[5] = 1.0f;
+ mtx[6] = 0.0f;
+ mtx[7] = 0.0f;
+ mtx[8] = rsin;
+ mtx[9] = 0.0f;
+ mtx[10] = rcos;
+ mtx[11] = 0.0f;
+ mtx[12] = 0.0f;
+ mtx[13] = 0.0f;
+ mtx[14] = 0.0f;
+ mtx[15] = 1.0f;
+ }
+
+ // Given the angle in degs, create a 4x4 matrix
+ // in mtx which rotates around the Z axis.
+ public void rotateAroundZ(float degs, float mtx[])
+ {
+ float rads, rsin, rcos;
+
+ rads = degs*(M_PI/180.0f);
+ rsin = (float)Math.sin(rads);
+ rcos = (float)Math.cos(rads);
+ mtx[0] = rcos;
+ mtx[1] = rsin;
+ mtx[2] = 0.0f;
+ mtx[3] = 0.0f;
+ mtx[4] = -rsin;
+ mtx[5] = rcos;
+ mtx[6] = 0.0f;
+ mtx[7] = 0.0f;
+ mtx[8] = 0.0f;
+ mtx[9] = 0.0f;
+ mtx[10] = 1.0f;
+ mtx[11] = 0.0f;
+ mtx[12] = 0.0f;
+ mtx[13] = 0.0f;
+ mtx[14] = 0.0f;
+ mtx[15] = 1.0f;
+ }
+
+ // Given two 4x4 matrices in mtx1 and mtx2, multiply
+ // them and put the result in dest.
+ // This routine uses a temporary buffer for the result,
+ // so if dest is the same as mtx1 or mtx2, it will still
+ // work properly.
+ public void multiplyMatrices(float mtx1[], float mtx2[], float dest[])
+ {
+ float nmtx[] = new float[16];
+
+ nmtx[0] =
+ (mtx1[0]*mtx2[0]) +
+ (mtx1[1]*mtx2[4]) +
+ (mtx1[2]*mtx2[8]) +
+ (mtx1[3]*mtx2[12]);
+ nmtx[1] =
+ (mtx1[0]*mtx2[1]) +
+ (mtx1[1]*mtx2[5]) +
+ (mtx1[2]*mtx2[9]) +
+ (mtx1[3]*mtx2[13]);
+ nmtx[2] =
+ (mtx1[0]*mtx2[2]) +
+ (mtx1[1]*mtx2[6]) +
+ (mtx1[2]*mtx2[10]) +
+ (mtx1[3]*mtx2[14]);
+ nmtx[3] =
+ (mtx1[0]*mtx2[3]) +
+ (mtx1[1]*mtx2[7]) +
+ (mtx1[2]*mtx2[11]) +
+ (mtx1[3]*mtx2[15]);
+ nmtx[4] =
+ (mtx1[4]*mtx2[0]) +
+ (mtx1[5]*mtx2[4]) +
+ (mtx1[6]*mtx2[8]) +
+ (mtx1[7]*mtx2[12]);
+ nmtx[5] =
+ (mtx1[4]*mtx2[1]) +
+ (mtx1[5]*mtx2[5]) +
+ (mtx1[6]*mtx2[9]) +
+ (mtx1[7]*mtx2[13]);
+ nmtx[6] =
+ (mtx1[4]*mtx2[2]) +
+ (mtx1[5]*mtx2[6]) +
+ (mtx1[6]*mtx2[10]) +
+ (mtx1[7]*mtx2[14]);
+ nmtx[7] =
+ (mtx1[4]*mtx2[3]) +
+ (mtx1[5]*mtx2[7]) +
+ (mtx1[6]*mtx2[11]) +
+ (mtx1[7]*mtx2[15]);
+ nmtx[8] =
+ (mtx1[8]*mtx2[0]) +
+ (mtx1[9]*mtx2[4]) +
+ (mtx1[10]*mtx2[8]) +
+ (mtx1[11]*mtx2[12]);
+ nmtx[9] =
+ (mtx1[8]*mtx2[1]) +
+ (mtx1[9]*mtx2[5]) +
+ (mtx1[10]*mtx2[9]) +
+ (mtx1[11]*mtx2[13]);
+ nmtx[10] =
+ (mtx1[8]*mtx2[2]) +
+ (mtx1[9]*mtx2[6]) +
+ (mtx1[10]*mtx2[10]) +
+ (mtx1[11]*mtx2[14]);
+ nmtx[11] =
+ (mtx1[8]*mtx2[3]) +
+ (mtx1[9]*mtx2[7]) +
+ (mtx1[10]*mtx2[11]) +
+ (mtx1[11]*mtx2[15]);
+ nmtx[12] =
+ (mtx1[12]*mtx2[0]) +
+ (mtx1[13]*mtx2[4]) +
+ (mtx1[14]*mtx2[8]) +
+ (mtx1[15]*mtx2[12]);
+ nmtx[13] =
+ (mtx1[12]*mtx2[1]) +
+ (mtx1[13]*mtx2[5]) +
+ (mtx1[14]*mtx2[9]) +
+ (mtx1[15]*mtx2[13]);
+ nmtx[14] =
+ (mtx1[12]*mtx2[2]) +
+ (mtx1[13]*mtx2[6]) +
+ (mtx1[14]*mtx2[10]) +
+ (mtx1[15]*mtx2[14]);
+ nmtx[15] =
+ (mtx1[12]*mtx2[3]) +
+ (mtx1[13]*mtx2[7]) +
+ (mtx1[14]*mtx2[11]) +
+ (mtx1[15]*mtx2[15]);
+ dest[0] = nmtx[0];
+ dest[1] = nmtx[1];
+ dest[2] = nmtx[2];
+ dest[3] = nmtx[3];
+ dest[4] = nmtx[4];
+ dest[5] = nmtx[5];
+ dest[6] = nmtx[6];
+ dest[7] = nmtx[7];
+ dest[8] = nmtx[8];
+ dest[9] = nmtx[9];
+ dest[10] = nmtx[10];
+ dest[11] = nmtx[11];
+ dest[12] = nmtx[12];
+ dest[13] = nmtx[13];
+ dest[14] = nmtx[14];
+ dest[15] = nmtx[15];
+ }
+}
diff --git a/demos/RonsDemos/animApplet.skel b/demos/RonsDemos/animApplet.skel new file mode 100644 index 0000000..ebbd52e --- /dev/null +++ b/demos/RonsDemos/animApplet.skel @@ -0,0 +1,125 @@ +/**
+ * Skeleton for animated applets (applets which automatically and
+ * continually redraw without intervention).
+ */
+
+/**
+ * @(#) [place applet name here].java
+ * @(#) author: [place author here] (converted to Java by Ron Cemer)
+ */
+
+import java.applet.*;
+import java.awt.*;
+import java.awt.event.*;
+import java.lang.*;
+import java.util.*;
+import java.io.*;
+import java.util.*;
+import gl4java.GLContext;
+import gl4java.awt.GLAnimCanvas;
+
+public class myapplet extends Applet
+{
+ myappletCanvas canvas = null;
+
+
+ /* Initialize the applet */
+
+
+ public void init()
+ {
+ Dimension d = getSize();
+ setLayout(new BorderLayout());
+ canvas = new myappletCanvas(d.width, d.height);
+ add("Center", canvas);
+ }
+
+
+ /* Start the applet */
+
+
+ public void start()
+ {
+ canvas.start();
+ }
+
+
+ /* Stop the applet */
+
+
+ public void stop()
+ {
+ canvas.stop();
+ }
+
+
+ /* Destroy the applet */
+
+
+ public void destroy()
+ {
+ canvas.stop();
+ canvas.destroy();
+ }
+
+
+ /* Local GLAnimCanvas extension class */
+
+
+ private class myappletCanvas extends GLAnimCanvas
+ {
+ public myappletCanvas(int w, int h)
+ {
+ super(w, h);
+ GLContext.gljNativeDebug = false;
+ GLContext.gljClassDebug = false;
+ setAnimateFps(60.0);
+ }
+
+ public void preInit()
+ {
+ doubleBuffer = true;
+ stereoView = false;
+ }
+
+ public void init()
+ {
+ System.out.println("init(): " + this);
+ reshape(getSize().width, getSize().height);
+
+// Put OpenGL initialization code here.
+
+ glj.gljCheckGL();
+ }
+
+ public void destroy()
+ {
+ System.out.println("destroy(): " + this);
+
+// Put any special takedown code here.
+
+ cvsDispose();
+ }
+
+ public void reshape(int width, int height)
+ {
+ gl.glViewport(0,0,width,height);
+
+// Put any custom reshape code here.
+
+ }
+
+ public void display()
+ {
+ if (glj.gljMakeCurrent(true) == false) return;
+
+// Put drawing code here.
+
+ glj.gljSwap();
+ glj.gljCheckGL();
+ glj.gljFree();
+
+ if (!isSuspended()) repaint(); // Animate at full speed.
+ }
+ }
+}
diff --git a/demos/RonsDemos/dinoshade.html b/demos/RonsDemos/dinoshade.html new file mode 100644 index 0000000..1b4fe08 --- /dev/null +++ b/demos/RonsDemos/dinoshade.html @@ -0,0 +1,21 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
+ <title>Dinoshade by Mark J. Kilgard; ported to Java by Ron Cemer</title>
+</head>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+Dinoshade applet
+<br>Originially written by Mark J. Kilgard
+<br>Ported to Java by Ron Cemer
+<br>Press and hold left mouse button, then drag to rotate view.
+<br>Press and hold left mouse button, then press and hold right mouse button, then drag to rotate light.
+<br>Click right mouse button for a menu of options.
+<br>NOTE: If your system does not support hardware-accelerated stenciling, this demo will run slowly unless you disable stenciling for shadows and reflections.
+<br>
+<applet code="dinoshade.class" width=400 height=400>
+</applet>
+<hr>
+</body>
+</html>
diff --git a/demos/RonsDemos/dinoshade.java b/demos/RonsDemos/dinoshade.java new file mode 100755 index 0000000..344fd00 --- /dev/null +++ b/demos/RonsDemos/dinoshade.java @@ -0,0 +1,1104 @@ +/**
+ * @(#) dinoshade.java
+ * @(#) author: Mark J. Kilgard (converted to Java by Ron Cemer)
+ */
+
+/* Copyright (c) Mark J. Kilgard, 1994, 1997. */
+
+/* This program is freely distributable without licensing fees
+ and is provided without guarantee or warrantee expressed or
+ implied. This program is -not- in the public domain. */
+
+/* Example for PC game developers to show how to *combine* texturing,
+ reflections, and projected shadows all in real-time with OpenGL.
+ Robust reflections use stenciling. Robust projected shadows
+ use both stenciling and polygon offset. PC game programmers
+ should realize that neither stenciling nor polygon offset are
+ supported by Direct3D, so these real-time rendering algorithms
+ are only really viable with OpenGL.
+
+ The program has modes for disabling the stenciling and polygon
+ offset uses. It is worth running this example with these features
+ toggled off so you can see the sort of artifacts that result.
+
+ Notice that the floor texturing, reflections, and shadowing
+ all co-exist properly. */
+
+/* When you run this program: Left mouse button controls the
+ view. Middle mouse button controls light position (left &
+ right rotates light around dino; up & down moves light
+ position up and down). Right mouse button pops up menu. */
+
+/* Check out the comments in the "redraw" routine to see how the
+ reflection blending and surface stenciling is done. You can
+ also see in "redraw" how the projected shadows are rendered,
+ including the use of stenciling and polygon offset. */
+
+import java.applet.*;
+import java.awt.*;
+import java.awt.event.*;
+import java.lang.*;
+import java.util.*;
+import java.io.*;
+import java.util.*;
+import gl4java.GLContext;
+import gl4java.awt.GLAnimCanvas;
+import gl4java.applet.SimpleGLAnimApplet1;
+
+public class dinoshade extends SimpleGLAnimApplet1
+{
+ static final float[][] bodyVerts =
+ {
+ { 0.0f, 3.0f, 0.0f},
+ { 1.0f, 1.0f, 0.0f},
+ { 5.0f, 1.0f, 0.0f},
+ { 8.0f, 4.0f, 0.0f},
+ { 10.0f, 4.0f, 0.0f},
+ { 11.0f, 5.0f, 0.0f},
+ { 11.0f, 11.5f, 0.0f},
+ { 13.0f, 12.0f, 0.0f},
+ { 13.0f, 13.0f, 0.0f},
+ { 10.0f, 13.5f, 0.0f},
+ { 13.0f, 14.0f, 0.0f},
+ { 13.0f, 15.0f, 0.0f},
+ { 11.0f, 16.0f, 0.0f},
+ { 8.0f, 16.0f, 0.0f},
+ { 7.0f, 15.0f, 0.0f},
+ { 7.0f, 13.0f, 0.0f},
+ { 8.0f, 12.0f, 0.0f},
+ { 7.0f, 11.0f, 0.0f},
+ { 6.0f, 6.0f, 0.0f},
+ { 4.0f, 3.0f, 0.0f},
+ { 3.0f, 2.0f, 0.0f},
+ { 1.0f, 2.0f, 0.0f},
+ };
+
+ static final int[][] bodyTris =
+ {
+ { 1, 0, 21 },
+ { 1, 21, 2 },
+ { 21, 20, 2 },
+ { 20, 19, 2 },
+ { 19, 3, 2 },
+ { 19, 18, 3 },
+ { 18, 4, 3 },
+ { 18, 5, 4 },
+ { 18, 6, 5 },
+ { 18, 17, 6 },
+ { 17, 16, 6 },
+ { 16, 7, 6 },
+ { 16, 8, 7 },
+ { 16, 15, 8 },
+ { 15, 9, 8 },
+ { 15, 14, 9 },
+ { 14, 13, 9 },
+ { 9, 13, 12 },
+ { 9, 12, 11 },
+ { 11, 10, 9 },
+ };
+
+ static final float[][] armVerts =
+ {
+ { 8.0f, 10.0f, 0.0f},
+ { 9.0f, 9.0f, 0.0f},
+ { 10.0f, 9.0f, 0.0f},
+ { 13.0f, 8.0f, 0.0f},
+ { 14.0f, 9.0f, 0.0f},
+ { 16.0f, 9.0f, 0.0f},
+ { 15.0f, 9.5f, 0.0f},
+ { 16.0f, 10.0f, 0.0f},
+ { 15.0f, 10.0f, 0.0f},
+ { 15.5f, 11.0f, 0.0f},
+ { 14.5f, 10.0f, 0.0f},
+ { 14.0f, 11.0f, 0.0f},
+ { 14.0f, 10.0f, 0.0f},
+ { 13.0f, 9.0f, 0.0f},
+ { 11.0f, 11.0f, 0.0f},
+ { 9.0f, 11.0f, 0.0f},
+ };
+
+ static final int[][] armTris =
+ {
+ { 0, 15, 1 },
+ { 15, 2, 1 },
+ { 15, 14, 2 },
+ { 14, 13, 2 },
+ { 13, 3, 2 },
+ { 13, 4, 3 },
+ { 13, 12, 4 },
+ { 12, 11, 10 },
+ { 12, 10, 4 },
+ { 10, 6, 4 },
+ { 6, 5, 4 },
+ { 8, 7, 6 },
+ { 10, 8, 6 },
+ { 10, 9, 8 },
+ };
+
+ static final float[][] legVerts =
+ {
+ { 8.0f, 6.0f, 0.0f},
+ { 8.0f, 4.0f, 0.0f},
+ { 9.0f, 3.0f, 0.0f},
+ { 9.0f, 2.0f, 0.0f},
+ { 8.0f, 1.0f, 0.0f},
+ { 8.0f, 0.5f, 0.0f},
+ { 9.0f, 0.0f, 0.0f},
+ { 12.0f, 0.0f, 0.0f},
+ { 10.0f, 1.0f, 0.0f},
+ { 10.0f, 2.0f, 0.0f},
+ { 12.0f, 4.0f, 0.0f},
+ { 11.0f, 6.0f, 0.0f},
+ { 10.0f, 7.0f, 0.0f},
+ { 9.0f, 7.0f, 0.0f},
+ };
+
+ static final int[][] legTris =
+ {
+ { 6, 5, 7 },
+ { 5, 8, 7 },
+ { 5, 4, 8 },
+ { 4, 3, 8 },
+ { 3, 9, 8 },
+ { 3, 2, 9 },
+ { 2, 10, 9 },
+ { 2, 1, 10 },
+ { 1, 0, 10 },
+ { 0, 11, 10 },
+ { 0, 12, 11 },
+ { 0, 13, 12 },
+ };
+
+ static final float[][] eyeVerts =
+ {
+ { 8.75f, 15.0f, 0.0f},
+ { 9.0f, 14.7f, 0.0f},
+ { 9.6f, 14.7f, 0.0f},
+ { 10.1f, 15.0f, 0.0f},
+ { 9.6f, 15.25f, 0.0f},
+ { 9.0f, 15.25f, 0.0f},
+ };
+
+ static final int[][] eyeTris =
+ {
+ { 1, 0, 2 },
+ { 0, 5, 2 },
+ { 5, 4, 2 },
+ { 4, 3, 2 },
+ };
+
+ static final float floorVertices[][] =
+ {
+ { -20.0f, 0.0f, 20.0f },
+ { 20.0f, 0.0f, 20.0f },
+ { 20.0f, 0.0f, -20.0f },
+ { -20.0f, 0.0f, -20.0f },
+ };
+
+
+ /* Initialize the applet */
+
+
+ public void init()
+ {
+ super.init();
+ Dimension d = getSize();
+ canvas = new dinoshadeCanvas(d.width, d.height);
+ add("Center", canvas);
+ }
+
+
+ public static void main( String args[] ) {
+ dinoshade applet =
+ new dinoshade();
+
+ Frame f = new Frame("dinoshade");
+
+ f.addWindowListener( new WindowAdapter()
+ {
+ public void windowClosed(WindowEvent e)
+ {
+ System.exit(0);
+ }
+ public void windowClosing(WindowEvent e)
+ {
+ windowClosed(e);
+ }
+ }
+ );
+
+ f.setLayout(new BorderLayout());
+ f.add("Center", applet);
+ applet.setSize(500,300);
+ applet.init(); + applet.start();
+ Dimension ps = applet.getPreferredSize();
+ f.setBounds(-100,-100,99,99);
+ f.setVisible(true);
+ f.setVisible(false);
+ Insets i = f.getInsets();
+ f.setBounds(0,0,
+ ps.width+i.left+i.right,
+ ps.height+i.top+i.bottom);
+ f.setVisible(true);
+ }
+
+ /* Local GLAnimCanvas extension class */
+
+
+ private class dinoshadeCanvas extends GLAnimCanvas
+ implements MouseListener, MouseMotionListener, ActionListener
+ {
+ private static final double M_PI = 3.14159265;
+
+ // Menu options:
+ private static final String M_NONE = "-----------------------";
+ private static final String M_MOTION = "Toggle motion";
+ private static final String M_LIGHT = "Toggle light";
+ private static final String M_TEXTURE = "Toggle texture";
+ private static final String M_SHADOWS = "Toggle shadows";
+ private static final String M_REFLECTION = "Toggle reflection";
+ private static final String M_DINOSAUR = "Toggle dinosaur";
+ private static final String M_STENCIL_REFLECTION = "Toggle reflection stenciling";
+ private static final String M_STENCIL_SHADOW = "Toggle shadow stenciling";
+ private static final String M_OFFSET_SHADOW = "Toggle shadow offset";
+ private static final String M_POSITIONAL = "Positional light";
+ private static final String M_DIRECTIONAL = "Directional light";
+
+ private PopupMenu menu = null;
+ private boolean menu_showing = false;
+ private boolean save_suspended = false;
+
+ /* Variables controlling various rendering modes. */
+ private boolean stencilReflection = true, stencilShadow = true, offsetShadow = true;
+ private boolean renderShadow = true, renderDinosaur = true, renderReflection = true;
+ private boolean linearFiltering = false, useTexture = true;
+// private boolean useMipmaps = false;
+ private boolean lightSwitch = true;
+ private boolean directionalLight = true;
+
+ /* Time varying or user-controled variables. */
+ private float jump = 0.0f;
+ private float lightAngle = 0.0f, lightHeight = 20.0f;
+ private float angle = -150.0f; /* in degrees */
+ private float angle2 = 30.0f; /* in degrees */
+
+ private boolean moving = false;
+ private int startx, starty;
+ private boolean lightMoving = false;
+ private int lightStartX, lightStartY;
+
+ private final float bodyWidth = 3.0f;
+
+ private final float[] lightPosition = new float[4];
+ private final float lightColor[] = {0.8f, 1.0f, 0.8f, 1.0f}; /* green-tinted */
+ private final float skinColor[] = {0.1f, 1.0f, 0.1f, 1.0f};
+ private final float eyeColor[] = {1.0f, 0.2f, 0.2f, 1.0f};
+ private final int X = 0, Y = 1, Z = 2, W = 3;
+ private final int A = 0, B = 1, C = 2, D = 3;
+
+ /* Enumerants for refering to display lists. */
+ private static final int
+ BODY_SIDE = 1, BODY_EDGE = 2, BODY_WHOLE = 3,
+ ARM_SIDE = 4, ARM_EDGE = 5, ARM_WHOLE = 6,
+ LEG_SIDE = 7, LEG_EDGE = 8, LEG_WHOLE = 9,
+ EYE_SIDE = 10, EYE_EDGE = 11, EYE_WHOLE = 12;
+ private float floorPlane[] = new float[4];
+ private float floorShadow[] = new float[16];
+
+ public dinoshadeCanvas(int w, int h)
+ {
+ super(w, h);
+ GLContext.gljNativeDebug = false;
+ GLContext.gljClassDebug = false;
+ setAnimateFps(30.0);
+ }
+
+ public void preInit()
+ {
+ doubleBuffer = true;
+ stereoView = false;
+ stencilBits = 3; + }
+
+ public void init()
+ {
+ int [] res=new int[6]; + + gl.glGetIntegerv(GL_STENCIL_BITS,res); + + System.out.println("init(): " + this + "\n\t" + + "Stencil bits are "+res[0] +"\n\t" + + "IsOwnCreatedWindow: "+createOwnWindow); + + reshape(getSize().width, getSize().height);
+
+ makeDinosaur();
+
+ gl.glPolygonOffset(-2.0f, -1.0f);
+
+ gl.glEnable(GL_CULL_FACE);
+ gl.glEnable(GL_DEPTH_TEST);
+ gl.glEnable(GL_TEXTURE_2D);
+ gl.glLineWidth(3.0f);
+
+ gl.glMatrixMode(GL_PROJECTION);
+ glu.gluPerspective
+ ( /* field of view in degree */ 40.0f,
+ /* aspect ratio */ 1.0f,
+ /* Z near */ 20.0f,
+ /* Z far */ 100.0f);
+ gl.glMatrixMode(GL_MODELVIEW);
+ glu.gluLookAt
+ (0.0f, 8.0f, 60.0f, /* eye is at (0,8,60) */
+ 0.0f, 8.0f, 0.0f, /* center is at (0,8,0) */
+ 0.0f, 1.0f, 0.0f); /* up is in postivie Y direction */
+
+ gl.glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 1);
+ gl.glLightfv(GL_LIGHT0, GL_DIFFUSE, lightColor);
+ gl.glLightf(GL_LIGHT0, GL_CONSTANT_ATTENUATION, 0.1f);
+ gl.glLightf(GL_LIGHT0, GL_LINEAR_ATTENUATION, 0.05f);
+ gl.glEnable(GL_LIGHT0);
+ gl.glEnable(GL_LIGHTING);
+
+ makeFloorTexture();
+
+ /* Setup floor plane for projected shadow calculations. */
+ findPlane
+ (floorPlane,
+ floorVertices[1],
+ floorVertices[2],
+ floorVertices[3]);
+
+ glj.gljCheckGL();
+
+ menu = new PopupMenu("Options");
+ menu.add(M_MOTION);
+ menu.add(M_NONE);
+ menu.add(M_LIGHT);
+ menu.add(M_TEXTURE);
+ menu.add(M_SHADOWS);
+ menu.add(M_REFLECTION);
+ menu.add(M_DINOSAUR);
+ menu.add(M_NONE);
+ menu.add(M_STENCIL_REFLECTION);
+ menu.add(M_STENCIL_SHADOW);
+ menu.add(M_OFFSET_SHADOW);
+ menu.add(M_NONE);
+ menu.add(M_POSITIONAL);
+ menu.add(M_DIRECTIONAL);
+ menu.addActionListener(this);
+ add(menu);
+
+ addMouseListener(this);
+ addMouseMotionListener(this);
+ }
+
+ public void doCleanup()
+ {
+ removeMouseListener(this);
+ removeMouseMotionListener(this);
+ menu.removeActionListener(this);
+ }
+
+ public void reshape(int width, int height)
+ {
+ gl.glViewport(0,0,width,height);
+ }
+
+ public void display()
+ {
+ if (glj.gljMakeCurrent() == false) return;
+
+ if (!isSuspended())
+ {
+ long ltime =
+ System.currentTimeMillis() % 3142L; //approximate 2*PI*500
+ float time = (float)(((double)ltime)/500.0);
+ jump = 4.0f * (float)Math.abs(Math.sin(time)*0.5);
+ if (!lightMoving) lightAngle += 0.0f;
+ }
+
+ /* Clear; default stencil clears to zero. */
+ if ((stencilReflection && renderReflection) || (stencilShadow && renderShadow))
+ gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
+ else
+ /* Avoid clearing stencil when not using it. */
+ gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+ /* Reposition the light source. */
+ lightPosition[0] = 12*(float)Math.cos(lightAngle);
+ lightPosition[1] = lightHeight;
+ lightPosition[2] = 12*(float)Math.sin(lightAngle);
+ if (directionalLight)
+ lightPosition[3] = 0.0f;
+ else
+ lightPosition[3] = 1.0f;
+
+ shadowMatrix(floorShadow, floorPlane, lightPosition);
+
+ gl.glPushMatrix();
+
+ /* Perform scene rotations based on user mouse input. */
+ gl.glRotatef(angle2, 1.0f, 0.0f, 0.0f);
+ gl.glRotatef(angle, 0.0f, 1.0f, 0.0f);
+
+ /* Tell GL new light source position. */
+ gl.glLightfv(GL_LIGHT0, GL_POSITION, lightPosition);
+
+ if (renderReflection)
+ {
+ if (stencilReflection)
+ {
+ /* We can eliminate the visual "artifact" of seeing the "flipped"
+ dinosaur underneath the floor by using stencil. The idea is
+ draw the floor without color or depth update but so that
+ a stencil value of one is where the floor will be. Later when
+ rendering the dinosaur reflection, we will only update pixels
+ with a stencil value of 1 to make sure the reflection only
+ lives on the floor, not below the floor. */
+
+ /* Don't update color or depth. */
+ gl.glDisable(GL_DEPTH_TEST);
+ gl.glColorMask(false, false, false, false);
+
+ /* Draw 1 into the stencil buffer. */
+ gl.glEnable(GL_STENCIL_TEST);
+ gl.glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE);
+ gl.glStencilFunc(GL_ALWAYS, 1, 0xffffffff);
+
+ /* Now render floor; floor pixels just get their stencil set to 1. */
+ drawFloor();
+
+ /* Re-enable update of color and depth. */
+ gl.glColorMask(true, true, true, true);
+ gl.glEnable(GL_DEPTH_TEST);
+
+ /* Now, only render where stencil is set to 1. */
+ gl.glStencilFunc(GL_EQUAL, 1, 0xffffffff); /* draw if ==1 */
+ gl.glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
+ }
+
+ gl.glPushMatrix();
+
+ /* The critical reflection step: Reflect dinosaur through the floor
+ (the Y=0 plane) to make a relection. */
+
+ gl.glScalef(1.0f, -1.0f, 1.0f);
+
+ /* Reflect the light position. */
+ gl.glLightfv(GL_LIGHT0, GL_POSITION, lightPosition);
+
+ /* To avoid our normals getting reversed and hence botched lighting
+ on the reflection, turn on normalize. */
+ gl.glEnable(GL_NORMALIZE);
+ gl.glCullFace(GL_FRONT);
+
+ /* Draw the reflected dinosaur. */
+ drawDinosaur();
+
+ /* Disable noramlize again and re-enable back face culling. */
+ gl.glDisable(GL_NORMALIZE);
+ gl.glCullFace(GL_BACK);
+
+ gl.glPopMatrix();
+
+ /* Switch back to the unreflected light position. */
+ gl.glLightfv(GL_LIGHT0, GL_POSITION, lightPosition);
+
+ if (stencilReflection) gl.glDisable(GL_STENCIL_TEST);
+ }
+
+ /* Back face culling will get used to only draw either the top or the
+ bottom floor. This let's us get a floor with two distinct
+ appearances. The top floor surface is reflective and kind of red.
+ The bottom floor surface is not reflective and blue. */
+
+ /* Draw "bottom" of floor in blue. */
+ gl.glFrontFace(GL_CW); /* Switch face orientation. */
+ gl.glColor4f(0.1f, 0.1f, 0.7f, 1.0f);
+ drawFloor();
+ gl.glFrontFace(GL_CCW);
+
+ if (renderShadow)
+ {
+ if (stencilShadow)
+ {
+ /* Draw the floor with stencil value 3. This helps us only
+ draw the shadow once per floor pixel (and only on the
+ floor pixels). */
+ gl.glEnable(GL_STENCIL_TEST);
+ gl.glStencilFunc(GL_ALWAYS, 3, 0xffffffff);
+ gl.glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
+ }
+ }
+
+ /* Draw "top" of floor. Use blending to blend in reflection. */
+ gl.glEnable(GL_BLEND);
+ gl.glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ gl.glColor4f(0.7f, 0.0f, 0.0f, 0.3f);
+ gl.glColor4f(1.0f, 1.0f, 1.0f, 0.3f);
+ drawFloor();
+ gl.glDisable(GL_BLEND);
+
+ /* Draw "actual" dinosaur, not its reflection. */
+ if (renderDinosaur) drawDinosaur();
+
+ if (renderShadow)
+ {
+ /* Render the projected shadow. */
+ if (stencilShadow)
+ {
+ /* Now, only render where stencil is set above 2 (ie, 3 where
+ the top floor is). Update stencil with 2 where the shadow
+ gets drawn so we don't redraw (and accidently reblend) the
+ shadow). */
+ gl.glStencilFunc(GL_LESS, 2, 0xffffffff); /* draw if ==1 */
+ gl.glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE);
+ }
+ /* To eliminate depth buffer artifacts, we use polygon offset
+ to raise the depth of the projected shadow slightly so
+ that it does not depth buffer alias with the floor. */
+ if (offsetShadow) gl.glEnable(GL_POLYGON_OFFSET_FILL);
+
+ /* Render 50% black shadow color on top of whatever the
+ floor appareance is. */
+ gl.glEnable(GL_BLEND);
+ gl.glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ gl.glDisable(GL_LIGHTING); /* Force the 50% black. */
+ gl.glColor4f(0.0f, 0.0f, 0.0f, 0.5f);
+
+ gl.glPushMatrix();
+ /* Project the shadow. */
+ gl.glMultMatrixf(floorShadow);
+ drawDinosaur();
+ gl.glPopMatrix();
+
+ gl.glDisable(GL_BLEND);
+ gl.glEnable(GL_LIGHTING);
+
+ if (offsetShadow) gl.glDisable(GL_POLYGON_OFFSET_FILL);
+ if (stencilShadow) gl.glDisable(GL_STENCIL_TEST);
+ }
+
+ gl.glPushMatrix();
+ gl.glDisable(GL_LIGHTING);
+ gl.glColor3f(1.0f, 1.0f, 0.0f);
+ if (directionalLight)
+ {
+ /* Draw an arrowhead. */
+ gl.glDisable(GL_CULL_FACE);
+ gl.glTranslatef(lightPosition[0], lightPosition[1], lightPosition[2]);
+ gl.glRotatef(lightAngle * (float)(-180.0 / M_PI), 0, 1, 0);
+ gl.glRotatef((float)Math.atan(lightHeight/12) * (float)(180.0 / M_PI), 0, 0, 1);
+ gl.glBegin(GL_TRIANGLE_FAN);
+ gl.glVertex3f(0, 0, 0);
+ gl.glVertex3f(2, 1, 1);
+ gl.glVertex3f(2, -1, 1);
+ gl.glVertex3f(2, -1, -1);
+ gl.glVertex3f(2, 1, -1);
+ gl.glVertex3f(2, 1, 1);
+ gl.glEnd();
+ /* Draw a white line from light direction. */
+ gl.glColor3f(1.0f, 1.0f, 1.0f);
+ gl.glBegin(GL_LINES);
+ gl.glVertex3f(0, 0, 0);
+ gl.glVertex3f(5, 0, 0);
+ gl.glEnd();
+ gl.glEnable(GL_CULL_FACE);
+ }
+ else
+ {
+ /* Draw a yellow ball at the light source. */
+ gl.glTranslatef(lightPosition[0], lightPosition[1], lightPosition[2]);
+ int qobj = glu.gluNewQuadric();
+ glu.gluQuadricOrientation(qobj,GLU_OUTSIDE);
+ glu.gluQuadricNormals(qobj,GLU_SMOOTH);
+ glu.gluQuadricTexture(qobj,false);
+ glu.gluSphere(qobj,1.0f,5,5);
+ glu.gluDeleteQuadric(qobj);
+ }
+ gl.glEnable(GL_LIGHTING);
+ gl.glPopMatrix();
+
+ gl.glPopMatrix();
+
+ glj.gljSwap();
+ glj.gljCheckGL();
+ glj.gljFree();
+
+ // if (!isSuspended()) repaint(); // Animate at full speed.
+ }
+
+ private void makeDinosaur()
+ {
+ extrudeSolidFromPolygon
+ (bodyVerts,
+ bodyTris,
+ bodyWidth,
+ BODY_SIDE,
+ BODY_EDGE,
+ BODY_WHOLE);
+ extrudeSolidFromPolygon
+ (armVerts,
+ armTris,
+ bodyWidth/4,
+ ARM_SIDE,
+ ARM_EDGE,
+ ARM_WHOLE);
+ extrudeSolidFromPolygon
+ (legVerts,
+ legTris,
+ bodyWidth/2,
+ LEG_SIDE,
+ LEG_EDGE,
+ LEG_WHOLE);
+ extrudeSolidFromPolygon
+ (eyeVerts,
+ eyeTris,
+ bodyWidth+0.2f,
+ EYE_SIDE,
+ EYE_EDGE,
+ EYE_WHOLE);
+ }
+
+ private void drawDinosaur()
+ {
+ gl.glPushMatrix();
+ /* Translate the dinosaur to be at (0,8,0). */
+ gl.glTranslatef(-8, 0, -bodyWidth / 2);
+ gl.glTranslatef(0.0f, jump, 0.0f);
+ gl.glMaterialfv(GL_FRONT, GL_DIFFUSE, skinColor);
+ gl.glCallList(BODY_WHOLE);
+ gl.glTranslatef(0.0f, 0.0f, bodyWidth);
+ gl.glCallList(ARM_WHOLE);
+ gl.glCallList(LEG_WHOLE);
+ gl.glTranslatef(0.0f, 0.0f, -bodyWidth - bodyWidth / 4);
+ gl.glCallList(ARM_WHOLE);
+ gl.glTranslatef(0.0f, 0.0f, -bodyWidth / 4);
+ gl.glCallList(LEG_WHOLE);
+ gl.glTranslatef(0.0f, 0.0f, bodyWidth / 2 - 0.1f);
+ gl.glMaterialfv(GL_FRONT, GL_DIFFUSE, eyeColor);
+ gl.glCallList(EYE_WHOLE);
+ gl.glPopMatrix();
+ }
+
+ private void makeFloorTexture()
+ {
+ /* Nice floor texture tiling pattern. */
+ String circles[] =
+ {
+ "....xxxx........",
+ "..xxxxxxxx......",
+ ".xxxxxxxxxx.....",
+ ".xxx....xxx.....",
+ "xxx......xxx....",
+ "xxx......xxx....",
+ "xxx......xxx....",
+ "xxx......xxx....",
+ ".xxx....xxx.....",
+ ".xxxxxxxxxx.....",
+ "..xxxxxxxx......",
+ "....xxxx........",
+ "................",
+ "................",
+ "................",
+ "................"
+ };
+ byte floorTexture[] = new byte[16*16*3];
+
+ /* Setup RGB image for the texture. */
+ int idx = 0;
+ for (int t = 0; t < 16; t++)
+ {
+ for (int s = 0; s < 16; s++)
+ {
+ if (circles[t].charAt(s) == 'x')
+ {
+ /* Nice blue. */
+ floorTexture[idx++] = (byte)0x1f;
+ floorTexture[idx++] = (byte)0x1f;
+ floorTexture[idx++] = (byte)0x8f;
+ }
+ else
+ {
+ /* Light gray. */
+ floorTexture[idx++] = (byte)0xca;
+ floorTexture[idx++] = (byte)0xca;
+ floorTexture[idx++] = (byte)0xca;
+ }
+ }
+ }
+
+ gl.glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+
+// if (useMipmaps)
+// {
+// gl.glTexParameteri
+// (GL_TEXTURE_2D,
+// GL_TEXTURE_MIN_FILTER,
+// GL_LINEAR_MIPMAP_LINEAR);
+// glu.gluBuild2DMipmaps
+// (GL_TEXTURE_2D,3,16,16,GL_RGB,GL_UNSIGNED_BYTE,floorTexture);
+// }
+// else
+ {
+ if (linearFiltering)
+ {
+ gl.glTexParameteri
+ (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ gl.glTexParameteri
+ (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ }
+ else
+ {
+ gl.glTexParameteri
+ (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ gl.glTexParameteri
+ (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ }
+ gl.glTexImage2D
+ (GL_TEXTURE_2D,0,3,16,16,0,GL_RGB,GL_UNSIGNED_BYTE,floorTexture);
+ }
+ }
+
+ /* Draw a floor (possibly textured). */
+ private void drawFloor()
+ {
+ gl.glDisable(GL_LIGHTING);
+ if (useTexture) gl.glEnable(GL_TEXTURE_2D);
+ gl.glBegin(GL_QUADS);
+ gl.glTexCoord2f(0.0f, 0.0f);
+ gl.glVertex3fv(floorVertices[0]);
+ gl.glTexCoord2f(0.0f, 16.0f);
+ gl.glVertex3fv(floorVertices[1]);
+ gl.glTexCoord2f(16.0f, 16.0f);
+ gl.glVertex3fv(floorVertices[2]);
+ gl.glTexCoord2f(16.0f, 0.0f);
+ gl.glVertex3fv(floorVertices[3]);
+ gl.glEnd();
+ if (useTexture) gl.glDisable(GL_TEXTURE_2D);
+ gl.glEnable(GL_LIGHTING);
+ }
+
+ /* create a matrix that will project the desired shadow */
+ void shadowMatrix(float shadowMat[], float groundplane[], float lightpos[])
+ {
+ float dot;
+
+ /* find dot product between light position vector
+ and ground plane normal */
+ dot =
+ groundplane[0] * lightpos[0] +
+ groundplane[1] * lightpos[1] +
+ groundplane[2] * lightpos[2] +
+ groundplane[3] * lightpos[3];
+
+ shadowMat[0] = dot - lightpos[0] * groundplane[0];
+ shadowMat[4] = -lightpos[0] * groundplane[1];
+ shadowMat[8] = -lightpos[0] * groundplane[2];
+ shadowMat[12] = -lightpos[0] * groundplane[3];
+
+ shadowMat[1] = -lightpos[1] * groundplane[0];
+ shadowMat[5] = dot - lightpos[1] * groundplane[1];
+ shadowMat[9] = -lightpos[1] * groundplane[2];
+ shadowMat[13] = -lightpos[1] * groundplane[3];
+
+ shadowMat[2] = -lightpos[2] * groundplane[0];
+ shadowMat[6] = -lightpos[2] * groundplane[1];
+ shadowMat[10] = dot - lightpos[2] * groundplane[2];
+ shadowMat[14] = -lightpos[2] * groundplane[3];
+
+ shadowMat[3] = -lightpos[3] * groundplane[0];
+ shadowMat[7] = -lightpos[3] * groundplane[1];
+ shadowMat[11] = -lightpos[3] * groundplane[2];
+ shadowMat[15] = dot - lightpos[3] * groundplane[3];
+ }
+
+ /* find the plane equation given 3 points */
+ void findPlane(float plane[], float v0[], float v1[], float v2[])
+ {
+ float vec0[] = new float[3], vec1[] = new float[3];
+
+ /* need 2 vectors to find cross product */
+ vec0[X] = v1[X] - v0[X];
+ vec0[Y] = v1[Y] - v0[Y];
+ vec0[Z] = v1[Z] - v0[Z];
+
+ vec1[X] = v2[X] - v0[X];
+ vec1[Y] = v2[Y] - v0[Y];
+ vec1[Z] = v2[Z] - v0[Z];
+
+ /* find cross product to get A, B, and C of plane equation */
+ plane[A] = vec0[Y] * vec1[Z] - vec0[Z] * vec1[Y];
+ plane[B] = -(vec0[X] * vec1[Z] - vec0[Z] * vec1[X]);
+ plane[C] = vec0[X] * vec1[Y] - vec0[Y] * vec1[X];
+ plane[D] = -(plane[A]*v0[X] + plane[B]*v0[Y] + plane[C]*v0[Z]);
+ }
+
+ /* Mark Kilgard's tessellation code from the "dino" demos.
+ Bug fixes and re-write without GLU tesselator
+ by Ronald B. Cemer */
+ private void extrudeSolidFromPolygon
+ (float data[][],
+ int outlineTriIndices[][],
+ float thickness,
+ int side,
+ int edge,
+ int whole)
+ {
+ double dx, dy, len;
+ int i, j0, j1, j2;
+ int min, max, range;
+ float x0, y0, x1, y1;
+ int count = data.length;
+ int tricount = outlineTriIndices.length;
+
+ gl.glNewList(side, GL_COMPILE);
+ gl.glShadeModel(GL_SMOOTH);
+ gl.glBegin(GL_TRIANGLES);
+ for (i = 0; i < tricount; i++)
+ {
+/* *+*+* Note that we use the triangle indices in reverse order here
+ because they are specified in reverse order in the arrays. */
+ j0 = outlineTriIndices[i][2];
+ j1 = outlineTriIndices[i][1];
+ j2 = outlineTriIndices[i][0];
+ gl.glVertex3f(data[j0][0],data[j0][1],0.0f);
+ gl.glVertex3f(data[j1][0],data[j1][1],0.0f);
+ gl.glVertex3f(data[j2][0],data[j2][1],0.0f);
+ }
+ gl.glEnd();
+ gl.glEndList();
+
+ gl.glNewList(edge, GL_COMPILE);
+ gl.glShadeModel(GL_FLAT); /* flat shade keeps angular hands
+ from being "smoothed" */
+ for (min = max = 0; min < count; min = max)
+ {
+ for (max = min+1; max < count; max++)
+ if (data[max][2] != 0.0f) break;
+ range = max-min;
+ gl.glBegin(GL_QUAD_STRIP);
+ for (i = min; i <= max; i++)
+ {
+ j0 = i;
+ j1 = i+1;
+ if (j0 >= max) j0 -= range;
+ if (j1 >= max) j1 -= range;
+ x0 = data[j0][0];
+ y0 = data[j0][1];
+ x1 = data[j1][0];
+ y1 = data[j1][1];
+ gl.glVertex3f(x0, y0, 0.0f);
+ gl.glVertex3f(x0, y0, thickness);
+ // Normals
+ dx = y1 - y0;
+ dy = x0 - x1;
+ len = Math.sqrt(dx * dx + dy * dy);
+ gl.glNormal3f((float)(dx / len), (float)(dy / len), 0.0f);
+ }
+ gl.glEnd();
+ }
+ gl.glEndList();
+
+ gl.glNewList(whole, GL_COMPILE);
+ gl.glFrontFace(GL_CW);
+
+ gl.glCallList(edge);
+
+ gl.glNormal3f(0.0f, 0.0f, -1.0f);
+ gl.glCallList(side);
+ gl.glPushMatrix();
+ gl.glTranslatef(0.0f, 0.0f, thickness);
+ gl.glFrontFace(GL_CCW);
+ gl.glNormal3f(0.0f, 0.0f, 1.0f);
+ gl.glCallList(side);
+ gl.glPopMatrix();
+
+ gl.glEndList();
+ }
+
+ // Methods required for the implementation of MouseListener
+ public void mouseEntered(MouseEvent evt)
+ {
+ }
+
+ public void mouseExited(MouseEvent evt)
+ {
+ }
+
+ public void mousePressed(MouseEvent evt)
+ {
+ // Left button moves view.
+ // Both buttons moves light.
+ // Right button pops up menu.
+ if (!menu_showing)
+ {
+ if ((evt.getModifiers() & evt.BUTTON3_MASK) == 0)
+ {
+ moving = true;
+ startx = evt.getX();
+ starty = evt.getY();
+ }
+ else if (moving)
+ {
+ moving = false;
+ lightMoving = true;
+ lightStartX = evt.getX();
+ lightStartY = evt.getY();
+ }
+ else
+ {
+ // Must be right mouse button.
+ menu_showing = true;
+ save_suspended = isSuspended();
+ if (!save_suspended)
+ {
+ setSuspended(true);
+ repaint(100);
+ try
+ {
+ Thread.currentThread().sleep(200);
+ }
+ catch (Exception e)
+ { }
+ }
+ menu.show(this,evt.getX(),evt.getY());
+ }
+ }
+ else
+ {
+ menu_showing = false;
+ setSuspended(save_suspended);
+ }
+ }
+
+ public void mouseReleased(MouseEvent evt)
+ {
+ lightMoving = false;
+ if ((evt.getModifiers() & evt.BUTTON3_MASK) == 0)
+ {
+ // Must be left button.
+ moving = false;
+ }
+ }
+
+ public void mouseClicked(MouseEvent evt)
+ {
+ }
+
+ // Methods required for the implementation of MouseMotionListener
+ public void mouseDragged(MouseEvent evt)
+ {
+ int x = evt.getX(), y = evt.getY();
+ if (moving)
+ {
+ angle += (x - startx);
+ while (angle < 0.0f) angle += 360.0f;
+ while (angle >= 360.0f) angle -= 360.0f;
+ angle2 += (y - starty);
+ if (angle2 < -180.0f)
+ angle2 = -180.0f;
+ else if (angle2 > 180.0f)
+ angle2 = 180.0f;
+ startx = x;
+ starty = y;
+ if (isSuspended()) repaint();
+ }
+ else if (lightMoving)
+ {
+ lightAngle += (lightStartX - x)/40.0f;
+ while (lightAngle < 0.0f) lightAngle += 360.0f;
+ while (lightAngle >= 360.0f) lightAngle -= 360.0f;
+ lightHeight += (lightStartY - y)/20.0f;
+ lightStartX = x;
+ lightStartY = y;
+ if (isSuspended()) repaint();
+ }
+ }
+
+ public void mouseMoved(MouseEvent evt)
+ {
+ }
+
+ // Method required for the implementation of ActionListener
+ public void actionPerformed(ActionEvent evt)
+ {
+ if (glj.gljMakeCurrent() == false) return;
+ boolean dorepaint = false;
+ String c = evt.getActionCommand();
+
+ if (c.equals(M_MOTION))
+ {
+ if (menu_showing)
+ save_suspended = !save_suspended;
+ else
+ setSuspended(!isSuspended());
+ dorepaint = true;
+ }
+ else if (c.equals(M_LIGHT))
+ {
+ lightSwitch = !lightSwitch;
+ if (lightSwitch)
+ gl.glEnable(GL_LIGHT0);
+ else
+ gl.glDisable(GL_LIGHT0);
+ dorepaint = true;
+ }
+ else if (c.equals(M_TEXTURE))
+ {
+ useTexture = !useTexture;
+ dorepaint = true;
+ }
+ else if (c.equals(M_SHADOWS))
+ {
+ renderShadow = !renderShadow;
+ dorepaint = true;
+ }
+ else if (c.equals(M_REFLECTION))
+ {
+ renderReflection = !renderReflection;
+ dorepaint = true;
+ }
+ else if (c.equals(M_DINOSAUR))
+ {
+ renderDinosaur = !renderDinosaur;
+ dorepaint = true;
+ }
+ else if (c.equals(M_STENCIL_REFLECTION))
+ {
+ stencilReflection = !stencilReflection;
+ dorepaint = true;
+ }
+ else if (c.equals(M_STENCIL_SHADOW))
+ {
+ stencilShadow = !stencilShadow;
+ dorepaint = true;
+ }
+ else if (c.equals(M_OFFSET_SHADOW))
+ {
+ offsetShadow = !offsetShadow;
+ dorepaint = true;
+ }
+ else if (c.equals(M_POSITIONAL))
+ {
+ directionalLight = false;
+ dorepaint = true;
+ }
+ else if (c.equals(M_DIRECTIONAL))
+ {
+ directionalLight = true;
+ dorepaint = true;
+ }
+
+ glj.gljFree();
+ if (menu_showing)
+ {
+ menu_showing = false;
+ setSuspended(save_suspended);
+ }
+ if ( (isSuspended()) && (dorepaint) ) repaint();
+ }
+ }
+}
diff --git a/demos/RonsDemos/dinoshade_plugin13.html b/demos/RonsDemos/dinoshade_plugin13.html new file mode 100644 index 0000000..da6f965 --- /dev/null +++ b/demos/RonsDemos/dinoshade_plugin13.html @@ -0,0 +1,52 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
+ <title>Dinoshade by Mark J. Kilgard; ported to Java by Ron Cemer</title>
+</head>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+Dinoshade applet
+<br>Originially written by Mark J. Kilgard
+<br>Ported to Java by Ron Cemer
+<br>Press and hold left mouse button, then drag to rotate view.
+<br>Press and hold left mouse button, then press and hold right mouse button, then drag to rotate light.
+<br>Click right mouse button for a menu of options.
+<br>NOTE: If your system does not support hardware-accelerated stenciling, this demo will run slowly unless you disable stenciling for shadows and reflections.
+<br>
+<!--"CONVERTED_APPLET"-->
+<!-- CONVERTER VERSION 1.3 --> +<SCRIPT LANGUAGE="JavaScript"><!-- + var _info = navigator.userAgent; var _ns = false; + var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0); +//--></SCRIPT> +<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!-- + var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0))); +//--></SCRIPT></COMMENT> + +<SCRIPT LANGUAGE="JavaScript"><!-- + if (_ie == true) document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = 400 HEIGHT = 400 codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0"><NOEMBED><XMP>'); + else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.3" CODE = "dinoshade.class" WIDTH = 400 HEIGHT = 400 scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html"><NOEMBED><XMP>'); +//--></SCRIPT> +<APPLET CODE = "dinoshade.class" WIDTH = 400 HEIGHT = 400></XMP> +<PARAM NAME = CODE VALUE = "dinoshade.class" >
+ +<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3"> +<PARAM NAME="scriptable" VALUE="false"> + +</APPLET> + +</NOEMBED></EMBED></OBJECT> + + +<!-- +<APPLET CODE = "dinoshade.class" WIDTH = 400 HEIGHT = 400>
+
+
+</APPLET> +--> +<!--"END_CONVERTED_APPLET"-->
+
+<hr>
+</body>
+</html>
diff --git a/demos/RonsDemos/dof.html b/demos/RonsDemos/dof.html new file mode 100644 index 0000000..b614546 --- /dev/null +++ b/demos/RonsDemos/dof.html @@ -0,0 +1,17 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
+ <title>DOF by Silicon Graphics; ported to Java by Ron Cemer</title>
+</head>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+DOF applet
+<br>Originially written by Silicon Graphics
+<br>Ported to Java by Ron Cemer
+<br>
+<applet code="dof.class" width=400 height=400>
+</applet>
+<hr>
+</body>
+</html>
diff --git a/demos/RonsDemos/dof.java b/demos/RonsDemos/dof.java new file mode 100644 index 0000000..58d4e1a --- /dev/null +++ b/demos/RonsDemos/dof.java @@ -0,0 +1,513 @@ +/**
+ * @(#) dof.java
+ * @(#) author: Silicon Graphics (converted to Java by Ron Cemer)
+ */
+
+import java.applet.*;
+import java.awt.*;
+import java.awt.event.*;
+import java.lang.*;
+import java.util.*;
+import java.io.*;
+import java.util.*;
+import gl4java.GLContext;
+import gl4java.awt.GLCanvas;
+
+/*
+ * Copyright (c) 1993-1997, Silicon Graphics, Inc.
+ * ALL RIGHTS RESERVED
+ * Permission to use, copy, modify, and distribute this software for
+ * any purpose and without fee is hereby granted, provided that the above
+ * copyright notice appear in all copies and that both the copyright notice
+ * and this permission notice appear in supporting documentation, and that
+ * the name of Silicon Graphics, Inc. not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission.
+ *
+ * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
+ * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
+ * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
+ * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
+ * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
+ * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
+ * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
+ * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
+ * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * US Government Users Restricted Rights
+ * Use, duplication, or disclosure by the Government is subject to
+ * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
+ * (c)(1)(ii) of the Rights in Technical Data and Computer Software
+ * clause at DFARS 252.227-7013 and/or in similar or successor
+ * clauses in the FAR or the DOD or NASA FAR Supplement.
+ * Unpublished-- rights reserved under the copyright laws of the
+ * United States. Contractor/manufacturer is Silicon Graphics,
+ * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
+ *
+ * OpenGL(R) is a registered trademark of Silicon Graphics, Inc.
+ */
+
+/*
+ * This program demonstrates use of the accumulation buffer to
+ * create an out-of-focus depth-of-field effect. The teapots
+ * are drawn several times into the accumulation buffer. The
+ * viewing volume is jittered, except at the focal point, where
+ * the viewing volume is at the same position, each time. In
+ * this case, the gold teapot remains in focus.
+ */
+
+public class dof extends Applet
+{
+ // Data for drawing teapots:
+ /* Rim, body, lid, and bottom data must be reflected in x and
+ y; handle and spout data across the y axis only. */
+ private static final int patchdata[][] =
+ {
+ /* rim */
+ {102, 103, 104, 105, 4, 5, 6, 7, 8, 9, 10, 11,
+ 12, 13, 14, 15},
+ /* body */
+ {12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+ 24, 25, 26, 27},
+ {24, 25, 26, 27, 29, 30, 31, 32, 33, 34, 35, 36,
+ 37, 38, 39, 40},
+ /* lid */
+ {96, 96, 96, 96, 97, 98, 99, 100, 101, 101, 101,
+ 101, 0, 1, 2, 3,},
+ {0, 1, 2, 3, 106, 107, 108, 109, 110, 111, 112,
+ 113, 114, 115, 116, 117},
+ /* bottom */
+ {118, 118, 118, 118, 124, 122, 119, 121, 123, 126,
+ 125, 120, 40, 39, 38, 37},
+ /* handle */
+ {41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
+ 53, 54, 55, 56},
+ {53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
+ 28, 65, 66, 67},
+ /* spout */
+ {68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
+ 80, 81, 82, 83},
+ {80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91,
+ 92, 93, 94, 95}
+ };
+ private static final float cpdata[][] =
+ {
+ {0.2f, 0.0f, 2.7f}, {0.2f, -0.112f, 2.7f}, {0.112f, -0.2f, 2.7f}, {0.0f,
+ -0.2f, 2.7f}, {1.3375f, 0.0f, 2.53125f}, {1.3375f, -0.749f, 2.53125f},
+ {0.749f, -1.3375f, 2.53125f}, {0.0f, -1.3375f, 2.53125f}, {1.4375f,
+ 0.0f, 2.53125f}, {1.4375f, -0.805f, 2.53125f}, {0.805f, -1.4375f,
+ 2.53125f}, {0.0f, -1.4375f, 2.53125f}, {1.5f, 0.0f, 2.4f}, {1.5f, -0.84f,
+ 2.4f}, {0.84f, -1.5f, 2.4f}, {0.0f, -1.5f, 2.4f}, {1.75f, 0.0f, 1.875f},
+ {1.75f, -0.98f, 1.875f}, {0.98f, -1.75f, 1.875f}, {0.0f, -1.75f,
+ 1.875f}, {2f, 0.0f, 1.35f}, {2f, -1.12f, 1.35f}, {1.12f, -2f, 1.35f},
+ {0.0f, -2f, 1.35f}, {2f, 0.0f, 0.9f}, {2f, -1.12f, 0.9f}, {1.12f, -2f,
+ 0.9f}, {0.0f, -2f, 0.9f}, {-2f, 0.0f, 0.9f}, {2f, 0.0f, 0.45f}, {2f, -1.12f,
+ 0.45f}, {1.12f, -2f, 0.45f}, {0.0f, -2f, 0.45f}, {1.5f, 0.0f, 0.225f},
+ {1.5f, -0.84f, 0.225f}, {0.84f, -1.5f, 0.225f}, {0.0f, -1.5f, 0.225f},
+ {1.5f, 0.0f, 0.15f}, {1.5f, -0.84f, 0.15f}, {0.84f, -1.5f, 0.15f}, {0.0f,
+ -1.5f, 0.15f}, {-1.6f, 0.0f, 2.025f}, {-1.6f, -0.3f, 2.025f}, {-1.5f,
+ -0.3f, 2.25f}, {-1.5f, 0.0f, 2.25f}, {-2.3f, 0.0f, 2.025f}, {-2.3f, -0.3f,
+ 2.025f}, {-2.5f, -0.3f, 2.25f}, {-2.5f, 0.0f, 2.25f}, {-2.7f, 0.0f,
+ 2.025f}, {-2.7f, -0.3f, 2.025f}, {-3f, -0.3f, 2.25f}, {-3f, 0.0f,
+ 2.25f}, {-2.7f, 0.0f, 1.8f}, {-2.7f, -0.3f, 1.8f}, {-3f, -0.3f, 1.8f},
+ {-3f, 0.0f, 1.8f}, {-2.7f, 0.0f, 1.575f}, {-2.7f, -0.3f, 1.575f}, {-3f,
+ -0.3f, 1.35f}, {-3f, 0.0f, 1.35f}, {-2.5f, 0.0f, 1.125f}, {-2.5f, -0.3f,
+ 1.125f}, {-2.65f, -0.3f, 0.9375f}, {-2.65f, 0.0f, 0.9375f}, {-2f,
+ -0.3f, 0.9f}, {-1.9f, -0.3f, 0.6f}, {-1.9f, 0.0f, 0.6f}, {1.7f, 0.0f,
+ 1.425f}, {1.7f, -0.66f, 1.425f}, {1.7f, -0.66f, 0.6f}, {1.7f, 0.0f,
+ 0.6f}, {2.6f, 0.0f, 1.425f}, {2.6f, -0.66f, 1.425f}, {3.1f, -0.66f,
+ 0.825f}, {3.1f, 0.0f, 0.825f}, {2.3f, 0.0f, 2.1f}, {2.3f, -0.25f, 2.1f},
+ {2.4f, -0.25f, 2.025f}, {2.4f, 0.0f, 2.025f}, {2.7f, 0.0f, 2.4f}, {2.7f,
+ -0.25f, 2.4f}, {3.3f, -0.25f, 2.4f}, {3.3f, 0.0f, 2.4f}, {2.8f, 0.0f,
+ 2.475f}, {2.8f, -0.25f, 2.475f}, {3.525f, -0.25f, 2.49375f},
+ {3.525f, 0.0f, 2.49375f}, {2.9f, 0.0f, 2.475f}, {2.9f, -0.15f, 2.475f},
+ {3.45f, -0.15f, 2.5125f}, {3.45f, 0.0f, 2.5125f}, {2.8f, 0.0f, 2.4f},
+ {2.8f, -0.15f, 2.4f}, {3.2f, -0.15f, 2.4f}, {3.2f, 0.0f, 2.4f}, {0.0f, 0.0f,
+ 3.15f}, {0.8f, 0.0f, 3.15f}, {0.8f, -0.45f, 3.15f}, {0.45f, -0.8f,
+ 3.15f}, {0.0f, -0.8f, 3.15f}, {0.0f, 0.0f, 2.85f}, {1.4f, 0.0f, 2.4f}, {1.4f,
+ -0.784f, 2.4f}, {0.784f, -1.4f, 2.4f}, {0.0f, -1.4f, 2.4f}, {0.4f, 0.0f,
+ 2.55f}, {0.4f, -0.224f, 2.55f}, {0.224f, -0.4f, 2.55f}, {0.0f, -0.4f,
+ 2.55f}, {1.3f, 0.0f, 2.55f}, {1.3f, -0.728f, 2.55f}, {0.728f, -1.3f,
+ 2.55f}, {0.0f, -1.3f, 2.55f}, {1.3f, 0.0f, 2.4f}, {1.3f, -0.728f, 2.4f},
+ {0.728f, -1.3f, 2.4f}, {0.0f, -1.3f, 2.4f}, {0.0f, 0.0f, 0.0f}, {1.425f,
+ -0.798f, 0.0f}, {1.5f, 0.0f, 0.075f}, {1.425f, 0.0f, 0.0f}, {0.798f, -1.425f,
+ 0.0f}, {0.0f, -1.5f, 0.075f}, {0.0f, -1.425f, 0.0f}, {1.5f, -0.84f, 0.075f},
+ {0.84f, -1.5f, 0.075f}
+ };
+ private static final float tex[] =
+ {
+ 0.0f, 0.0f,
+ 1.0f, 0.0f,
+ 0.0f, 1.0f,
+ 1.0f, 1.0f
+ };
+ /* 8 jitter points */
+ double j8[][] =
+ {
+ {-0.334818, 0.435331},
+ { 0.286438, -0.393495},
+ { 0.459462, 0.141540},
+ {-0.414498, -0.192829},
+ {-0.183790, 0.082102},
+ {-0.079263, -0.317383},
+ { 0.102254, 0.299133},
+ { 0.164216, -0.054399}
+ };
+
+ dofCanvas canvas = null;
+
+
+ /* Initialize the applet */
+
+
+ public void init()
+ {
+ Dimension d = getSize();
+ setLayout(new BorderLayout());
+ canvas = new dofCanvas(d.width, d.height);
+ add("Center", canvas);
+ }
+
+
+ /* Start the applet */
+
+
+ public void start()
+ {
+ }
+
+
+ /* Stop the applet */
+
+
+ public void stop()
+ {
+ }
+
+
+ /* Destroy the applet */
+
+
+ public void destroy()
+ {
+ canvas.cvsDispose();
+ }
+
+
+ /* Local GLCanvas extension class */
+
+
+ private class dofCanvas extends GLCanvas
+ {
+ private final double PI_ = 3.14159265358979323846;
+ int teapotList;
+
+ public dofCanvas(int w, int h)
+ {
+ super(w, h);
+ GLContext.gljNativeDebug = false;
+ GLContext.gljClassDebug = false;
+ }
+
+ public void preInit()
+ {
+ doubleBuffer = true;
+ stereoView = false;
+ accumSize = 8;
+ }
+
+ public void init()
+ {
+ System.out.println("init(): " + this);
+ reshape(getSize().width, getSize().height);
+
+ float ambient[] = { 0.0f, 0.0f, 0.0f, 1.0f };
+ float diffuse[] = { 1.0f, 1.0f, 1.0f, 1.0f };
+ float specular[] = { 1.0f, 1.0f, 1.0f, 1.0f };
+ float position[] = { 0.0f, 3.0f, 3.0f, 0.0f };
+
+ float lmodel_ambient[] = { 0.2f, 0.2f, 0.2f, 1.0f };
+ float local_view[] = { 0.0f };
+
+ gl.glLightfv(GL_LIGHT0, GL_AMBIENT, ambient);
+ gl.glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse);
+ gl.glLightfv(GL_LIGHT0, GL_POSITION, position);
+
+ gl.glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient);
+ gl.glLightModelfv(GL_LIGHT_MODEL_LOCAL_VIEWER, local_view);
+
+ gl.glFrontFace(GL_CW);
+ gl.glEnable(GL_LIGHTING);
+ gl.glEnable(GL_LIGHT0);
+ gl.glEnable(GL_AUTO_NORMAL);
+ gl.glEnable(GL_NORMALIZE);
+ gl.glEnable(GL_DEPTH_TEST);
+
+ gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
+ gl.glClearAccum(0.0f, 0.0f, 0.0f, 0.0f);
+
+ /* make teapot display list */
+ teapotList = gl.glGenLists(1);
+ gl.glNewList(teapotList, GL_COMPILE);
+ glutSolidTeapot(0.5);
+ gl.glEndList();
+
+ glj.gljCheckGL();
+ }
+
+ public void cvsDispose()
+ {
+ System.out.println("destroy(): " + this);
+ super.cvsDispose();
+ }
+
+ public void reshape(int width, int height)
+ {
+ gl.glViewport(0,0,width,height);
+ }
+
+ public void display()
+ {
+ if (glj.gljMakeCurrent() == false) return;
+
+ int viewport[] = new int[4];
+
+ gl.glGetIntegerv(GL_VIEWPORT, viewport);
+ gl.glClear(GL_ACCUM_BUFFER_BIT);
+
+ for (int jitter = 0; jitter < 8; jitter++)
+ {
+ gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ accPerspective
+ (45.0,
+ (double)viewport[2]/(double)viewport[3],
+ 1.0, 15.0, 0.0, 0.0,
+ 0.33*j8[jitter][0], 0.33*j8[jitter][1], 5.0);
+ /* ruby, gold, silver, emerald, and cyan teapots */
+ renderTeapot
+ (-1.1f, -0.5f, -4.5f, 0.1745f, 0.01175f,
+ 0.01175f, 0.61424f, 0.04136f, 0.04136f,
+ 0.727811f, 0.626959f, 0.626959f, 0.6f);
+ renderTeapot
+ (-0.5f, -0.5f, -5.0f, 0.24725f, 0.1995f,
+ 0.0745f, 0.75164f, 0.60648f, 0.22648f,
+ 0.628281f, 0.555802f, 0.366065f, 0.4f);
+ renderTeapot
+ (0.2f, -0.5f, -5.5f, 0.19225f, 0.19225f,
+ 0.19225f, 0.50754f, 0.50754f, 0.50754f,
+ 0.508273f, 0.508273f, 0.508273f, 0.4f);
+ renderTeapot
+ (1.0f, -0.5f, -6.0f, 0.0215f, 0.1745f, 0.0215f,
+ 0.07568f, 0.61424f, 0.07568f, 0.633f,
+ 0.727811f, 0.633f, 0.6f);
+ renderTeapot
+ (1.8f, -0.5f, -6.5f, 0.0f, 0.1f, 0.06f, 0.0f,
+ 0.50980392f, 0.50980392f, 0.50196078f,
+ 0.50196078f, 0.50196078f, 0.25f);
+ gl.glAccum(GL_ACCUM, 0.125f);
+ }
+ gl.glAccum (GL_RETURN, 1.0f);
+
+ glj.gljSwap();
+ glj.gljCheckGL();
+ glj.gljFree();
+ }
+
+ // Imported from glut.
+ private void glutSolidTeapot(double scale)
+ {
+ teapot(14, scale, GL_FILL);
+ }
+
+ // Imported from glut.
+ private void teapot(int grid, double scale, int type)
+ {
+ float p[] = new float[4*4*3];
+ float q[] = new float[4*4*3];
+ float r[] = new float[4*4*3];
+ float s[] = new float[4*4*3];
+ float sc = (float)(0.5*scale);
+
+ gl.glPushAttrib(GL_ENABLE_BIT | GL_EVAL_BIT);
+ gl.glEnable(GL_AUTO_NORMAL);
+ gl.glEnable(GL_NORMALIZE);
+ gl.glEnable(GL_MAP2_VERTEX_3);
+ gl.glEnable(GL_MAP2_TEXTURE_COORD_2);
+ gl.glPushMatrix();
+ gl.glRotatef(270.0f, 1.0f, 0.0f, 0.0f);
+ gl.glScalef(sc, sc, sc);
+ gl.glTranslatef(0.0f, 0.0f, -1.5f);
+ for (int i = 0; i < 10; i++)
+ {
+ for (int j = 0; j < 4; j++)
+ {
+ for (int k = 0; k < 4; k++)
+ {
+ for (int l = 0; l < 3; l++)
+ {
+ p[(j*12)+(k*3)+l] = cpdata[patchdata[i][j * 4 + k]][l];
+ q[(j*12)+(k*3)+l] = cpdata[patchdata[i][j * 4 + (3 - k)]][l];
+ if (l == 1)
+ q[(j*12)+(k*3)+l] *= -1.0f;
+ if (i < 6)
+ {
+ r[(j*12)+(k*3)+l] =
+ cpdata[patchdata[i][j * 4 + (3 - k)]][l];
+ if (l == 0)
+ r[(j*12)+(k*3)+l] *= -1.0f;
+ s[(j*12)+(k*3)+l] =
+ cpdata[patchdata[i][j * 4 + k]][l];
+ if (l == 0)
+ s[(j*12)+(k*3)+l] *= -1.0f;
+ if (l == 1)
+ s[(j*12)+(k*3)+l] *= -1.0f;
+ }
+ }
+ }
+ }
+ gl.glMap2f
+ (GL_MAP2_TEXTURE_COORD_2, 0, 1, 2, 2, 0, 1, 4, 2, tex);
+ gl.glMap2f
+ (GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4, p);
+ gl.glMapGrid2f(grid, 0.0f, 1.0f, grid, 0.0f, 1.0f);
+ gl.glEvalMesh2(type, 0, grid, 0, grid);
+ gl.glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4, q);
+ gl.glEvalMesh2(type, 0, grid, 0, grid);
+ if (i < 6)
+ {
+ gl.glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4, r);
+ gl.glEvalMesh2(type, 0, grid, 0, grid);
+ gl.glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4, s);
+ gl.glEvalMesh2(type, 0, grid, 0, grid);
+ }
+ }
+ gl.glPopMatrix();
+ gl.glPopAttrib();
+ }
+
+ /* accFrustum()
+ * The first 6 arguments are identical to the glFrustum() call.
+ *
+ * pixdx and pixdy are anti-alias jitter in pixels.
+ * Set both equal to 0.0 for no anti-alias jitter.
+ * eyedx and eyedy are depth-of field jitter in pixels.
+ * Set both equal to 0.0 for no depth of field effects.
+ *
+ * focus is distance from eye to plane in focus.
+ * focus must be greater than, but not equal to 0.0.
+ *
+ * Note that accFrustum() calls glTranslatef(). You will
+ * probably want to insure that your ModelView matrix has been
+ * initialized to identity before calling accFrustum().
+ */
+ private void accFrustum
+ (double left,
+ double right,
+ double bottom,
+ double top,
+ double near,
+ double far,
+ double pixdx,
+ double pixdy,
+ double eyedx,
+ double eyedy,
+ double focus)
+ {
+ double xwsize, ywsize;
+ double dx, dy;
+ int viewport[] = new int[4];
+
+ gl.glGetIntegerv(GL_VIEWPORT, viewport);
+
+ xwsize = right - left;
+ ywsize = top - bottom;
+
+ dx = -(pixdx*xwsize/(double) viewport[2] + eyedx*near/focus);
+ dy = -(pixdy*ywsize/(double) viewport[3] + eyedy*near/focus);
+
+ gl.glMatrixMode(GL_PROJECTION);
+ gl.glLoadIdentity();
+ gl.glFrustum
+ ((float)(left + dx),
+ (float)(right + dx),
+ (float)(bottom + dy),
+ (float)(top + dy),
+ (float)near,
+ (float)far);
+ gl.glMatrixMode(GL_MODELVIEW);
+ gl.glLoadIdentity();
+ gl.glTranslatef((float)-eyedx, (float)-eyedy, 0.0f);
+ }
+
+ /* accPerspective()
+ *
+ * The first 4 arguments are identical to the gluPerspective() call.
+ * pixdx and pixdy are anti-alias jitter in pixels.
+ * Set both equal to 0.0 for no anti-alias jitter.
+ * eyedx and eyedy are depth-of field jitter in pixels.
+ * Set both equal to 0.0 for no depth of field effects.
+ *
+ * focus is distance from eye to plane in focus.
+ * focus must be greater than, but not equal to 0.0.
+ *
+ * Note that accPerspective() calls accFrustum().
+ */
+ private void accPerspective
+ (double fovy,
+ double aspect,
+ double near,
+ double far,
+ double pixdx,
+ double pixdy,
+ double eyedx,
+ double eyedy,
+ double focus)
+ {
+ double fov2,left,right,bottom,top;
+
+ fov2 = ((fovy*PI_) / 180.0) / 2.0;
+
+ top = near / (Math.cos(fov2) / Math.sin(fov2));
+ bottom = -top;
+
+ right = top * aspect;
+ left = -right;
+
+ accFrustum
+ (left,right,bottom,top,near,far,pixdx,pixdy,eyedx,eyedy,focus);
+ }
+
+ private void renderTeapot
+ (float x,
+ float y,
+ float z,
+ float ambr,
+ float ambg,
+ float ambb,
+ float difr,
+ float difg,
+ float difb,
+ float specr,
+ float specg,
+ float specb,
+ float shine)
+ {
+ float mat[] = new float[4];
+
+ gl.glPushMatrix();
+ gl.glTranslatef(x, y, z);
+ mat[0] = ambr; mat[1] = ambg; mat[2] = ambb; mat[3] = 1.0f;
+ gl.glMaterialfv(GL_FRONT, GL_AMBIENT, mat);
+ mat[0] = difr; mat[1] = difg; mat[2] = difb;
+ gl.glMaterialfv(GL_FRONT, GL_DIFFUSE, mat);
+ mat[0] = specr; mat[1] = specg; mat[2] = specb;
+ gl.glMaterialfv(GL_FRONT, GL_SPECULAR, mat);
+ gl.glMaterialf(GL_FRONT, GL_SHININESS, shine*128.0f);
+ gl.glCallList(teapotList);
+ gl.glPopMatrix();
+ }
+ }
+}
diff --git a/demos/RonsDemos/dof_plugin13.html b/demos/RonsDemos/dof_plugin13.html new file mode 100644 index 0000000..1f1e874 --- /dev/null +++ b/demos/RonsDemos/dof_plugin13.html @@ -0,0 +1,48 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
+ <title>DOF by Silicon Graphics; ported to Java by Ron Cemer</title>
+</head>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+DOF applet
+<br>Originially written by Silicon Graphics
+<br>Ported to Java by Ron Cemer
+<br>
+<!--"CONVERTED_APPLET"-->
+<!-- CONVERTER VERSION 1.3 --> +<SCRIPT LANGUAGE="JavaScript"><!-- + var _info = navigator.userAgent; var _ns = false; + var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0); +//--></SCRIPT> +<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!-- + var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0))); +//--></SCRIPT></COMMENT> + +<SCRIPT LANGUAGE="JavaScript"><!-- + if (_ie == true) document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = 400 HEIGHT = 400 codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0"><NOEMBED><XMP>'); + else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.3" CODE = "dof.class" WIDTH = 400 HEIGHT = 400 scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html"><NOEMBED><XMP>'); +//--></SCRIPT> +<APPLET CODE = "dof.class" WIDTH = 400 HEIGHT = 400></XMP> +<PARAM NAME = CODE VALUE = "dof.class" >
+ +<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3"> +<PARAM NAME="scriptable" VALUE="false"> + +</APPLET> + +</NOEMBED></EMBED></OBJECT> + + +<!-- +<APPLET CODE = "dof.class" WIDTH = 400 HEIGHT = 400>
+
+
+</APPLET> +--> +<!--"END_CONVERTED_APPLET"-->
+
+<hr>
+</body>
+</html>
diff --git a/demos/RonsDemos/fog.html b/demos/RonsDemos/fog.html new file mode 100644 index 0000000..b7684ab --- /dev/null +++ b/demos/RonsDemos/fog.html @@ -0,0 +1,18 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
+ <title>Fog by Silicon Graphics; ported to Java by Ron Cemer</title>
+</head>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+Fog applet
+<br>Originially written by Silicon Graphics
+<br>Ported to Java by Ron Cemer
+<br>Click inside the window to cycle the fog mode.
+<br>
+<applet code="fog.class" width=400 height=400>
+</applet>
+<hr>
+</body>
+</html>
diff --git a/demos/RonsDemos/fog.java b/demos/RonsDemos/fog.java new file mode 100644 index 0000000..7f99c94 --- /dev/null +++ b/demos/RonsDemos/fog.java @@ -0,0 +1,266 @@ +/**
+ * @(#) fog.java
+ * @(#) author: Silicon Graphics (converted to Java by Ron Cemer)
+ */
+
+/*
+ * Copyright (c) 1993-1997, Silicon Graphics, Inc.
+ * ALL RIGHTS RESERVED
+ * Permission to use, copy, modify, and distribute this software for
+ * any purpose and without fee is hereby granted, provided that the above
+ * copyright notice appear in all copies and that both the copyright notice
+ * and this permission notice appear in supporting documentation, and that
+ * the name of Silicon Graphics, Inc. not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission.
+ *
+ * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
+ * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
+ * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
+ * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
+ * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
+ * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
+ * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
+ * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
+ * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * US Government Users Restricted Rights
+ * Use, duplication, or disclosure by the Government is subject to
+ * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
+ * (c)(1)(ii) of the Rights in Technical Data and Computer Software
+ * clause at DFARS 252.227-7013 and/or in similar or successor
+ * clauses in the FAR or the DOD or NASA FAR Supplement.
+ * Unpublished-- rights reserved under the copyright laws of the
+ * United States. Contractor/manufacturer is Silicon Graphics,
+ * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
+ *
+ * OpenGL(R) is a registered trademark of Silicon Graphics, Inc.
+ */
+
+/*
+ * This program draws 5 red spheres, each at a different
+ * z distance from the eye, in different types of fog.
+ * Pressing the f key chooses between 3 types of
+ * fog: exponential, exponential squared, and linear.
+ * In this program, there is a fixed density value, as well
+ * as fixed start and end values for the linear fog.
+ */
+
+import java.applet.*;
+import java.awt.*;
+import java.awt.event.*;
+import java.lang.*;
+import java.util.*;
+import java.io.*;
+import java.util.*;
+import gl4java.GLContext;
+import gl4java.awt.GLCanvas;
+
+public class fog extends Applet
+{
+ fogCanvas canvas = null;
+
+
+ /* Initialize the applet */
+
+
+ public void init()
+ {
+ Dimension d = getSize();
+ setLayout(new BorderLayout());
+ canvas = new fogCanvas(d.width, d.height);
+ add("Center", canvas);
+ }
+
+
+ /* Start the applet */
+
+
+ public void start()
+ {
+ }
+
+
+ /* Stop the applet */
+
+
+ public void stop()
+ {
+ }
+
+
+ /* Destroy the applet */
+
+
+ public void destroy()
+ {
+ canvas.cvsDispose();
+ }
+
+
+ /* Local GLCanvas extension class */
+
+
+ private class fogCanvas extends GLCanvas implements MouseListener
+ {
+ int fogMode;
+
+ public fogCanvas(int w, int h)
+ {
+ super(w, h);
+ GLContext.gljNativeDebug = false;
+ GLContext.gljClassDebug = false;
+ }
+
+ public void preInit()
+ {
+ doubleBuffer = true;
+ stereoView = false;
+ }
+
+ public void init()
+ {
+ System.out.println("init(): " + this);
+ reshape(getSize().width, getSize().height);
+
+ float position[] = { 0.5f, 0.5f, 3.0f, 0.0f };
+
+ gl.glEnable(GL_DEPTH_TEST);
+
+ gl.glLightfv(GL_LIGHT0, GL_POSITION, position);
+ gl.glEnable(GL_LIGHTING);
+ gl.glEnable(GL_LIGHT0);
+
+ float mat[] = {0.1745f, 0.01175f, 0.01175f};
+ gl.glMaterialfv(GL_FRONT, GL_AMBIENT, mat);
+ mat[0] = 0.61424f; mat[1] = 0.04136f; mat[2] = 0.04136f;
+ gl.glMaterialfv(GL_FRONT, GL_DIFFUSE, mat);
+ mat[0] = 0.727811f; mat[1] = 0.626959f; mat[2] = 0.626959f;
+ gl.glMaterialfv(GL_FRONT, GL_SPECULAR, mat);
+ gl.glMaterialf(GL_FRONT, GL_SHININESS, 0.6f*128.0f);
+
+ gl.glEnable(GL_FOG);
+
+ float fogColor[] = {0.5f, 0.5f, 0.5f, 1.0f};
+ fogMode = GL_EXP;
+ gl.glFogi(GL_FOG_MODE, fogMode);
+ gl.glFogfv(GL_FOG_COLOR, fogColor);
+ gl.glFogf(GL_FOG_DENSITY, 0.35f);
+ gl.glHint(GL_FOG_HINT, GL_DONT_CARE);
+ gl.glFogf(GL_FOG_START, 1.0f);
+ gl.glFogf(GL_FOG_END, 5.0f);
+
+ gl.glClearColor(0.5f, 0.5f, 0.5f, 1.0f); /* fog color */
+
+ glj.gljCheckGL();
+
+ addMouseListener(this);
+ }
+
+ public void cvsDispose()
+ {
+ System.out.println("destroy(): " + this);
+ removeMouseListener(this);
+ super.cvsDispose();
+ }
+
+ public void reshape(int width, int height)
+ {
+ gl.glViewport(0,0,width,height);
+ gl.glMatrixMode(GL_PROJECTION);
+
+ gl.glLoadIdentity();
+ if (width <= height)
+ gl.glOrtho
+ (-2.5f,
+ 2.5f,
+ -2.5f*(float)height/(float)width,
+ 2.5f*(float)height/(float)width,
+ -10.0f,
+ 10.0f);
+ else
+ gl.glOrtho
+ (-2.5f*(float)width/(float)height,
+ 2.5f*(float)width/(float)height,
+ -2.5f,
+ 2.5f,
+ -10.0f,
+ 10.0f);
+ gl.glMatrixMode(GL_MODELVIEW);
+ gl.glLoadIdentity ();
+ }
+
+ public void display()
+ {
+ if (glj.gljMakeCurrent() == false) return;
+
+ gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ renderSphere(-2.0f, -0.5f, -1.0f);
+ renderSphere(-1.0f, -0.5f, -2.0f);
+ renderSphere(0.0f, -0.5f, -3.0f);
+ renderSphere(1.0f, -0.5f, -4.0f);
+ renderSphere(2.0f, -0.5f, -5.0f);
+ gl.glFlush();
+
+ glj.gljSwap();
+ glj.gljCheckGL();
+ glj.gljFree();
+ }
+
+ private void renderSphere(float x, float y, float z)
+ {
+ gl.glPushMatrix();
+ gl.glTranslatef(x, y, z);
+
+ int qobj = glu.gluNewQuadric();
+ glu.gluQuadricOrientation(qobj,GLU_OUTSIDE);
+ glu.gluQuadricNormals(qobj,GLU_SMOOTH);
+ glu.gluQuadricTexture(qobj,false);
+ glu.gluSphere(qobj,0.4f,16,16);
+ glu.gluDeleteQuadric(qobj);
+
+ gl.glPopMatrix();
+ }
+
+ // Methods required for the implementation of MouseListener
+ public void mouseEntered( MouseEvent evt )
+ {
+ }
+
+ public void mouseExited( MouseEvent evt )
+ {
+ }
+
+ public void mousePressed( MouseEvent evt )
+ {
+ if (fogMode == GL_EXP)
+ {
+ fogMode = GL_EXP2;
+ System.out.println("Fog mode is GL_EXP2");
+ }
+ else if (fogMode == GL_EXP2)
+ {
+ fogMode = GL_LINEAR;
+ System.out.println("Fog mode is GL_LINEAR");
+ }
+ else
+ {
+ fogMode = GL_EXP;
+ System.out.println("Fog mode is GL_EXP");
+ }
+ gl.glFogi(GL_FOG_MODE,fogMode);
+ repaint();
+ }
+
+ public void mouseReleased( MouseEvent evt )
+ {
+ }
+
+ public void mouseClicked( MouseEvent evt )
+ {
+ }
+ }
+}
diff --git a/demos/RonsDemos/fog_plugin13.html b/demos/RonsDemos/fog_plugin13.html new file mode 100644 index 0000000..94f367d --- /dev/null +++ b/demos/RonsDemos/fog_plugin13.html @@ -0,0 +1,49 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
+ <title>Fog by Silicon Graphics; ported to Java by Ron Cemer</title>
+</head>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+Fog applet
+<br>Originially written by Silicon Graphics
+<br>Ported to Java by Ron Cemer
+<br>Click inside the window to cycle the fog mode.
+<br>
+<!--"CONVERTED_APPLET"-->
+<!-- CONVERTER VERSION 1.3 --> +<SCRIPT LANGUAGE="JavaScript"><!-- + var _info = navigator.userAgent; var _ns = false; + var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0); +//--></SCRIPT> +<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!-- + var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0))); +//--></SCRIPT></COMMENT> + +<SCRIPT LANGUAGE="JavaScript"><!-- + if (_ie == true) document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = 400 HEIGHT = 400 codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0"><NOEMBED><XMP>'); + else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.3" CODE = "fog.class" WIDTH = 400 HEIGHT = 400 scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html"><NOEMBED><XMP>'); +//--></SCRIPT> +<APPLET CODE = "fog.class" WIDTH = 400 HEIGHT = 400></XMP> +<PARAM NAME = CODE VALUE = "fog.class" >
+ +<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3"> +<PARAM NAME="scriptable" VALUE="false"> + +</APPLET> + +</NOEMBED></EMBED></OBJECT> + + +<!-- +<APPLET CODE = "fog.class" WIDTH = 400 HEIGHT = 400>
+
+
+</APPLET> +--> +<!--"END_CONVERTED_APPLET"-->
+
+<hr>
+</body>
+</html>
diff --git a/demos/RonsDemos/gears.html b/demos/RonsDemos/gears.html new file mode 100644 index 0000000..fb44ddb --- /dev/null +++ b/demos/RonsDemos/gears.html @@ -0,0 +1,23 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
+ <title>Gears by Brian Paul; ported to Java by Ron Cemer</title>
+</head>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+Gears applet
+<br>Originially written by Brian Paul
+<br>Ported to Java by Ron Cemer
+<br>
+<hr>
+<br>You can rotate the view by holding the left mouse button down and
+<br>dragging the mouse within the applet's window.
+<br>If you hold the right button down instead, the view will rotate
+<br>around the Z axis.
+<br>
+<applet code="gears.class" width=400 height=400>
+</applet>
+<hr>
+</body>
+</html>
diff --git a/demos/RonsDemos/gears.java b/demos/RonsDemos/gears.java new file mode 100644 index 0000000..cdc1634 --- /dev/null +++ b/demos/RonsDemos/gears.java @@ -0,0 +1,432 @@ +/**
+ * @(#) gears.java
+ * @(#) author: Brian Paul (converted to Java by Ron Cemer)
+ */
+
+import java.applet.*;
+import java.awt.*;
+import java.awt.event.*;
+import java.lang.*;
+import java.util.*;
+import java.io.*;
+import java.util.*;
+import gl4java.GLContext;
+import gl4java.awt.GLAnimCanvas;
+import gl4java.applet.SimpleGLAnimApplet1;
+
+public class gears extends SimpleGLAnimApplet1
+{
+
+ /* Initialize the applet */
+
+
+ public void init()
+ {
+ super.init();
+ Dimension d = getSize();
+ canvas = new gearsCanvas(d.width, d.height);
+ add("Center", canvas);
+ }
+
+
+ public static void main( String args[] )
+ {
+ Frame mainFrame = new Frame("gears");
+
+ gears applet = new gears();
+
+ applet.setSize(400, 400);
+ applet.init();
+ applet.start();
+
+ mainFrame.add(applet);
+
+ mainFrame.pack();
+ mainFrame.setVisible(true);
+ }
+
+
+ /* Local GLAnimCanvas extension class */
+
+
+ private class gearsCanvas extends GLAnimCanvas implements MouseListener, MouseMotionListener
+ {
+ private static final float M_PI = 3.14159265359f;
+ private int gear1, gear2, gear3;
+ private float angle = 0.0f;
+
+ private MatrixFuncs mtxfuncs = null;
+ private int prevMouseX, prevMouseY;
+ private boolean mouseRButtonDown = false;
+ private float rot_matrix[] =
+ {
+ 1.0f, 0.0f, 0.0f, 0.0f,
+ 0.0f, 1.0f, 0.0f, 0.0f,
+ 0.0f, 0.0f, 1.0f, 0.0f,
+ 0.0f, 0.0f, 0.0f, 1.0f
+ };
+
+ public gearsCanvas(int w, int h)
+ {
+ super(w, h);
+ GLContext.gljNativeDebug = false;
+ GLContext.gljClassDebug = false;
+ setAnimateFps(30.0);
+
+ mtxfuncs = new MatrixFuncs();
+ }
+
+ public void preInit()
+ {
+ doubleBuffer = true;
+ stereoView = false;
+ }
+
+ public void init()
+ {
+ System.out.println("init(): " + this);
+ reshape(getSize().width, getSize().height);
+
+ setInitialRotation();
+
+ float pos[] = { 5.0f, 5.0f, 10.0f, 0.0f };
+ float red[] = { 0.8f, 0.1f, 0.0f, 1.0f };
+ float green[] = { 0.0f, 0.8f, 0.2f, 1.0f };
+ float blue[] = { 0.2f, 0.2f, 1.0f, 1.0f };
+
+ gl.glLightfv(GL_LIGHT0, GL_POSITION, pos);
+ gl.glEnable(GL_CULL_FACE);
+ gl.glEnable(GL_LIGHTING);
+ gl.glEnable(GL_LIGHT0);
+ gl.glEnable(GL_DEPTH_TEST);
+
+ /* make the gears */
+ gear1 = gl.glGenLists(1);
+ gl.glNewList(gear1, GL_COMPILE);
+ gl.glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red);
+ gear(1.0f, 4.0f, 1.0f, 20, 0.7f);
+ gl.glEndList();
+
+ gear2 = gl.glGenLists(1);
+ gl.glNewList(gear2, GL_COMPILE);
+ gl.glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green);
+ gear(0.5f, 2.0f, 2.0f, 10, 0.7f);
+ gl.glEndList();
+
+ gear3 = gl.glGenLists(1);
+ gl.glNewList(gear3, GL_COMPILE);
+ gl.glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue);
+ gear(1.3f, 2.0f, 0.5f, 10, 0.7f);
+ gl.glEndList();
+
+ gl.glEnable(GL_NORMALIZE);
+
+ glj.gljCheckGL();
+
+ addMouseListener(this);
+ addMouseMotionListener(this);
+ }
+
+ public void doCleanup()
+ {
+ System.out.println("destroy(): " + this);
+ removeMouseListener(this);
+ removeMouseMotionListener(this);
+ }
+
+ public void reshape(int width, int height)
+ {
+ float h = (float)height / (float)width;
+
+ gl.glViewport(0,0,width,height);
+ gl.glMatrixMode(GL_PROJECTION);
+ gl.glLoadIdentity();
+ gl.glFrustum(-1.0f, 1.0f, -h, h, 5.0f, 60.0f);
+ gl.glMatrixMode(GL_MODELVIEW);
+ gl.glLoadIdentity();
+ gl.glTranslatef(0.0f, 0.0f, -40.0f);
+ }
+
+ public void display()
+ {
+ if (glj.gljMakeCurrent() == false) return;
+
+ angle += 0.5f;
+
+ gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+ gl.glPushMatrix();
+ gl.glMultMatrixf(rot_matrix);
+
+ gl.glPushMatrix();
+ gl.glTranslatef(-3.0f, -2.0f, 0.0f);
+ gl.glRotatef(angle, 0.0f, 0.0f, 1.0f);
+ gl.glCallList(gear1);
+ gl.glPopMatrix();
+
+ gl.glPushMatrix();
+ gl.glTranslatef(3.1f, -2.0f, 0.0f);
+ gl.glRotatef(-2.0f * angle - 9.0f, 0.0f, 0.0f, 1.0f);
+ gl.glCallList(gear2);
+ gl.glPopMatrix();
+
+ gl.glPushMatrix();
+ gl.glTranslatef(-3.1f, 4.2f, 0.0f);
+ gl.glRotatef(-2.0f * angle - 25.0f, 0.0f, 0.0f, 1.0f);
+ gl.glCallList(gear3);
+ gl.glPopMatrix();
+
+ gl.glPopMatrix();
+
+ glj.gljSwap();
+ glj.gljCheckGL();
+ glj.gljFree();
+
+ //if (!isSuspended()) repaint(); // Animate at full speed.
+ }
+
+ private void gear
+ (float inner_radius,
+ float outer_radius,
+ float width,
+ int teeth,
+ float tooth_depth)
+ {
+ int i;
+ float r0, r1, r2;
+ float angle, da;
+ float u, v, len;
+
+ r0 = inner_radius;
+ r1 = outer_radius - tooth_depth / 2.0f;
+ r2 = outer_radius + tooth_depth / 2.0f;
+
+ da = 2.0f * M_PI / teeth / 4.0f;
+
+ gl.glShadeModel(GL_FLAT);
+
+ gl.glNormal3f(0.0f, 0.0f, 1.0f);
+
+ /* draw front face */
+ gl.glBegin(GL_QUAD_STRIP);
+ for (i = 0; i <= teeth; i++)
+ {
+ angle = i * 2.0f * M_PI / teeth;
+ gl.glVertex3f(r0 * (float)Math.cos(angle), r0 * (float)Math.sin(angle), width * 0.5f);
+ gl.glVertex3f(r1 * (float)Math.cos(angle), r1 * (float)Math.sin(angle), width * 0.5f);
+ gl.glVertex3f(r0 * (float)Math.cos(angle), r0 * (float)Math.sin(angle), width * 0.5f);
+ gl.glVertex3f(r1 * (float)Math.cos(angle + 3.0f * da), r1 * (float)Math.sin(angle + 3.0f * da), width * 0.5f);
+ }
+ gl.glEnd();
+
+ /* draw front sides of teeth */
+ gl.glBegin(GL_QUADS);
+ da = 2.0f * M_PI / teeth / 4.0f;
+ for (i = 0; i < teeth; i++)
+ {
+ angle = i * 2.0f * M_PI / teeth;
+ gl.glVertex3f(r1 * (float)Math.cos(angle), r1 * (float)Math.sin(angle), width * 0.5f);
+ gl.glVertex3f(r2 * (float)Math.cos(angle + da), r2 * (float)Math.sin(angle + da), width * 0.5f);
+ gl.glVertex3f(r2 * (float)Math.cos(angle + 2.0f * da), r2 * (float)Math.sin(angle + 2.0f * da), width * 0.5f);
+ gl.glVertex3f(r1 * (float)Math.cos(angle + 3.0f * da), r1 * (float)Math.sin(angle + 3.0f * da), width * 0.5f);
+ }
+ gl.glEnd();
+
+ gl.glNormal3f(0.0f, 0.0f, -1.0f);
+
+ /* draw back face */
+ gl.glBegin(GL_QUAD_STRIP);
+ for (i = 0; i <= teeth; i++)
+ {
+ angle = i * 2.0f * M_PI / teeth;
+ gl.glVertex3f(r1 * (float)Math.cos(angle), r1 * (float)Math.sin(angle), -width * 0.5f);
+ gl.glVertex3f(r0 * (float)Math.cos(angle), r0 * (float)Math.sin(angle), -width * 0.5f);
+ gl.glVertex3f(r1 * (float)Math.cos(angle + 3 * da), r1 * (float)Math.sin(angle + 3 * da), -width * 0.5f);
+ gl.glVertex3f(r0 * (float)Math.cos(angle), r0 * (float)Math.sin(angle), -width * 0.5f);
+ }
+ gl.glEnd();
+
+ /* draw back sides of teeth */
+ gl.glBegin(GL_QUADS);
+ da = 2.0f * M_PI / teeth / 4.0f;
+ for (i = 0; i < teeth; i++)
+ {
+ angle = i * 2.0f * M_PI / teeth;
+ gl.glVertex3f(r1 * (float)Math.cos(angle + 3 * da), r1 * (float)Math.sin(angle + 3 * da), -width * 0.5f);
+ gl.glVertex3f(r2 * (float)Math.cos(angle + 2 * da), r2 * (float)Math.sin(angle + 2 * da), -width * 0.5f);
+ gl.glVertex3f(r2 * (float)Math.cos(angle + da), r2 * (float)Math.sin(angle + da), -width * 0.5f);
+ gl.glVertex3f(r1 * (float)Math.cos(angle), r1 * (float)Math.sin(angle), -width * 0.5f);
+ }
+ gl.glEnd();
+
+ /* draw outward faces of teeth */
+ gl.glBegin(GL_QUAD_STRIP);
+ for (i = 0; i < teeth; i++)
+ {
+ angle = i * 2.0f * M_PI / teeth;
+ gl.glVertex3f(r1 * (float)Math.cos(angle), r1 * (float)Math.sin(angle), width * 0.5f);
+ gl.glVertex3f(r1 * (float)Math.cos(angle), r1 * (float)Math.sin(angle), -width * 0.5f);
+ u = r2 * (float)Math.cos(angle + da) - r1 * (float)Math.cos(angle);
+ v = r2 * (float)Math.sin(angle + da) - r1 * (float)Math.sin(angle);
+ len = (float)Math.sqrt(u * u + v * v);
+ u /= len;
+ v /= len;
+ gl.glNormal3f(v, -u, 0.0f);
+ gl.glVertex3f(r2 * (float)Math.cos(angle + da), r2 * (float)Math.sin(angle + da), width * 0.5f);
+ gl.glVertex3f(r2 * (float)Math.cos(angle + da), r2 * (float)Math.sin(angle + da), -width * 0.5f);
+ gl.glNormal3f((float)Math.cos(angle), (float)Math.sin(angle), 0.0f);
+ gl.glVertex3f(r2 * (float)Math.cos(angle + 2 * da), r2 * (float)Math.sin(angle + 2 * da), width * 0.5f);
+ gl.glVertex3f(r2 * (float)Math.cos(angle + 2 * da), r2 * (float)Math.sin(angle + 2 * da), -width * 0.5f);
+ u = r1 * (float)Math.cos(angle + 3 * da) - r2 * (float)Math.cos(angle + 2 * da);
+ v = r1 * (float)Math.sin(angle + 3 * da) - r2 * (float)Math.sin(angle + 2 * da);
+ gl.glNormal3f(v, -u, 0.0f);
+ gl.glVertex3f(r1 * (float)Math.cos(angle + 3 * da), r1 * (float)Math.sin(angle + 3 * da), width * 0.5f);
+ gl.glVertex3f(r1 * (float)Math.cos(angle + 3 * da), r1 * (float)Math.sin(angle + 3 * da), -width * 0.5f);
+ gl.glNormal3f((float)Math.cos(angle), (float)Math.sin(angle), 0.0f);
+ }
+ gl.glVertex3f(r1 * (float)Math.cos(0), r1 * (float)Math.sin(0), width * 0.5f);
+ gl.glVertex3f(r1 * (float)Math.cos(0), r1 * (float)Math.sin(0), -width * 0.5f);
+ gl.glEnd();
+
+ gl.glShadeModel(GL_SMOOTH);
+
+ /* draw inside radius cylinder */
+ gl.glBegin(GL_QUAD_STRIP);
+ for (i = 0; i <= teeth; i++)
+ {
+ angle = i * 2.0f * M_PI / teeth;
+ gl.glNormal3f(-(float)Math.cos(angle), -(float)Math.sin(angle), 0.0f);
+ gl.glVertex3f(r0 * (float)Math.cos(angle), r0 * (float)Math.sin(angle), -width * 0.5f);
+ gl.glVertex3f(r0 * (float)Math.cos(angle), r0 * (float)Math.sin(angle), width * 0.5f);
+ }
+ gl.glEnd();
+ }
+
+ // Reset the rotation matrix to the default view.
+ private void setInitialRotation()
+ {
+ float mtxbuf[] = new float[16];
+ float mtxbuf2[] = new float[16];
+
+ mtxfuncs.rotateAroundY(30.0f,mtxbuf);
+ mtxfuncs.rotateAroundX(20.0f,mtxbuf2);
+ mtxfuncs.multiplyMatrices(mtxbuf2,mtxbuf,rot_matrix);
+ fixRotationMatrix();
+ }
+
+ private void fixRotationMatrix()
+ {
+ // Fix any problems with the rotation matrix.
+ rot_matrix[3] =
+ rot_matrix[7] =
+ rot_matrix[11] =
+ rot_matrix[12] =
+ rot_matrix[13] =
+ rot_matrix[14] = 0.0f;
+ rot_matrix[15] = 1.0f;
+ float fac;
+ if ((fac = (float)Math.sqrt
+ ((rot_matrix[0]*rot_matrix[0]) +
+ (rot_matrix[4]*rot_matrix[4]) +
+ (rot_matrix[8]*rot_matrix[8]))) != 1.0f)
+ {
+ if (fac != 0.0f)
+ {
+ fac = 1.0f/fac;
+ rot_matrix[0] *= fac;
+ rot_matrix[4] *= fac;
+ rot_matrix[8] *= fac;
+ }
+ }
+ if ((fac = (float)Math.sqrt
+ ((rot_matrix[1]*rot_matrix[1]) +
+ (rot_matrix[5]*rot_matrix[5]) +
+ (rot_matrix[9]*rot_matrix[9]))) != 1.0f)
+ {
+ if (fac != 0.0f)
+ {
+ fac = 1.0f/fac;
+ rot_matrix[1] *= fac;
+ rot_matrix[5] *= fac;
+ rot_matrix[9] *= fac;
+ }
+ }
+ if ((fac = (float)Math.sqrt
+ ((rot_matrix[2]*rot_matrix[2]) +
+ (rot_matrix[6]*rot_matrix[6]) +
+ (rot_matrix[10]*rot_matrix[10]))) != 1.0f)
+ {
+ if (fac != 0.0f)
+ {
+ fac = 1.0f/fac;
+ rot_matrix[2] *= fac;
+ rot_matrix[6] *= fac;
+ rot_matrix[10] *= fac;
+ }
+ }
+ }
+
+ // Methods required for the implementation of MouseListener
+ public void mouseEntered( MouseEvent evt )
+ {
+ }
+
+ public void mouseExited( MouseEvent evt )
+ {
+ }
+
+ public void mousePressed( MouseEvent evt )
+ {
+ prevMouseX = evt.getX();
+ prevMouseY = evt.getY();
+ if ((evt.getModifiers() & evt.BUTTON3_MASK) != 0)
+ {
+ mouseRButtonDown = true;
+ evt.consume();
+ }
+ }
+
+ public void mouseReleased( MouseEvent evt )
+ {
+ if ((evt.getModifiers() & evt.BUTTON3_MASK) != 0)
+ {
+ mouseRButtonDown = false;
+ evt.consume();
+ }
+ }
+
+ public void mouseClicked( MouseEvent evt )
+ {
+ }
+
+ // Methods required for the implementation of MouseMotionListener
+ public void mouseDragged( MouseEvent evt )
+ {
+ int x = evt.getX();
+ int y = evt.getY();
+ float thetaX = (float)(x-prevMouseX)*(360.0f/(float)getSize().width);
+ float thetaY = (float)(prevMouseY-y)*(360.0f/(float)getSize().height);
+ float mtxbuf[] = new float[16];
+ float mtxbuf2[] = new float[16];
+
+ prevMouseX = x;
+ prevMouseY = y;
+ if ( (thetaX != 0.0f) || (thetaY != 0.0f) )
+ {
+ mtxfuncs.rotateAroundY(((float)thetaX),mtxbuf);
+ if (mouseRButtonDown)
+ mtxfuncs.rotateAroundZ(thetaY,mtxbuf2);
+ else
+ mtxfuncs.rotateAroundX(-thetaY,mtxbuf2);
+ mtxfuncs.multiplyMatrices(mtxbuf2,mtxbuf,mtxbuf);
+ mtxfuncs.multiplyMatrices(rot_matrix,mtxbuf,rot_matrix);
+ fixRotationMatrix();
+ }
+ evt.consume();
+ }
+
+ public void mouseMoved( MouseEvent evt )
+ {
+ }
+ }
+}
diff --git a/demos/RonsDemos/gears_plugin13.html b/demos/RonsDemos/gears_plugin13.html new file mode 100644 index 0000000..2069b32 --- /dev/null +++ b/demos/RonsDemos/gears_plugin13.html @@ -0,0 +1,54 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
+ <title>Gears by Brian Paul; ported to Java by Ron Cemer</title>
+</head>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+Gears applet
+<br>Originially written by Brian Paul
+<br>Ported to Java by Ron Cemer
+<br>
+<hr>
+<br>You can rotate the view by holding the left mouse button down and
+<br>dragging the mouse within the applet's window.
+<br>If you hold the right button down instead, the view will rotate
+<br>around the Z axis.
+<br>
+<!--"CONVERTED_APPLET"-->
+<!-- CONVERTER VERSION 1.3 --> +<SCRIPT LANGUAGE="JavaScript"><!-- + var _info = navigator.userAgent; var _ns = false; + var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0); +//--></SCRIPT> +<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!-- + var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0))); +//--></SCRIPT></COMMENT> + +<SCRIPT LANGUAGE="JavaScript"><!-- + if (_ie == true) document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = 400 HEIGHT = 400 codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0"><NOEMBED><XMP>'); + else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.3" CODE = "gears.class" WIDTH = 400 HEIGHT = 400 scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html"><NOEMBED><XMP>'); +//--></SCRIPT> +<APPLET CODE = "gears.class" WIDTH = 400 HEIGHT = 400></XMP> +<PARAM NAME = CODE VALUE = "gears.class" >
+ +<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3"> +<PARAM NAME="scriptable" VALUE="false"> + +</APPLET> + +</NOEMBED></EMBED></OBJECT> + + +<!-- +<APPLET CODE = "gears.class" WIDTH = 400 HEIGHT = 400>
+
+
+</APPLET> +--> +<!--"END_CONVERTED_APPLET"-->
+
+<hr>
+</body>
+</html>
diff --git a/demos/RonsDemos/gl4java.policy b/demos/RonsDemos/gl4java.policy new file mode 100644 index 0000000..6ea44cc --- /dev/null +++ b/demos/RonsDemos/gl4java.policy @@ -0,0 +1,27 @@ +
+grant codeBase "http://www.jausoft.com/Files/Java/1.1.X/GL4Java/demos/-"
+{
+ permission java.security.RuntimePermission;
+};
+
+grant codeBase "http://www.jausoft.com/Files/Java/1.1.X/GL4Java/demos/RonsDemos/-"
+{
+ permission java.security.RuntimePermission;
+};
+
+grant codeBase "http://jausoft.goethel.de/Files/Java/1.1.X/GL4Java/demos/RonsDemos/-" {
+ permission java.security.RuntimePermission;
+};
+
+grant codeBase "http://jausoft.goethel.de/Files/Java/1.1.X/GL4Java/demos/-" {
+ permission java.security.RuntimePermission;
+};
+
+grant codeBase "file://f/java-1.1.X/GL4Java/demos/-" {
+ permission java.security.AllPermission;
+};
+
+grant codeBase "file://f/java-1.1.X/GL4Java/demos/RonsDemos/-" {
+ permission java.security.AllPermission;
+};
+
diff --git a/demos/RonsDemos/glutplane.html b/demos/RonsDemos/glutplane.html new file mode 100644 index 0000000..3e7760d --- /dev/null +++ b/demos/RonsDemos/glutplane.html @@ -0,0 +1,19 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
+ <title>Glutplane by Mark J. Kilgard; ported to Java by Ron Cemer</title>
+</head>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+Glutplane applet
+<br>Originially written by Mark J. Kilgard
+<br>Ported to Java by Ron Cemer
+<br>Right-click within the window for a menu of commands.
+<br>While suspended, left-click within the window to render the next frame.
+<br>
+<applet code="glutplane.class" width=400 height=400>
+</applet>
+<hr>
+</body>
+</html>
diff --git a/demos/RonsDemos/glutplane.java b/demos/RonsDemos/glutplane.java new file mode 100644 index 0000000..c1e0e52 --- /dev/null +++ b/demos/RonsDemos/glutplane.java @@ -0,0 +1,334 @@ +/**
+ * @(#) glutplane.java
+ * @(#) author: Mark J. Kilgard (converted to Java by Ron Cemer)
+ */
+
+/* This program is freely distributable without licensing fees
+ and is provided without guarantee or warrantee expressed or
+ implied. This program is -not- in the public domain. */
+
+import java.applet.*;
+import java.awt.*;
+import java.awt.event.*;
+import java.lang.*;
+import java.util.*;
+import java.io.*;
+import java.util.*;
+import gl4java.GLContext;
+import gl4java.awt.GLAnimCanvas;
+import gl4java.applet.SimpleGLAnimApplet1;
+
+public class glutplane extends SimpleGLAnimApplet1
+{
+ /* Initialize the applet */
+
+
+ public void init()
+ {
+ super.init();
+ Dimension d = getSize();
+ canvas = new glutplaneCanvas(d.width, d.height);
+ add("Center", canvas);
+ }
+
+
+ private class planeobj
+ {
+ float speed = 0.0f; /* zero speed means not flying */
+ float red = 0.0f, green = 0.0f, blue = 0.0f;
+ float theta = 0.0f;
+ float x = 0.0f, y = 0.0f, z = 0.0f, angle = 0.0f;
+
+ public void setColor(float r, float g, float b)
+ {
+ red = r;
+ green = g;
+ blue = b;
+ }
+ };
+
+
+ /* Local GLAnimCanvas extension class */
+
+
+ private class glutplaneCanvas extends GLAnimCanvas
+ implements MouseListener, ActionListener
+ {
+ private final double M_PI = 3.14159265;
+ private final double M_PI_2 = 1.57079632;
+ private final int MAX_PLANES = 15;
+ private final String ADD_PLANE = "Add plane";
+ private final String REMOVE_PLANE = "Remove plane";
+ private final String SUSPEND_RESUME = "Suspend/resume animation";
+
+ private planeobj planes[] = null;
+ private Random random = null;
+ private PopupMenu menu = null;
+ private boolean menu_showing = false;
+ private boolean save_suspended = false;
+
+ public glutplaneCanvas(int w, int h)
+ {
+ super(w, h);
+ GLContext.gljNativeDebug = false;
+ GLContext.gljClassDebug = false;
+ setAnimateFps(30.0);
+ }
+
+ public void preInit()
+ {
+ doubleBuffer = true;
+ stereoView = false;
+ }
+
+ public void init()
+ {
+ System.out.println("init(): " + this);
+ reshape(getSize().width, getSize().height);
+
+ gl.glClearDepth(1.0f);
+ gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
+ gl.glMatrixMode(GL_PROJECTION);
+ gl.glFrustum(-1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 20.0f);
+ gl.glMatrixMode(GL_MODELVIEW);
+ /* add three initial random planes */
+ planes = new planeobj[MAX_PLANES];
+ for (int i = 0; i < MAX_PLANES; i++)
+ planes[i] = new planeobj();
+ random = new Random(System.currentTimeMillis());
+ add_plane();
+ add_plane();
+ add_plane();
+
+ glj.gljCheckGL();
+
+ menu = new PopupMenu("Options");
+ menu.add(ADD_PLANE);
+ menu.add(REMOVE_PLANE);
+ menu.add(SUSPEND_RESUME);
+ menu.addActionListener(this);
+ add(menu);
+
+ addMouseListener(this);
+ }
+
+ public void doCleanup()
+ {
+ System.out.println("destroy(): " + this);
+ removeMouseListener(this);
+ menu.removeActionListener(this);
+ }
+
+ public void reshape(int width, int height)
+ {
+ gl.glViewport(0,0,width,height);
+ }
+
+ public void display()
+ {
+ if (glj.gljMakeCurrent() == false) return;
+
+ tick();
+
+ float red, green, blue;
+
+ gl.glClear(GL_DEPTH_BUFFER_BIT);
+ /* paint black to blue smooth shaded polygon for background */
+ gl.glDisable(GL_DEPTH_TEST);
+ gl.glShadeModel(GL_SMOOTH);
+ gl.glBegin(GL_POLYGON);
+ gl.glColor3f(0.0f, 0.0f, 0.0f);
+ gl.glVertex3f(-20f, 20f, -19f);
+ gl.glVertex3f(20f, 20f, -19f);
+ gl.glColor3f(0.0f, 0.0f, 1.0f);
+ gl.glVertex3f(20f, -20f, -19f);
+ gl.glVertex3f(-20f, -20f, -19f);
+ gl.glEnd();
+ /* paint planes */
+ gl.glEnable(GL_DEPTH_TEST);
+ gl.glShadeModel(GL_FLAT);
+ for (int i = 0; i < MAX_PLANES; i++)
+ {
+ if (planes[i].speed != 0.0f)
+ {
+ gl.glPushMatrix();
+ gl.glTranslatef(planes[i].x, planes[i].y, planes[i].z);
+ gl.glRotatef(290.0f, 1.0f, 0.0f, 0.0f);
+ gl.glRotatef(planes[i].angle, 0.0f, 0.0f, 1.0f);
+ gl.glScalef(1.0f / 3.0f, 1.0f / 4.0f, 1.0f / 4.0f);
+ gl.glTranslatef(0.0f, -4.0f, -1.5f);
+ gl.glBegin(GL_TRIANGLE_STRIP);
+ /* left wing */
+ gl.glVertex3f(-7.0f, 0.0f, 2.0f);
+ gl.glVertex3f(-1.0f, 0.0f, 3.0f);
+ red = planes[i].red;
+ green = planes[i].green;
+ blue = planes[i].blue;
+ gl.glColor3f(red,green,blue);
+ gl.glVertex3f(-1.0f, 7.0f, 3.0f);
+ /* left side */
+ gl.glColor3f(0.6f * red, 0.6f * green, 0.6f * blue);
+ gl.glVertex3f(0.0f, 0.0f, 0.0f);
+ gl.glVertex3f(0.0f, 8.0f, 0.0f);
+ /* right side */
+ gl.glVertex3f(1.0f, 0.0f, 3.0f);
+ gl.glVertex3f(1.0f, 7.0f, 3.0f);
+ /* final tip of right wing */
+ gl.glColor3f(red, green, blue);
+ gl.glVertex3f(7.0f, 0.0f, 2.0f);
+ gl.glEnd();
+ gl.glPopMatrix();
+ }
+ }
+
+ glj.gljSwap();
+ glj.gljCheckGL();
+ glj.gljFree();
+
+ // if (!isSuspended()) repaint(); // Animate at full speed.
+ }
+
+ // Methods required for the implementation of MouseListener
+ public void mouseEntered(MouseEvent evt)
+ {
+ }
+
+ public void mouseExited(MouseEvent evt)
+ {
+ }
+
+ public void mousePressed(MouseEvent evt)
+ {
+ // If user presses right mouse button within canvas area,
+ // suspend animation and pop up menu.
+ // If menu was already popped up and user presses either
+ // mouse button within canvas area, resume animation
+ // because the menu will have been removed automatically.
+ if (!menu_showing)
+ {
+ if ((evt.getModifiers() & evt.BUTTON3_MASK) != 0)
+ {
+ menu_showing = true;
+ save_suspended = isSuspended();
+ if (!save_suspended)
+ {
+ setSuspended(true);
+ repaint(100);
+ try
+ {
+ Thread.currentThread().sleep(200);
+ }
+ catch (Exception e)
+ { }
+ }
+ menu.show(this,evt.getX(),evt.getY());
+ }
+ else
+ {
+ // Must be left button.
+ if (isSuspended()) repaint();
+ }
+ }
+ else
+ {
+ menu_showing = false;
+ setSuspended(save_suspended);
+ }
+ }
+
+ public void mouseReleased(MouseEvent evt)
+ {
+ }
+
+ public void mouseClicked(MouseEvent evt)
+ {
+ }
+
+ // Method required for the implementation of ActionListener
+ public void actionPerformed(ActionEvent evt)
+ {
+ String c = evt.getActionCommand();
+ if (c.equals(ADD_PLANE))
+ {
+ add_plane();
+ }
+ else if (c.equals(REMOVE_PLANE))
+ {
+ remove_plane();
+ }
+ else if (c.equals(SUSPEND_RESUME))
+ {
+ if (menu_showing)
+ save_suspended = !save_suspended;
+ else
+ setSuspended(!isSuspended()); // not likely to happen
+ }
+ if (menu_showing)
+ {
+ menu_showing = false;
+ setSuspended(save_suspended);
+ }
+ }
+
+ private void tick_per_plane(int i)
+ {
+ float theta = planes[i].theta += planes[i].speed;
+ planes[i].z = -9.0f + 4.0f * (float)Math.cos(theta);
+ planes[i].x = 4 * (float)Math.sin(2.0f * theta);
+ planes[i].y = (float)Math.sin(theta / 3.4f) * 3.0f;
+ planes[i].angle = (float)
+ (((Math.atan(2.0) + M_PI_2) * Math.sin(theta) - M_PI_2) *
+ 180.0 / M_PI);
+ if (planes[i].speed < 0.0f) planes[i].angle += 180.0f;
+ }
+
+ private void add_plane()
+ {
+ for (int i = 0; i < MAX_PLANES; i++)
+ {
+ if (planes[i].speed == 0.0f)
+ {
+ int c = random.nextInt() & 0x07;
+ while (c == 0) c = random.nextInt() & 0x07;
+ float r = (float)((c >> 2) & 0x01);
+ float g = (float)((c >> 1) & 0x01);
+ float b = (float)(c & 0x01);
+ // Blue fades into the background; lighten it up.
+ if (c == 0x01) r = g = 0.4f;
+ planes[i].setColor(r,g,b);
+ planes[i].speed =
+ ((float)(random.nextInt() % 20)) * 0.001f + 0.02f;
+ if ((random.nextInt() & 0x01) != 0)
+ planes[i].speed *= -1.0f;
+ planes[i].theta =
+ ((float)(random.nextInt() % 257))*0.1111f;
+ tick_per_plane(i);
+ if (isSuspended()) repaint();
+ return;
+ }
+ }
+ }
+
+ private void remove_plane()
+ {
+ for (int i = MAX_PLANES - 1; i >= 0; i--)
+ {
+ if (planes[i].speed != 0.0f)
+ {
+ planes[i].speed = 0.0f;
+ if (isSuspended()) repaint();
+ return;
+ }
+ }
+ }
+
+ private void tick()
+ {
+ for (int i = 0; i < MAX_PLANES; i++)
+ {
+ if (planes[i].speed != 0.0f)
+ tick_per_plane(i);
+ }
+ }
+ }
+}
diff --git a/demos/RonsDemos/glutplane_plugin13.html b/demos/RonsDemos/glutplane_plugin13.html new file mode 100644 index 0000000..c0d6353 --- /dev/null +++ b/demos/RonsDemos/glutplane_plugin13.html @@ -0,0 +1,50 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
+ <title>Glutplane by Mark J. Kilgard; ported to Java by Ron Cemer</title>
+</head>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+Glutplane applet
+<br>Originially written by Mark J. Kilgard
+<br>Ported to Java by Ron Cemer
+<br>Right-click within the window for a menu of commands.
+<br>While suspended, left-click within the window to render the next frame.
+<br>
+<!--"CONVERTED_APPLET"-->
+<!-- CONVERTER VERSION 1.3 --> +<SCRIPT LANGUAGE="JavaScript"><!-- + var _info = navigator.userAgent; var _ns = false; + var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0); +//--></SCRIPT> +<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!-- + var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0))); +//--></SCRIPT></COMMENT> + +<SCRIPT LANGUAGE="JavaScript"><!-- + if (_ie == true) document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = 400 HEIGHT = 400 codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0"><NOEMBED><XMP>'); + else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.3" CODE = "glutplane.class" WIDTH = 400 HEIGHT = 400 scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html"><NOEMBED><XMP>'); +//--></SCRIPT> +<APPLET CODE = "glutplane.class" WIDTH = 400 HEIGHT = 400></XMP> +<PARAM NAME = CODE VALUE = "glutplane.class" >
+ +<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3"> +<PARAM NAME="scriptable" VALUE="false"> + +</APPLET> + +</NOEMBED></EMBED></OBJECT> + + +<!-- +<APPLET CODE = "glutplane.class" WIDTH = 400 HEIGHT = 400>
+
+
+</APPLET> +--> +<!--"END_CONVERTED_APPLET"-->
+
+<hr>
+</body>
+</html>
diff --git a/demos/RonsDemos/index.html b/demos/RonsDemos/index.html new file mode 100644 index 0000000..c3005c5 --- /dev/null +++ b/demos/RonsDemos/index.html @@ -0,0 +1,123 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="Author" content="Ron Cemer & Sven Goethel">
+ <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
+ <title>OpenGL Demos Ported to GL4Java</title>
+</head>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+<br>
+<p><a href="index_plugin13.html">To use the Java2 Plug-In (Java2, JRE, Plug-In 1.3), click here !</a><br>
+<br>
+!!! The original demos are ported by Ron Cemer !!! <br>
+<br>
+I have made some changes, which i described below !<br>
+<br>
+Many THANXS to Ron Cemer !!!!!!!!! <br>
+<br>
+Sven Goethel
+<hr>
+
+This page contains OpenGL demos, originally
+written in C, which have been ported to Java and
+<br>modified to use the GL4Java library.
+<p>Since the source code is readily available for these demos, they could
+serve as a great starting point
+<br>for aspiring Java applet programmers who may or may not have experience
+with OpenGL. You DO
+<br>need to know Java in order to understand what is going on. Additionally,
+I STRONGLY recommend
+<br>that you buy the "OpenGL Programmer's Guide" (often called the "Red
+Book") if you plan to do
+<br>OpenGL programming, whether for C, Java or any other language.
+<p>*** YOU MUST INSTALL THE GL4JAVA LIBRARIES BEFORE RUNNING THE DEMOS
+***
+<br>If you haven't installed the GL4Java libraries yet, go do that first,
+then come back here and enjoy!
+<p>Here are the demos:
+<p> <a href="renormal.html">Renormal, originally by Brian Paul</a>
+: a sphere that grows and shrinks; demonstrates how to use auto-normalization.
+<br> <a href="gears.html">Gears, originally by Brian Paul</a> : three
+animated gears; user can rotate the scene using the mouse.
+<br> <a href="texobj.html">Texobj, originally by Brian Paul</a> :
+two animated, texture-mapped squares.
+<br> <a href="reflect.html">Reflect, originally by Brian Paul</a>
+: rotating, textured, reflective platform with hovering objects.
+<br> <a href="star.html">Star, originally by Silicon Graphics</a>
+: particle animation of stars flying toward the viewer.
+<br> <a href="movelight.html">Movelight, originally by Silicon Graphics</a>
+: interactive directional lighting demonstration.
+<br> <a href="molehill.html">Molehill, author unknown</a>
+: shiny nurbs/evaluators example.
+<br> <a href="fog.html">Fog, originally by Silicon Graphics</a>
+: red spheres fading into a fog background.
+<br> <a href="surface.html">Surface, originally by Silicon Graphics</a>
+: NURBS surface demo.
+<br> <a href="moth.html">Moth, originally by Robert Doyle</a>
+: simulation of a moth flying around a light.
+<br> <a href="shadowvol.html">Shadowvol, originally by Tom McReynolds, SGI</a>
+: demonstrates the use of shadow volumes.
+<br> <a href="softshadow.html">Softshadow, originally by Tom McReynolds, SGI</a>
+: demonstrates use of the accumulation buffer for soft shadows.
+<br> <a href="material.html">Material, originally by Silicon Graphics</a>
+: demonstrates the use of the OpenGL lighting model and materials.
+<br> <a href="logo.html">Logo, author unknown</a>
+: 3D SGI logo with textures and user-adjustable rendering parameters.
+<br> <a href="glutplane.html">Glutplane, originally by Mark J. Kilgard</a>
+: Paper airplanes demo. Originally written for Mark J Kilgard's GL Utility Toolkit (GLUT).
+<br> <a href="spots.html">Spots, originally by Mark J. Kilgard</a>
+: Spot light demo.
+<br> <a href="rings.html">Rings, originally by Philip Winston</a>
+: Do a slow zoom on a bunch of rings (ala Superman III?).
+<br> <a href="steam.html">Steam, originally by Troy Robinette</a>
+: Miniature steam engine simulation.
+<br> <a href="dof.html">DOF, originally by Silicon Graphics</a>
+: Uses accumulation buffer to create an out-of-focus depth-of-field effect.
+<br> <a href="pointblast.html">Pointblast, originally by Mark J. Kilgard</a>
+: Particle animation demo.
+<br> <a href="quadric.html">Quadric, originally by Silicon Graphics</a>
+: Demonstrates the use of some of the gluQuadric* routines.
+<br> <a href="mipmap.html">Mipmap, originally by Silicon Graphics</a>
+: Demonstrates the use of mipmaps for texture maps.
+<br> <a href="teapots.html">Teapots, originally by Silicon Graphics</a>
+: Demonstrates lots of material properties.
+<br> <a href="texgen.html">Texgen, originally by Silicon Graphics</a>
+: Demonstrates the use of automatically generated texture coordinates.
+<br> <a href="polyoff.html">Polyoff, originally by Silicon Graphics</a>
+: Uses polygon offset to draw wireframe over shaded polygons without ugly "stitching" artifacts.
+<br> <a href="scube.html">Scube, originally by David G Yu/Mark J. Kilgard/Silicon Graphics</a>
+: Displays a spinning cube and its shadow.
+<br> <a href="particle.html">Particle, originally by Nate Robins</a>
+: An example of a simple particle system.
+<br> <a href="text3d.html">Text3d, originally by Robert J. Doyle, Jr.</a>
+: 3D animated text.
+<br> <a href="dinoshade.html">Dinoshade, originally by Mark J. Kilgard</a>
+: Combines texturing, reflections, and projected shadows.
+<br>
+<br>
+<br>
+<hr>
+I have only added a new Class, to support a simple <br>
+customizing feature to these Applets ! <br>
+<br>
+The new Class is called "gl4java.applet.SimpleGLAnimApplet1", <br>
+and it supports to customize the frame/secounds (fps) value <br>
+and the refresh technique - both for animations ! <br>
+This new Class is now part of the GL4Java distribution,
+but is added here for portability !<br>
+<br>
+I removed the endless refresh technique from Ron, <br>
+so that the more portable "repaint" technique is used as default. <br>
+You can switch this off, like the "fps-sleep" delay ... <br>
+But you should know, what you are doing, e.g. be sure to have a <br>
+native thread JVM (MS-IE, and unix JVM's runs well with it) ! <br>
+<br>
+I removed the cab-files, and the jar-files also, <br>
+because it looks too confusing and too overdriven for me. <br>
+If you use MS-IE 4.0, be sure to have the new <br>
+MS-JVM machine (build 3186) installed ! <br>
+<br>
+Sven Goethel
+</body>
+</html>
diff --git a/demos/RonsDemos/index_plugin13.html b/demos/RonsDemos/index_plugin13.html new file mode 100644 index 0000000..e2f5095 --- /dev/null +++ b/demos/RonsDemos/index_plugin13.html @@ -0,0 +1,124 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="Author" content="Ron Cemer & Sven Goethel">
+ <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
+ <title>OpenGL Demos Ported to GL4Java</title>
+</head>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+<br>
+<a href="../../Installer/java.policy">The Java2 (sdk, jre, plugin 1.3) policy file example to give GL4Java the necessary permissions (Click here) !</a>
+<br>
+<hr>
+!!! The original demos are ported by Ron Cemer !!! <br>
+<br>
+I have made some changes, which i described below !<br>
+<br>
+Many THANXS to Ron Cemer !!!!!!!!! <br>
+<br>
+Sven Goethel
+<hr>
+
+This page contains OpenGL demos, originally
+written in C, which have been ported to Java and
+<br>modified to use the GL4Java library.
+<p>Since the source code is readily available for these demos, they could
+serve as a great starting point
+<br>for aspiring Java applet programmers who may or may not have experience
+with OpenGL. You DO
+<br>need to know Java in order to understand what is going on. Additionally,
+I STRONGLY recommend
+<br>that you buy the "OpenGL Programmer's Guide" (often called the "Red
+Book") if you plan to do
+<br>OpenGL programming, whether for C, Java or any other language.
+<p>*** YOU MUST INSTALL THE GL4JAVA LIBRARIES BEFORE RUNNING THE DEMOS
+***
+<br>If you haven't installed the GL4Java libraries yet, go do that first,
+then come back here and enjoy!
+<p>Here are the demos:
+<p> <a href="renormal_plugin13.html">Renormal, originally by Brian Paul</a>
+: a sphere that grows and shrinks; demonstrates how to use auto-normalization.
+<br> <a href="gears_plugin13.html">Gears, originally by Brian Paul</a> : three
+animated gears; user can rotate the scene using the mouse.
+<br> <a href="texobj_plugin13.html">Texobj, originally by Brian Paul</a> :
+two animated, texture-mapped squares.
+<br> <a href="reflect_plugin13.html">Reflect, originally by Brian Paul</a>
+: rotating, textured, reflective platform with hovering objects.
+<br> <a href="star_plugin13.html">Star, originally by Silicon Graphics</a>
+: particle animation of stars flying toward the viewer.
+<br> <a href="movelight_plugin13.html">Movelight, originally by Silicon Graphics</a>
+: interactive directional lighting demonstration.
+<br> <a href="molehill_plugin13.html">Molehill, author unknown</a>
+: shiny nurbs/evaluators example.
+<br> <a href="fog_plugin13.html">Fog, originally by Silicon Graphics</a>
+: red spheres fading into a fog background.
+<br> <a href="surface_plugin13.html">Surface, originally by Silicon Graphics</a>
+: NURBS surface demo.
+<br> <a href="moth_plugin13.html">Moth, originally by Robert Doyle</a>
+: simulation of a moth flying around a light.
+<br> <a href="shadowvol_plugin13.html">Shadowvol, originally by Tom McReynolds, SGI</a>
+: demonstrates the use of shadow volumes.
+<br> <a href="softshadow_plugin13.html">Softshadow, originally by Tom McReynolds, SGI</a>
+: demonstrates use of the accumulation buffer for soft shadows.
+<br> <a href="material_plugin13.html">Material, originally by Silicon Graphics</a>
+: demonstrates the use of the OpenGL lighting model and materials.
+<br> <a href="logo_plugin13.html">Logo, author unknown</a>
+: 3D SGI logo with textures and user-adjustable rendering parameters.
+<br> <a href="glutplane_plugin13.html">Glutplane, originally by Mark J. Kilgard</a>
+: Paper airplanes demo. Originally written for Mark J Kilgard's GL Utility Toolkit (GLUT).
+<br> <a href="spots_plugin13.html">Spots, originally by Mark J. Kilgard</a>
+: Spot light demo.
+<br> <a href="rings_plugin13.html">Rings, originally by Philip Winston</a>
+: Do a slow zoom on a bunch of rings (ala Superman III?).
+<br> <a href="steam_plugin13.html">Steam, originally by Troy Robinette</a>
+: Miniature steam engine simulation.
+<br> <a href="dof_plugin13.html">DOF, originally by Silicon Graphics</a>
+: Uses accumulation buffer to create an out-of-focus depth-of-field effect.
+<br> <a href="pointblast_plugin13.html">Pointblast, originally by Mark J. Kilgard</a>
+: Particle animation demo.
+<br> <a href="quadric_plugin13.html">Quadric, originally by Silicon Graphics</a>
+: Demonstrates the use of some of the gluQuadric* routines.
+<br> <a href="mipmap_plugin13.html">Mipmap, originally by Silicon Graphics</a>
+: Demonstrates the use of mipmaps for texture maps.
+<br> <a href="teapots_plugin13.html">Teapots, originally by Silicon Graphics</a>
+: Demonstrates lots of material properties.
+<br> <a href="texgen_plugin13.html">Texgen, originally by Silicon Graphics</a>
+: Demonstrates the use of automatically generated texture coordinates.
+<br> <a href="polyoff_plugin13.html">Polyoff, originally by Silicon Graphics</a>
+: Uses polygon offset to draw wireframe over shaded polygons without ugly "stitching" artifacts.
+<br> <a href="scube_plugin13.html">Scube, originally by David G Yu/Mark J. Kilgard/Silicon Graphics</a>
+: Displays a spinning cube and its shadow.
+<br> <a href="particle_plugin13.html">Particle, originally by Nate Robins</a>
+: An example of a simple particle system.
+<br> <a href="text3d_plugin13.html">Text3d, originally by Robert J. Doyle, Jr.</a>
+: 3D animated text.
+<br> <a href="dinoshade_plugin13.html">Dinoshade, originally by Mark J. Kilgard</a>
+: Combines texturing, reflections, and projected shadows.
+<br>
+<br>
+<br>
+<hr>
+I have only added a new Class, to support a simple <br>
+customizing feature to these Applets ! <br>
+<br>
+The new Class is called "gl4java.applet.SimpleGLAnimApplet1", <br>
+and it supports to customize the frame/secounds (fps) value <br>
+and the refresh technique - both for animations ! <br>
+This new Class is now part of the GL4Java distribution,
+but is added here for portability !<br>
+<br>
+I removed the endless refresh technique from Ron, <br>
+so that the more portable "repaint" technique is used as default. <br>
+You can switch this off, like the "fps-sleep" delay ... <br>
+But you should know, what you are doing, e.g. be sure to have a <br>
+native thread JVM (MS-IE, and unix JVM's runs well with it) ! <br>
+<br>
+I removed the cab-files, and the jar-files also, <br>
+because it looks too confusing and too overdriven for me. <br>
+If you use MS-IE 4.0, be sure to have the new <br>
+MS-JVM machine (build 3186) installed ! <br>
+<br>
+Sven Goethel
+</body>
+</html>
diff --git a/demos/RonsDemos/logo.html b/demos/RonsDemos/logo.html new file mode 100644 index 0000000..98055c7 --- /dev/null +++ b/demos/RonsDemos/logo.html @@ -0,0 +1,45 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
+ <title>Logo (author unknown); ported to Java by Ron Cemer</title>
+</head>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+Logo applet
+<br>Originial author unknown
+<br>Ported to Java by Ron Cemer
+<br>SEE BELOW FOR INSTRUCTIONS.
+<br>
+<applet code="logo.class" width=400 height=400>
+</applet>
+<br>Click inside the window, then press any of the following keys:
+<br>Up/down arrows: move the clipping plane in or out
+<br>Left/right arrows: rotate the model
+<br>z/Z: translate (move) the model in or out
+<br>1: render points only
+<br>2: render line drawing
+<br>3: render polygons
+<br>4: enable polygon smoothing
+<br>5: disable polygon smoothing
+<br>6: enable dithering
+<br>7: disable dithering
+<br>8: enable polygon stippling
+<br>9: disable polygon stippling
+<br>-: smooth shading
+<br>=: flat shading
+<br>q: disable culling
+<br>w: cull backfaces
+<br>e: cull frontfaces
+<br>r: frontfaces are counterclockwise (CCW)
+<br>t: frontfaces are clockwise (CW)
+<br>y/u: change stippling pattern
+<br>a: enable texturing; use brick texture
+<br>s: enable texturing; use checkered texture
+<br>d: disable texturing
+<br>f: texure modulate mode
+<br>g: texure decal mode
+<br>
+<hr>
+</body>
+</html>
diff --git a/demos/RonsDemos/logo.java b/demos/RonsDemos/logo.java new file mode 100644 index 0000000..0360ef8 --- /dev/null +++ b/demos/RonsDemos/logo.java @@ -0,0 +1,1091 @@ +/**
+ * @(#) logo.java
+ * @(#) author unknown (converted to Java by Ron Cemer)
+ */
+
+import java.applet.*;
+import java.awt.*;
+import java.awt.event.*;
+import java.lang.*;
+import java.util.*;
+import java.io.*;
+import java.util.*;
+import gl4java.GLContext;
+import gl4java.awt.GLCanvas;
+
+public class logo extends Applet
+{
+ // [3*CHECKIMAGEWIDTH*CHECKIMAGEHEIGHT]
+ private static final byte checkImage[] =
+ {
+ (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xff,
+ (byte)0xff, (byte)0xff, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xff, (byte)0xff,
+ (byte)0xff, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0x00, (byte)0x00, (byte)0x00,
+ (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xff,
+ (byte)0xff, (byte)0xff, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xff, (byte)0xff,
+ (byte)0xff, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0x00, (byte)0x00, (byte)0x00,
+ (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xff,
+ (byte)0xff, (byte)0xff, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xff, (byte)0xff,
+ (byte)0xff, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0x00, (byte)0x00, (byte)0x00,
+ (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xff,
+ (byte)0xff, (byte)0xff, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xff, (byte)0xff,
+ (byte)0xff, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0x00, (byte)0x00, (byte)0x00,
+ };
+ // [4*BRICKIMAGEWIDTH*BRICKIMAGEHEIGHT]
+ private static final byte brickImage[] =
+ {
+ (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff,
+ (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff,
+ (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff,
+ (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff,
+ (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff, (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff, (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff, (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff, (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff, (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff, (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff, (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff, (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff, (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff, (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff, (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff, (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff, (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff, (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff, (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff,
+ (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff,
+ (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff,
+ (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff,
+ (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff,
+ (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff, (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff, (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff, (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff, (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff, (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff, (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff, (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff, (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff, (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff, (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff, (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff, (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff, (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff, (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff, (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff,
+ (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff,
+ (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff,
+ (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff,
+ (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff,
+ (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff, (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff, (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff, (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff, (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff, (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff, (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff, (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff, (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff, (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff, (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff, (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff, (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff, (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff, (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff, (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff,
+ (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff, (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff, (byte)0xa4,(byte)0x00,(byte)0x00,(byte)0xff
+ };
+ // [4*32]
+ private static final byte stipple[] =
+ {
+ (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+ (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+ (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+ (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+ (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+ (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+ (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+ (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+
+ (byte)0x00, (byte)0x0F, (byte)0xF0, (byte)0x00,
+ (byte)0x00, (byte)0x0F, (byte)0xF0, (byte)0x00,
+ (byte)0x00, (byte)0x0F, (byte)0xF0, (byte)0x00,
+ (byte)0x00, (byte)0x0F, (byte)0xF0, (byte)0x00,
+ (byte)0x00, (byte)0x0F, (byte)0xF0, (byte)0x00,
+ (byte)0x00, (byte)0x0F, (byte)0xF0, (byte)0x00,
+ (byte)0x00, (byte)0x0F, (byte)0xF0, (byte)0x00,
+ (byte)0x00, (byte)0x0F, (byte)0xF0, (byte)0x00,
+
+ (byte)0x00, (byte)0x0F, (byte)0xF0, (byte)0x00,
+ (byte)0x00, (byte)0x0F, (byte)0xF0, (byte)0x00,
+ (byte)0x00, (byte)0x0F, (byte)0xF0, (byte)0x00,
+ (byte)0x00, (byte)0x0F, (byte)0xF0, (byte)0x00,
+ (byte)0x00, (byte)0x0F, (byte)0xF0, (byte)0x00,
+ (byte)0x00, (byte)0x0F, (byte)0xF0, (byte)0x00,
+ (byte)0x00, (byte)0x0F, (byte)0xF0, (byte)0x00,
+ (byte)0x00, (byte)0x0F, (byte)0xF0, (byte)0x00,
+
+ (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+ (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+ (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+ (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+ (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+ (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+ (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+ (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+ };
+ // [18][2]
+ private static final float tscp[][] =
+ {
+ { 0.0f, 0.0f },
+ { 1.0f, 0.0f },
+ { 0.0f, 0.125f },
+ { 1.0f, 0.125f },
+ { 0.0f, 0.250f },
+ { 1.0f, 0.25f },
+ { 0.0f, 0.375f },
+ { 1.0f, 0.375f },
+ { 0.0f, 0.50f },
+ { 1.0f, 0.50f },
+ { 0.0f, 0.625f },
+ { 1.0f, 0.625f },
+ { 0.0f, 0.75f },
+ { 1.0f, 0.75f },
+ { 0.0f, 0.875f },
+ { 1.0f, 0.875f },
+ { 0.0f, 1.0f },
+ { 1.0f, 1.0f }
+ };
+ // [18][3]
+ private static final float scp[][] =
+ {
+ { 1.000000f, 0.000000f, 0.000000f },
+ { 1.000000f, 0.000000f, 5.000000f },
+ { 0.707107f, 0.707107f, 0.000000f },
+ { 0.707107f, 0.707107f, 5.000000f },
+ { 0.000000f, 1.000000f, 0.000000f },
+ { 0.000000f, 1.000000f, 5.000000f },
+ { -0.707107f, 0.707107f, 0.000000f },
+ { -0.707107f, 0.707107f, 5.000000f },
+ { -1.000000f, 0.000000f, 0.000000f },
+ { -1.000000f, 0.000000f, 5.000000f },
+ { -0.707107f, -0.707107f, 0.000000f },
+ { -0.707107f, -0.707107f, 5.000000f },
+ { 0.000000f, -1.000000f, 0.000000f },
+ { 0.000000f, -1.000000f, 5.000000f },
+ { 0.707107f, -0.707107f, 0.000000f },
+ { 0.707107f, -0.707107f, 5.000000f },
+ { 1.000000f, 0.000000f, 0.000000f },
+ { 1.000000f, 0.000000f, 5.000000f }
+ };
+ // [18][3]
+ private static final float dcp[][] =
+ {
+ { 1.000000f, 0.000000f, 0.000000f },
+ { 1.000000f, 0.000000f, 7.000000f },
+ { 0.707107f, 0.707107f, 0.000000f },
+ { 0.707107f, 0.707107f, 7.000000f },
+ { 0.000000f, 1.000000f, 0.000000f },
+ { 0.000000f, 1.000000f, 7.000000f },
+ { -0.707107f, 0.707107f, 0.000000f },
+ { -0.707107f, 0.707107f, 7.000000f },
+ { -1.000000f, 0.000000f, 0.000000f },
+ { -1.000000f, 0.000000f, 7.000000f },
+ { -0.707107f, -0.707107f, 0.000000f },
+ { -0.707107f, -0.707107f, 7.000000f },
+ { 0.000000f, -1.000000f, 0.000000f },
+ { 0.000000f, -1.000000f, 7.000000f },
+ { 0.707107f, -0.707107f, 0.000000f },
+ { 0.707107f, -0.707107f, 7.000000f },
+ { 1.000000f, 0.000000f, 0.000000f },
+ { 1.000000f, 0.000000f, 7.000000f }
+ };
+ // [7][9][3]
+ private static final float ep[][][] =
+ {
+ {
+ { 1.000000f, 0.000000f, 0.000000f },
+ { 0.707107f, 0.707107f, 0.000000f },
+ { 0.000000f, 1.000000f, 0.000000f },
+ { -0.707107f, 0.707107f, 0.000000f },
+ { -1.000000f, 0.000000f, 0.000000f },
+ { -0.707107f, -0.707107f, 0.000000f },
+ { 0.000000f, -1.000000f, 0.000000f },
+ { 0.707107f, -0.707107f, 0.000000f },
+ { 1.000000f, 0.000000f, 0.000000f }
+ },
+ {
+ { 1.000000f, 0.034074f, 0.258819f },
+ { 0.707107f, 0.717087f, 0.075806f },
+ { 0.000000f, 1.000000f, 0.000000f },
+ { -0.707107f, 0.717087f, 0.075806f },
+ { -1.000000f, 0.034074f, 0.258819f },
+ { -0.707107f, -0.648939f, 0.441832f },
+ { 0.000000f, -0.931852f, 0.517638f },
+ { 0.707107f, -0.648939f, 0.441832f },
+ { 1.000000f, 0.034074f, 0.258819f }
+ },
+ {
+ { 1.000000f, 0.133975f, 0.500000f },
+ { 0.707107f, 0.746347f, 0.146447f },
+ { 0.000000f, 1.000000f, 0.000000f },
+ { -0.707107f, 0.746347f, 0.146447f },
+ { -1.000000f, 0.133975f, 0.500000f },
+ { -0.707107f, -0.478398f, 0.853553f },
+ { 0.000000f, -0.732051f, 1.000000f },
+ { 0.707107f, -0.478398f, 0.853553f },
+ { 1.000000f, 0.133975f, 0.500000f }
+ },
+ {
+ { 1.000000f, 0.292893f, 0.707107f },
+ { 0.707107f, 0.792893f, 0.207107f },
+ { 0.000000f, 1.000000f, 0.000000f },
+ { -0.707107f, 0.792893f, 0.207107f },
+ { -1.000000f, 0.292893f, 0.707107f },
+ { -0.707107f, -0.207107f, 1.207107f },
+ { 0.000000f, -0.414214f, 1.414214f },
+ { 0.707107f, -0.207107f, 1.207107f },
+ { 1.000000f, 0.292893f, 0.707107f }
+ },
+ {
+ { 1.000000f, 0.500000f, 0.866025f },
+ { 0.707107f, 0.853553f, 0.253653f },
+ { 0.000000f, 1.000000f, 0.000000f },
+ { -0.707107f, 0.853553f, 0.253653f },
+ { -1.000000f, 0.500000f, 0.866025f },
+ { -0.707107f, 0.146447f, 1.478398f },
+ { 0.000000f, 0.000000f, 1.732051f },
+ { 0.707107f, 0.146447f, 1.478398f },
+ { 1.000000f, 0.500000f, 0.866025f }
+ },
+ {
+ { 1.000000f, 0.741181f, 0.965926f },
+ { 0.707107f, 0.924194f, 0.282913f },
+ { 0.000000f, 1.000000f, 0.000000f },
+ { -0.707107f, 0.924194f, 0.282913f },
+ { -1.000000f, 0.741181f, 0.965926f },
+ { -0.707107f, 0.558168f, 1.648939f },
+ { 0.000000f, 0.482362f, 1.931852f },
+ { 0.707107f, 0.558168f, 1.648939f },
+ { 1.000000f, 0.741181f, 0.965926f }
+ },
+ {
+ { 1.000000f, 1.000000f, 1.000000f },
+ { 0.707107f, 1.000000f, 0.292893f },
+ { 0.000000f, 1.000000f, 0.000000f },
+ { -0.707107f, 1.000000f, 0.292893f },
+ { -1.000000f, 1.000000f, 1.000000f },
+ { -0.707107f, 1.000000f, 1.707107f },
+ { 0.000000f, 1.000000f, 2.000000f },
+ { 0.707107f, 1.000000f, 1.707107f },
+ { 1.000000f, 1.000000f, 1.000000f }
+ }
+ };
+ // [7][9][3]
+ private static final float en[][][] =
+ {
+ {
+ { 1.000000f, 0.000000f, 0.000000f },
+ { 0.707107f, 0.707107f, 0.000000f },
+ { 0.000000f, 1.000000f, 0.000000f },
+ { -0.707107f, 0.707107f, 0.000000f },
+ { -1.000000f, 0.000000f, 0.000000f },
+ { -0.707107f, -0.707107f, 0.000000f },
+ { 0.000000f, -1.000000f, 0.000000f },
+ { 0.707107f, -0.707107f, 0.000000f },
+ { 1.000000f, 0.000000f, 0.000000f }
+ },
+ {
+ { 1.000000f, 0.000000f, 0.000000f },
+ { 0.707107f, 0.683013f, -0.183013f },
+ { 0.000000f, 0.965926f, -0.258819f },
+ { -0.707107f, 0.683013f, -0.183013f },
+ { -1.000000f, 0.000000f, 0.000000f },
+ { -0.707107f, -0.683013f, 0.183013f },
+ { 0.000000f, -0.965926f, 0.258819f },
+ { 0.707107f, -0.683013f, 0.183013f },
+ { 1.000000f, 0.000000f, 0.000000f }
+ },
+ {
+ { 1.000000f, 0.000000f, 0.000000f },
+ { 0.707107f, 0.612372f, -0.353553f },
+ { 0.000000f, 0.866025f, -0.500000f },
+ { -0.707107f, 0.612372f, -0.353553f },
+ { -1.000000f, 0.000000f, 0.000000f },
+ { -0.707107f, -0.612372f, 0.353553f },
+ { 0.000000f, -0.866025f, 0.500000f },
+ { 0.707107f, -0.612372f, 0.353553f },
+ { 1.000000f, 0.000000f, 0.000000f }
+ },
+ {
+ { 1.000000f, 0.000000f, 0.000000f },
+ { 0.000000f, 0.707107f, -0.707107f },
+ { -0.707107f, 0.500000f, -0.500000f },
+ { -1.000000f, 0.000000f, 0.000000f },
+ { -0.707107f, -0.500000f, 0.500000f },
+ { 0.000000f, -0.707107f, 0.707107f },
+ { 0.707107f, -0.500000f, 0.500000f },
+ { 1.000000f, 0.000000f, 0.000000f },
+ { 0.000000f, 0.000000f, 0.000000f } /// ???
+ },
+ {
+ { 1.000000f, 0.000000f, 0.000000f },
+ { 0.707107f, 0.353553f, -0.612372f },
+ { 0.000000f, 0.500000f, -0.866025f },
+ { -0.707107f, 0.353553f, -0.612372f },
+ { -1.000000f, 0.000000f, 0.000000f },
+ { -0.707107f, -0.353553f, 0.612372f },
+ { 0.000000f, -0.500000f, 0.866025f },
+ { 0.707107f, -0.353553f, 0.612372f },
+ { 1.000000f, 0.000000f, 0.000000f }
+ },
+ {
+ { 1.000000f, 0.000000f, 0.000000f },
+ { 0.707107f, 0.183013f, -0.683013f },
+ { 0.000000f, 0.258819f, -0.965926f },
+ { -0.707107f, 0.183013f, -0.683013f },
+ { -1.000000f, 0.000000f, 0.000000f },
+ { -0.707107f, -0.183013f, 0.683013f },
+ { 0.000000f, -0.258819f, 0.965926f },
+ { 0.707107f, -0.183013f, 0.683013f },
+ { 1.000000f, 0.000000f, 0.000000f }
+ },
+ {
+ { 1.000000f, 0.000000f, 0.000000f },
+ { 0.707107f, 0.000000f, -0.707107f },
+ { 0.000000f, 0.000000f, -1.000000f },
+ { -0.707107f, 0.000000f, -0.707107f },
+ { -1.000000f, 0.000000f, 0.000000f },
+ { -0.707107f, 0.000000f, 0.707107f },
+ { 0.000000f, 0.000000f, 1.000000f },
+ { 0.707107f, 0.000000f, 0.707107f },
+ { 1.000000f, 0.000000f, 0.000000f }
+ }
+ };
+ // [7][9][2]
+ private static final float tep[][][] =
+ {
+ {
+ { 0.0f, 0.0f },
+ { 0.125f, 0.0f },
+ { 0.25f, 0.0f },
+ { 0.375f, 0.0f },
+ { 0.5f, 0.0f },
+ { 0.625f, 0.0f },
+ { 0.75f, 0.0f },
+ { 0.875f, 0.0f },
+ { 1.0f, 0.0f }
+ },
+ {
+ { 0.0f, 0.16667f },
+ { 0.125f, 0.16667f },
+ { 0.25f, 0.16667f },
+ { 0.375f, 0.16667f },
+ { 0.5f, 0.16667f },
+ { 0.625f, 0.16667f },
+ { 0.75f, 0.16667f },
+ { 0.875f, 0.16667f },
+ { 1.0f, 0.16667f }
+ },
+ {
+ { 0.0f, 0.33333f },
+ { 0.125f, 0.33333f },
+ { 0.25f, 0.33333f },
+ { 0.375f, 0.33333f },
+ { 0.5f, 0.33333f },
+ { 0.625f, 0.33333f },
+ { 0.75f, 0.33333f },
+ { 0.875f, 0.33333f },
+ { 1.0f, 0.33333f }
+ },
+ {
+ { 0.0f, 0.5f },
+ { 0.125f, 0.5f },
+ { 0.25f, 0.5f },
+ { 0.375f, 0.5f },
+ { 0.5f, 0.5f },
+ { 0.625f, 0.5f },
+ { 0.75f, 0.5f },
+ { 0.875f, 0.5f },
+ { 1.0f, 0.5f }
+ },
+ {
+ { 0.0f, 0.6667f },
+ { 0.125f, 0.6667f },
+ { 0.25f, 0.6667f },
+ { 0.375f, 0.6667f },
+ { 0.5f, 0.6667f },
+ { 0.625f, 0.6667f },
+ { 0.75f, 0.6667f },
+ { 0.875f, 0.6667f },
+ { 1.0f, 0.6667f }
+ },
+ {
+ { 0.0f, 0.83333f },
+ { 0.125f, 0.83333f },
+ { 0.25f, 0.83333f },
+ { 0.375f, 0.83333f },
+ { 0.5f, 0.83333f },
+ { 0.625f, 0.83333f },
+ { 0.75f, 0.83333f },
+ { 0.875f, 0.83333f },
+ { 1.0f, 0.83333f }
+ },
+ {
+ { 0.0f, 1.0f },
+ { 0.125f, 1.0f },
+ { 0.25f, 1.0f },
+ { 0.375f, 1.0f },
+ { 0.5f, 1.0f },
+ { 0.625f, 1.0f },
+ { 0.75f, 1.0f },
+ { 0.875f, 1.0f },
+ { 1.0f, 1.0f }
+ }
+ };
+
+ logoCanvas canvas = null;
+
+
+ /* Initialize the applet */
+
+
+ public void init()
+ {
+ Dimension d = getSize();
+ setLayout(new BorderLayout());
+ canvas = new logoCanvas(d.width, d.height);
+ canvas.requestFocus();
+ add("Center", canvas);
+ }
+
+
+ /* Start the applet */
+
+
+ public void start()
+ {
+ }
+
+
+ /* Stop the applet */
+
+
+ public void stop()
+ {
+ }
+
+
+ /* Destroy the applet */
+
+
+ public void destroy()
+ {
+ canvas.cvsDispose();
+ }
+
+
+ /* Local GLCanvas extension class */
+
+
+ private class logoCanvas extends GLCanvas
+ implements KeyListener, MouseListener
+ {
+ byte BLACK = (byte)0;
+ byte GRAY = (byte)128;
+ byte WHITE = (byte)255;
+ int CHECKIMAGEWIDTH = 8;
+ int CHECKIMAGEHEIGHT = 8;
+ int BRICKIMAGEWIDTH = 16;
+ int BRICKIMAGEHEIGHT = 16;
+ float black[] = {0.0f, 0.0f, 0.0f};
+ float white[] = {1.0f, 1.0f, 1.0f};
+ float gray[] = {0.5f, 0.5f, 0.5f};
+ float blue[] = {0.0f, 0.0f, 1.0f};
+ int colorIndexes[] = {0, 200, 255};
+ double plane[] = {1.0f, 0.0f, -1.0f, 12.0f};
+ float yRotation = 30.0f;
+ float zTranslation = -15.0f;
+ int singleCylinder;
+ int doubleCylinder;
+ int elbow, logo;
+ byte[] image = checkImage;
+ int imageHeight = CHECKIMAGEHEIGHT;
+ int imageWidth = CHECKIMAGEWIDTH;
+ float decal[] = { (float)GL_DECAL };
+ float modulate[] = { (float)GL_MODULATE };
+ float repeat[] = { (float)GL_REPEAT };
+ float nearest[] = { (float)GL_NEAREST };
+
+ public logoCanvas(int w, int h)
+ {
+ super(w, h);
+ GLContext.gljNativeDebug = false;
+ GLContext.gljClassDebug = false;
+ }
+
+ public void preInit()
+ {
+ doubleBuffer = true;
+ stereoView = false;
+ }
+
+ public void init()
+ {
+ System.out.println("init(): " + this);
+ reshape(getSize().width, getSize().height);
+
+ float ambient[] = {0.1f, 0.1f, 0.1f, 1.0f};
+ float diffuse[] = {0.5f, 1.0f, 1.0f, 1.0f};
+ float position[] = {90.0f, 90.0f, 150.0f, 0.0f};
+ float front_mat_shininess[] = {30.0f};
+ float front_mat_specular[] = {0.2f, 0.2f, 0.2f, 1.0f};
+ float front_mat_diffuse[] = {0.5f, 0.28f, 0.38f, 1.0f};
+ float back_mat_shininess[] = {50.0f};
+ float back_mat_specular[] = {0.5f, 0.5f, 0.2f, 1.0f};
+ float back_mat_diffuse[] = {1.0f, 1.0f, 0.2f, 1.0f};
+ float lmodel_ambient[] = {1.0f, 1.0f, 1.0f, 1.0f};
+ float lmodel_twoside[] = {(float)1.0};
+
+ gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
+
+ gl.glFrontFace(GL_CW);
+
+ gl.glEnable(GL_DEPTH_TEST);
+
+ gl.glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient);
+ gl.glLightModelfv(GL_LIGHT_MODEL_TWO_SIDE, lmodel_twoside);
+ gl.glLightfv(GL_LIGHT0, GL_AMBIENT, ambient);
+ gl.glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse);
+ gl.glLightfv(GL_LIGHT0, GL_POSITION, position);
+ gl.glEnable(GL_LIGHTING);
+ gl.glEnable(GL_LIGHT0);
+
+ gl.glMaterialfv(GL_FRONT, GL_SHININESS, front_mat_shininess);
+ gl.glMaterialfv(GL_FRONT, GL_SPECULAR, front_mat_specular);
+ gl.glMaterialfv(GL_FRONT, GL_DIFFUSE, front_mat_diffuse);
+ gl.glMaterialfv(GL_BACK, GL_SHININESS, back_mat_shininess);
+ gl.glMaterialfv(GL_BACK, GL_SPECULAR, back_mat_specular);
+ gl.glMaterialfv(GL_BACK, GL_DIFFUSE, back_mat_diffuse);
+
+ gl.glEnable(GL_CLIP_PLANE0);
+
+ gl.glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, modulate);
+ gl.glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, repeat);
+ gl.glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, repeat);
+ gl.glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, nearest);
+ gl.glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, nearest);
+ gl.glTexImage2D
+ (GL_TEXTURE_2D,
+ 0,
+ 4,
+ BRICKIMAGEWIDTH,
+ BRICKIMAGEHEIGHT,
+ 0,
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ brickImage);
+ gl.glEnable(GL_TEXTURE_2D);
+
+ gl.glCullFace(GL_BACK);
+ gl.glEnable(GL_CULL_FACE);
+
+ BuildLists();
+
+ glj.gljCheckGL();
+
+ addKeyListener(this);
+ addMouseListener(this);
+ }
+
+ public void cvsDispose()
+ {
+ System.out.println("destroy(): " + this);
+ removeKeyListener(this);
+ super.cvsDispose();
+ }
+
+ public void reshape(int width, int height)
+ {
+ gl.glViewport(0,0,width,height);
+ gl.glMatrixMode(GL_PROJECTION);
+ gl.glLoadIdentity();
+ glu.gluPerspective(90.0f, 1.0f, 1.0f, 200.0f);
+ gl.glMatrixMode(GL_MODELVIEW);
+ }
+
+ public void display()
+ {
+ if (glj.gljMakeCurrent() == false) return;
+
+ gl.glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
+
+ gl.glPushMatrix();
+
+ gl.glTranslatef(0.0f, 0.0f, zTranslation);
+ gl.glRotatef(30.0f, 1.0f, 0.0f, 0.0f);
+ gl.glRotatef(yRotation, 0.0f, 1.0f, 0.0f);
+ gl.glClipPlane(GL_CLIP_PLANE0, plane);
+ gl.glCallList(logo);
+
+ gl.glPopMatrix();
+
+ glj.gljSwap();
+ glj.gljCheckGL();
+ glj.gljFree();
+ }
+
+ // Methods required for the implementation of KeyListener
+ public void keyPressed(KeyEvent e)
+ {
+ switch (e.getKeyCode())
+ {
+ case KeyEvent.VK_LEFT:
+ yRotation -= 0.5f;
+ repaint();
+ break;
+ case KeyEvent.VK_RIGHT:
+ yRotation += 0.5f;
+ repaint();
+ break;
+ case KeyEvent.VK_UP:
+ plane[3] -= 2.0;
+ repaint();
+ break;
+ case KeyEvent.VK_DOWN:
+ plane[3] += 2.0;
+ repaint();
+ break;
+ }
+ }
+
+ public void keyReleased(KeyEvent e)
+ {
+ }
+
+ public void keyTyped(KeyEvent e)
+ {
+ if (glj.gljMakeCurrent() == false) return;
+ boolean dorepaint = false;
+ switch ((char)e.getKeyChar())
+ {
+ case 'z':
+ zTranslation -= 1.0f;
+ dorepaint = true;
+ break;
+ case 'Z':
+ zTranslation += 1.0f;
+ dorepaint = true;
+ break;
+ case '1':
+ gl.glPolygonMode(GL_FRONT_AND_BACK, GL_POINT);
+ dorepaint = true;
+ break;
+ case '2':
+ gl.glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
+ dorepaint = true;
+ break;
+ case '3':
+ gl.glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
+ dorepaint = true;
+ break;
+ case '4':
+ gl.glEnable(GL_POLYGON_SMOOTH);
+ gl.glBlendFunc(GL_SRC_ALPHA, GL_ONE);
+ gl.glEnable(GL_BLEND);
+ gl.glDisable(GL_DEPTH_TEST);
+ dorepaint = true;
+ break;
+ case '5':
+ gl.glDisable(GL_POLYGON_SMOOTH);
+ gl.glBlendFunc(GL_ONE, GL_ZERO);
+ gl.glDisable(GL_BLEND);
+ gl.glEnable(GL_DEPTH_TEST);
+ dorepaint = true;
+ break;
+ case '6':
+ gl.glEnable(GL_DITHER);
+ dorepaint = true;
+ break;
+ case '7':
+ gl.glDisable(GL_DITHER);
+ dorepaint = true;
+ break;
+ case '8':
+ gl.glPolygonStipple(stipple);
+ gl.glEnable(GL_POLYGON_STIPPLE);
+ dorepaint = true;
+ break;
+ case '9':
+ gl.glDisable(GL_POLYGON_STIPPLE);
+ dorepaint = true;
+ break;
+ case '-':
+ gl.glShadeModel(GL_SMOOTH);
+ dorepaint = true;
+ break;
+ case '=':
+ gl.glShadeModel(GL_FLAT);
+ dorepaint = true;
+ break;
+ case 'q':
+ gl.glDisable(GL_CULL_FACE);
+ dorepaint = true;
+ break;
+ case 'w':
+ gl.glEnable(GL_CULL_FACE);
+ gl.glCullFace(GL_BACK);
+ dorepaint = true;
+ break;
+ case 'e':
+ gl.glEnable(GL_CULL_FACE);
+ gl.glCullFace(GL_FRONT);
+ dorepaint = true;
+ break;
+ case 'r':
+ gl.glFrontFace(GL_CCW);
+ dorepaint = true;
+ break;
+ case 't':
+ gl.glFrontFace(GL_CW);
+ dorepaint = true;
+ break;
+ case 'y':
+ gl.glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+ gl.glPixelStorei(GL_UNPACK_LSB_FIRST, 0);
+ gl.glPolygonStipple(stipple);
+ dorepaint = true;
+ break;
+ case 'u':
+ gl.glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+ gl.glPixelStorei(GL_UNPACK_LSB_FIRST, 1);
+ gl.glPolygonStipple(stipple);
+ dorepaint = true;
+ break;
+ case 'a':
+ gl.glEnable(GL_TEXTURE_2D);
+ gl.glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, repeat);
+ gl.glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, repeat);
+ gl.glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, nearest);
+ gl.glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, nearest);
+ gl.glTexImage2D
+ (GL_TEXTURE_2D,
+ 0,
+ 4,
+ BRICKIMAGEWIDTH,
+ BRICKIMAGEHEIGHT,
+ 0,
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ brickImage);
+ dorepaint = true;
+ break;
+ case 's':
+ gl.glEnable(GL_TEXTURE_2D);
+ gl.glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, repeat);
+ gl.glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, repeat);
+ gl.glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, nearest);
+ gl.glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, nearest);
+ gl.glTexImage2D
+ (GL_TEXTURE_2D,
+ 0,
+ 3,
+ CHECKIMAGEWIDTH,
+ CHECKIMAGEHEIGHT,
+ 0,
+ GL_RGB,
+ GL_UNSIGNED_BYTE,
+ checkImage);
+ dorepaint = true;
+ break;
+ case 'd':
+ gl.glDisable(GL_TEXTURE_2D);
+ dorepaint = true;
+ break;
+ case 'f':
+ gl.glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, modulate);
+ dorepaint = true;
+ break;
+ case 'g':
+ gl.glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, decal);
+ dorepaint = true;
+ break;
+ }
+ glj.gljFree();
+ if (dorepaint) repaint();
+ }
+
+ private void BendForward()
+ {
+ gl.glTranslatef(0.0f, 1.0f, 0.0f);
+ gl.glRotatef(90.0f, 1.0f, 0.0f, 0.0f);
+ gl.glTranslatef(0.0f, -1.0f, 0.0f);
+ }
+
+ private void BendLeft()
+ {
+ gl.glRotatef(-90.0f, 0.0f, 0.0f, 1.0f);
+ gl.glTranslatef(0.0f, 1.0f, 0.0f);
+ gl.glRotatef(90.0f, 1.0f, 0.0f, 0.0f);
+ gl.glTranslatef(0.0f, -1.0f, 0.0f);
+ }
+
+ private void BendRight()
+ {
+ gl.glRotatef(90.0f, 0.0f, 0.0f, 1.0f);
+ gl.glTranslatef(0.0f, 1.0f, 0.0f);
+ gl.glRotatef(90.0f, 1.0f, 0f, 0.0f);
+ gl.glTranslatef(0.0f, -1.0f, 0.0f);
+ }
+
+ private void BuildSingleCylinder()
+ {
+ gl.glNewList(singleCylinder, GL_COMPILE);
+ gl.glBegin(GL_TRIANGLE_STRIP);
+ gl.glNormal3fv(scp[0]); gl.glTexCoord2fv(tscp[0]); gl.glVertex3fv(scp[0]);
+ gl.glNormal3fv(scp[0]); gl.glTexCoord2fv(tscp[1]); gl.glVertex3fv(scp[1]);
+ gl.glNormal3fv(scp[2]); gl.glTexCoord2fv(tscp[2]); gl.glVertex3fv(scp[2]);
+ gl.glNormal3fv(scp[2]); gl.glTexCoord2fv(tscp[3]); gl.glVertex3fv(scp[3]);
+ gl.glNormal3fv(scp[4]); gl.glTexCoord2fv(tscp[4]); gl.glVertex3fv(scp[4]);
+ gl.glNormal3fv(scp[4]); gl.glTexCoord2fv(tscp[5]); gl.glVertex3fv(scp[5]);
+ gl.glNormal3fv(scp[6]); gl.glTexCoord2fv(tscp[6]); gl.glVertex3fv(scp[6]);
+ gl.glNormal3fv(scp[6]); gl.glTexCoord2fv(tscp[7]); gl.glVertex3fv(scp[7]);
+ gl.glNormal3fv(scp[8]); gl.glTexCoord2fv(tscp[8]); gl.glVertex3fv(scp[8]);
+ gl.glNormal3fv(scp[8]); gl.glTexCoord2fv(tscp[9]); gl.glVertex3fv(scp[9]);
+ gl.glNormal3fv(scp[10]); gl.glTexCoord2fv(tscp[10]); gl.glVertex3fv(scp[10]);
+ gl.glNormal3fv(scp[10]); gl.glTexCoord2fv(tscp[11]); gl.glVertex3fv(scp[11]);
+ gl.glNormal3fv(scp[12]); gl.glTexCoord2fv(tscp[12]); gl.glVertex3fv(scp[12]);
+ gl.glNormal3fv(scp[12]); gl.glTexCoord2fv(tscp[13]); gl.glVertex3fv(scp[13]);
+ gl.glNormal3fv(scp[14]); gl.glTexCoord2fv(tscp[14]); gl.glVertex3fv(scp[14]);
+ gl.glNormal3fv(scp[14]); gl.glTexCoord2fv(tscp[15]); gl.glVertex3fv(scp[15]);
+ gl.glNormal3fv(scp[16]); gl.glTexCoord2fv(tscp[16]); gl.glVertex3fv(scp[16]);
+ gl.glNormal3fv(scp[16]); gl.glTexCoord2fv(tscp[17]); gl.glVertex3fv(scp[17]);
+ gl.glEnd();
+ gl.glEndList();
+ }
+
+ private void BuildDoubleCylinder()
+ {
+ gl.glNewList(doubleCylinder, GL_COMPILE);
+ gl.glBegin(GL_TRIANGLE_STRIP);
+ gl.glNormal3fv(dcp[0]); gl.glTexCoord2fv(tscp[0]); gl.glVertex3fv(dcp[0]);
+ gl.glNormal3fv(dcp[0]); gl.glTexCoord2fv(tscp[1]); gl.glVertex3fv(dcp[1]);
+ gl.glNormal3fv(dcp[2]); gl.glTexCoord2fv(tscp[2]); gl.glVertex3fv(dcp[2]);
+ gl.glNormal3fv(dcp[2]); gl.glTexCoord2fv(tscp[3]); gl.glVertex3fv(dcp[3]);
+ gl.glNormal3fv(dcp[4]); gl.glTexCoord2fv(tscp[4]); gl.glVertex3fv(dcp[4]);
+ gl.glNormal3fv(dcp[4]); gl.glTexCoord2fv(tscp[5]); gl.glVertex3fv(dcp[5]);
+ gl.glNormal3fv(dcp[6]); gl.glTexCoord2fv(tscp[6]); gl.glVertex3fv(dcp[6]);
+ gl.glNormal3fv(dcp[6]); gl.glTexCoord2fv(tscp[7]); gl.glVertex3fv(dcp[7]);
+ gl.glNormal3fv(dcp[8]); gl.glTexCoord2fv(tscp[8]); gl.glVertex3fv(dcp[8]);
+ gl.glNormal3fv(dcp[8]); gl.glTexCoord2fv(tscp[9]); gl.glVertex3fv(dcp[9]);
+ gl.glNormal3fv(dcp[10]); gl.glTexCoord2fv(tscp[10]); gl.glVertex3fv(dcp[10]);
+ gl.glNormal3fv(dcp[10]); gl.glTexCoord2fv(tscp[11]); gl.glVertex3fv(dcp[11]);
+ gl.glNormal3fv(dcp[12]); gl.glTexCoord2fv(tscp[12]); gl.glVertex3fv(dcp[12]);
+ gl.glNormal3fv(dcp[12]); gl.glTexCoord2fv(tscp[13]); gl.glVertex3fv(dcp[13]);
+ gl.glNormal3fv(dcp[14]); gl.glTexCoord2fv(tscp[14]); gl.glVertex3fv(dcp[14]);
+ gl.glNormal3fv(dcp[14]); gl.glTexCoord2fv(tscp[15]); gl.glVertex3fv(dcp[15]);
+ gl.glNormal3fv(dcp[16]); gl.glTexCoord2fv(tscp[16]); gl.glVertex3fv(dcp[16]);
+ gl.glNormal3fv(dcp[16]); gl.glTexCoord2fv(tscp[17]); gl.glVertex3fv(dcp[17]);
+ gl.glEnd();
+ gl.glEndList();
+ }
+
+ private void BuildElbow()
+ {
+ gl.glNewList(elbow, GL_COMPILE);
+ gl.glBegin(GL_TRIANGLE_STRIP);
+ gl.glNormal3fv(en[0][0]); gl.glTexCoord2fv(tep[0][0]); gl.glVertex3fv(ep[0][0]);
+ gl.glNormal3fv(en[1][0]); gl.glTexCoord2fv(tep[1][0]); gl.glVertex3fv(ep[1][0]);
+ gl.glNormal3fv(en[0][1]); gl.glTexCoord2fv(tep[0][1]); gl.glVertex3fv(ep[0][1]);
+ gl.glNormal3fv(en[1][1]); gl.glTexCoord2fv(tep[1][1]); gl.glVertex3fv(ep[1][1]);
+ gl.glNormal3fv(en[0][2]); gl.glTexCoord2fv(tep[0][2]); gl.glVertex3fv(ep[0][2]);
+ gl.glNormal3fv(en[1][2]); gl.glTexCoord2fv(tep[1][2]); gl.glVertex3fv(ep[1][2]);
+ gl.glNormal3fv(en[0][3]); gl.glTexCoord2fv(tep[0][3]); gl.glVertex3fv(ep[0][3]);
+ gl.glNormal3fv(en[1][3]); gl.glTexCoord2fv(tep[1][3]); gl.glVertex3fv(ep[1][3]);
+ gl.glNormal3fv(en[0][4]); gl.glTexCoord2fv(tep[0][4]); gl.glVertex3fv(ep[0][4]);
+ gl.glNormal3fv(en[1][4]); gl.glTexCoord2fv(tep[1][4]); gl.glVertex3fv(ep[1][4]);
+ gl.glNormal3fv(en[0][5]); gl.glTexCoord2fv(tep[0][5]); gl.glVertex3fv(ep[0][5]);
+ gl.glNormal3fv(en[1][5]); gl.glTexCoord2fv(tep[1][5]); gl.glVertex3fv(ep[1][5]);
+ gl.glNormal3fv(en[0][6]); gl.glTexCoord2fv(tep[0][6]); gl.glVertex3fv(ep[0][6]);
+ gl.glNormal3fv(en[1][6]); gl.glTexCoord2fv(tep[1][6]); gl.glVertex3fv(ep[1][6]);
+ gl.glNormal3fv(en[0][7]); gl.glTexCoord2fv(tep[0][7]); gl.glVertex3fv(ep[0][7]);
+ gl.glNormal3fv(en[1][7]); gl.glTexCoord2fv(tep[1][7]); gl.glVertex3fv(ep[1][7]);
+ gl.glNormal3fv(en[0][8]); gl.glTexCoord2fv(tep[0][8]); gl.glVertex3fv(ep[0][8]);
+ gl.glNormal3fv(en[1][8]); gl.glTexCoord2fv(tep[1][8]); gl.glVertex3fv(ep[1][8]);
+ gl.glEnd();
+ gl.glBegin(GL_TRIANGLE_STRIP);
+ gl.glNormal3fv(en[1][0]); gl.glTexCoord2fv(tep[1][0]); gl.glVertex3fv(ep[1][0]);
+ gl.glNormal3fv(en[2][0]); gl.glTexCoord2fv(tep[2][0]); gl.glVertex3fv(ep[2][0]);
+ gl.glNormal3fv(en[1][1]); gl.glTexCoord2fv(tep[1][1]); gl.glVertex3fv(ep[1][1]);
+ gl.glNormal3fv(en[2][1]); gl.glTexCoord2fv(tep[2][1]); gl.glVertex3fv(ep[2][1]);
+ gl.glNormal3fv(en[1][2]); gl.glTexCoord2fv(tep[1][2]); gl.glVertex3fv(ep[1][2]);
+ gl.glNormal3fv(en[2][2]); gl.glTexCoord2fv(tep[2][2]); gl.glVertex3fv(ep[2][2]);
+ gl.glNormal3fv(en[1][3]); gl.glTexCoord2fv(tep[1][3]); gl.glVertex3fv(ep[1][3]);
+ gl.glNormal3fv(en[2][3]); gl.glTexCoord2fv(tep[2][3]); gl.glVertex3fv(ep[2][3]);
+ gl.glNormal3fv(en[1][4]); gl.glTexCoord2fv(tep[1][4]); gl.glVertex3fv(ep[1][4]);
+ gl.glNormal3fv(en[2][4]); gl.glTexCoord2fv(tep[2][4]); gl.glVertex3fv(ep[2][4]);
+ gl.glNormal3fv(en[1][5]); gl.glTexCoord2fv(tep[1][5]); gl.glVertex3fv(ep[1][5]);
+ gl.glNormal3fv(en[2][5]); gl.glTexCoord2fv(tep[2][5]); gl.glVertex3fv(ep[2][5]);
+ gl.glNormal3fv(en[1][6]); gl.glTexCoord2fv(tep[1][6]); gl.glVertex3fv(ep[1][6]);
+ gl.glNormal3fv(en[2][6]); gl.glTexCoord2fv(tep[2][6]); gl.glVertex3fv(ep[2][6]);
+ gl.glNormal3fv(en[1][7]); gl.glTexCoord2fv(tep[1][7]); gl.glVertex3fv(ep[1][7]);
+ gl.glNormal3fv(en[2][7]); gl.glTexCoord2fv(tep[2][7]); gl.glVertex3fv(ep[2][7]);
+ gl.glNormal3fv(en[1][8]); gl.glTexCoord2fv(tep[1][8]); gl.glVertex3fv(ep[1][8]);
+ gl.glNormal3fv(en[2][8]); gl.glTexCoord2fv(tep[2][8]); gl.glVertex3fv(ep[2][8]);
+ gl.glEnd();
+ gl.glBegin(GL_TRIANGLE_STRIP);
+ gl.glNormal3fv(en[2][0]); gl.glTexCoord2fv(tep[2][0]); gl.glVertex3fv(ep[2][0]);
+ gl.glNormal3fv(en[3][0]); gl.glTexCoord2fv(tep[3][0]); gl.glVertex3fv(ep[3][0]);
+ gl.glNormal3fv(en[2][1]); gl.glTexCoord2fv(tep[2][1]); gl.glVertex3fv(ep[2][1]);
+ gl.glNormal3fv(en[3][1]); gl.glTexCoord2fv(tep[3][1]); gl.glVertex3fv(ep[3][1]);
+ gl.glNormal3fv(en[2][2]); gl.glTexCoord2fv(tep[2][2]); gl.glVertex3fv(ep[2][2]);
+ gl.glNormal3fv(en[3][2]); gl.glTexCoord2fv(tep[3][2]); gl.glVertex3fv(ep[3][2]);
+ gl.glNormal3fv(en[2][3]); gl.glTexCoord2fv(tep[2][3]); gl.glVertex3fv(ep[2][3]);
+ gl.glNormal3fv(en[3][3]); gl.glTexCoord2fv(tep[3][3]); gl.glVertex3fv(ep[3][3]);
+ gl.glNormal3fv(en[2][4]); gl.glTexCoord2fv(tep[2][4]); gl.glVertex3fv(ep[2][4]);
+ gl.glNormal3fv(en[3][4]); gl.glTexCoord2fv(tep[3][4]); gl.glVertex3fv(ep[3][4]);
+ gl.glNormal3fv(en[2][5]); gl.glTexCoord2fv(tep[2][5]); gl.glVertex3fv(ep[2][5]);
+ gl.glNormal3fv(en[3][5]); gl.glTexCoord2fv(tep[3][5]); gl.glVertex3fv(ep[3][5]);
+ gl.glNormal3fv(en[2][6]); gl.glTexCoord2fv(tep[2][6]); gl.glVertex3fv(ep[2][6]);
+ gl.glNormal3fv(en[3][6]); gl.glTexCoord2fv(tep[3][6]); gl.glVertex3fv(ep[3][6]);
+ gl.glNormal3fv(en[2][7]); gl.glTexCoord2fv(tep[2][7]); gl.glVertex3fv(ep[2][7]);
+ gl.glNormal3fv(en[3][7]); gl.glTexCoord2fv(tep[3][7]); gl.glVertex3fv(ep[3][7]);
+ gl.glNormal3fv(en[2][8]); gl.glTexCoord2fv(tep[2][8]); gl.glVertex3fv(ep[2][8]);
+ gl.glNormal3fv(en[3][8]); gl.glTexCoord2fv(tep[3][8]); gl.glVertex3fv(ep[3][8]);
+ gl.glEnd();
+ gl.glBegin(GL_TRIANGLE_STRIP);
+ gl.glNormal3fv(en[3][0]); gl.glTexCoord2fv(tep[3][0]); gl.glVertex3fv(ep[3][0]);
+ gl.glNormal3fv(en[4][0]); gl.glTexCoord2fv(tep[4][0]); gl.glVertex3fv(ep[4][0]);
+ gl.glNormal3fv(en[3][1]); gl.glTexCoord2fv(tep[3][1]); gl.glVertex3fv(ep[3][1]);
+ gl.glNormal3fv(en[4][1]); gl.glTexCoord2fv(tep[4][1]); gl.glVertex3fv(ep[4][1]);
+ gl.glNormal3fv(en[3][2]); gl.glTexCoord2fv(tep[3][2]); gl.glVertex3fv(ep[3][2]);
+ gl.glNormal3fv(en[4][2]); gl.glTexCoord2fv(tep[4][2]); gl.glVertex3fv(ep[4][2]);
+ gl.glNormal3fv(en[3][3]); gl.glTexCoord2fv(tep[3][3]); gl.glVertex3fv(ep[3][3]);
+ gl.glNormal3fv(en[4][3]); gl.glTexCoord2fv(tep[4][3]); gl.glVertex3fv(ep[4][3]);
+ gl.glNormal3fv(en[3][4]); gl.glTexCoord2fv(tep[3][4]); gl.glVertex3fv(ep[3][4]);
+ gl.glNormal3fv(en[4][4]); gl.glTexCoord2fv(tep[4][4]); gl.glVertex3fv(ep[4][4]);
+ gl.glNormal3fv(en[3][5]); gl.glTexCoord2fv(tep[3][5]); gl.glVertex3fv(ep[3][5]);
+ gl.glNormal3fv(en[4][5]); gl.glTexCoord2fv(tep[4][5]); gl.glVertex3fv(ep[4][5]);
+ gl.glNormal3fv(en[3][6]); gl.glTexCoord2fv(tep[3][6]); gl.glVertex3fv(ep[3][6]);
+ gl.glNormal3fv(en[4][6]); gl.glTexCoord2fv(tep[4][6]); gl.glVertex3fv(ep[4][6]);
+ gl.glNormal3fv(en[3][7]); gl.glTexCoord2fv(tep[3][7]); gl.glVertex3fv(ep[3][7]);
+ gl.glNormal3fv(en[4][7]); gl.glTexCoord2fv(tep[4][7]); gl.glVertex3fv(ep[4][7]);
+ gl.glNormal3fv(en[3][8]); gl.glTexCoord2fv(tep[3][8]); gl.glVertex3fv(ep[3][8]);
+ gl.glNormal3fv(en[4][8]); gl.glTexCoord2fv(tep[4][8]); gl.glVertex3fv(ep[4][8]);
+ gl.glEnd();
+ gl.glBegin(GL_TRIANGLE_STRIP);
+ gl.glNormal3fv(en[4][0]); gl.glTexCoord2fv(tep[4][0]); gl.glVertex3fv(ep[4][0]);
+ gl.glNormal3fv(en[5][0]); gl.glTexCoord2fv(tep[5][0]); gl.glVertex3fv(ep[5][0]);
+ gl.glNormal3fv(en[4][1]); gl.glTexCoord2fv(tep[4][1]); gl.glVertex3fv(ep[4][1]);
+ gl.glNormal3fv(en[5][1]); gl.glTexCoord2fv(tep[5][1]); gl.glVertex3fv(ep[5][1]);
+ gl.glNormal3fv(en[4][2]); gl.glTexCoord2fv(tep[4][2]); gl.glVertex3fv(ep[4][2]);
+ gl.glNormal3fv(en[5][2]); gl.glTexCoord2fv(tep[5][2]); gl.glVertex3fv(ep[5][2]);
+ gl.glNormal3fv(en[4][3]); gl.glTexCoord2fv(tep[4][3]); gl.glVertex3fv(ep[4][3]);
+ gl.glNormal3fv(en[5][3]); gl.glTexCoord2fv(tep[5][3]); gl.glVertex3fv(ep[5][3]);
+ gl.glNormal3fv(en[4][4]); gl.glTexCoord2fv(tep[4][4]); gl.glVertex3fv(ep[4][4]);
+ gl.glNormal3fv(en[5][4]); gl.glTexCoord2fv(tep[5][4]); gl.glVertex3fv(ep[5][4]);
+ gl.glNormal3fv(en[4][5]); gl.glTexCoord2fv(tep[4][5]); gl.glVertex3fv(ep[4][5]);
+ gl.glNormal3fv(en[5][5]); gl.glTexCoord2fv(tep[5][5]); gl.glVertex3fv(ep[5][5]);
+ gl.glNormal3fv(en[4][6]); gl.glTexCoord2fv(tep[4][6]); gl.glVertex3fv(ep[4][6]);
+ gl.glNormal3fv(en[5][6]); gl.glTexCoord2fv(tep[5][6]); gl.glVertex3fv(ep[5][6]);
+ gl.glNormal3fv(en[4][7]); gl.glTexCoord2fv(tep[4][7]); gl.glVertex3fv(ep[4][7]);
+ gl.glNormal3fv(en[5][7]); gl.glTexCoord2fv(tep[5][7]); gl.glVertex3fv(ep[5][7]);
+ gl.glNormal3fv(en[4][8]); gl.glTexCoord2fv(tep[4][8]); gl.glVertex3fv(ep[4][8]);
+ gl.glNormal3fv(en[5][8]); gl.glTexCoord2fv(tep[5][8]); gl.glVertex3fv(ep[5][8]);
+ gl.glEnd();
+ gl.glBegin(GL_TRIANGLE_STRIP);
+ gl.glNormal3fv(en[5][0]); gl.glTexCoord2fv(tep[5][0]); gl.glVertex3fv(ep[5][0]);
+ gl.glNormal3fv(en[6][0]); gl.glTexCoord2fv(tep[6][0]); gl.glVertex3fv(ep[6][0]);
+ gl.glNormal3fv(en[5][1]); gl.glTexCoord2fv(tep[5][1]); gl.glVertex3fv(ep[5][1]);
+ gl.glNormal3fv(en[6][1]); gl.glTexCoord2fv(tep[6][1]); gl.glVertex3fv(ep[6][1]);
+ gl.glNormal3fv(en[5][2]); gl.glTexCoord2fv(tep[5][2]); gl.glVertex3fv(ep[5][2]);
+ gl.glNormal3fv(en[6][2]); gl.glTexCoord2fv(tep[6][2]); gl.glVertex3fv(ep[6][2]);
+ gl.glNormal3fv(en[5][3]); gl.glTexCoord2fv(tep[5][3]); gl.glVertex3fv(ep[5][3]);
+ gl.glNormal3fv(en[6][3]); gl.glTexCoord2fv(tep[6][3]); gl.glVertex3fv(ep[6][3]);
+ gl.glNormal3fv(en[5][4]); gl.glTexCoord2fv(tep[5][4]); gl.glVertex3fv(ep[5][4]);
+ gl.glNormal3fv(en[6][4]); gl.glTexCoord2fv(tep[6][4]); gl.glVertex3fv(ep[6][4]);
+ gl.glNormal3fv(en[5][5]); gl.glTexCoord2fv(tep[5][5]); gl.glVertex3fv(ep[5][5]);
+ gl.glNormal3fv(en[6][5]); gl.glTexCoord2fv(tep[6][5]); gl.glVertex3fv(ep[6][5]);
+ gl.glNormal3fv(en[5][6]); gl.glTexCoord2fv(tep[5][6]); gl.glVertex3fv(ep[5][6]);
+ gl.glNormal3fv(en[6][6]); gl.glTexCoord2fv(tep[6][6]); gl.glVertex3fv(ep[6][6]);
+ gl.glNormal3fv(en[5][7]); gl.glTexCoord2fv(tep[5][7]); gl.glVertex3fv(ep[5][7]);
+ gl.glNormal3fv(en[6][7]); gl.glTexCoord2fv(tep[6][7]); gl.glVertex3fv(ep[6][7]);
+ gl.glNormal3fv(en[5][8]); gl.glTexCoord2fv(tep[5][8]); gl.glVertex3fv(ep[5][8]);
+ gl.glNormal3fv(en[6][8]); gl.glTexCoord2fv(tep[6][8]); gl.glVertex3fv(ep[6][8]);
+ gl.glEnd();
+ gl.glEndList();
+ }
+
+ private void BuildLogo()
+ {
+ gl.glNewList(logo, GL_COMPILE);
+ gl.glTranslatef(5.5f, -3.5f, 4.5f);
+ gl.glTranslatef(0.0f, 0.0f, -7.0f);
+ gl.glCallList(doubleCylinder);
+ BendForward();
+ gl.glCallList(elbow);
+ gl.glTranslatef(0.0f, 0.0f, -7.0f);
+ gl.glCallList(doubleCylinder);
+ BendForward();
+ gl.glCallList(elbow);
+ gl.glTranslatef(0.0f, 0.0f, -5.0f);
+ gl.glCallList(singleCylinder);
+ BendRight();
+ gl.glCallList(elbow);
+ gl.glTranslatef(0.0f, 0.0f, -7.0f);
+ gl.glCallList(doubleCylinder);
+ BendForward();
+ gl.glCallList(elbow);
+ gl.glTranslatef(0.0f, 0.0f, -7.0f);
+ gl.glCallList(doubleCylinder);
+ BendForward();
+ gl.glCallList(elbow);
+ gl.glTranslatef(0.0f, 0.0f, -5.0f);
+ gl.glCallList(singleCylinder);
+ BendLeft();
+ gl.glCallList(elbow);
+ gl.glTranslatef(0.0f, 0.0f, -7.0f);
+ gl.glCallList(doubleCylinder);
+ BendForward();
+ gl.glCallList(elbow);
+ gl.glTranslatef(0.0f, 0.0f, -7.0f);
+ gl.glCallList(doubleCylinder);
+ BendForward();
+ gl.glCallList(elbow);
+ gl.glTranslatef(0.0f, 0.0f, -5.0f);
+ gl.glCallList(singleCylinder);
+ BendRight();
+ gl.glCallList(elbow);
+ gl.glTranslatef(0.0f, 0.0f, -7.0f);
+ gl.glCallList(doubleCylinder);
+ BendForward();
+ gl.glCallList(elbow);
+ gl.glTranslatef(0.0f, 0.0f, -7.0f);
+ gl.glCallList(doubleCylinder);
+ BendForward();
+ gl.glCallList(elbow);
+ gl.glTranslatef(0.0f, 0.0f, -5.0f);
+ gl.glCallList(singleCylinder);
+ BendLeft();
+ gl.glCallList(elbow);
+ gl.glTranslatef(0.0f, 0.0f, -7.0f);
+ gl.glCallList(doubleCylinder);
+ BendForward();
+ gl.glCallList(elbow);
+ gl.glTranslatef(0.0f, 0.0f, -7.0f);
+ gl.glCallList(doubleCylinder);
+ BendForward();
+ gl.glCallList(elbow);
+ gl.glTranslatef(0.0f, 0.0f, -5.0f);
+ gl.glCallList(singleCylinder);
+ BendRight();
+ gl.glCallList(elbow);
+ gl.glTranslatef(0.0f, 0.0f, -7.0f);
+ gl.glCallList(doubleCylinder);
+ BendForward();
+ gl.glCallList(elbow);
+ gl.glTranslatef(0.0f, 0.0f, -7.0f);
+ gl.glCallList(doubleCylinder);
+ BendForward();
+ gl.glCallList(elbow);
+ gl.glTranslatef(0.0f, 0.0f, -5.0f);
+ gl.glCallList(singleCylinder);
+ BendLeft();
+ gl.glCallList(elbow);
+ gl.glEndList();
+ }
+
+ private void BuildLists()
+ {
+ singleCylinder = gl.glGenLists(1);
+ doubleCylinder = gl.glGenLists(1);
+ elbow = gl.glGenLists(1);
+ logo = gl.glGenLists(1);
+ BuildSingleCylinder();
+ BuildDoubleCylinder();
+ BuildElbow();
+ BuildLogo();
+ }
+
+ // Methods required for the implementation of MouseListener
+ public void mouseEntered( MouseEvent evt )
+ {
+ Component comp = evt.getComponent();
+ if( comp.equals(this ) )
+ {
+ requestFocus();
+ }
+ }
+
+ public void mouseExited( MouseEvent evt )
+ { }
+ public void mousePressed( MouseEvent evt )
+ { }
+ public void mouseReleased( MouseEvent evt )
+ { }
+ public void mouseClicked( MouseEvent evt )
+ {
+ Component comp = evt.getComponent();
+ if( comp.equals(this ) )
+ {
+ requestFocus();
+ }
+ }
+ }
+}
diff --git a/demos/RonsDemos/logo_plugin13.html b/demos/RonsDemos/logo_plugin13.html new file mode 100644 index 0000000..45fcee6 --- /dev/null +++ b/demos/RonsDemos/logo_plugin13.html @@ -0,0 +1,76 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
+ <title>Logo (author unknown); ported to Java by Ron Cemer</title>
+</head>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+Logo applet
+<br>Originial author unknown
+<br>Ported to Java by Ron Cemer
+<br>SEE BELOW FOR INSTRUCTIONS.
+<br>
+<!--"CONVERTED_APPLET"-->
+<!-- CONVERTER VERSION 1.3 --> +<SCRIPT LANGUAGE="JavaScript"><!-- + var _info = navigator.userAgent; var _ns = false; + var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0); +//--></SCRIPT> +<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!-- + var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0))); +//--></SCRIPT></COMMENT> + +<SCRIPT LANGUAGE="JavaScript"><!-- + if (_ie == true) document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = 400 HEIGHT = 400 codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0"><NOEMBED><XMP>'); + else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.3" CODE = "logo.class" WIDTH = 400 HEIGHT = 400 scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html"><NOEMBED><XMP>'); +//--></SCRIPT> +<APPLET CODE = "logo.class" WIDTH = 400 HEIGHT = 400></XMP> +<PARAM NAME = CODE VALUE = "logo.class" >
+ +<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3"> +<PARAM NAME="scriptable" VALUE="false"> + +</APPLET> + +</NOEMBED></EMBED></OBJECT> + + +<!-- +<APPLET CODE = "logo.class" WIDTH = 400 HEIGHT = 400>
+
+
+</APPLET> +--> +<!--"END_CONVERTED_APPLET"-->
+
+<br>Click inside the window, then press any of the following keys:
+<br>Up/down arrows: move the clipping plane in or out
+<br>Left/right arrows: rotate the model
+<br>z/Z: translate (move) the model in or out
+<br>1: render points only
+<br>2: render line drawing
+<br>3: render polygons
+<br>4: enable polygon smoothing
+<br>5: disable polygon smoothing
+<br>6: enable dithering
+<br>7: disable dithering
+<br>8: enable polygon stippling
+<br>9: disable polygon stippling
+<br>-: smooth shading
+<br>=: flat shading
+<br>q: disable culling
+<br>w: cull backfaces
+<br>e: cull frontfaces
+<br>r: frontfaces are counterclockwise (CCW)
+<br>t: frontfaces are clockwise (CW)
+<br>y/u: change stippling pattern
+<br>a: enable texturing; use brick texture
+<br>s: enable texturing; use checkered texture
+<br>d: disable texturing
+<br>f: texure modulate mode
+<br>g: texure decal mode
+<br>
+<hr>
+</body>
+</html>
diff --git a/demos/RonsDemos/material.html b/demos/RonsDemos/material.html new file mode 100644 index 0000000..b740970 --- /dev/null +++ b/demos/RonsDemos/material.html @@ -0,0 +1,17 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
+ <title>Material by Silicon Graphics; ported to Java by Ron Cemer</title>
+</head>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+Material applet
+<br>Originially written by Silicon Graphics
+<br>Ported to Java by Ron Cemer
+<br>
+<applet code="material.class" width=400 height=400>
+</applet>
+<hr>
+</body>
+</html>
diff --git a/demos/RonsDemos/material.java b/demos/RonsDemos/material.java new file mode 100644 index 0000000..2558c84 --- /dev/null +++ b/demos/RonsDemos/material.java @@ -0,0 +1,416 @@ +/**
+ * @(#) material.java
+ * @(#) author: Silicon Graphics (converted to Java by Ron Cemer)
+ */
+
+/*
+ * Copyright (c) 1993-1997, Silicon Graphics, Inc.
+ * ALL RIGHTS RESERVED
+ * Permission to use, copy, modify, and distribute this software for
+ * any purpose and without fee is hereby granted, provided that the above
+ * copyright notice appear in all copies and that both the copyright notice
+ * and this permission notice appear in supporting documentation, and that
+ * the name of Silicon Graphics, Inc. not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission.
+ *
+ * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
+ * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
+ * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
+ * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
+ * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
+ * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
+ * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
+ * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
+ * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * US Government Users Restricted Rights
+ * Use, duplication, or disclosure by the Government is subject to
+ * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
+ * (c)(1)(ii) of the Rights in Technical Data and Computer Software
+ * clause at DFARS 252.227-7013 and/or in similar or successor
+ * clauses in the FAR or the DOD or NASA FAR Supplement.
+ * Unpublished-- rights reserved under the copyright laws of the
+ * United States. Contractor/manufacturer is Silicon Graphics,
+ * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
+ *
+ * OpenGL(R) is a registered trademark of Silicon Graphics, Inc.
+ */
+
+/*
+ * This program demonstrates the use of the GL lighting model.
+ * Several objects are drawn using different material characteristics.
+ * A single light source illuminates the objects.
+ */
+
+import java.applet.*;
+import java.awt.*;
+import java.awt.event.*;
+import java.lang.*;
+import java.util.*;
+import java.io.*;
+import java.util.*;
+import gl4java.GLContext;
+import gl4java.awt.GLCanvas;
+
+public class material extends Applet
+{
+ materialCanvas canvas = null;
+
+
+ /* Initialize the applet */
+
+
+ public void init()
+ {
+ Dimension d = getSize();
+ setLayout(new BorderLayout());
+ canvas = new materialCanvas(d.width, d.height);
+ add("Center", canvas);
+ }
+
+
+ /* Start the applet */
+
+
+ public void start()
+ {
+ }
+
+
+ /* Stop the applet */
+
+
+ public void stop()
+ {
+ }
+
+
+ /* Destroy the applet */
+
+
+ public void destroy()
+ {
+ canvas.cvsDispose();
+ }
+
+
+ /* Local GLCanvas extension class */
+
+
+ private class materialCanvas extends GLCanvas
+ {
+ public materialCanvas(int w, int h)
+ {
+ super(w, h);
+ GLContext.gljNativeDebug = false;
+ GLContext.gljClassDebug = false;
+ }
+
+ public void preInit()
+ {
+ doubleBuffer = true;
+ stereoView = false;
+ }
+
+ public void init()
+ {
+ System.out.println("init(): " + this);
+ reshape(getSize().width, getSize().height);
+
+ float ambient[] = { 0.0f, 0.0f, 0.0f, 1.0f };
+ float diffuse[] = { 1.0f, 1.0f, 1.0f, 1.0f };
+ float specular[] = { 1.0f, 1.0f, 1.0f, 1.0f };
+ float position[] = { 0.0f, 3.0f, 2.0f, 0.0f };
+ float lmodel_ambient[] = { 0.4f, 0.4f, 0.4f, 1.0f };
+ float local_view[] = { 0.0f };
+
+ gl.glClearColor(0.0f, 0.1f, 0.1f, 0.0f);
+ gl.glEnable(GL_DEPTH_TEST);
+ gl.glShadeModel(GL_SMOOTH);
+
+ gl.glLightfv(GL_LIGHT0, GL_AMBIENT, ambient);
+ gl.glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse);
+ gl.glLightfv(GL_LIGHT0, GL_POSITION, position);
+ gl.glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient);
+ gl.glLightModelfv(GL_LIGHT_MODEL_LOCAL_VIEWER, local_view);
+
+ gl.glEnable(GL_LIGHTING);
+ gl.glEnable(GL_LIGHT0);
+
+ glj.gljCheckGL();
+ }
+
+ public void cvsDispose()
+ {
+ System.out.println("destroy(): " + this);
+ super.cvsDispose();
+ }
+
+ public void reshape(int width, int height)
+ {
+ gl.glViewport(0,0,width,height);
+ gl.glMatrixMode(GL_PROJECTION);
+ gl.glLoadIdentity();
+ if (width <= (height * 2))
+ gl.glOrtho
+ (-6.0f,
+ 6.0f,
+ -3.0f*((float)(height*2))/(float)width,
+ 3.0f*((float)(height*2))/(float)width,
+ -10.0f,
+ 10.0f);
+ else
+ gl.glOrtho
+ (-6.0f*(float)width/((float)(height*2)),
+ 6.0f*(float)width/((float)(height*2)),
+ -3.0f,
+ 3.0f,
+ -10.0f,
+ 10.0f);
+ gl.glMatrixMode(GL_MODELVIEW);
+ gl.glLoadIdentity();
+ }
+
+ public void display()
+ {
+ if (glj.gljMakeCurrent() == false) return;
+
+ float no_mat[] = { 0.0f, 0.0f, 0.0f, 1.0f };
+ float mat_ambient[] = { 0.7f, 0.7f, 0.7f, 1.0f };
+ float mat_ambient_color[] = { 0.8f, 0.8f, 0.2f, 1.0f };
+ float mat_diffuse[] = { 0.1f, 0.5f, 0.8f, 1.0f };
+ float mat_specular[] = { 1.0f, 1.0f, 1.0f, 1.0f };
+ float no_shininess[] = { 0.0f };
+ float low_shininess[] = { 5.0f };
+ float high_shininess[] = { 100.0f };
+ float mat_emission[] = {0.3f, 0.2f, 0.2f, 0.0f};
+ int qobj;
+
+ gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+ /* draw sphere in first row, first column
+ * diffuse reflection only; no ambient or specular
+ */
+ gl.glPushMatrix();
+ gl.glTranslatef (-3.75f, 3.0f, 0.0f);
+ gl.glMaterialfv(GL_FRONT, GL_AMBIENT, no_mat);
+ gl.glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse);
+ gl.glMaterialfv(GL_FRONT, GL_SPECULAR, no_mat);
+ gl.glMaterialfv(GL_FRONT, GL_SHININESS, no_shininess);
+ gl.glMaterialfv(GL_FRONT, GL_EMISSION, no_mat);
+ qobj = glu.gluNewQuadric();
+ glu.gluQuadricOrientation(qobj,GLU_OUTSIDE);
+ glu.gluQuadricNormals(qobj,GLU_SMOOTH);
+ glu.gluQuadricTexture(qobj,false);
+ glu.gluSphere(qobj,1.0f,16,16);
+ glu.gluDeleteQuadric(qobj);
+ gl.glPopMatrix();
+
+ /* draw sphere in first row, second column
+ * diffuse and specular reflection; low shininess; no ambient
+ */
+ gl.glPushMatrix();
+ gl.glTranslatef(-1.25f, 3.0f, 0.0f);
+ gl.glMaterialfv(GL_FRONT, GL_AMBIENT, no_mat);
+ gl.glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse);
+ gl.glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
+ gl.glMaterialfv(GL_FRONT, GL_SHININESS, low_shininess);
+ gl.glMaterialfv(GL_FRONT, GL_EMISSION, no_mat);
+ qobj = glu.gluNewQuadric();
+ glu.gluQuadricOrientation(qobj,GLU_OUTSIDE);
+ glu.gluQuadricNormals(qobj,GLU_SMOOTH);
+ glu.gluQuadricTexture(qobj,false);
+ glu.gluSphere(qobj,1.0f,16,16);
+ glu.gluDeleteQuadric(qobj);
+ gl.glPopMatrix();
+
+ /* draw sphere in first row, third column
+ * diffuse and specular reflection; high shininess; no ambient
+ */
+ gl.glPushMatrix();
+ gl.glTranslatef(1.25f, 3.0f, 0.0f);
+ gl.glMaterialfv(GL_FRONT, GL_AMBIENT, no_mat);
+ gl.glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse);
+ gl.glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
+ gl.glMaterialfv(GL_FRONT, GL_SHININESS, high_shininess);
+ gl.glMaterialfv(GL_FRONT, GL_EMISSION, no_mat);
+ qobj = glu.gluNewQuadric();
+ glu.gluQuadricOrientation(qobj,GLU_OUTSIDE);
+ glu.gluQuadricNormals(qobj,GLU_SMOOTH);
+ glu.gluQuadricTexture(qobj,false);
+ glu.gluSphere(qobj,1.0f,16,16);
+ glu.gluDeleteQuadric(qobj);
+ gl.glPopMatrix();
+
+ /* draw sphere in first row, fourth column
+ * diffuse reflection; emission; no ambient or specular reflection
+ */
+ gl.glPushMatrix();
+ gl.glTranslatef(3.75f, 3.0f, 0.0f);
+ gl.glMaterialfv(GL_FRONT, GL_AMBIENT, no_mat);
+ gl.glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse);
+ gl.glMaterialfv(GL_FRONT, GL_SPECULAR, no_mat);
+ gl.glMaterialfv(GL_FRONT, GL_SHININESS, no_shininess);
+ gl.glMaterialfv(GL_FRONT, GL_EMISSION, mat_emission);
+ qobj = glu.gluNewQuadric();
+ glu.gluQuadricOrientation(qobj,GLU_OUTSIDE);
+ glu.gluQuadricNormals(qobj,GLU_SMOOTH);
+ glu.gluQuadricTexture(qobj,false);
+ glu.gluSphere(qobj,1.0f,16,16);
+ glu.gluDeleteQuadric(qobj);
+ gl.glPopMatrix();
+
+ /* draw sphere in second row, first column
+ * ambient and diffuse reflection; no specular
+ */
+ gl.glPushMatrix();
+ gl.glTranslatef(-3.75f, 0.0f, 0.0f);
+ gl.glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient);
+ gl.glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse);
+ gl.glMaterialfv(GL_FRONT, GL_SPECULAR, no_mat);
+ gl.glMaterialfv(GL_FRONT, GL_SHININESS, no_shininess);
+ gl.glMaterialfv(GL_FRONT, GL_EMISSION, no_mat);
+ qobj = glu.gluNewQuadric();
+ glu.gluQuadricOrientation(qobj,GLU_OUTSIDE);
+ glu.gluQuadricNormals(qobj,GLU_SMOOTH);
+ glu.gluQuadricTexture(qobj,false);
+ glu.gluSphere(qobj,1.0f,16,16);
+ glu.gluDeleteQuadric(qobj);
+ gl.glPopMatrix();
+
+ /* draw sphere in second row, second column
+ * ambient, diffuse and specular reflection; low shininess
+ */
+ gl.glPushMatrix();
+ gl.glTranslatef(-1.25f, 0.0f, 0.0f);
+ gl.glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient);
+ gl.glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse);
+ gl.glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
+ gl.glMaterialfv(GL_FRONT, GL_SHININESS, low_shininess);
+ gl.glMaterialfv(GL_FRONT, GL_EMISSION, no_mat);
+ qobj = glu.gluNewQuadric();
+ glu.gluQuadricOrientation(qobj,GLU_OUTSIDE);
+ glu.gluQuadricNormals(qobj,GLU_SMOOTH);
+ glu.gluQuadricTexture(qobj,false);
+ glu.gluSphere(qobj,1.0f,16,16);
+ glu.gluDeleteQuadric(qobj);
+ gl.glPopMatrix();
+
+ /* draw sphere in second row, third column
+ * ambient, diffuse and specular reflection; high shininess
+ */
+ gl.glPushMatrix();
+ gl.glTranslatef(1.25f, 0.0f, 0.0f);
+ gl.glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient);
+ gl.glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse);
+ gl.glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
+ gl.glMaterialfv(GL_FRONT, GL_SHININESS, high_shininess);
+ gl.glMaterialfv(GL_FRONT, GL_EMISSION, no_mat);
+ qobj = glu.gluNewQuadric();
+ glu.gluQuadricOrientation(qobj,GLU_OUTSIDE);
+ glu.gluQuadricNormals(qobj,GLU_SMOOTH);
+ glu.gluQuadricTexture(qobj,false);
+ glu.gluSphere(qobj,1.0f,16,16);
+ glu.gluDeleteQuadric(qobj);
+ gl.glPopMatrix();
+
+ /* draw sphere in second row, fourth column
+ * ambient and diffuse reflection; emission; no specular
+ */
+ gl.glPushMatrix();
+ gl.glTranslatef(3.75f, 0.0f, 0.0f);
+ gl.glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient);
+ gl.glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse);
+ gl.glMaterialfv(GL_FRONT, GL_SPECULAR, no_mat);
+ gl.glMaterialfv(GL_FRONT, GL_SHININESS, no_shininess);
+ gl.glMaterialfv(GL_FRONT, GL_EMISSION, mat_emission);
+ qobj = glu.gluNewQuadric();
+ glu.gluQuadricOrientation(qobj,GLU_OUTSIDE);
+ glu.gluQuadricNormals(qobj,GLU_SMOOTH);
+ glu.gluQuadricTexture(qobj,false);
+ glu.gluSphere(qobj,1.0f,16,16);
+ glu.gluDeleteQuadric(qobj);
+ gl.glPopMatrix();
+
+ /* draw sphere in third row, first column
+ * colored ambient and diffuse reflection; no specular
+ */
+ gl.glPushMatrix();
+ gl.glTranslatef(-3.75f, -3.0f, 0.0f);
+ gl.glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient_color);
+ gl.glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse);
+ gl.glMaterialfv(GL_FRONT, GL_SPECULAR, no_mat);
+ gl.glMaterialfv(GL_FRONT, GL_SHININESS, no_shininess);
+ gl.glMaterialfv(GL_FRONT, GL_EMISSION, no_mat);
+ qobj = glu.gluNewQuadric();
+ glu.gluQuadricOrientation(qobj,GLU_OUTSIDE);
+ glu.gluQuadricNormals(qobj,GLU_SMOOTH);
+ glu.gluQuadricTexture(qobj,false);
+ glu.gluSphere(qobj,1.0f,16,16);
+ glu.gluDeleteQuadric(qobj);
+ gl.glPopMatrix();
+
+ /* draw sphere in third row, second column
+ * colored ambient, diffuse and specular reflection; low shininess
+ */
+ gl.glPushMatrix();
+ gl.glTranslatef(-1.25f, -3.0f, 0.0f);
+ gl.glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient_color);
+ gl.glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse);
+ gl.glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
+ gl.glMaterialfv(GL_FRONT, GL_SHININESS, low_shininess);
+ gl.glMaterialfv(GL_FRONT, GL_EMISSION, no_mat);
+ qobj = glu.gluNewQuadric();
+ glu.gluQuadricOrientation(qobj,GLU_OUTSIDE);
+ glu.gluQuadricNormals(qobj,GLU_SMOOTH);
+ glu.gluQuadricTexture(qobj,false);
+ glu.gluSphere(qobj,1.0f,16,16);
+ glu.gluDeleteQuadric(qobj);
+ gl.glPopMatrix();
+
+ /* draw sphere in third row, third column
+ * colored ambient, diffuse and specular reflection; high shininess
+ */
+ gl.glPushMatrix();
+ gl.glTranslatef(1.25f, -3.0f, 0.0f);
+ gl.glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient_color);
+ gl.glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse);
+ gl.glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
+ gl.glMaterialfv(GL_FRONT, GL_SHININESS, high_shininess);
+ gl.glMaterialfv(GL_FRONT, GL_EMISSION, no_mat);
+ qobj = glu.gluNewQuadric();
+ glu.gluQuadricOrientation(qobj,GLU_OUTSIDE);
+ glu.gluQuadricNormals(qobj,GLU_SMOOTH);
+ glu.gluQuadricTexture(qobj,false);
+ glu.gluSphere(qobj,1.0f,16,16);
+ glu.gluDeleteQuadric(qobj);
+ gl.glPopMatrix();
+
+ /* draw sphere in third row, fourth column
+ * colored ambient and diffuse reflection; emission; no specular
+ */
+ gl.glPushMatrix();
+ gl.glTranslatef(3.75f, -3.0f, 0.0f);
+ gl.glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient_color);
+ gl.glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse);
+ gl.glMaterialfv(GL_FRONT, GL_SPECULAR, no_mat);
+ gl.glMaterialfv(GL_FRONT, GL_SHININESS, no_shininess);
+ gl.glMaterialfv(GL_FRONT, GL_EMISSION, mat_emission);
+ qobj = glu.gluNewQuadric();
+ glu.gluQuadricOrientation(qobj,GLU_OUTSIDE);
+ glu.gluQuadricNormals(qobj,GLU_SMOOTH);
+ glu.gluQuadricTexture(qobj,false);
+ glu.gluSphere(qobj,1.0f,16,16);
+ glu.gluDeleteQuadric(qobj);
+ gl.glPopMatrix();
+
+ glj.gljSwap();
+ glj.gljCheckGL();
+ glj.gljFree();
+ }
+ }
+}
diff --git a/demos/RonsDemos/material_plugin13.html b/demos/RonsDemos/material_plugin13.html new file mode 100644 index 0000000..07b01bb --- /dev/null +++ b/demos/RonsDemos/material_plugin13.html @@ -0,0 +1,48 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
+ <title>Material by Silicon Graphics; ported to Java by Ron Cemer</title>
+</head>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+Material applet
+<br>Originially written by Silicon Graphics
+<br>Ported to Java by Ron Cemer
+<br>
+<!--"CONVERTED_APPLET"-->
+<!-- CONVERTER VERSION 1.3 --> +<SCRIPT LANGUAGE="JavaScript"><!-- + var _info = navigator.userAgent; var _ns = false; + var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0); +//--></SCRIPT> +<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!-- + var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0))); +//--></SCRIPT></COMMENT> + +<SCRIPT LANGUAGE="JavaScript"><!-- + if (_ie == true) document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = 400 HEIGHT = 400 codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0"><NOEMBED><XMP>'); + else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.3" CODE = "material.class" WIDTH = 400 HEIGHT = 400 scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html"><NOEMBED><XMP>'); +//--></SCRIPT> +<APPLET CODE = "material.class" WIDTH = 400 HEIGHT = 400></XMP> +<PARAM NAME = CODE VALUE = "material.class" >
+ +<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3"> +<PARAM NAME="scriptable" VALUE="false"> + +</APPLET> + +</NOEMBED></EMBED></OBJECT> + + +<!-- +<APPLET CODE = "material.class" WIDTH = 400 HEIGHT = 400>
+
+
+</APPLET> +--> +<!--"END_CONVERTED_APPLET"-->
+
+<hr>
+</body>
+</html>
diff --git a/demos/RonsDemos/mipmap.html b/demos/RonsDemos/mipmap.html new file mode 100644 index 0000000..e61d18e --- /dev/null +++ b/demos/RonsDemos/mipmap.html @@ -0,0 +1,17 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
+ <title>Mipmap by Silicon Graphics; ported to Java by Ron Cemer</title>
+</head>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+Mipmap applet
+<br>Originially written by Silicon Graphics
+<br>Ported to Java by Ron Cemer
+<br>
+<applet code="mipmap.class" width=400 height=400>
+</applet>
+<hr>
+</body>
+</html>
diff --git a/demos/RonsDemos/mipmap.java b/demos/RonsDemos/mipmap.java new file mode 100644 index 0000000..7d5f233 --- /dev/null +++ b/demos/RonsDemos/mipmap.java @@ -0,0 +1,317 @@ +/**
+ * @(#) mipmap.java
+ * @(#) author: Silicon Graphics, Inc. (converted to Java by Ron Cemer)
+ */
+
+/*
+ * Copyright (c) 1993-1997, Silicon Graphics, Inc.
+ * ALL RIGHTS RESERVED
+ * Permission to use, copy, modify, and distribute this software for
+ * any purpose and without fee is hereby granted, provided that the above
+ * copyright notice appear in all copies and that both the copyright notice
+ * and this permission notice appear in supporting documentation, and that
+ * the name of Silicon Graphics, Inc. not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission.
+ *
+ * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
+ * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
+ * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
+ * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
+ * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
+ * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
+ * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
+ * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
+ * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * US Government Users Restricted Rights
+ * Use, duplication, or disclosure by the Government is subject to
+ * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
+ * (c)(1)(ii) of the Rights in Technical Data and Computer Software
+ * clause at DFARS 252.227-7013 and/or in similar or successor
+ * clauses in the FAR or the DOD or NASA FAR Supplement.
+ * Unpublished-- rights reserved under the copyright laws of the
+ * United States. Contractor/manufacturer is Silicon Graphics,
+ * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
+ *
+ * OpenGL(R) is a registered trademark of Silicon Graphics, Inc.
+ */
+
+/* mipmap.c
+ * This program demonstrates using mipmaps for texture maps.
+ * To overtly show the effect of mipmaps, each mipmap reduction
+ * level has a solidly colored, contrasting texture image.
+ * Thus, the quadrilateral which is drawn is drawn with several
+ * different colors.
+ */
+
+import java.applet.*;
+import java.awt.*;
+import java.awt.event.*;
+import java.lang.*;
+import java.util.*;
+import java.io.*;
+import java.util.*;
+import gl4java.GLContext;
+import gl4java.awt.GLCanvas;
+
+public class mipmap extends Applet
+{
+ mipmapCanvas canvas = null;
+
+
+ /* Initialize the applet */
+
+
+ public void init()
+ {
+ Dimension d = getSize();
+ setLayout(new BorderLayout());
+ canvas = new mipmapCanvas(d.width, d.height);
+ add("Center", canvas);
+ }
+
+
+ /* Start the applet */
+
+
+ public void start()
+ {
+ }
+
+
+ /* Stop the applet */
+
+
+ public void stop()
+ {
+ }
+
+
+ /* Destroy the applet */
+
+
+ public void destroy()
+ {
+ canvas.cvsDispose();
+ }
+
+
+ /* Local GLCanvas extension class */
+
+
+ private class mipmapCanvas extends GLCanvas
+ {
+ byte mipmapImage32[] = new byte[32*32*4];
+ byte mipmapImage16[] = new byte[16*16*4];
+ byte mipmapImage8[] = new byte[8*8*4];
+ byte mipmapImage4[] = new byte[4*4*4];
+ byte mipmapImage2[] = new byte[2*2*4];
+ byte mipmapImage1[] = new byte[1*1*4];
+ int texName;
+
+ public mipmapCanvas(int w, int h)
+ {
+ super(w, h);
+ GLContext.gljNativeDebug = false;
+ GLContext.gljClassDebug = false;
+ }
+
+ public void preInit()
+ {
+ doubleBuffer = true;
+ stereoView = false;
+ }
+
+ public void init()
+ {
+ System.out.println("init(): " + this);
+ reshape(getSize().width, getSize().height);
+
+ gl.glEnable(GL_DEPTH_TEST);
+ gl.glShadeModel(GL_FLAT);
+
+ gl.glTranslatef(0.0f, 0.0f, -3.6f);
+ makeImages();
+ gl.glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+
+ int tnbuf[] = new int[1];
+ gl.glGenTextures(1, tnbuf);
+ texName = tnbuf[0];
+ gl.glBindTexture(GL_TEXTURE_2D, texName);
+ gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
+ gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
+ gl.glTexParameteri
+ (GL_TEXTURE_2D,
+ GL_TEXTURE_MAG_FILTER,
+ GL_NEAREST);
+ gl.glTexParameteri
+ (GL_TEXTURE_2D,
+ GL_TEXTURE_MIN_FILTER,
+ GL_NEAREST_MIPMAP_NEAREST);
+ gl.glTexImage2D
+ (GL_TEXTURE_2D,
+ 0,
+ GL_RGBA,
+ 32,
+ 32,
+ 0,
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ mipmapImage32);
+ gl.glTexImage2D
+ (GL_TEXTURE_2D,
+ 1,
+ GL_RGBA,
+ 16,
+ 16,
+ 0,
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ mipmapImage16);
+ gl.glTexImage2D
+ (GL_TEXTURE_2D,
+ 2,
+ GL_RGBA,
+ 8,
+ 8,
+ 0,
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ mipmapImage8);
+ gl.glTexImage2D
+ (GL_TEXTURE_2D,
+ 3,
+ GL_RGBA,
+ 4,
+ 4,
+ 0,
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ mipmapImage4);
+ gl.glTexImage2D
+ (GL_TEXTURE_2D,
+ 4,
+ GL_RGBA,
+ 2,
+ 2,
+ 0,
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ mipmapImage2);
+ gl.glTexImage2D
+ (GL_TEXTURE_2D,
+ 5,
+ GL_RGBA,
+ 1,
+ 1,
+ 0,
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ mipmapImage1);
+
+ gl.glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
+ gl.glEnable(GL_TEXTURE_2D);
+
+ glj.gljCheckGL();
+ }
+
+ public void cvsDispose()
+ {
+ System.out.println("destroy(): " + this);
+ super.cvsDispose();
+ }
+
+ public void reshape(int width, int height)
+ {
+ gl.glViewport(0,0,width,height);
+ gl.glMatrixMode(GL_PROJECTION);
+ gl.glLoadIdentity();
+ glu.gluPerspective(60.0f,(float)width/(float)height,1.0f,30000.0f);
+ gl.glMatrixMode(GL_MODELVIEW);
+ gl.glLoadIdentity();
+ }
+
+ public void display()
+ {
+ if (glj.gljMakeCurrent() == false) return;
+
+ gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ gl.glBindTexture(GL_TEXTURE_2D, texName);
+ gl.glBegin(GL_QUADS);
+ gl.glTexCoord2f(0.0f,0.0f); gl.glVertex3f(-2.0f,-1.0f,0.0f);
+ gl.glTexCoord2f(0.0f,8.0f); gl.glVertex3f(-2.0f,1.0f,0.0f);
+ gl.glTexCoord2f(8.0f,8.0f); gl.glVertex3f(2000.0f,1.0f,-6000.0f);
+ gl.glTexCoord2f(8.0f,0.0f); gl.glVertex3f(2000.0f,-1.0f,-6000.0f);
+ gl.glEnd();
+ gl.glFlush();
+
+ glj.gljSwap();
+ glj.gljCheckGL();
+ glj.gljFree();
+ }
+
+ private void makeImages()
+ {
+ int i, j, idx;
+
+ for (idx = i = 0; i < 32; i++)
+ {
+ for (j = 0; j < 32; j++)
+ {
+ mipmapImage32[idx++] = (byte)255;
+ mipmapImage32[idx++] = (byte)255;
+ mipmapImage32[idx++] = (byte)0;
+ mipmapImage32[idx++] = (byte)255;
+ }
+ }
+ for (idx = i = 0; i < 16; i++)
+ {
+ for (j = 0; j < 16; j++)
+ {
+ mipmapImage16[idx++] = (byte)255;
+ mipmapImage16[idx++] = (byte)0;
+ mipmapImage16[idx++] = (byte)255;
+ mipmapImage16[idx++] = (byte)255;
+ }
+ }
+ for (idx = i = 0; i < 8; i++)
+ {
+ for (j = 0; j < 8; j++)
+ {
+ mipmapImage8[idx++] = (byte)255;
+ mipmapImage8[idx++] = (byte)0;
+ mipmapImage8[idx++] = (byte)0;
+ mipmapImage8[idx++] = (byte)255;
+ }
+ }
+ for (idx = i = 0; i < 4; i++)
+ {
+ for (j = 0; j < 4; j++)
+ {
+ mipmapImage4[idx++] = (byte)0;
+ mipmapImage4[idx++] = (byte)255;
+ mipmapImage4[idx++] = (byte)0;
+ mipmapImage4[idx++] = (byte)255;
+ }
+ }
+ for (idx = i = 0; i < 2; i++)
+ {
+ for (j = 0; j < 2; j++)
+ {
+ mipmapImage2[idx++] = (byte)0;
+ mipmapImage2[idx++] = (byte)0;
+ mipmapImage2[idx++] = (byte)255;
+ mipmapImage2[idx++] = (byte)255;
+ }
+ }
+ mipmapImage1[0] = (byte)255;
+ mipmapImage1[1] = (byte)255;
+ mipmapImage1[2] = (byte)255;
+ mipmapImage1[3] = (byte)255;
+ }
+ }
+}
diff --git a/demos/RonsDemos/mipmap_plugin13.html b/demos/RonsDemos/mipmap_plugin13.html new file mode 100644 index 0000000..f197e77 --- /dev/null +++ b/demos/RonsDemos/mipmap_plugin13.html @@ -0,0 +1,48 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
+ <title>Mipmap by Silicon Graphics; ported to Java by Ron Cemer</title>
+</head>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+Mipmap applet
+<br>Originially written by Silicon Graphics
+<br>Ported to Java by Ron Cemer
+<br>
+<!--"CONVERTED_APPLET"-->
+<!-- CONVERTER VERSION 1.3 --> +<SCRIPT LANGUAGE="JavaScript"><!-- + var _info = navigator.userAgent; var _ns = false; + var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0); +//--></SCRIPT> +<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!-- + var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0))); +//--></SCRIPT></COMMENT> + +<SCRIPT LANGUAGE="JavaScript"><!-- + if (_ie == true) document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = 400 HEIGHT = 400 codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0"><NOEMBED><XMP>'); + else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.3" CODE = "mipmap.class" WIDTH = 400 HEIGHT = 400 scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html"><NOEMBED><XMP>'); +//--></SCRIPT> +<APPLET CODE = "mipmap.class" WIDTH = 400 HEIGHT = 400></XMP> +<PARAM NAME = CODE VALUE = "mipmap.class" >
+ +<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3"> +<PARAM NAME="scriptable" VALUE="false"> + +</APPLET> + +</NOEMBED></EMBED></OBJECT> + + +<!-- +<APPLET CODE = "mipmap.class" WIDTH = 400 HEIGHT = 400>
+
+
+</APPLET> +--> +<!--"END_CONVERTED_APPLET"-->
+
+<hr>
+</body>
+</html>
diff --git a/demos/RonsDemos/molehill.html b/demos/RonsDemos/molehill.html new file mode 100644 index 0000000..361f5b1 --- /dev/null +++ b/demos/RonsDemos/molehill.html @@ -0,0 +1,17 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
+ <title>Molehill by unknown author; ported to Java by Ron Cemer</title>
+</head>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+Molehill applet
+<br>Originial author unknown
+<br>Ported to Java by Ron Cemer
+<br>
+<applet code="molehill.class" width=400 height=400>
+</applet>
+<hr>
+</body>
+</html>
diff --git a/demos/RonsDemos/molehill.java b/demos/RonsDemos/molehill.java new file mode 100644 index 0000000..8dbe12e --- /dev/null +++ b/demos/RonsDemos/molehill.java @@ -0,0 +1,286 @@ +/**
+ * @(#) molehill.java
+ * @(#) author: unknown (converted to Java by Ron Cemer)
+ */
+
+import java.applet.*;
+import java.awt.*;
+import java.awt.event.*;
+import java.lang.*;
+import java.util.*;
+import java.io.*;
+import java.util.*;
+import gl4java.GLContext;
+import gl4java.awt.GLCanvas;
+
+public class molehill extends Applet
+{
+ molehillCanvas canvas = null;
+
+
+ /* Initialize the applet */
+
+
+ public void init()
+ {
+ Dimension d = getSize();
+ setLayout(new BorderLayout());
+ canvas = new molehillCanvas(d.width, d.height);
+ add("Center", canvas);
+ }
+
+
+ /* Start the applet */
+
+
+ public void start()
+ {
+ }
+
+
+ /* Stop the applet */
+
+
+ public void stop()
+ {
+ }
+
+
+ /* Destroy the applet */
+
+
+ public void destroy()
+ {
+ canvas.cvsDispose();
+ }
+
+
+ public static void main( String args[] )
+ {
+ Frame mainFrame = new Frame("molehill");
+
+ molehill applet = new molehill();
+
+ applet.setSize(400, 400);
+ applet.init();
+ applet.start();
+
+ mainFrame.add(applet);
+
+ mainFrame.pack();
+ mainFrame.setVisible(true);
+ }
+
+ /* Local GLCanvas extension class */
+
+
+ private class molehillCanvas extends GLCanvas
+ {
+ float mat_red_diffuse[] = { 0.7f, 0.0f, 0.1f, 1.0f };
+ float mat_green_diffuse[] = { 0.0f, 0.7f, 0.1f, 1.0f };
+ float mat_blue_diffuse[] = { 0.0f, 0.1f, 0.7f, 1.0f };
+ float mat_yellow_diffuse[] = { 0.7f, 0.8f, 0.1f, 1.0f };
+ float mat_specular[] = { 1.0f, 1.0f, 1.0f, 1.0f };
+ float mat_shininess[] = { 100.0f };
+ float knots[] = { 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f };
+ float pts1[] = new float[4*4*3];
+ float pts2[] = new float[4*4*3];
+ float pts3[] = new float[4*4*3];
+ float pts4[] = new float[4*4*3];
+ int nurb;
+ int u, v;
+
+ public molehillCanvas(int w, int h)
+ {
+ super(w, h);
+ GLContext.gljNativeDebug = false;
+ GLContext.gljClassDebug = false;
+ }
+
+ public void preInit()
+ {
+ doubleBuffer = true;
+ stereoView = false;
+ }
+
+ public void init()
+ {
+ System.out.println("init(): " + this);
+ reshape(getSize().width, getSize().height);
+
+ gl.glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
+ gl.glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess);
+ gl.glEnable(GL_LIGHTING);
+ gl.glEnable(GL_LIGHT0);
+ gl.glEnable(GL_DEPTH_TEST);
+ gl.glEnable(GL_AUTO_NORMAL);
+ gl.glEnable(GL_NORMALIZE);
+ nurb = glu.gluNewNurbsRenderer();
+ glu.gluNurbsProperty(nurb, GLU_SAMPLING_TOLERANCE, 25.0f);
+ glu.gluNurbsProperty(nurb, GLU_DISPLAY_MODE, GLU_FILL);
+
+ /* Build control points for NURBS mole hills. */
+ for(u=0; u<4; u++)
+ {
+ for(v=0; v<4; v++)
+ {
+ /* Red. */
+ pts1[(u*12)+(v*3)+0] = 2.0f*((float)u);
+ pts1[(u*12)+(v*3)+1] = 2.0f*((float)v);
+ if((u==1 || u == 2) && (v == 1 || v == 2))
+ pts1[(u*12)+(v*3)+2] = 6.0f; /* Stretch up middle. */
+ else
+ pts1[(u*12)+(v*3)+2] = 0.0f;
+
+ /* Green. */
+ pts2[(u*12)+(v*3)+0] = 2.0f*((float)u - 3.0f);
+ pts2[(u*12)+(v*3)+1] = 2.0f*((float)v - 3.0f);
+ if((u==1 || u == 2) && (v == 1 || v == 2))
+ if(u == 1 && v == 1)
+ pts2[(u*12)+(v*3)+2] = 15.0f; /* Pull hard on single middle square. */
+ else
+ pts2[(u*12)+(v*3)+2] = -2.0f; /* Push down on other middle squares. */
+ else
+ pts2[(u*12)+(v*3)+2] = 0.0f;
+
+ /* Blue. */
+ pts3[(u*12)+(v*3)+0] = 2.0f*((float)u - 3.0f);
+ pts3[(u*12)+(v*3)+1] = 2.0f*((float)v);
+ if((u==1 || u == 2) && (v == 1 || v == 2))
+ if(u == 1 && v == 2)
+ pts3[(u*12)+(v*3)+2] = 11.0f; /* Pull up on single middple square. */
+ else
+ pts3[(u*12)+(v*3)+2] = 2.0f; /* Pull up slightly on other middle squares. */
+ else
+ pts3[(u*12)+(v*3)+2] = 0.0f;
+
+ /* Yellow. */
+ pts4[(u*12)+(v*3)+0] = 2.0f*((float)u);
+ pts4[(u*12)+(v*3)+1] = 2.0f*((float)v - 3.0f);
+ if((u==1 || u == 2 || u == 3) && (v == 1 || v == 2))
+ if(v == 1)
+ pts4[(u*12)+(v*3)+2] = -2.0f; /* Push down front middle and right squares. */
+ else
+ pts4[(u*12)+(v*3)+2] = 5.0f; /* Pull up back middle and right squares. */
+ else
+ pts4[(u*12)+(v*3)+2] = 0.0f;
+ }
+ }
+
+ /* Stretch up red's far right corner. */
+ pts1[(3*12)+(3*3)+2] = 6;
+ /* Pull down green's near left corner a little. */
+ pts2[(0*12)+(0*3)+2] = -2;
+ /* Turn up meeting of four corners. */
+ pts1[(0*12)+(0*3)+2] = 1;
+ pts2[(3*12)+(3*3)+2] = 1;
+ pts3[(3*12)+(0*3)+2] = 1;
+ pts4[(0*12)+(3*3)+2] = 1;
+
+ gl.glMatrixMode(GL_PROJECTION);
+ glu.gluPerspective(55.0f, 1.0f, 2.0f, 24.0f);
+ gl.glMatrixMode(GL_MODELVIEW);
+ gl.glTranslatef(0.0f, 0.0f, -15.0f);
+ gl.glRotatef(330.0f, 1.0f, 0.0f, 0.0f);
+
+ gl.glNewList(1, GL_COMPILE);
+
+ /* Render red hill. */
+ gl.glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_red_diffuse);
+ glu.gluBeginSurface(nurb);
+ glu.gluNurbsSurface
+ (nurb,
+ 8,
+ knots,
+ 8,
+ knots,
+ (4 * 3),
+ 3,
+ pts1,
+ 4,
+ 4,
+ GL_MAP2_VERTEX_3);
+ glu.gluEndSurface(nurb);
+
+ /* Render green hill. */
+ gl.glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_green_diffuse);
+ glu.gluBeginSurface(nurb);
+ glu.gluNurbsSurface
+ (nurb,
+ 8,
+ knots,
+ 8,
+ knots,
+ (4 * 3),
+ 3,
+ pts2,
+ 4,
+ 4,
+ GL_MAP2_VERTEX_3);
+ glu.gluEndSurface(nurb);
+
+ /* Render blue hill. */
+ gl.glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_blue_diffuse);
+ glu.gluBeginSurface(nurb);
+ glu.gluNurbsSurface
+ (nurb,
+ 8,
+ knots,
+ 8,
+ knots,
+ (4 * 3),
+ 3,
+ pts3,
+ 4,
+ 4,
+ GL_MAP2_VERTEX_3);
+ glu.gluEndSurface(nurb);
+
+ /* Render yellow hill. */
+ gl.glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_yellow_diffuse);
+ glu.gluBeginSurface(nurb);
+ glu.gluNurbsSurface
+ (nurb,
+ 8,
+ knots,
+ 8,
+ knots,
+ (4 * 3),
+ 3,
+ pts4,
+ 4,
+ 4,
+ GL_MAP2_VERTEX_3);
+ glu.gluEndSurface(nurb);
+
+ gl.glEndList();
+
+ glj.gljCheckGL();
+ }
+
+ public void cvsDispose()
+ {
+ System.out.println("destroy(): " + this);
+ super.cvsDispose();
+ }
+
+ public void reshape(int width, int height)
+ {
+ gl.glViewport(0,0,width,height);
+ gl.glMatrixMode(GL_PROJECTION);
+ }
+
+ public void display()
+ {
+ if (glj.gljMakeCurrent() == false) return;
+
+ gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ gl.glCallList(1);
+ gl.glFlush();
+
+ glj.gljSwap();
+ glj.gljCheckGL();
+ glj.gljFree();
+ }
+ }
+}
diff --git a/demos/RonsDemos/molehill_plugin13.html b/demos/RonsDemos/molehill_plugin13.html new file mode 100644 index 0000000..5ce9215 --- /dev/null +++ b/demos/RonsDemos/molehill_plugin13.html @@ -0,0 +1,48 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
+ <title>Molehill by unknown author; ported to Java by Ron Cemer</title>
+</head>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+Molehill applet
+<br>Originial author unknown
+<br>Ported to Java by Ron Cemer
+<br>
+<!--"CONVERTED_APPLET"-->
+<!-- CONVERTER VERSION 1.3 --> +<SCRIPT LANGUAGE="JavaScript"><!-- + var _info = navigator.userAgent; var _ns = false; + var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0); +//--></SCRIPT> +<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!-- + var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0))); +//--></SCRIPT></COMMENT> + +<SCRIPT LANGUAGE="JavaScript"><!-- + if (_ie == true) document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = 400 HEIGHT = 400 codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0"><NOEMBED><XMP>'); + else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.3" CODE = "molehill.class" WIDTH = 400 HEIGHT = 400 scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html"><NOEMBED><XMP>'); +//--></SCRIPT> +<APPLET CODE = "molehill.class" WIDTH = 400 HEIGHT = 400></XMP> +<PARAM NAME = CODE VALUE = "molehill.class" >
+ +<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3"> +<PARAM NAME="scriptable" VALUE="false"> + +</APPLET> + +</NOEMBED></EMBED></OBJECT> + + +<!-- +<APPLET CODE = "molehill.class" WIDTH = 400 HEIGHT = 400>
+
+
+</APPLET> +--> +<!--"END_CONVERTED_APPLET"-->
+
+<hr>
+</body>
+</html>
diff --git a/demos/RonsDemos/moth.html b/demos/RonsDemos/moth.html new file mode 100644 index 0000000..020ab04 --- /dev/null +++ b/demos/RonsDemos/moth.html @@ -0,0 +1,19 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
+ <title>Moth by Robert Doyle; ported to Java by Ron Cemer</title>
+</head>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+Moth applet
+<br>Originially written by Silicon Graphics
+<br>Ported to Java by Ron Cemer
+<br>Click the left mouse button within the window to pause/resume simulation.
+<br>Click the right mouse button within the window to restart simulation.
+<br>
+<applet code="moth.class" width=400 height=400>
+</applet>
+<hr>
+</body>
+</html>
diff --git a/demos/RonsDemos/moth.java b/demos/RonsDemos/moth.java new file mode 100644 index 0000000..c12a4a9 --- /dev/null +++ b/demos/RonsDemos/moth.java @@ -0,0 +1,1149 @@ +/**
+ * @(#) moth.java
+ * @(#) author: Robert Doyle (converted to Java by Ron Cemer)
+ */
+
+/*
+ "moth" by Robert Doyle, Naval Research Laboratory, Washington, DC.
+ Scene objects are built into display lists in the 'init()' method.
+ Objects are assembled and motion described in the 'display()' method.
+*/
+
+import java.applet.*;
+import java.awt.*;
+import java.awt.event.*;
+import java.lang.*;
+import java.util.*;
+import java.io.*;
+import java.util.*;
+import gl4java.GLContext;
+import gl4java.awt.GLAnimCanvas;
+import gl4java.applet.SimpleGLAnimApplet1;
+
+public class moth extends SimpleGLAnimApplet1
+{
+
+ /* Initialize the applet */
+
+
+ public void init()
+ {
+ super.init();
+ Dimension d = getSize();
+ canvas = new mothCanvas(d.width, d.height);
+ add("Center", canvas);
+ }
+
+
+ /* Local GLAnimCanvas extension class */
+
+
+ private class mothCanvas extends GLAnimCanvas implements MouseListener
+ {
+ float wall_color[] = {1.0f, 1.0f, 1.0f, 1.0f};
+ float wall_ambient[] = {0.5f, 0.5f, 0.5f, 1.0f};
+ float floor_color[] = {0.5f, 1.0f, 0.5f, 0.5f};
+ float column_color[] = {1.0f, 0.0f, 0.0f, 1.0f};
+ float column_ambient[] = {0.25f, 0.0f, 0.0f, 1.0f};
+
+ float panel_color[] = {0.1f, 0.1f, 1.0f, 1.0f};
+ float panel_ambient[] = {0.01f, 0.01f, 0.3f, 1.0f};
+
+ float lamp_ambient[] = {1.0f, 1.0f, 1.0f, 1.0f};
+ float lamp_diffuse[] = {1.0f, 1.0f, 1.0f, 1.0f};
+ float lamp_specular[] = {1.0f, 1.0f, 1.0f, 1.0f};
+ float lamp_post_diffuse[] = {0.8f, 0.0f, 0.0f, 1.0f};
+ float lamp_post_specular[] = {0.8f, 0.0f, 0.0f, 1.0f};
+ float lamp_post_ambient[] = {0.25f, 0.0f, 0.0f, 1.0f};
+
+ float satellite_diffuse[] = {1.0f, 0.69f, 0.0f, 1.0f};
+ float satellite_shiny[] = {128.0f};
+ float satellite_specular[] = {1.0f, 1.0f, 1.0f, 1.0f};
+ float satellite_ambient[] = {0.37f, 0.25f, 0.0f, 1.0f};
+
+ float cube_color[] = {1.0f, 1.0f, 0.0f, 1.0f};
+ float cube_shiny[] = {99.0f};
+ float cube_specular[] = {0.9f, 0.9f, 0.9f, 1.0f};
+ float cube_ambient[] = {0.1f, 0.1f, 0.1f, 1.0f};
+
+ float shadow_ambient[] = {0.0f, 0.0f, 0.0f, 1.0f};
+ float shadow_diffuse[] = {0.0f, 0.0f, 0.0f, 0.3f};
+ float shadow_shiny[] = {0.0f};
+ float shadow_specular[] = {0.0f, 0.0f, 0.0f, 1.0f};
+
+ int column = 3;
+ int ground_shadow_matrix = 16;
+ int left_wall_shadow_matrix = 17;
+ int ground = 30;
+ int left_wall = 40;
+ int right_wall = 50;
+ int four_columns = 7;
+ int two_columns = 32;
+ int satellite1 = 301;
+ int satellite2 = 302;
+ int panel1 = 303;
+ int panel2 = 304;
+
+ float default_Tx = -0.01f;
+ float default_Ty = -0.01f;
+ float default_Tz = -0.02f;
+
+ float default_mvt_x = -15.0f;
+ float default_mvt_y = -15.0f;
+ float default_mvt_z = -30.7f;
+
+ float default_mvr_d = 150.0f;
+
+ float Tx = default_Tx;
+ float Ty = default_Ty;
+ float Tz = default_Tz;
+
+ float mvt_x = default_mvt_x;
+ float mvt_y = default_mvt_y;
+ float mvt_z = default_mvt_z;
+
+ float mvr_d = default_mvr_d;
+
+ float mvr_x = 1.0f;
+ float mvr_y = -1.0f;
+ float mvr_z = -1.0f;
+
+ float Rx = 0.1f;
+
+ float cubeXform[] = new float[16];
+ float column1Xform[] = new float[16];
+ float column2Xform[] = new float[16];
+ float column3Xform[] = new float[16];
+ float four_columnsXform[] = new float[16];
+
+ float shadowMat_ground[] = new float[16];
+ float shadowMat_left[] = new float[16];
+ float shadowMat_back[] = new float[16];
+ float shadowMat_column[] = new float[16];
+ float shadowMat_right[] = new float[16];
+
+ float shadowMat1_ground[] = new float[16];
+ float shadowMat1_left[] = new float[16];
+ float shadowMat1_back[] = new float[16];
+ float shadowMat1_right[] = new float[16];
+
+ int tick = -1;
+
+ boolean moving = true;
+
+ float lightPos[] = {1.0f, 2.5f, 3.0f, 1.0f};
+
+ float light1Pos[] = {0.0f, 1.6f, -5.0f, 1.0f};
+ float light1Amb[] = {1.0f, 1.0f, 1.0f, 1.0f};
+ float light1Diff[] = {1.0f, 1.0f, 1.0f, 1.0f};
+ float light1Spec[] = {1.0f, 1.0f, 1.0f, 1.0f};
+
+ float leftPlane[] = {1.0f, 0.0f, 0.0f, 4.88f}; /* X = -4.88 */
+ float rightPlane[] = {-1.0f, 0.0f, 0.0f, 4.88f}; /* X = 4.98 */
+ float groundPlane[] = {0.0f, 1.0f, 0.0f, 1.450f}; /* Y = -1.480 */
+ float columnPlane[] = {0.0f, 0.0f, 1.0f, 0.899f}; /* Z = -0.899 */
+ float backPlane[] = {0.0f, 0.0f, 1.0f, 8.98f}; /* Z = -8.98 */
+
+ final float S = 0.7071f;
+ final float NS = 0.382683f;
+ final float NC = 0.923880f;
+
+ /* satellite body. */
+ float oct_vertices[][][] =
+ {
+ {
+ {0.0f, 0.0f, 0.0f, 1.0f},
+ {0.0f, 1.0f, 0.0f, 1.0f},
+ {-S, S, 0.0f, 1.0f}},
+
+ {
+ {0.0f, 0.0f, 0.0f, 1.0f},
+ {-S, S, 0.0f, 1.0f},
+ {-1.0f, 0.0f, 0.0f, 1.0f}},
+
+ {
+ {0.0f, 0.0f, 0.0f, 1.0f},
+ {-1.0f, 0.0f, 0.0f, 1.0f},
+ {-S, -S, 0.0f, 1.0f}},
+
+ {
+ {0.0f, 0.0f, 0.0f, 1.0f},
+ {-S, -S, 0.0f, 1.0f},
+ {0.0f, -1.0f, 0.0f, 1.0f}},
+
+ {
+ {0.0f, 0.0f, 0.0f, 1.0f},
+ {0.0f, -1.0f, 0.0f, 1.0f},
+ {S, -S, 0.0f, 1.0f}},
+
+ {
+
+ {0.0f, 0.0f, 0.0f, 1.0f},
+ {S, -S, 0.0f, 1.0f},
+ {1.0f, 0.0f, 0.0f, 1.0f}},
+
+ {
+ {0.0f, 0.0f, 0.0f, 1.0f},
+ {1.0f, 0.0f, 0.0f, 1.0f},
+ {S, S, 0.0f, 1.0f}},
+
+ {
+ {0.0f, 0.0f, 0.0f, 1.0f},
+ {S, S, 0.0f, 1.0f},
+ {0.0f, 1.0f, 0.0f, 1.0f}}
+
+ };
+
+ float oct_side_vertices[][][] =
+ {
+ {
+ {-S, S, 0.0f, 1.0f},
+ {0.0f, 1.0f, 0.0f, 1.0f},
+ {0.0f, 1.0f, -1.0f, 1.0f},
+ {-S, S, -1.0f, 1.0f}},
+
+ {
+ {-1.0f, 0.0f, 0.0f, 1.0f},
+ {-S, S, 0.0f, 1.0f},
+ {-S, S, -1.0f, 1.0f},
+ {-1.0f, 0.0f, -1.0f, 1.0f}},
+
+ {
+ {-S, -S, 0.0f, 1.0f},
+ {-1.0f, 0.0f, 0.0f, 1.0f},
+ {-1.0f, 0.0f, -1.0f, 1.0f},
+ {-S, -S, -1.0f, 1.0f}},
+
+ {
+ {0.0f, -1.0f, 0.0f, 1.0f},
+ {-S, -S, 0.0f, 1.0f},
+ {-S, -S, -1.0f, 1.0f},
+ {0.0f, -1.0f, -1.0f, 1.0f}},
+
+ {
+ {S, -S, 0.0f, 1.0f},
+ {0.0f, -1.0f, 0.0f, 1.0f},
+ {0.0f, -1.0f, -1.0f, 1.0f},
+ {S, -S, -1.0f, 1.0f}},
+
+ {
+ {1.0f, 0.0f, 0.0f, 1.0f},
+ {S, -S, 0.0f, 1.0f},
+ {S, -S, -1.0f, 1.0f},
+ {1.0f, 0.0f, -1.0f, 1.0f}},
+
+ {
+ {S, S, 0.0f, 1.0f},
+ {1.0f, 0.0f, 0.0f, 1.0f},
+ {1.0f, 0.0f, -1.0f, 1.0f},
+ {S, S, -1.0f, 1.0f}},
+
+ {
+ {0.0f, 1.0f, 0.0f, 1.0f},
+ {S, S, 0.0f, 1.0f},
+ {S, S, -1.0f, 1.0f},
+ {0.0f, 1.0f, -1.0f, 1.0f}}
+
+ };
+
+ float oct_side_normals[][] =
+ {
+ {-NS, NC, 0.0f},
+ {-NC, NS, 0.0f},
+ {-NC, -NS, 0.0f},
+ {-NS, -NC, 0.0f},
+ {NS, -NC, 0.0f},
+ {NC, -NS, 0.0f},
+ {NC, NS, 0.0f},
+ {NS, NC, 0.0f}
+ };
+
+ float cube_vertexes[][][] =
+ {
+ {
+ {-1.0f, -1.0f, -1.0f, 1.0f},
+ {-1.0f, -1.0f, 1.0f, 1.0f},
+ {-1.0f, 1.0f, 1.0f, 1.0f},
+ {-1.0f, 1.0f, -1.0f, 1.0f}},
+
+ {
+ {1.0f, 1.0f, 1.0f, 1.0f},
+ {1.0f, -1.0f, 1.0f, 1.0f},
+ {1.0f, -1.0f, -1.0f, 1.0f},
+ {1.0f, 1.0f, -1.0f, 1.0f}},
+
+ {
+ {-1.0f, -1.0f, -1.0f, 1.0f},
+ {1.0f, -1.0f, -1.0f, 1.0f},
+ {1.0f, -1.0f, 1.0f, 1.0f},
+ {-1.0f, -1.0f, 1.0f, 1.0f}},
+
+ {
+ {1.0f, 1.0f, 1.0f, 1.0f},
+ {1.0f, 1.0f, -1.0f, 1.0f},
+ {-1.0f, 1.0f, -1.0f, 1.0f},
+ {-1.0f, 1.0f, 1.0f, 1.0f}},
+
+ {
+ {-1.0f, -1.0f, -1.0f, 1.0f},
+ {-1.0f, 1.0f, -1.0f, 1.0f},
+ {1.0f, 1.0f, -1.0f, 1.0f},
+ {1.0f, -1.0f, -1.0f, 1.0f}},
+
+ {
+ {1.0f, 1.0f, 1.0f, 1.0f},
+ {-1.0f, 1.0f, 1.0f, 1.0f},
+ {-1.0f, -1.0f, 1.0f, 1.0f},
+ {1.0f, -1.0f, 1.0f, 1.0f}}
+ };
+
+ float cube_normals[][] =
+ {
+ {-1.0f, 0.0f, 0.0f, 0.0f},
+ {1.0f, 0.0f, 0.0f, 0.0f},
+ {0.0f, -1.0f, 0.0f, 0.0f},
+ {0.0f, 1.0f, 0.0f, 0.0f},
+ {0.0f, 0.0f, -1.0f, 0.0f},
+ {0.0f, 0.0f, 1.0f, 0.0f}
+ };
+
+ public mothCanvas(int w, int h)
+ {
+ super(w, h);
+ GLContext.gljNativeDebug = false;
+ GLContext.gljClassDebug = false;
+ setAnimateFps(30.0);
+ }
+
+ public void preInit()
+ {
+ doubleBuffer = true;
+ stereoView = false;
+ }
+
+ public void init()
+ {
+ System.out.println("init(): " + this);
+ reshape(getSize().width, getSize().height);
+
+ /*** Initial light position is declared in the display function ***/
+
+ gl.glLightfv(GL_LIGHT1, GL_AMBIENT, light1Amb);
+ gl.glLightfv(GL_LIGHT1, GL_DIFFUSE, light1Diff);
+ gl.glLightfv(GL_LIGHT1, GL_SPECULAR, light1Spec);
+ gl.glEnable(GL_LIGHT1);
+
+ gl.glEnable(GL_LIGHTING);
+
+ gl.glLightf(GL_LIGHT1, GL_QUADRATIC_ATTENUATION, 0.07f); /* try 0.07 w/ 24 bit color */
+
+ /*....Shadow Matrices For Floor, Left Wall, Back Wall, and Right Wall......*/
+
+ /* For light0 */
+
+ myShadowMatrix(groundPlane, lightPos, shadowMat_ground);
+ myShadowMatrix(leftPlane, lightPos, shadowMat_left);
+ myShadowMatrix(columnPlane, lightPos, shadowMat_column);
+ myShadowMatrix(backPlane, lightPos, shadowMat_back);
+ myShadowMatrix(rightPlane, lightPos, shadowMat_right);
+
+ /* For light1 */
+
+ myShadowMatrix(groundPlane, light1Pos, shadowMat1_ground);
+ myShadowMatrix(leftPlane, light1Pos, shadowMat1_left);
+ myShadowMatrix(backPlane, light1Pos, shadowMat1_back);
+ myShadowMatrix(rightPlane, light1Pos, shadowMat1_right);
+
+ /*sssssssssssssssss Make Satellite Body and Shadow ssssssssssssssssssssssss*/
+
+ gl.glNewList(satellite1, GL_COMPILE);
+ gl.glPushMatrix();
+ drawSatellite(satellite_diffuse, satellite_ambient, satellite_specular, satellite_shiny);
+ gl.glPopMatrix();
+ gl.glEndList();
+ gl.glNewList(satellite2, GL_COMPILE);
+ gl.glPushMatrix();
+ drawSatellite(shadow_diffuse, shadow_ambient, shadow_specular, shadow_shiny);
+ gl.glPopMatrix();
+ gl.glEndList();
+
+ /*ppppppppppppppppppppppppppp Make Solar Panels and Shadows pppppppppppppppppp*/
+
+ gl.glNewList(panel1, GL_COMPILE);
+ gl.glPushMatrix();
+ drawPanels(panel_color, panel_ambient);
+ gl.glPopMatrix();
+ gl.glEndList();
+
+ gl.glNewList(panel2, GL_COMPILE);
+ gl.glPushMatrix();
+ drawPanels(shadow_diffuse, shadow_ambient);
+ gl.glPopMatrix();
+ gl.glEndList();
+
+ /*========= Make Floor ==============*/
+
+ gl.glNewList(ground, GL_COMPILE);
+ gl.glPushMatrix();
+ gl.glPushAttrib(GL_LIGHTING_BIT);
+ gl.glMaterialfv(GL_FRONT, GL_DIFFUSE, floor_color);
+ gl.glMaterialfv(GL_FRONT, GL_AMBIENT, shadow_ambient);
+ gl.glTranslatef(0.0f, -1.5f, -5.0f);
+ gl.glRotatef(-90.0f, 1.0f, 0.0f, 0.0f);
+ gl.glScalef(5.0f, 5.0f, 1.0f);
+ drawGround(); /* draw ground */
+ gl.glPopAttrib();
+ gl.glPopMatrix();
+ gl.glEndList();
+
+ /*@@@@@@@@@@ Make Lamp Post and Lamp @@@@@@@@@@@@*/
+
+ gl.glNewList(21, GL_COMPILE);
+ gl.glPushMatrix();
+ gl.glPushAttrib(GL_LIGHTING_BIT);
+ gl.glMaterialfv(GL_FRONT, GL_AMBIENT, lamp_post_specular);
+ gl.glTranslatef(0.0f, -0.1f, -5.0f);
+ gl.glScalef(0.07f, 1.45f, 0.07f);
+ drawCube(lamp_post_diffuse, lamp_post_ambient); /* draw lamp post */
+ gl.glPopAttrib();
+ gl.glPopMatrix();
+ gl.glPushMatrix();
+ gl.glTranslatef(0.0f, -1.45f, -5.0f);
+ gl.glScalef(0.3f, 0.05f, 0.3f);
+ drawCube(wall_color, cube_ambient); /* draw lamp post base */
+ gl.glPopMatrix();
+ gl.glEndList();
+
+ gl.glNewList(22, GL_COMPILE);
+ gl.glPushMatrix();
+ gl.glPushAttrib(GL_LIGHTING_BIT);
+ gl.glMaterialfv(GL_FRONT, GL_AMBIENT, lamp_ambient);
+ gl.glMaterialfv(GL_FRONT, GL_DIFFUSE, lamp_diffuse);
+ gl.glMaterialfv(GL_FRONT, GL_SPECULAR, lamp_specular);
+ gl.glTranslatef(0.0f, 1.6f, -5.0f);
+
+ /* draw lamp */
+ int qobj = glu.gluNewQuadric();
+ glu.gluQuadricOrientation(qobj,GLU_OUTSIDE);
+ glu.gluQuadricNormals(qobj,GLU_SMOOTH);
+ glu.gluQuadricTexture(qobj,false);
+ glu.gluSphere(qobj,0.3f,20,20);
+ glu.gluDeleteQuadric(qobj);
+
+ gl.glPopAttrib();
+ gl.glPopMatrix();
+ gl.glEndList();
+
+ /*** Lamp post base shadow ***/
+
+ gl.glNewList(501, GL_COMPILE);
+ gl.glPushMatrix();
+ gl.glPushAttrib(GL_LIGHTING_BIT);
+ gl.glMaterialfv(GL_FRONT, GL_AMBIENT, shadow_ambient);
+ gl.glMaterialfv(GL_FRONT, GL_DIFFUSE, shadow_diffuse);
+ gl.glMaterialfv(GL_FRONT, GL_SPECULAR, shadow_specular);
+ gl.glMaterialfv(GL_FRONT, GL_SHININESS, shadow_shiny);
+ gl.glTranslatef(0.0f, -1.49f, -5.0f);
+ gl.glRotatef(-90.0f, 1.0f, 0.0f, 0.0f);
+ gl.glScalef(0.7f, 0.7f, 1.0f);
+ drawOct();
+ gl.glPopAttrib();
+ gl.glPopMatrix();
+ gl.glEndList();
+
+ /*||||||||||| Make Left Wall |||||||||||||*/
+
+ gl.glNewList(left_wall, GL_COMPILE);
+ gl.glPushMatrix();
+ gl.glPushAttrib(GL_LIGHTING_BIT);
+ gl.glMaterialfv(GL_FRONT, GL_DIFFUSE, wall_color);
+ gl.glMaterialfv(GL_FRONT, GL_AMBIENT, wall_ambient);
+ gl.glTranslatef(0.0f, -1.5f, 0.0f);
+ gl.glTranslatef(0.0f, 1.2f, 0.0f);
+ gl.glTranslatef(0.0f, 0.0f, -5.0f);
+ gl.glTranslatef(-5.0f, 0.0f, 0.0f);
+ gl.glRotatef(90.0f, 0.0f, 1.0f, 0.0f);
+ gl.glScalef(4.5f, 1.2f, 1.0f);
+ gl.glNormal3f(0.0f, 0.0f, 1.0f);
+ drawGround(); /* draw left wall */
+ gl.glPopAttrib();
+ gl.glPopMatrix();
+ gl.glEndList();
+
+ /*\\\\\\\\\\\\\ Make Right Wall \\\\\\\\\\\\\\\\\\\*/
+
+ gl.glNewList(right_wall, GL_COMPILE);
+ gl.glPushMatrix();
+ gl.glPushAttrib(GL_LIGHTING_BIT);
+ gl.glMaterialfv(GL_FRONT, GL_DIFFUSE, wall_color);
+ gl.glMaterialfv(GL_FRONT, GL_AMBIENT, wall_ambient);
+ gl.glTranslatef(0.0f, -1.5f, 0.0f);
+ gl.glTranslatef(0.0f, 1.2f, 0.0f);
+
+ gl.glTranslatef(0.0f, 0.0f, -5.0f);
+ gl.glTranslatef(5.0f, 0.0f, 0.0f);
+ gl.glRotatef(270.0f, 0.0f, 1.0f, 0.0f);
+
+ gl.glScalef(4.5f, 1.2f, 1.0f);
+ gl.glNormal3f(0.0f, 0.0f, 1.0f);
+ drawGround(); /* draw right wall */
+ gl.glPopAttrib();
+ gl.glPopMatrix();
+ gl.glEndList();
+
+ /*[[[[[[[[[[[ Build Columns ]]]]]]]]]]]*/
+
+ gl.glPushMatrix();
+ gl.glNewList(1, GL_COMPILE);
+ gl.glPushMatrix();
+ gl.glScalef(0.4f, 1.4f, 0.4f);
+ drawCube(column_color, column_ambient); /* draw column1 */
+ gl.glPopMatrix();
+ gl.glEndList();
+
+ gl.glNewList(2, GL_COMPILE);
+ gl.glPushMatrix();
+ gl.glTranslatef(0.0f, -1.45f, 0.0f);
+ gl.glScalef(0.5f, 0.1f, 0.5f);
+ drawCube(wall_color, cube_ambient); /* draw base */
+ gl.glPopMatrix();
+ gl.glPushMatrix();
+ gl.glTranslatef(0.0f, 1.45f, 0.0f);
+ gl.glScalef(0.5f, 0.1f, 0.5f);
+ drawCube(wall_color, cube_ambient); /* draw top */
+ gl.glPopMatrix();
+ gl.glEndList();
+ gl.glPopMatrix();
+
+ gl.glNewList(column, GL_COMPILE);
+ gl.glPushMatrix();
+ gl.glCallList(1);
+ gl.glCallList(2);
+ gl.glPopMatrix();
+ gl.glEndList();
+
+ /***** Place columns at front of scene. *****/
+
+ gl.glNewList(4, GL_COMPILE);
+ gl.glPushMatrix();
+ gl.glTranslatef(-5.0f, 0.0f, -0.5f);
+ gl.glCallList(column);
+ gl.glPopMatrix();
+ gl.glEndList();
+
+ gl.glNewList(5, GL_COMPILE);
+ gl.glPushMatrix();
+ gl.glTranslatef(-1.75f, 0.0f, -0.5f);
+ gl.glCallList(column);
+ gl.glPopMatrix();
+ gl.glEndList();
+
+ gl.glNewList(6, GL_COMPILE);
+ gl.glPushMatrix();
+ gl.glTranslatef(1.75f, 0.0f, -0.5f);
+ gl.glCallList(column);
+ gl.glPopMatrix();
+ gl.glEndList();
+
+ gl.glNewList(17, GL_COMPILE);
+ gl.glPushMatrix();
+ gl.glTranslatef(5.0f, 0.0f, -0.5f);
+ gl.glCallList(column);
+ gl.glPopMatrix();
+ gl.glEndList();
+
+ /*** Get the modelview matrix once ***/
+ gl.glPushMatrix();
+ gl.glRotatef(-mvr_d, mvr_x, mvr_y, mvr_z);
+ gl.glTranslatef(-mvt_x, -mvt_y, -mvt_z);
+ gl.glGetFloatv(GL_MODELVIEW_MATRIX, four_columnsXform);
+ gl.glPopMatrix();
+
+ gl.glNewList(four_columns, GL_COMPILE);
+ gl.glPushMatrix();
+ gl.glCallList(4);
+ gl.glCallList(5);
+ gl.glCallList(6);
+ gl.glCallList(17);
+ gl.glPopMatrix();
+ gl.glEndList();
+
+ /***** Make two columns for sides of scene *****/
+
+ gl.glNewList(two_columns, GL_COMPILE);
+ gl.glPushMatrix();
+ gl.glRotatef(90.0f, 0.0f, 1.0f, 0.0f);
+ gl.glTranslatef(5.0f, 0.0f, -5.0f);
+ gl.glPushMatrix();
+ gl.glTranslatef(0.0f, 0.0f, -0.3f);
+ gl.glCallList(column);
+ gl.glPopMatrix();
+ gl.glPushMatrix();
+ gl.glTranslatef(0.0f, 0.0f, 10.3f);
+ gl.glCallList(column);
+ gl.glPopMatrix();
+ gl.glPopMatrix();
+ gl.glEndList();
+
+ /* .......................Make shadows .........................*/
+
+ gl.glPushMatrix();
+ gl.glNewList(8, GL_COMPILE);
+ gl.glPushMatrix();
+ gl.glScalef(0.4f, 1.4f, 0.4f);
+ drawCube(shadow_diffuse, shadow_ambient); /* draw column1 */
+ gl.glPopMatrix();
+ gl.glEndList();
+
+
+ gl.glNewList(9, GL_COMPILE);
+ gl.glPushMatrix();
+ gl.glTranslatef(0.0f, -1.45f, 0.0f);
+ gl.glScalef(0.5f, 0.1f, 0.5f);
+ drawCube(shadow_diffuse, shadow_ambient); /* draw base. */
+ gl.glPopMatrix();
+ gl.glPushMatrix();
+ gl.glTranslatef(0.0f, 1.45f, 0.0f);
+ gl.glScalef(0.5f, 0.1f, 0.5f);
+ drawCube(shadow_diffuse, shadow_ambient); /* draw top. */
+ gl.glPopMatrix();
+ gl.glEndList();
+ gl.glPopMatrix();
+
+ gl.glNewList(10, GL_COMPILE);
+ gl.glPushMatrix();
+ gl.glCallList(8);
+ gl.glCallList(9);
+ gl.glPopMatrix();
+ gl.glEndList();
+
+ gl.glNewList(11, GL_COMPILE);
+ gl.glPushMatrix();
+ gl.glTranslatef(-5.0f, 0.0f, -0.5f);
+ gl.glCallList(10);
+ gl.glPopMatrix();
+ gl.glEndList();
+
+ gl.glNewList(12, GL_COMPILE);
+ gl.glPushMatrix();
+ gl.glTranslatef(-1.75f, 0.0f, -0.5f);
+ gl.glCallList(10);
+ gl.glPopMatrix();
+ gl.glEndList();
+
+ gl.glNewList(13, GL_COMPILE);
+ gl.glPushMatrix();
+ gl.glTranslatef(1.75f, 0.0f, -0.5f);
+ gl.glCallList(10);
+ gl.glPopMatrix();
+ gl.glEndList();
+
+ gl.glNewList(14, GL_COMPILE);
+ gl.glPushMatrix();
+ gl.glTranslatef(5.0f, 0.0f, -0.5f);
+ gl.glCallList(10);
+ gl.glPopMatrix();
+ gl.glEndList();
+
+ gl.glNewList(15, GL_COMPILE);
+ gl.glPushMatrix();
+ gl.glCallList(11);
+ gl.glCallList(12);
+ gl.glCallList(13);
+ gl.glCallList(14);
+ gl.glPopMatrix();
+ gl.glEndList();
+
+ gl.glNewList(100, GL_COMPILE);
+ gl.glPushMatrix();
+ gl.glMultMatrixf(shadowMat_ground);
+ gl.glTranslatef(-mvt_x, -mvt_y, -mvt_z); /* correct for modelview matrix */
+ gl.glRotatef(-mvr_d, mvr_x, mvr_y, mvr_z);
+ gl.glMultMatrixf(four_columnsXform);
+ gl.glCallList(15);
+ gl.glPopMatrix();
+ gl.glEndList();
+
+ gl.glNewList(101, GL_COMPILE);
+ gl.glPushMatrix();
+ gl.glMultMatrixf(shadowMat_left);
+ gl.glTranslatef(-mvt_x, -mvt_y, -mvt_z); /* correct for modelview matrix */
+ gl.glRotatef(-mvr_d, mvr_x, mvr_y, mvr_z);
+ gl.glMultMatrixf(four_columnsXform);
+ gl.glCallList(15);
+ gl.glPopMatrix();
+ gl.glEndList();
+
+ gl.glNewList(102, GL_COMPILE);
+ gl.glPushMatrix();
+ gl.glMultMatrixf(shadowMat_back);
+ gl.glRotatef(-mvr_d, mvr_x, mvr_y, mvr_z);
+ gl.glTranslatef(-mvt_x, -mvt_y, -mvt_z); /* correct for modelview matrix */
+ gl.glMultMatrixf(four_columnsXform);
+ gl.glCallList(15);
+ gl.glPopMatrix();
+ gl.glEndList();
+
+ gl.glNewList(103, GL_COMPILE);
+ gl.glPushMatrix();
+ gl.glMultMatrixf(shadowMat_right);
+ gl.glRotatef(-mvr_d, mvr_x, mvr_y, mvr_z);
+ gl.glTranslatef(-mvt_x, -mvt_y, -mvt_z); /* correct for modelview matrix */
+ gl.glMultMatrixf(four_columnsXform);
+ gl.glCallList(15);
+ gl.glPopMatrix();
+ gl.glEndList();
+
+ glj.gljCheckGL();
+
+ addMouseListener(this);
+ }
+
+ public void doCleanup()
+ {
+ System.out.println("destroy(): " + this);
+ removeMouseListener(this);
+ }
+
+ public void reshape(int width, int height)
+ {
+ gl.glViewport(0,0,width,height);
+ gl.glMatrixMode(GL_PROJECTION);
+
+
+ gl.glMatrixMode(GL_PROJECTION);
+ gl.glLoadIdentity();
+
+ gl.glFrustum(-0.9f, 0.9f, -0.9f, 0.9f, 1.0f, 35.0f);
+
+ gl.glMatrixMode(GL_MODELVIEW);
+ gl.glLoadIdentity();
+
+ gl.glEnable(GL_NORMALIZE);
+ gl.glEnable(GL_CULL_FACE);
+ gl.glCullFace(GL_BACK); /* double your fun */
+ gl.glShadeModel(GL_SMOOTH);
+ gl.glDepthFunc(GL_LESS);
+ gl.glDepthMask(true);
+ gl.glEnable(GL_DEPTH_TEST);
+ }
+
+ public void display()
+ {
+ if (glj.gljMakeCurrent() == false) return;
+
+ tick++;
+ if (tick >= 60) tick = 0;
+
+ gl.glPushMatrix();
+
+ gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ gl.glLoadIdentity();
+
+ /*@@@@@@ Rotation and Translation of Entire Scene @@@@@*/
+
+ if (mvt_x < 0.0f && mvt_y < 0.0f)
+ {
+ gl.glTranslatef(mvt_x ,mvt_y ,mvt_z );
+ mvt_x = mvt_x - Tx;
+ mvt_y = mvt_y - Ty;
+ mvt_z = mvt_z - Tz;
+
+ gl.glRotatef(mvr_d, mvr_x, mvr_y, mvr_z);
+ mvr_d = mvr_d - Rx;
+ }
+ else
+ gl.glTranslatef(0.0f, 0.0f ,mvt_z);
+
+ /*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
+
+ gl.glPushMatrix();
+ gl.glLightfv(GL_LIGHT1, GL_POSITION, light1Pos);
+ gl.glPopMatrix();
+
+ /*______________________ Draw Floor _______________________*/
+
+ gl.glPushMatrix();
+ gl.glCallList(ground);
+ gl.glPopMatrix();
+
+ /*@@@@@@@@@ Draw Lamp Post amd Lamp @@@@@@@@@@*/
+
+ gl.glPushMatrix();
+ gl.glCallList(21);
+ gl.glPopMatrix();
+
+ gl.glPushMatrix();
+ gl.glCallList(22);
+ gl.glPopMatrix();
+
+ gl.glPushMatrix();
+ gl.glEnable(GL_BLEND);
+ gl.glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ gl.glCallList(501);
+ gl.glDisable(GL_BLEND);
+ gl.glPopMatrix();
+
+ /*||||||||||||||||||| Draw Left Wall ||||||||||||||||||*/
+
+ gl.glCallList(left_wall);
+
+ /*\\\\\\\\\\\\\\\\ Draw Right Wall \\\\\\\\\\\\\\*/
+
+ gl.glCallList(right_wall);
+
+ /*[[[[[[[[[[[[[[[[[[[ Draw Columns ]]]]]]]]]]]]]]]]]]]*/
+
+ /***** Place columns at front of scene. *****/
+
+ gl.glCallList(four_columns);
+
+ /***** Place columns at back of scene. *****/
+
+ gl.glPushMatrix();
+ gl.glTranslatef(0.0f, 0.0f, -9.0f);
+ gl.glCallList(four_columns);
+ gl.glPopMatrix();
+
+ /***** Place columns at centers of left and right walls. *****/
+
+ gl.glCallList(two_columns);
+
+ /************************* CUBE ***********************/
+
+ gl.glMaterialf(GL_FRONT, GL_SHININESS, 99.0f);
+ gl.glMaterialfv(GL_FRONT, GL_SPECULAR, cube_specular);
+
+ gl.glPushMatrix();
+ gl.glTranslatef(0.0f, 0.0f, -5.0f);
+ gl.glRotatef((360.0f / (30 * 2)) * tick, 0, 1, 0);
+ gl.glPushMatrix();
+ gl.glTranslatef(0.0f, 0.2f, 2.0f);
+ gl.glRotatef((360.0f / (30 * 1)) * tick, 1, 0, 0);
+ gl.glRotatef((360.0f / (30 * 2)) * tick, 0, 1, 0);
+ gl.glRotatef((360.0f / (30 * 4)) * tick, 0, 0, 1);
+
+ gl.glGetFloatv(GL_MODELVIEW_MATRIX, cubeXform);
+
+ gl.glCallList(satellite1);
+ gl.glCallList(panel1);
+
+ gl.glPopMatrix();
+ gl.glPopMatrix();
+
+ gl.glMaterialf(GL_FRONT, GL_SHININESS, 0.0f);
+ gl.glMaterialfv(GL_FRONT, GL_SPECULAR, shadow_specular);
+
+ /*................... CUBE SHADOWS .............................*/
+
+ gl.glEnable(GL_BLEND);
+ gl.glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+
+ gl.glPushMatrix();
+ gl.glMultMatrixf(shadowMat1_ground);
+ gl.glRotatef(-mvr_d, mvr_x, mvr_y, mvr_z);
+ gl.glTranslatef(-mvt_x, -mvt_y, -mvt_z); /* correct for modelview matrix */
+ gl.glMultMatrixf(cubeXform);
+
+
+ gl.glCallList(satellite2);
+ gl.glTranslatef(0.0f, -.040f, 0.0f);
+ gl.glCallList(panel2);
+ gl.glPopMatrix();
+
+ /* Shadow left wall only if cube is in front of left wall. */
+ if((tick*6) >= 220 && (tick*6) <= 320)
+ {
+ gl.glPushMatrix();
+ gl.glMultMatrixf(shadowMat1_left);
+ gl.glRotatef(-mvr_d, mvr_x, mvr_y, mvr_z);
+ gl.glTranslatef(-mvt_x, -mvt_y, -mvt_z); /* correct for modelview matrix */
+ gl.glMultMatrixf(cubeXform);
+ drawSatellite(shadow_diffuse, shadow_ambient, shadow_specular, shadow_shiny); /* draw left shadow */
+ drawPanels(shadow_diffuse, shadow_ambient);
+ gl.glPopMatrix();
+ }
+
+ /* Shadow back wall only if cube is in front of back wall. */
+ if((tick*6) >= 125 && (tick*6) <= 330)
+ {
+ gl.glPushMatrix();
+ gl.glMultMatrixf(shadowMat1_back);
+ gl.glRotatef(-mvr_d, mvr_x, mvr_y, mvr_z);
+ gl.glTranslatef(-mvt_x, -mvt_y, -mvt_z); /* correct for modelview matrix */
+ gl.glMultMatrixf(cubeXform);
+ drawSatellite(shadow_diffuse, shadow_ambient, shadow_specular, shadow_shiny); /* draw back wall shadow */
+ drawPanels(shadow_diffuse, shadow_ambient);
+ gl.glPopMatrix();
+ }
+
+ /* Shadow right wall only if cube is in front of right wall. */
+ if((tick*6) >= 40 && (tick*6) <= 145)
+ {
+ gl.glPushMatrix();
+ gl.glMultMatrixf(shadowMat1_right);
+ gl.glRotatef(-mvr_d, mvr_x, mvr_y, mvr_z);
+ gl.glTranslatef(-mvt_x, -mvt_y, -mvt_z); /* correct for modelview matrix */
+ gl.glMultMatrixf(cubeXform);
+ drawSatellite(shadow_diffuse, shadow_ambient, shadow_specular, shadow_shiny); /* draw right wall shadow */
+ drawPanels(shadow_diffuse, shadow_ambient);
+ gl.glPopMatrix();
+ }
+
+ gl.glDisable(GL_BLEND);
+
+ gl.glPopMatrix(); /* Clear the matrix stack */
+
+ glj.gljSwap();
+ glj.gljCheckGL();
+ glj.gljFree();
+
+ //if (!isSuspended()) repaint(); // Animate at full speed.
+ }
+
+ // Methods required for the implementation of MouseListener
+ public void mouseEntered( MouseEvent evt )
+ {
+ }
+
+ public void mouseExited( MouseEvent evt )
+ {
+ }
+
+ public void mousePressed( MouseEvent evt )
+ {
+ if ((evt.getModifiers() & evt.BUTTON3_MASK) != 0)
+ {
+ Tx = default_Tx;
+ Ty = default_Ty;
+ Tz = default_Tz;
+
+ mvt_x = default_mvt_x;
+ mvt_y = default_mvt_y;
+ mvt_z = default_mvt_z;
+
+ mvr_d = default_mvr_d;
+
+ tick = -1;
+
+ setSuspended(false);
+ moving = true;
+ }
+ else
+ {
+ setSuspended(moving);
+ moving = !moving;
+ }
+ }
+
+ public void mouseReleased( MouseEvent evt )
+ {
+ }
+
+ public void mouseClicked( MouseEvent evt )
+ {
+ }
+ /*%%%%%%%%%%%%%%%%%%%% DRAW CUBE %%%%%%%%%%%%%%%%%%*/
+
+ private void drawCube(float color[], float ambient[])
+ {
+ gl.glMaterialfv(GL_FRONT, GL_DIFFUSE, color);
+ gl.glMaterialfv(GL_FRONT, GL_AMBIENT, ambient);
+
+ for (int i = 0; i < 6; ++i)
+ {
+ gl.glNormal3fv(cube_normals[i]);
+ gl.glBegin(GL_POLYGON);
+ gl.glVertex4fv(cube_vertexes[i][0]);
+ gl.glVertex4fv(cube_vertexes[i][1]);
+ gl.glVertex4fv(cube_vertexes[i][2]);
+ gl.glVertex4fv(cube_vertexes[i][3]);
+ gl.glEnd();
+ }
+ }
+
+ /*OOOOOOOOOOO DRAW OCTOGON TOP OOOOOOOOOOOOO*/
+
+ private void drawOct()
+ {
+ for (int i = 0; i < 8; ++i)
+ {
+ gl.glNormal3f(0.0f, 0.0f, 1.0f);
+ gl.glBegin(GL_TRIANGLE_FAN);
+ gl.glVertex4fv(oct_vertices[i][0]);
+ gl.glVertex4fv(oct_vertices[i][1]);
+ gl.glVertex4fv(oct_vertices[i][2]);
+ gl.glEnd();
+ }
+ }
+
+ /*oooooooooooDRAW OCTOGON SIDES ooooooooo*/
+
+ private void drawOctSides()
+ {
+ for (int i = 0; i < 8; ++i)
+ {
+ gl.glNormal3fv(oct_side_normals[i]);
+ gl.glBegin(GL_POLYGON);
+ gl.glVertex4fv(oct_side_vertices[i][0]);
+ gl.glVertex4fv(oct_side_vertices[i][1]);
+ gl.glVertex4fv(oct_side_vertices[i][2]);
+ gl.glVertex4fv(oct_side_vertices[i][3]);
+ gl.glEnd();
+ }
+ }
+
+ /*SSSSSSSSSSSSSSSS DRAW SATELLITE BODY SSSSSSSSSSSSSSSSSSS*/
+
+ private void drawSatellite(float diffuse[], float ambient[], float specular[], float shiny[])
+ {
+ gl.glMaterialfv(GL_FRONT, GL_DIFFUSE, diffuse);
+ gl.glMaterialfv(GL_FRONT, GL_AMBIENT, ambient);
+ gl.glMaterialfv(GL_FRONT, GL_SPECULAR, specular);
+ gl.glMaterialfv(GL_FRONT, GL_SHININESS, shiny);
+
+ gl.glPushMatrix();
+ gl.glScalef(0.3f, 0.3f, 0.9f);
+ gl.glPushMatrix();
+ drawOctSides();
+ gl.glPopMatrix();
+
+ gl.glPushMatrix();
+ gl.glTranslatef(0.0f, 0.0f, 0.0f);
+ drawOct();
+ gl.glPopMatrix();
+ gl.glPushMatrix();
+ gl.glRotatef(180f, 1.0f, 0.0f, 0.0f);
+ gl.glTranslatef(0.0f, 0.0f, 1.0f);
+ drawOct();
+ gl.glPopMatrix();
+ gl.glPopMatrix();
+ }
+
+ /*PPPPPPPPPPPPPPPP DRAW SOLAR PANELS PPPPPPPPPPPP*/
+
+ private void drawPanels(float color[], float ambient[])
+ {
+ gl.glMaterialfv(GL_FRONT, GL_DIFFUSE, color);
+ gl.glMaterialfv(GL_FRONT, GL_AMBIENT, ambient);
+
+ gl.glPushMatrix();
+ gl.glTranslatef(0.95f, 0.0f, -0.45f);
+ gl.glRotatef(45.0f, 1.0f, 0.0f, 0.0f);
+ gl.glScalef(0.65f, 0.20f, 0.02f);
+ drawCube(color, ambient);
+ gl.glPopMatrix();
+ gl.glPushMatrix();
+ gl.glTranslatef(-0.95f, 0.0f, -0.45f);
+ gl.glRotatef(45.0f, 1.0f, 0.0f, 0.0f);
+ gl.glScalef(0.65f, 0.20f, 0.02f);
+ drawCube(color, ambient);
+ gl.glPopMatrix();
+ }
+
+ /*################ DRAW FLOOR ################*/
+
+ private void drawFloor(float f_color[], float ambient[])
+ {
+
+ gl.glMaterialfv(GL_FRONT, GL_DIFFUSE, f_color);
+ gl.glMaterialfv(GL_FRONT, GL_AMBIENT, ambient);
+
+ gl.glBegin(GL_QUADS);
+ gl.glVertex3f(-1.0f, -1.0f, 0.0f);
+ gl.glVertex3f(1.0f, -1.0f, 0.0f);
+ gl.glVertex3f(1.0f, 1.0f, 0.0f);
+ gl.glVertex3f(-1.0f, 1.0f, 0.0f);
+ gl.glEnd();
+ }
+
+ /*||||||||||||||| DRAW GROUND |||||||||||||||||*/
+
+ /* Ground coordinates are in drawGround() below. Subdivision */
+ /* of triangles id done by subDivide(). */
+
+ private void subDivide(float u1[], float u2[], float u3[], int depth)
+ {
+ float u12[] = new float[3];
+ float u23[] = new float[3];
+ float u31[] = new float[3];
+
+ if (depth == 0)
+ {
+ gl.glBegin(GL_POLYGON);
+ gl.glNormal3f(0.0f, 0.0f, 1.0f); gl.glVertex3fv(u1);
+ gl.glNormal3f(0.0f, 0.0f, 1.0f); gl.glVertex3fv(u2);
+ gl.glNormal3f(0.0f, 0.0f, 1.0f); gl.glVertex3fv(u3);
+ gl.glEnd();
+ return;
+ }
+
+ for (int i = 0; i < 3; i++)
+ {
+ u12[i] = (u1[i] + u2[i]) / 2.0f;
+ u23[i] = (u2[i] + u3[i]) / 2.0f;
+ u31[i] = (u3[i] + u1[i]) / 2.0f;
+ }
+ subDivide(u1, u12, u31, depth - 1);
+ subDivide(u2, u23, u12, depth - 1);
+ subDivide(u3, u31, u23, depth - 1);
+ subDivide(u12, u23, u31, depth - 1);
+ }
+
+ private void drawGround()
+ {
+ /* Use two subdivided triangles for the unscaled 1X1 square. */
+ /* Subdivide to this depth: */
+
+ int maxdepth = 2;
+
+ /* Coordinates of first triangle: */
+
+ float u1[] = {-1.0f, -1.0f, 0.0f};
+ float u2[] = {1.0f, -1.0f, 0.0f};
+ float u3[] = {1.0f, 1.0f, 0.0f};
+
+ /* Coordinates of second triangle: */
+
+ float v1[] = {-1.0f, -1.0f, 0.0f};
+ float v2[] = {1.0f, 1.0f, 0.0f};
+ float v3[] = {-1.0f, 1.0f, 0.0f};
+
+ subDivide(u1, u2, u3, maxdepth);
+ subDivide(v1, v2, v3, maxdepth);
+ }
+
+ /* Matrix for shadow. From Mark Kilgard's "scube". */
+
+ private void myShadowMatrix(float ground[], float light[], float shadowMat[])
+ {
+ float dot;
+
+ dot =
+ ground[0] * light[0] +
+ ground[1] * light[1] +
+ ground[2] * light[2] +
+ ground[3] * light[3];
+
+ shadowMat[0] = dot - light[0] * ground[0];
+ shadowMat[4] = -light[0] * ground[1];
+ shadowMat[8] = -light[0] * ground[2];
+ shadowMat[12] = -light[0] * ground[3];
+
+ shadowMat[1] = -light[1] * ground[0];
+ shadowMat[5] = dot - light[1] * ground[1];
+ shadowMat[9] = -light[1] * ground[2];
+ shadowMat[13] = -light[1] * ground[3];
+
+ shadowMat[2] = -light[2] * ground[0];
+ shadowMat[6] = -light[2] * ground[1];
+ shadowMat[10] = dot - light[2] * ground[2];
+ shadowMat[14] = -light[2] * ground[3];
+
+ shadowMat[3] = -light[3] * ground[0];
+ shadowMat[7] = -light[3] * ground[1];
+ shadowMat[11] = -light[3] * ground[2];
+ shadowMat[15] = dot - light[3] * ground[3];
+ }
+ }
+}
diff --git a/demos/RonsDemos/moth_plugin13.html b/demos/RonsDemos/moth_plugin13.html new file mode 100644 index 0000000..b10d99e --- /dev/null +++ b/demos/RonsDemos/moth_plugin13.html @@ -0,0 +1,50 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
+ <title>Moth by Robert Doyle; ported to Java by Ron Cemer</title>
+</head>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+Moth applet
+<br>Originially written by Silicon Graphics
+<br>Ported to Java by Ron Cemer
+<br>Click the left mouse button within the window to pause/resume simulation.
+<br>Click the right mouse button within the window to restart simulation.
+<br>
+<!--"CONVERTED_APPLET"-->
+<!-- CONVERTER VERSION 1.3 --> +<SCRIPT LANGUAGE="JavaScript"><!-- + var _info = navigator.userAgent; var _ns = false; + var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0); +//--></SCRIPT> +<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!-- + var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0))); +//--></SCRIPT></COMMENT> + +<SCRIPT LANGUAGE="JavaScript"><!-- + if (_ie == true) document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = 400 HEIGHT = 400 codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0"><NOEMBED><XMP>'); + else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.3" CODE = "moth.class" WIDTH = 400 HEIGHT = 400 scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html"><NOEMBED><XMP>'); +//--></SCRIPT> +<APPLET CODE = "moth.class" WIDTH = 400 HEIGHT = 400></XMP> +<PARAM NAME = CODE VALUE = "moth.class" >
+ +<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3"> +<PARAM NAME="scriptable" VALUE="false"> + +</APPLET> + +</NOEMBED></EMBED></OBJECT> + + +<!-- +<APPLET CODE = "moth.class" WIDTH = 400 HEIGHT = 400>
+
+
+</APPLET> +--> +<!--"END_CONVERTED_APPLET"-->
+
+<hr>
+</body>
+</html>
diff --git a/demos/RonsDemos/movelight.html b/demos/RonsDemos/movelight.html new file mode 100644 index 0000000..a323355 --- /dev/null +++ b/demos/RonsDemos/movelight.html @@ -0,0 +1,20 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
+ <title>Movelight by Silicon Graphics; ported to Java by Ron Cemer</title>
+</head>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+Movelight applet
+<br>Originially written by Silicon Graphics
+<br>Ported to Java by Ron Cemer
+<br>
+<hr>Each time you click inside the window, the light source will rotate to
+<br>a new position.
+<br>
+<applet code="movelight.class" width=400 height=400>
+</applet>
+<hr>
+</body>
+</html>
diff --git a/demos/RonsDemos/movelight.java b/demos/RonsDemos/movelight.java new file mode 100644 index 0000000..bb983d9 --- /dev/null +++ b/demos/RonsDemos/movelight.java @@ -0,0 +1,322 @@ +/**
+ * @(#) movelight.java
+ * @(#) author: Silicon Graphics (converted to Java by Ron Cemer)
+ */
+
+/*
+ * Copyright (c) 1993-1997, Silicon Graphics, Inc.
+ * ALL RIGHTS RESERVED
+ * Permission to use, copy, modify, and distribute this software for
+ * any purpose and without fee is hereby granted, provided that the above
+ * copyright notice appear in all copies and that both the copyright notice
+ * and this permission notice appear in supporting documentation, and that
+ * the name of Silicon Graphics, Inc. not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission.
+ *
+ * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
+ * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
+ * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
+ * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
+ * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
+ * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
+ * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
+ * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
+ * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * US Government Users Restricted Rights
+ * Use, duplication, or disclosure by the Government is subject to
+ * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
+ * (c)(1)(ii) of the Rights in Technical Data and Computer Software
+ * clause at DFARS 252.227-7013 and/or in similar or successor
+ * clauses in the FAR or the DOD or NASA FAR Supplement.
+ * Unpublished-- rights reserved under the copyright laws of the
+ * United States. Contractor/manufacturer is Silicon Graphics,
+ * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
+ *
+ * OpenGL(R) is a registered trademark of Silicon Graphics, Inc.
+ */
+
+/*
+ * movelight.java
+ * This applet demonstrates when to issue lighting and
+ * transformation commands to render a model with a light
+ * which is moved by a modeling transformation (rotate or
+ * translate). The light position is reset after the modeling
+ * transformation is called. The eye position does not change.
+ *
+ * A torus is drawn using a grey material characteristic.
+ * A single light source illuminates the object.
+ *
+ * Interaction: pressing the left mouse button alters
+ * the modeling transformation (x rotation) by 30 degrees.
+ * The scene is then redrawn with the light in a new position.
+ */
+
+import java.applet.*;
+import java.awt.*;
+import java.awt.event.*;
+import java.lang.*;
+import java.util.*;
+import java.io.*;
+import java.util.*;
+import gl4java.GLContext;
+import gl4java.awt.GLCanvas;
+
+public class movelight extends Applet
+{
+ private static final float boxnormals[][] =
+ {
+ {-1.0f, 0.0f, 0.0f},
+ {0.0f, 1.0f, 0.0f},
+ {1.0f, 0.0f, 0.0f},
+ {0.0f, -1.0f, 0.0f},
+ {0.0f, 0.0f, 1.0f},
+ {0.0f, 0.0f, -1.0f}
+ };
+ private static final int boxfaces[][] =
+ {
+ {0, 1, 2, 3},
+ {3, 2, 6, 7},
+ {7, 6, 5, 4},
+ {4, 5, 1, 0},
+ {5, 6, 2, 1},
+ {7, 4, 0, 3}
+ };
+
+ movelightCanvas canvas = null;
+
+
+ /* Initialize the applet */
+
+
+ public void init()
+ {
+ Dimension d = getSize();
+ setLayout(new BorderLayout());
+ canvas = new movelightCanvas(d.width, d.height);
+ add("Center", canvas);
+ }
+
+
+ /* Start the applet */
+
+
+ public void start()
+ {
+ }
+
+
+ /* Stop the applet */
+
+
+ public void stop()
+ {
+ }
+
+
+ /* Destroy the applet */
+
+
+ public void destroy()
+ {
+ canvas.cvsDispose();
+ }
+
+
+ /* Local GLCanvas extension class */
+
+
+ private class movelightCanvas extends GLCanvas implements MouseListener
+ {
+ private static final float M_PI = 3.14159265359f;
+
+ private int spin = 0;
+
+ public movelightCanvas(int w, int h)
+ {
+ super(w, h);
+ GLContext.gljNativeDebug = false;
+ GLContext.gljClassDebug = false;
+ }
+
+ public void preInit()
+ {
+ doubleBuffer = true;
+ stereoView = false;
+ }
+
+ public void init()
+ {
+ System.out.println("init(): " + this);
+ reshape(getSize().width, getSize().height);
+
+ gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
+ gl.glShadeModel(GL_SMOOTH);
+ gl.glEnable(GL_LIGHTING);
+ gl.glEnable(GL_LIGHT0);
+ gl.glEnable(GL_DEPTH_TEST);
+
+ glj.gljCheckGL();
+
+ addMouseListener(this);
+ }
+
+ public void cvsDispose()
+ {
+ System.out.println("destroy(): " + this);
+ removeMouseListener(this);
+ super.cvsDispose();
+ }
+
+ public void reshape(int width, int height)
+ {
+ gl.glViewport(0,0,width,height);
+ gl.glMatrixMode(GL_PROJECTION);
+ gl.glLoadIdentity();
+ glu.gluPerspective(40.0f,(float)width/(float)height,1.0f,20.0f);
+ gl.glMatrixMode(GL_MODELVIEW);
+ gl.glLoadIdentity();
+ }
+
+ public void display()
+ {
+ if (glj.gljMakeCurrent() == false) return;
+
+ float position[] = { 0.0f, 0.0f, 1.5f, 1.0f };
+
+ gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ gl.glPushMatrix();
+ glu.gluLookAt(0.0f, 0.0f, 5.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f);
+
+ gl.glPushMatrix();
+ gl.glRotated((double)spin, 1.0, 0.0, 0.0);
+ gl.glLightfv(GL_LIGHT0, GL_POSITION, position);
+
+ gl.glTranslated(0.0, 0.0, 1.5);
+ gl.glDisable(GL_LIGHTING);
+ gl.glColor3f(0.0f, 1.0f, 1.0f);
+ glutWireCube(0.1f);
+ gl.glEnable(GL_LIGHTING);
+ gl.glPopMatrix();
+
+ glutSolidTorus(0.275f, 0.85f, 8, 15);
+ gl.glPopMatrix();
+ gl.glFlush();
+
+ glj.gljSwap();
+ glj.gljCheckGL();
+ glj.gljFree();
+ }
+
+ // Imported from glut.
+ private void glutWireCube(float size)
+ {
+ drawBox(size, GL_LINE_LOOP);
+ }
+
+ // Imported from glut.
+ private void glutSolidTorus
+ (float innerRadius,
+ float outerRadius,
+ int nsides,
+ int rings)
+ {
+ doughnut(innerRadius, outerRadius, nsides, rings);
+ }
+
+ // Imported from glut.
+ private void drawBox(float size, int type)
+ {
+ float v[][] = new float[8][3];
+ int i;
+
+ v[0][0] = v[1][0] = v[2][0] = v[3][0] = -size / 2;
+ v[4][0] = v[5][0] = v[6][0] = v[7][0] = size / 2;
+ v[0][1] = v[1][1] = v[4][1] = v[5][1] = -size / 2;
+ v[2][1] = v[3][1] = v[6][1] = v[7][1] = size / 2;
+ v[0][2] = v[3][2] = v[4][2] = v[7][2] = -size / 2;
+ v[1][2] = v[2][2] = v[5][2] = v[6][2] = size / 2;
+
+ for (i = 5; i >= 0; i--)
+ {
+ gl.glBegin(type);
+ gl.glNormal3fv(boxnormals[i]);
+ gl.glVertex3fv(v[boxfaces[i][0]]);
+ gl.glVertex3fv(v[boxfaces[i][1]]);
+ gl.glVertex3fv(v[boxfaces[i][2]]);
+ gl.glVertex3fv(v[boxfaces[i][3]]);
+ gl.glEnd();
+ }
+ }
+
+ // Imported from glut.
+ private void doughnut(float r, float R, int nsides, int rings)
+ {
+ int i, j;
+ float theta, phi, theta1;
+ float cosTheta, sinTheta;
+ float cosTheta1, sinTheta1;
+ float ringDelta, sideDelta;
+
+ ringDelta = 2.0f * M_PI / rings;
+ sideDelta = 2.0f * M_PI / nsides;
+
+ theta = 0.0f;
+ cosTheta = 1.0f;
+ sinTheta = 0.0f;
+ for (i = rings - 1; i >= 0; i--)
+ {
+ theta1 = theta + ringDelta;
+ cosTheta1 = (float)Math.cos(theta1);
+ sinTheta1 = (float)Math.sin(theta1);
+ gl.glBegin(GL_QUAD_STRIP);
+ phi = 0.0f;
+ for (j = nsides; j >= 0; j--)
+ {
+ float cosPhi, sinPhi, dist;
+
+ phi += sideDelta;
+ cosPhi = (float)Math.cos(phi);
+ sinPhi = (float)Math.sin(phi);
+ dist = R + r * cosPhi;
+
+ gl.glNormal3f(cosTheta1 * cosPhi, -sinTheta1 * cosPhi, sinPhi);
+ gl.glVertex3f(cosTheta1 * dist, -sinTheta1 * dist, r * sinPhi);
+ gl.glNormal3f(cosTheta * cosPhi, -sinTheta * cosPhi, sinPhi);
+ gl.glVertex3f(cosTheta * dist, -sinTheta * dist, r * sinPhi);
+ }
+ gl.glEnd();
+ theta = theta1;
+ cosTheta = cosTheta1;
+ sinTheta = sinTheta1;
+ }
+ }
+
+ // Methods required for the implementation of MouseListener
+ public void mouseEntered( MouseEvent evt )
+ {
+ }
+
+ public void mouseExited( MouseEvent evt )
+ {
+ }
+
+ public void mousePressed( MouseEvent evt )
+ {
+ spin = (spin + 30) % 360;
+ repaint();
+ }
+
+ public void mouseReleased( MouseEvent evt )
+ {
+ }
+
+ public void mouseClicked( MouseEvent evt )
+ {
+ }
+ }
+}
diff --git a/demos/RonsDemos/movelight_plugin13.html b/demos/RonsDemos/movelight_plugin13.html new file mode 100644 index 0000000..2c0d494 --- /dev/null +++ b/demos/RonsDemos/movelight_plugin13.html @@ -0,0 +1,51 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
+ <title>Movelight by Silicon Graphics; ported to Java by Ron Cemer</title>
+</head>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+Movelight applet
+<br>Originially written by Silicon Graphics
+<br>Ported to Java by Ron Cemer
+<br>
+<hr>Each time you click inside the window, the light source will rotate to
+<br>a new position.
+<br>
+<!--"CONVERTED_APPLET"-->
+<!-- CONVERTER VERSION 1.3 --> +<SCRIPT LANGUAGE="JavaScript"><!-- + var _info = navigator.userAgent; var _ns = false; + var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0); +//--></SCRIPT> +<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!-- + var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0))); +//--></SCRIPT></COMMENT> + +<SCRIPT LANGUAGE="JavaScript"><!-- + if (_ie == true) document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = 400 HEIGHT = 400 codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0"><NOEMBED><XMP>'); + else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.3" CODE = "movelight.class" WIDTH = 400 HEIGHT = 400 scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html"><NOEMBED><XMP>'); +//--></SCRIPT> +<APPLET CODE = "movelight.class" WIDTH = 400 HEIGHT = 400></XMP> +<PARAM NAME = CODE VALUE = "movelight.class" >
+ +<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3"> +<PARAM NAME="scriptable" VALUE="false"> + +</APPLET> + +</NOEMBED></EMBED></OBJECT> + + +<!-- +<APPLET CODE = "movelight.class" WIDTH = 400 HEIGHT = 400>
+
+
+</APPLET> +--> +<!--"END_CONVERTED_APPLET"-->
+
+<hr>
+</body>
+</html>
diff --git a/demos/RonsDemos/nonAnimApplet.skel b/demos/RonsDemos/nonAnimApplet.skel new file mode 100644 index 0000000..a1697d2 --- /dev/null +++ b/demos/RonsDemos/nonAnimApplet.skel @@ -0,0 +1,120 @@ +/**
+ * Skeleton for non-animated applets (applets which redraw once each
+ * time the repaint() method is called, but do not continually animate
+ * automatically).
+ */
+
+/**
+ * @(#) [place applet name here].java
+ * @(#) author: [place author here] (converted to Java by Ron Cemer)
+ */
+
+import java.applet.*;
+import java.awt.*;
+import java.awt.event.*;
+import java.lang.*;
+import java.util.*;
+import java.io.*;
+import java.util.*;
+import gl4java.GLContext;
+import gl4java.awt.GLCanvas;
+
+public class myapplet extends Applet
+{
+ myappletCanvas canvas = null;
+
+
+ /* Initialize the applet */
+
+
+ public void init()
+ {
+ Dimension d = getSize();
+ setLayout(new BorderLayout());
+ canvas = new myappletCanvas(d.width, d.height);
+ add("Center", canvas);
+ }
+
+
+ /* Start the applet */
+
+
+ public void start()
+ {
+ }
+
+
+ /* Stop the applet */
+
+
+ public void stop()
+ {
+ }
+
+
+ /* Destroy the applet */
+
+
+ public void destroy()
+ {
+ canvas.destroy();
+ }
+
+
+ /* Local GLCanvas extension class */
+
+
+ private class myappletCanvas extends GLCanvas
+ {
+ public myappletCanvas(int w, int h)
+ {
+ super(w, h);
+ GLContext.gljNativeDebug = false;
+ GLContext.gljClassDebug = false;
+ }
+
+ public void preInit()
+ {
+ doubleBuffer = true;
+ stereoView = false;
+ }
+
+ public void init()
+ {
+ System.out.println("init(): " + this);
+ reshape(getSize().width, getSize().height);
+
+// Put OpenGL initialization code here.
+
+ glj.gljCheckGL();
+ }
+
+ public void destroy()
+ {
+ System.out.println("destroy(): " + this);
+
+// Put any special takedown code here.
+
+ cvsDispose();
+ }
+
+ public void reshape(int width, int height)
+ {
+ gl.glViewport(0,0,width,height);
+
+// Put any custom reshape code here.
+
+ }
+
+ public void display()
+ {
+ if (glj.gljMakeCurrent(true) == false) return;
+
+// Put drawing code here.
+
+ glj.gljSwap();
+ glj.gljCheckGL();
+ glj.gljFree();
+ }
+ }
+}
diff --git a/demos/RonsDemos/particle.html b/demos/RonsDemos/particle.html new file mode 100644 index 0000000..ec8231d --- /dev/null +++ b/demos/RonsDemos/particle.html @@ -0,0 +1,26 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
+ <title>Particle by Nate Robins; ported to Java by Ron Cemer</title>
+</head>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+Particle applet
+<br>Originially written by Nate Robins
+<br>Ported to Java by Ron Cemer
+<br>Drag the mouse inside the window to rotate the view.
+<br>Click inside the window, then press any of the following keys:
+<br>W/w: waterfall mode
+<br>F/f: fountain mode
+<br>S/s: toggle sphere collision
+<br>L/l: toggle between points lines
+<br>P/p: increase/decrease point size
+<br>+/-: increase/decrease number of particles
+<br>R/r: reset view rotation
+<br>
+<applet code="particle.class" width=400 height=400>
+</applet>
+<hr>
+</body>
+</html>
diff --git a/demos/RonsDemos/particle.java b/demos/RonsDemos/particle.java new file mode 100644 index 0000000..2369b00 --- /dev/null +++ b/demos/RonsDemos/particle.java @@ -0,0 +1,613 @@ +/**
+ * @(#) particle.java
+ * @(#) author: Nate Robins (converted to Java by Ron Cemer)
+ */
+
+/*
+ particle
+ Nate Robins, 1997
+
+ An example of a simple particle system.
+ */
+
+import java.applet.*;
+import java.awt.*;
+import java.awt.event.*;
+import java.lang.*;
+import java.util.*;
+import java.io.*;
+import java.util.*;
+import gl4java.GLContext;
+import gl4java.awt.GLAnimCanvas;
+import gl4java.applet.SimpleGLAnimApplet1;
+
+public class particle extends SimpleGLAnimApplet1
+{
+ private static final int PS_WATERFALL = 0, PS_FOUNTAIN = 1;
+ private static Random random = null;
+
+ /* Initialize the applet */
+
+
+ public void init()
+ {
+ super.init();
+ Dimension d = getSize();
+ canvas = new particleCanvas(d.width, d.height);
+ add("Center", canvas);
+ canvas.requestFocus();
+ random = new Random(System.currentTimeMillis());
+ }
+
+
+ private class PSsphere
+ {
+ protected float x, y, z;
+ protected float radius, radiussquared;
+
+ public PSsphere(float x, float y, float z, float radius)
+ {
+ this.x = x;
+ this.y = y;
+ this.z = z;
+ this.radius = radius;
+ radiussquared = radius*radius;
+ }
+ }
+
+ private class PSparticle
+ {
+ private final float PS_GRAVITY = -9.8f;
+
+ protected float position[] = new float[3]; /* current position */
+ protected float previous[] = new float[3]; /* previous position */
+ protected float velocity[] = new float[3]; /* velocity (magnitude & direction) */
+ protected float dampening = 0.0f; /* % of energy lost on collision */
+ protected boolean alive = false; /* is this particle alive? */
+
+ public PSparticle()
+ {
+ velocity[0] = previous[0] = position[0] = 0.0f;
+ velocity[1] = previous[1] = position[1] = 0.0f;
+ velocity[2] = previous[2] = position[2] = 0.0f;
+ dampening = 0.0f;
+ alive = false;
+ }
+
+ public PSparticle(float dt, int type)
+ {
+ if (type == PS_WATERFALL)
+ {
+ velocity[0] = (random.nextFloat()-0.5f);
+ velocity[1] = 0.0f;
+ velocity[2] = 0.5f*random.nextFloat();
+ position[0] = 0.0f;
+ position[1] = 2.0f;
+ position[2] = 0.0f;
+ dampening = 0.45f*random.nextFloat();
+ }
+ else if (type == PS_FOUNTAIN)
+ {
+ velocity[0] = 2.0f*(random.nextFloat()-0.5f);
+ velocity[1] = 6.0f;
+ velocity[2] = 2.0f*(random.nextFloat()-0.5f);
+ position[0] = 0.0f;
+ position[1] = 0.0f;
+ position[2] = 0.0f;
+ dampening = 0.35f*random.nextFloat();
+ }
+ previous[0] = position[0];
+ previous[1] = position[1];
+ previous[2] = position[2];
+ alive = true;
+ psTimeStep(2.0f*dt*random.nextFloat());
+ }
+
+ public void psTimeStep(float dt)
+ {
+ if (!alive) return;
+
+ velocity[1] += PS_GRAVITY*dt;
+
+ previous[0] = position[0];
+ previous[1] = position[1];
+ previous[2] = position[2];
+
+ position[0] += velocity[0]*dt;
+ position[1] += velocity[1]*dt;
+ position[2] += velocity[2]*dt;
+ }
+
+ /* psBounce: the particle has gone past (or exactly hit) the
+ ground plane, so calculate the time at which the particle
+ actually intersected the ground plane (s). essentially, this
+ just rolls back time to when the particle hit the ground plane,
+ then starts time again from then.
+
+ - - o A (previous position)
+ | | \
+ | s \ o (position it _should_ be at) -
+ t | \ / | t - s
+ | - ------X-------- -
+ | \
+ - o B (new position)
+
+ A + V*s = 0 or s = -A/V
+
+ to calculate where the particle should be:
+
+ A + V*t + V*(t-s)*d
+
+ where d is a damping factor which accounts for the loss
+ of energy due to the bounce. */
+ public void psBounce(float dt)
+ {
+ if (!alive) return;
+
+ /* since we know it is the ground plane, we only need to
+ calculate s for a single dimension. */
+ float s = -previous[1]/velocity[1];
+
+ position[0] =
+ (previous[0] + velocity[0]*s + velocity[0]*(dt-s)*dampening);
+ position[1] =
+ -velocity[1] * (dt-s) * dampening; /* reflect */
+ position[2] =
+ (previous[2] + velocity[2]*s + velocity[2]*(dt-s)*dampening);
+
+ /* damp the reflected velocity (since the particle hit
+ something, it lost some energy) */
+ velocity[0] *= dampening;
+ velocity[1] *= -dampening; /* reflect */
+ velocity[2] *= dampening;
+ }
+
+ public void psCollide(PSsphere sphere)
+ {
+ if (!alive) return;
+
+ float vx = position[0] - sphere.x;
+ float vy = position[1] - sphere.y;
+ float vz = position[2] - sphere.z;
+ float distance, distancesquared;
+
+ // Use distancesquared and radiussquared for comparison,
+ // eliminating the sqrt() call unless it is absolutely
+ // necessary, since it is time-consuming.
+ distancesquared = (vx*vx + vy*vy + vz*vz);
+ if (distancesquared < sphere.radiussquared)
+ {
+ distance = (float)Math.sqrt(distancesquared);
+ position[0] = sphere.x+(vx/distance)*sphere.radius;
+ position[1] = sphere.y+(vy/distance)*sphere.radius;
+ position[2] = sphere.z+(vz/distance)*sphere.radius;
+ previous[0] = position[0];
+ previous[1] = position[1];
+ previous[2] = position[2];
+ velocity[0] = vx/distance;
+ velocity[1] = vy/distance;
+ velocity[2] = vz/distance;
+ }
+ }
+ }
+
+
+ /* Local GLAnimCanvas extension class */
+
+
+ private class particleCanvas extends GLAnimCanvas
+ implements MouseListener, MouseMotionListener, KeyListener
+ {
+ private static final float M_PI = 3.14159265359f;
+
+ private MatrixFuncs mtxfuncs = null;
+ private int prevMouseX, prevMouseY;
+ private boolean mouseRButtonDown = false;
+ private float rot_matrix[] =
+ {
+ 1.0f, 0.0f, 0.0f, 0.0f,
+ 0.0f, 1.0f, 0.0f, 0.0f,
+ 0.0f, 0.0f, 1.0f, 0.0f,
+ 0.0f, 0.0f, 0.0f, 1.0f
+ };
+
+ private PSparticle[] particles = null;
+ private PSsphere sphere = new PSsphere(0.0f,1.0f,0.0f,0.25f);
+ private int num_particles = 5000;
+ private int living = 0; /* index to end of live particles */
+ private int type = PS_WATERFALL;
+ private boolean use_lines = false;
+ private boolean do_sphere = false;
+ private float flow = 500.0f;
+ private float slow_down = 1.0f;
+ private int point_size = 3;
+ private int sphere_list = 0;
+
+ public particleCanvas(int w, int h)
+ {
+ super(w, h);
+ GLContext.gljNativeDebug = false;
+ GLContext.gljClassDebug = false;
+ setAnimateFps(30.0);
+
+ mtxfuncs = new MatrixFuncs();
+ }
+
+ public void preInit()
+ {
+ doubleBuffer = true;
+ stereoView = false;
+ }
+
+ public void init()
+ {
+ System.out.println("init(): " + this);
+ reshape(getSize().width, getSize().height);
+
+ setInitialRotation();
+
+ particles = new PSparticle[num_particles];
+ for (int i = 0; i < num_particles; i++)
+ particles[i] = new PSparticle();
+
+ sphere_list = gl.glGenLists(1);
+ gl.glNewList(sphere_list,GL_COMPILE);
+ gl.glColor3ub((byte)0, (byte)255, (byte)128);
+ int qobj = glu.gluNewQuadric();
+ glu.gluQuadricOrientation(qobj,GLU_OUTSIDE);
+ glu.gluQuadricNormals(qobj,GLU_SMOOTH);
+ glu.gluQuadricTexture(qobj,false);
+ glu.gluSphere(qobj,sphere.radius, 16, 16);
+ glu.gluDeleteQuadric(qobj);
+ gl.glEndList();
+
+ glj.gljCheckGL();
+
+ addMouseListener(this);
+ addMouseMotionListener(this);
+ addKeyListener(this);
+ }
+
+ public void doCleanup()
+ {
+ System.out.println("destroy(): " + this);
+ removeMouseListener(this);
+ removeMouseMotionListener(this);
+ removeKeyListener(this);
+ }
+
+ public void reshape(int width, int height)
+ {
+ gl.glViewport(0,0,width,height);
+
+ float black[] = { 0, 0, 0, 0 };
+
+ gl.glMatrixMode(GL_PROJECTION);
+ gl.glLoadIdentity();
+ glu.gluPerspective(60, 1, 0.1, 1000);
+ gl.glMatrixMode(GL_MODELVIEW);
+ gl.glLoadIdentity();
+ glu.gluLookAt(0, 1, 3, 0, 1, 0, 0, 1, 0);
+ gl.glFogfv(GL_FOG_COLOR, black);
+ gl.glFogf(GL_FOG_START, 2.5f);
+ gl.glFogf(GL_FOG_END, 4f);
+ gl.glEnable(GL_FOG);
+ gl.glFogi(GL_FOG_MODE, GL_LINEAR);
+ gl.glPointSize(point_size);
+ gl.glEnable(GL_POINT_SMOOTH);
+ gl.glEnable(GL_BLEND);
+ gl.glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ gl.glEnable(GL_COLOR_MATERIAL);
+ gl.glEnable(GL_DEPTH_TEST);
+ gl.glEnable(GL_LIGHT0);
+
+ timedelta();
+ }
+
+ public void display()
+ {
+ if (glj.gljMakeCurrent() == false) return;
+
+ gl.glPushMatrix();
+ gl.glMultMatrixf(rot_matrix);
+
+ // Update particles.
+
+ float dt = timedelta();
+ float truedt = dt;
+
+ /* slow the simulation if we can't keep the frame rate up
+ around 10 fps */
+ if (dt > 0.1f)
+ slow_down = 0.75f;
+ else if (dt < 0.1f)
+ slow_down = 1.0f;
+ dt *= slow_down;
+
+ /* resurrect a few particles */
+ for (int i = 0; i < flow*dt; i++)
+ {
+ particles[living] = new PSparticle(dt,type);
+ living++;
+ if (living >= num_particles) living = 0;
+ }
+
+ for (int i = 0; i < num_particles; i++)
+ {
+ particles[i].psTimeStep(dt);
+ /* collision with sphere? */
+ if (do_sphere) particles[i].psCollide(sphere);
+ /* collision with ground? */
+ if (particles[i].position[1] <= 0.0f)
+ particles[i].psBounce(dt);
+ /* dead particle? */
+ if ( (particles[i].position[1] < 0.1f)
+ && (Math.abs(particles[i].velocity[1]) < 0.2f) )
+ particles[i].alive = false;
+ }
+
+ // Draw the scene.
+
+ gl.glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
+
+ gl.glEnable(GL_LIGHTING);
+ if (do_sphere)
+ {
+ gl.glPushMatrix();
+ gl.glTranslatef(sphere.x, sphere.y, sphere.z);
+ gl.glCallList(sphere_list);
+ gl.glPopMatrix();
+ }
+ gl.glDisable(GL_LIGHTING);
+
+ gl.glColor3ub((byte)0, (byte)128, (byte)255);
+ gl.glBegin(GL_QUADS);
+ gl.glVertex3f(-2f, 0f, -2f);
+ gl.glVertex3f(-2f, 0f, 2f);
+ gl.glVertex3f(2f, 0f, 2f);
+ gl.glVertex3f(2f, 0f, -2f);
+ gl.glEnd();
+
+ float r, g;
+ if (!use_lines)
+ {
+ gl.glBegin(GL_POINTS);
+ for (int i = 0; i < num_particles; i++)
+ {
+ if (!particles[i].alive) continue;
+ r = particles[i].position[1]/2.1f*255f;
+ g = 128.0f+(r*0.5f);
+ gl.glColor3ub((byte)r, (byte)g, (byte)255);
+ gl.glVertex3fv(particles[i].position);
+ }
+ gl.glEnd();
+ }
+ else
+ {
+ gl.glBegin(GL_LINES);
+ for (int i = 0; i < num_particles; i++)
+ {
+ if (!particles[i].alive) continue;
+ r = particles[i].previous[1]/2.1f*255f;
+ g = 128.0f+(r*0.5f);
+ gl.glColor3ub((byte)r, (byte)g, (byte)255);
+ gl.glVertex3fv(particles[i].previous);
+ r = particles[i].position[1]/2.1f*255f;
+ g = 128.0f+(r*0.5f);
+ gl.glColor3ub((byte)r, (byte)g, (byte)255);
+ gl.glVertex3fv(particles[i].position);
+ }
+ gl.glEnd();
+ }
+
+ gl.glPopMatrix();
+
+ glj.gljSwap();
+ glj.gljCheckGL();
+ glj.gljFree();
+
+ //if (!isSuspended()) repaint(); // Animate at full speed.
+ }
+
+ /* timedelta: returns the number of seconds that have elapsed
+ since the previous call to the function. */
+ private long timedelta_prev = 0L;
+ private float timedelta()
+ {
+ long current = System.currentTimeMillis();
+ if (timedelta_prev == 0L) timedelta_prev = current;
+ long delta = current-timedelta_prev;
+ timedelta_prev = current;
+ return ((float)delta) * 0.001f;
+ }
+
+ // Reset the rotation matrix to the default view.
+ private void setInitialRotation()
+ {
+ for (int i = 0; i < 16; i++)
+ rot_matrix[i] = ((i % 5) == 0) ? 1.0f : 0.0f;
+ }
+
+ private void fixRotationMatrix()
+ {
+ // Fix any problems with the rotation matrix.
+ rot_matrix[3] =
+ rot_matrix[7] =
+ rot_matrix[11] =
+ rot_matrix[12] =
+ rot_matrix[13] =
+ rot_matrix[14] = 0.0f;
+ rot_matrix[15] = 1.0f;
+ float fac;
+ if ((fac = (float)Math.sqrt
+ ((rot_matrix[0]*rot_matrix[0]) +
+ (rot_matrix[4]*rot_matrix[4]) +
+ (rot_matrix[8]*rot_matrix[8]))) != 1.0f)
+ {
+ if (fac != 0.0f)
+ {
+ fac = 1.0f/fac;
+ rot_matrix[0] *= fac;
+ rot_matrix[4] *= fac;
+ rot_matrix[8] *= fac;
+ }
+ }
+ if ((fac = (float)Math.sqrt
+ ((rot_matrix[1]*rot_matrix[1]) +
+ (rot_matrix[5]*rot_matrix[5]) +
+ (rot_matrix[9]*rot_matrix[9]))) != 1.0f)
+ {
+ if (fac != 0.0f)
+ {
+ fac = 1.0f/fac;
+ rot_matrix[1] *= fac;
+ rot_matrix[5] *= fac;
+ rot_matrix[9] *= fac;
+ }
+ }
+ if ((fac = (float)Math.sqrt
+ ((rot_matrix[2]*rot_matrix[2]) +
+ (rot_matrix[6]*rot_matrix[6]) +
+ (rot_matrix[10]*rot_matrix[10]))) != 1.0f)
+ {
+ if (fac != 0.0f)
+ {
+ fac = 1.0f/fac;
+ rot_matrix[2] *= fac;
+ rot_matrix[6] *= fac;
+ rot_matrix[10] *= fac;
+ }
+ }
+ }
+
+ // Methods required for the implementation of MouseListener
+ public void mouseEntered( MouseEvent evt )
+ {
+ Component comp = evt.getComponent();
+ if( comp.equals(this ) )
+ {
+ requestFocus();
+ }
+ }
+
+ public void mouseClicked( MouseEvent evt )
+ {
+ Component comp = evt.getComponent();
+ if( comp.equals(this ) )
+ {
+ requestFocus();
+ }
+ }
+
+ public void mouseExited( MouseEvent evt )
+ {
+ }
+
+ public void mousePressed( MouseEvent evt )
+ {
+ prevMouseX = evt.getX();
+ prevMouseY = evt.getY();
+ if ((evt.getModifiers() & evt.BUTTON3_MASK) != 0)
+ {
+ mouseRButtonDown = true;
+ evt.consume();
+ }
+ }
+
+ public void mouseReleased( MouseEvent evt )
+ {
+ if ((evt.getModifiers() & evt.BUTTON3_MASK) != 0)
+ {
+ mouseRButtonDown = false;
+ evt.consume();
+ }
+ }
+
+ // Methods required for the implementation of MouseMotionListener
+ public void mouseDragged( MouseEvent evt )
+ {
+ int x = evt.getX();
+ int y = evt.getY();
+ float thetaX = (float)(x-prevMouseX)*(360.0f/(float)getSize().width);
+ float thetaY = (float)(prevMouseY-y)*(360.0f/(float)getSize().height);
+ float mtxbuf[] = new float[16];
+ float mtxbuf2[] = new float[16];
+
+ prevMouseX = x;
+ prevMouseY = y;
+ if ( (thetaX != 0.0f) || (thetaY != 0.0f) )
+ {
+ mtxfuncs.rotateAroundY(((float)thetaX),mtxbuf);
+ if (mouseRButtonDown)
+ mtxfuncs.rotateAroundZ(thetaY,mtxbuf2);
+ else
+ mtxfuncs.rotateAroundX(-thetaY,mtxbuf2);
+ mtxfuncs.multiplyMatrices(mtxbuf2,mtxbuf,mtxbuf);
+ mtxfuncs.multiplyMatrices(rot_matrix,mtxbuf,rot_matrix);
+ fixRotationMatrix();
+ }
+ evt.consume();
+ }
+
+ public void mouseMoved( MouseEvent evt )
+ {
+ }
+
+ // Methods required for the implementation of KeyListener
+ public void keyPressed(KeyEvent e)
+ {
+ }
+
+ public void keyReleased(KeyEvent e)
+ {
+ }
+
+ public void keyTyped(KeyEvent e)
+ {
+ if (glj.gljMakeCurrent() == false) return;
+ switch ((char)e.getKeyChar())
+ {
+ case 'W':
+ case 'w':
+ type = PS_WATERFALL;
+ break;
+ case 'F':
+ case 'f':
+ type = PS_FOUNTAIN;
+ break;
+ case 'S':
+ case 's':
+ do_sphere = !do_sphere;
+ break;
+ case 'L':
+ case 'l':
+ use_lines = !use_lines;
+ break;
+ case 'P':
+ point_size++;
+ gl.glPointSize(point_size);
+ break;
+ case 'p':
+ point_size--;
+ if (point_size < 1) point_size = 1;
+ gl.glPointSize(point_size);
+ break;
+ case '+':
+ flow += 100;
+ if (flow > num_particles) flow = num_particles;
+ System.out.println(flow + " particles/second");
+ break;
+ case '-':
+ flow -= 100;
+ if (flow < 0) flow = 0;
+ System.out.println(flow + " particles/second");
+ break;
+ case 'R':
+ case 'r':
+ setInitialRotation();
+ break;
+ }
+ glj.gljFree();
+ }
+ }
+}
diff --git a/demos/RonsDemos/particle_plugin13.html b/demos/RonsDemos/particle_plugin13.html new file mode 100644 index 0000000..84268df --- /dev/null +++ b/demos/RonsDemos/particle_plugin13.html @@ -0,0 +1,57 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
+ <title>Particle by Nate Robins; ported to Java by Ron Cemer</title>
+</head>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+Particle applet
+<br>Originially written by Nate Robins
+<br>Ported to Java by Ron Cemer
+<br>Drag the mouse inside the window to rotate the view.
+<br>Click inside the window, then press any of the following keys:
+<br>W/w: waterfall mode
+<br>F/f: fountain mode
+<br>S/s: toggle sphere collision
+<br>L/l: toggle between points lines
+<br>P/p: increase/decrease point size
+<br>+/-: increase/decrease number of particles
+<br>R/r: reset view rotation
+<br>
+<!--"CONVERTED_APPLET"-->
+<!-- CONVERTER VERSION 1.3 --> +<SCRIPT LANGUAGE="JavaScript"><!-- + var _info = navigator.userAgent; var _ns = false; + var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0); +//--></SCRIPT> +<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!-- + var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0))); +//--></SCRIPT></COMMENT> + +<SCRIPT LANGUAGE="JavaScript"><!-- + if (_ie == true) document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = 400 HEIGHT = 400 codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0"><NOEMBED><XMP>'); + else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.3" CODE = "particle.class" WIDTH = 400 HEIGHT = 400 scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html"><NOEMBED><XMP>'); +//--></SCRIPT> +<APPLET CODE = "particle.class" WIDTH = 400 HEIGHT = 400></XMP> +<PARAM NAME = CODE VALUE = "particle.class" >
+ +<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3"> +<PARAM NAME="scriptable" VALUE="false"> + +</APPLET> + +</NOEMBED></EMBED></OBJECT> + + +<!-- +<APPLET CODE = "particle.class" WIDTH = 400 HEIGHT = 400>
+
+
+</APPLET> +--> +<!--"END_CONVERTED_APPLET"-->
+
+<hr>
+</body>
+</html>
diff --git a/demos/RonsDemos/pointblast.html b/demos/RonsDemos/pointblast.html new file mode 100644 index 0000000..d469a51 --- /dev/null +++ b/demos/RonsDemos/pointblast.html @@ -0,0 +1,19 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
+ <title>Pointblast by Mark J. Kilgard; ported to Java by Ron Cemer</title>
+</head>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+Pointblast applet
+<br>Originially written by Mark J. Kilgard
+<br>Ported to Java by Ron Cemer
+<br>Drag the mouse within the window to spin the image.
+<br>Right-click within the window for a menu of options.
+<br>
+<applet code="pointblast.class" width=400 height=400>
+</applet>
+<hr>
+</body>
+</html>
diff --git a/demos/RonsDemos/pointblast.java b/demos/RonsDemos/pointblast.java new file mode 100644 index 0000000..08570d1 --- /dev/null +++ b/demos/RonsDemos/pointblast.java @@ -0,0 +1,664 @@ +/**
+ * @(#) pointblast.java
+ * @(#) author: Mark J. Kilgard (converted to Java by Ron Cemer)
+ */
+
+/* Copyright (c) Mark J. Kilgard, 1997. */
+
+/* This program is freely distributable without licensing fees
+ and is provided without guarantee or warrantee expressed or
+ implied. This program is -not- in the public domain. */
+
+/* This example demonstrates how to render particle effects
+ with OpenGL. A cloud of pinkish/orange particles explodes with the
+ particles bouncing off the ground. When the EXT_point_parameters
+ is present , the particle size is attenuated based on eye distance. */
+
+import java.applet.*;
+import java.awt.*;
+import java.awt.event.*;
+import java.lang.*;
+import java.util.*;
+import java.io.*;
+import java.util.*;
+import gl4java.GLContext;
+import gl4java.awt.GLAnimCanvas;
+import gl4java.applet.SimpleGLAnimApplet1;
+
+public class pointblast extends SimpleGLAnimApplet1
+{
+ /* Initialize the applet */
+
+
+ public void init()
+ {
+ super.init();
+ Dimension d = getSize();
+ canvas = new pointblastCanvas(d.width, d.height);
+ add("Center", canvas);
+ }
+
+
+ /* Local GLAnimCanvas extension class */
+
+
+ private class pointblastCanvas extends GLAnimCanvas
+ implements MouseListener, MouseMotionListener, ActionListener
+ {
+ private final double M_PI = 3.14159265;
+
+ private final String MENU_PAUSE = "Pause";
+ private final String MENU_RESUME = "Resume";
+ private final String MENU_RESET_TIME = "Reset time";
+// private final String MENU_CONSTANT = "Constant";
+// private final String MENU_LINEAR = "Linear";
+// private final String MENU_QUADRATIC = "Quadratic";
+ private final String MENU_BLEND_ON = "Blend on";
+ private final String MENU_BLEND_OFF = "Blend off";
+// private final String MENU_THRESHOLD_1 = "Threshold 1";
+// private final String MENU_THRESHOLD_10 = "Threshold 10";
+ private final String MENU_POINT_SMOOTH_ON = "Point smooth on";
+ private final String MENU_POINT_SMOOTH_OFF = "Point smooth off";
+ private final String MENU_POINT_SIZE_2 = "Point size 2";
+ private final String MENU_POINT_SIZE_4 = "Point size 4";
+ private final String MENU_POINT_SIZE_8 = "Point size 8";
+ private final String MENU_ENABLE_SPIN = "Enable spin";
+ private final String MENU_DISABLE_SPIN = "Disable spin";
+ private final String MENU_200_POINTS = "200 points";
+ private final String MENU_500_POINTS = "500 points";
+ private final String MENU_1000_POINTS = "1000 points";
+ private final String MENU_2000_POINTS = "2000 points";
+ private final String MENU_ENABLE_TEXTURING = "Enable texturing";
+ private final String MENU_DISABLE_TEXTURING = "Disable texturing";
+ private final String MENU_LINEAR_TEXTURE_FILTERING = "Linear texture filtering";
+ private final String MENU_POINT_TEXTURE_FILTERING = "Point texture filtering";
+
+ private PopupMenu menu = null;
+ private boolean menu_showing = false;
+ private boolean save_suspended = false;
+
+ private float angle = -150; /* in degrees */
+ private boolean spin = false;
+ private boolean moving = false;
+ private int begin;
+ private boolean newModel = true;
+ private float theTime;
+ private boolean repeat = true;
+ private boolean blend = true;
+ private boolean texturing = true;
+// private boolean useMipmaps = true;
+ private boolean linearFiltering = true;
+
+ private float constant[] = { 1.0f/5.0f, 0.0f, 0.0f };
+ private float linear[] = { 0.0f, 1.0f/5.0f, 0.0f };
+ private float theQuad[] = { 0.25f, 0.0f, 1.0f/60.0f };
+
+ private final int MAX_POINTS = 2000;
+
+ private int numPoints = 200;
+
+ private float pointList[][] = new float[MAX_POINTS][3];
+ private float pointTime[] = new float[MAX_POINTS];
+ private float pointVelocity[][] = new float[MAX_POINTS][2];
+ private float pointDirection[][] = new float[MAX_POINTS][2];
+ private int colorList[] = new int[MAX_POINTS];
+ private boolean motion = false;
+
+ private Random random = new Random(System.currentTimeMillis());
+
+ private final float MEAN_VELOCITY = 3.0f;
+ private final float GRAVITY = 2.0f;
+ private final float TIME_DELTA = 0.025f; /* The speed of time. */
+
+ /* Modeling units of ground extent in each X and Z direction. */
+ private final int EDGE = 12;
+
+ private final float colorSet[][] =
+ {
+ /* Shades of red. */
+ { 0.7f, 0.2f, 0.4f, 0.5f },
+ { 0.8f, 0.0f, 0.7f, 0.5f },
+ { 1.0f, 0.0f, 0.0f, 0.5f },
+ { 0.9f, 0.3f, 0.6f, 0.5f },
+ { 1.0f, 0.4f, 0.0f, 0.5f },
+ { 1.0f, 0.0f, 0.5f, 0.5f }
+ };
+ private final int NUM_COLORS = colorSet.length;
+ private final int DEAD = NUM_COLORS;
+
+ public pointblastCanvas(int w, int h)
+ {
+ super(w, h);
+ GLContext.gljNativeDebug = false;
+ GLContext.gljClassDebug = false;
+ setAnimateFps(30.0);
+ }
+
+ public void preInit()
+ {
+ doubleBuffer = true;
+ stereoView = false;
+ }
+
+ public void init()
+ {
+ System.out.println("init(): " + this);
+ reshape(getSize().width, getSize().height);
+
+ gl.glShadeModel(GL_FLAT);
+ gl.glEnable(GL_DEPTH_TEST);
+ gl.glEnable(GL_POINT_SMOOTH);
+ gl.glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ gl.glPointSize(8.0f);
+// gl.glPointParameterfvEXT(GL_DISTANCE_ATTENUATION_EXT, theQuad);
+ gl.glMatrixMode(GL_PROJECTION);
+ glu.gluPerspective
+ (/* field of view in degree */ 40.0,
+ /* aspect ratio */ 1.0,
+ /* Z near */ 0.5,
+ /* Z far */ 40.0);
+ gl.glMatrixMode(GL_MODELVIEW);
+ glu.gluLookAt
+ (0.0f, 1.0f, 8.0f, /* eye location */
+ 0.0f, 1.0f, 0.0f, /* center is at (0,0,0) */
+ 0.0f, 1.0f, 0.0f); /* up is in postivie Y direction */
+ gl.glPushMatrix(); /* dummy push so we can pop on model
+ recalc */
+ makePointList();
+ makeFloorTexture();
+
+ glj.gljCheckGL();
+
+ menu = new PopupMenu("Options");
+ menu.add(MENU_PAUSE);
+ menu.add(MENU_RESUME);
+ menu.add(MENU_RESET_TIME);
+// menu.add(MENU_CONSTANT);
+// menu.add(MENU_LINEAR);
+// menu.add(MENU_QUADRATIC);
+ menu.add(MENU_BLEND_ON);
+ menu.add(MENU_BLEND_OFF);
+// menu.add(MENU_THRESHOLD_1);
+// menu.add(MENU_THRESHOLD_10);
+ menu.add(MENU_POINT_SMOOTH_ON);
+ menu.add(MENU_POINT_SMOOTH_OFF);
+ menu.add(MENU_POINT_SIZE_2);
+ menu.add(MENU_POINT_SIZE_4);
+ menu.add(MENU_POINT_SIZE_8);
+ menu.add(MENU_ENABLE_SPIN);
+ menu.add(MENU_DISABLE_SPIN);
+ menu.add(MENU_200_POINTS);
+ menu.add(MENU_500_POINTS);
+ menu.add(MENU_1000_POINTS);
+ menu.add(MENU_2000_POINTS);
+ menu.add(MENU_ENABLE_TEXTURING);
+ menu.add(MENU_DISABLE_TEXTURING);
+ menu.add(MENU_LINEAR_TEXTURE_FILTERING);
+ menu.add(MENU_POINT_TEXTURE_FILTERING);
+ menu.addActionListener(this);
+ add(menu);
+
+ addMouseListener(this);
+ addMouseMotionListener(this);
+ }
+
+ public void doCleanup()
+ {
+ System.out.println("destroy(): " + this);
+ removeMouseListener(this);
+ removeMouseMotionListener(this);
+ menu.removeActionListener(this);
+ }
+
+ public void reshape(int width, int height)
+ {
+ gl.glViewport(0,0,width,height);
+ }
+
+ public void display()
+ {
+ if (glj.gljMakeCurrent() == false) return;
+
+ if (!isSuspended())
+ {
+ if (spin)
+ {
+ angle += 0.3f;
+ newModel = true;
+ }
+ updatePointList();
+ }
+
+ gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ if (newModel) recalcModelView();
+
+ gl.glDepthMask(false);
+
+ /* Draw the floor. */
+ if (texturing) gl.glEnable(GL_TEXTURE_2D);
+ gl.glColor3f(0.5f, 1.0f, 0.5f);
+ gl.glBegin(GL_QUADS);
+ gl.glTexCoord2f(0.0f, 0.0f);
+ gl.glVertex3f(-EDGE, -0.05f, -EDGE);
+ gl.glTexCoord2f(20.0f, 0.0f);
+ gl.glVertex3f(EDGE, -0.05f, -EDGE);
+ gl.glTexCoord2f(20.0f, 20.0f);
+ gl.glVertex3f(EDGE, -0.05f, EDGE);
+ gl.glTexCoord2f(0.0f, 20.0f);
+ gl.glVertex3f(-EDGE, -0.05f, EDGE);
+ gl.glEnd();
+
+ /* Allow particles to blend with each other. */
+ gl.glDepthMask(true);
+
+ if (blend) gl.glEnable(GL_BLEND);
+
+ if (texturing) gl.glDisable(GL_TEXTURE_2D);
+ gl.glBegin(GL_POINTS);
+ for (int i = 0; i < numPoints; i++)
+ {
+ /* Draw alive particles. */
+ int c = colorList[i];
+ if ( (c < 0) || (c >= DEAD) ) continue;
+ gl.glColor4fv(colorSet[colorList[i]]);
+ gl.glVertex3fv(pointList[i]);
+ }
+ gl.glEnd();
+
+ gl.glDisable(GL_BLEND);
+
+ glj.gljSwap();
+ glj.gljCheckGL();
+ glj.gljFree();
+
+ //if (!isSuspended()) repaint(); // Animate at full speed.
+ }
+
+ // Methods required for the implementation of MouseListener
+ public void mouseEntered(MouseEvent evt)
+ {
+ }
+
+ public void mouseExited(MouseEvent evt)
+ {
+ }
+
+ public void mousePressed(MouseEvent evt)
+ {
+ // If user presses right mouse button within canvas area,
+ // suspend animation and pop up menu.
+ // If menu was already popped up and user presses either
+ // mouse button within canvas area, resume animation
+ // because the menu will have been removed automatically.
+ if (!menu_showing)
+ {
+ if ((evt.getModifiers() & evt.BUTTON3_MASK) != 0)
+ {
+ menu_showing = true;
+ save_suspended = isSuspended();
+ if (!save_suspended)
+ {
+ setSuspended(true);
+ repaint(100);
+ try
+ {
+ Thread.currentThread().sleep(200);
+ }
+ catch (Exception e)
+ { }
+ }
+ menu.show(this,evt.getX(),evt.getY());
+ }
+ else
+ {
+ // Must be left button.
+ moving = true;
+ begin = evt.getX();
+ }
+ }
+ else
+ {
+ menu_showing = false;
+ setSuspended(save_suspended);
+ }
+ }
+
+ public void mouseReleased(MouseEvent evt)
+ {
+ if ((evt.getModifiers() & evt.BUTTON3_MASK) == 0)
+ {
+ // Must be left button.
+ moving = false;
+ }
+ }
+
+ public void mouseClicked(MouseEvent evt)
+ {
+ }
+
+ // Methods required for the implementation of MouseMotionListener
+ public void mouseDragged(MouseEvent evt)
+ {
+ if (moving)
+ {
+ int x = evt.getX();
+ angle = angle + (x - begin);
+ begin = x;
+ newModel = true;
+ if (isSuspended()) repaint();
+ }
+ }
+
+ public void mouseMoved(MouseEvent evt)
+ {
+ }
+
+ // Method required for the implementation of ActionListener
+ public void actionPerformed(ActionEvent evt)
+ {
+ if (glj.gljMakeCurrent() == false) return;
+ boolean dorepaint = false;
+ String c = evt.getActionCommand();
+ if (c.equals(MENU_PAUSE))
+ {
+ if (menu_showing)
+ save_suspended = true;
+ else if (!isSuspended())
+ setSuspended(true);
+ dorepaint = true;
+ }
+ else if (c.equals(MENU_RESUME))
+ {
+ if (menu_showing)
+ save_suspended = false;
+ else if (isSuspended())
+ setSuspended(false);
+ dorepaint = true;
+ }
+ else if (c.equals(MENU_RESET_TIME))
+ {
+ makePointList();
+ dorepaint = true;
+ }
+// else if (c.equals(MENU_CONSTANT))
+// {
+// gl.glPointParameterfvEXT(GL_DISTANCE_ATTENUATION_EXT, constant);
+// dorepaint = true;
+// }
+// else if (c.equals(MENU_LINEAR))
+// {
+// gl.glPointParameterfvEXT(GL_DISTANCE_ATTENUATION_EXT, linear);
+// dorepaint = true;
+// }
+// else if (c.equals(MENU_QUADRATIC))
+// {
+// gl.glPointParameterfvEXT(GL_DISTANCE_ATTENUATION_EXT, theQuad);
+// dorepaint = true;
+// }
+ else if (c.equals(MENU_BLEND_ON))
+ {
+ blend = true;
+ dorepaint = true;
+ }
+ else if (c.equals(MENU_BLEND_OFF))
+ {
+ blend = false;
+ dorepaint = true;
+ }
+// else if (c.equals(MENU_THRESHOLD_1))
+// {
+// gl.glPointParameterfEXT(GL_POINT_FADE_THRESHOLD_SIZE_EXT, 1.0f);
+// dorepaint = true;
+// }
+// else if (c.equals(MENU_THRESHOLD_10))
+// {
+// gl.glPointParameterfEXT(GL_POINT_FADE_THRESHOLD_SIZE_EXT, 10.0f);
+// dorepaint = true;
+// }
+ else if (c.equals(MENU_POINT_SMOOTH_ON))
+ {
+ gl.glEnable(GL_POINT_SMOOTH);
+ dorepaint = true;
+ }
+ else if (c.equals(MENU_POINT_SMOOTH_OFF))
+ {
+ gl.glDisable(GL_POINT_SMOOTH);
+ dorepaint = true;
+ }
+ else if (c.equals(MENU_POINT_SIZE_2))
+ {
+ gl.glPointSize(2.0f);
+ dorepaint = true;
+ }
+ else if (c.equals(MENU_POINT_SIZE_4))
+ {
+ gl.glPointSize(4.0f);
+ dorepaint = true;
+ }
+ else if (c.equals(MENU_POINT_SIZE_8))
+ {
+ gl.glPointSize(8.0f);
+ dorepaint = true;
+ }
+ else if (c.equals(MENU_ENABLE_SPIN))
+ {
+ spin = true;
+ dorepaint = true;
+ }
+ else if (c.equals(MENU_DISABLE_SPIN))
+ {
+ spin = false;
+ dorepaint = true;
+ }
+ else if (c.equals(MENU_200_POINTS))
+ {
+ numPoints = 200;
+ makePointList();
+ dorepaint = true;
+ }
+ else if (c.equals(MENU_500_POINTS))
+ {
+ numPoints = 500;
+ makePointList();
+ dorepaint = true;
+ }
+ else if (c.equals(MENU_1000_POINTS))
+ {
+ numPoints = 1000;
+ makePointList();
+ dorepaint = true;
+ }
+ else if (c.equals(MENU_2000_POINTS))
+ {
+ numPoints = 2000;
+ makePointList();
+ dorepaint = true;
+ }
+ else if (c.equals(MENU_ENABLE_TEXTURING))
+ {
+ texturing = true;
+ dorepaint = true;
+ }
+ else if (c.equals(MENU_DISABLE_TEXTURING))
+ {
+ texturing = false;
+ dorepaint = true;
+ }
+ else if (c.equals(MENU_LINEAR_TEXTURE_FILTERING))
+ {
+ linearFiltering = true;
+ makeFloorTexture();
+ dorepaint = true;
+ }
+ else if (c.equals(MENU_POINT_TEXTURE_FILTERING))
+ {
+ linearFiltering = false;
+ makeFloorTexture();
+ dorepaint = true;
+ }
+
+ glj.gljFree();
+ if (menu_showing)
+ {
+ menu_showing = false;
+ setSuspended(save_suspended);
+ }
+ if ( (isSuspended()) && (dorepaint) ) repaint();
+ }
+
+ private float float_rand()
+ {
+ return random.nextFloat();
+ }
+
+ private float RANDOM_RANGE(float lo, float hi)
+ {
+ return lo + ((hi - lo) * float_rand());
+ }
+
+ private void makePointList()
+ {
+ float angle, velocity, direction;
+ motion = true;
+ for (int i = 0; i < numPoints; i++)
+ {
+ pointList[i][0] = 0.0f;
+ pointList[i][1] = 0.0f;
+ pointList[i][2] = 0.0f;
+ pointTime[i] = 0.0f;
+ angle = (RANDOM_RANGE(60.0f, 70.0f)) * ((float)M_PI)/180.0f;
+ direction = RANDOM_RANGE(0.0f, 360.0f) * ((float)M_PI)/180.0f;
+ pointDirection[i][0] = (float)Math.cos(direction);
+ pointDirection[i][1] = (float)Math.sin(direction);
+ velocity = MEAN_VELOCITY + RANDOM_RANGE(-0.8f, 1.0f);
+ pointVelocity[i][0] = velocity * (float)Math.cos(angle);
+ pointVelocity[i][1] = velocity * (float)Math.sin(angle);
+ colorList[i] = random.nextInt() % NUM_COLORS;
+ }
+ theTime = 0.0f;
+ }
+
+ private void updatePointList()
+ {
+ float distance;
+ motion = false;
+ for (int i = 0; i < numPoints; i++)
+ {
+ distance = pointVelocity[i][0] * theTime;
+
+ /* X and Z */
+ pointList[i][0] = pointDirection[i][0] * distance;
+ pointList[i][2] = pointDirection[i][1] * distance;
+
+ /* Z */
+ pointList[i][1] =
+ (pointVelocity[i][1] - 0.5f * GRAVITY * pointTime[i])*pointTime[i];
+
+ /* If we hit the ground, bounce the point upward again. */
+ if (pointList[i][1] <= 0.0f)
+ {
+ if (distance > EDGE)
+ {
+ /* Particle has hit ground past the distance duration of
+ the particles. Mark particle as dead. */
+ colorList[i] = DEAD; /* Not moving. */
+ continue;
+ }
+ pointVelocity[i][1] *= 0.8f; /* 80% of previous up velocity. */
+ pointTime[i] = 0.0f; /* Reset the particles sense of up time. */
+ }
+ motion = true;
+ pointTime[i] += TIME_DELTA;
+ }
+ theTime += TIME_DELTA;
+ if ( (repeat) && (!motion) ) makePointList();
+ }
+
+ private void recalcModelView()
+ {
+ gl.glPopMatrix();
+ gl.glPushMatrix();
+ gl.glRotatef(angle, 0.0f, 1.0f, 0.0f);
+ newModel = false;
+ }
+
+ private void makeFloorTexture()
+ {
+ /* Nice floor texture tiling pattern. */
+ String circles[] =
+ {
+ "....xxxx........",
+ "..xxxxxxxx......",
+ ".xxxxxxxxxx.....",
+ ".xxx....xxx.....",
+ "xxx......xxx....",
+ "xxx......xxx....",
+ "xxx......xxx....",
+ "xxx......xxx....",
+ ".xxx....xxx.....",
+ ".xxxxxxxxxx.....",
+ "..xxxxxxxx......",
+ "....xxxx........",
+ "................",
+ "................",
+ "................",
+ "................"
+ };
+ byte floorTexture[] = new byte[16*16*3];
+
+ /* Setup RGB image for the texture. */
+ int idx = 0;
+ for (int t = 0; t < 16; t++)
+ {
+ for (int s = 0; s < 16; s++)
+ {
+ if (circles[t].charAt(s) == 'x')
+ {
+ /* Nice blue. */
+ floorTexture[idx++] = (byte)0x1f;
+ floorTexture[idx++] = (byte)0x1f;
+ floorTexture[idx++] = (byte)0x8f;
+ }
+ else
+ {
+ /* Light gray. */
+ floorTexture[idx++] = (byte)0xca;
+ floorTexture[idx++] = (byte)0xca;
+ floorTexture[idx++] = (byte)0xca;
+ }
+ }
+ }
+
+ gl.glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+
+// if (useMipmaps)
+// {
+// gl.glTexParameteri
+// (GL_TEXTURE_2D,
+// GL_TEXTURE_MIN_FILTER,
+// GL_LINEAR_MIPMAP_LINEAR);
+// glu.gluBuild2DMipmaps
+// (GL_TEXTURE_2D,3,16,16,GL_RGB,GL_UNSIGNED_BYTE,floorTexture);
+// }
+// else
+ {
+ if (linearFiltering)
+ {
+ gl.glTexParameteri
+ (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ gl.glTexParameteri
+ (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ }
+ else
+ {
+ gl.glTexParameteri
+ (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ gl.glTexParameteri
+ (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ }
+ gl.glTexImage2D
+ (GL_TEXTURE_2D,0,3,16,16,0,GL_RGB,GL_UNSIGNED_BYTE,floorTexture);
+ }
+ }
+ }
+}
diff --git a/demos/RonsDemos/pointblast_plugin13.html b/demos/RonsDemos/pointblast_plugin13.html new file mode 100644 index 0000000..0133e90 --- /dev/null +++ b/demos/RonsDemos/pointblast_plugin13.html @@ -0,0 +1,50 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
+ <title>Pointblast by Mark J. Kilgard; ported to Java by Ron Cemer</title>
+</head>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+Pointblast applet
+<br>Originially written by Mark J. Kilgard
+<br>Ported to Java by Ron Cemer
+<br>Drag the mouse within the window to spin the image.
+<br>Right-click within the window for a menu of options.
+<br>
+<!--"CONVERTED_APPLET"-->
+<!-- CONVERTER VERSION 1.3 --> +<SCRIPT LANGUAGE="JavaScript"><!-- + var _info = navigator.userAgent; var _ns = false; + var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0); +//--></SCRIPT> +<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!-- + var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0))); +//--></SCRIPT></COMMENT> + +<SCRIPT LANGUAGE="JavaScript"><!-- + if (_ie == true) document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = 400 HEIGHT = 400 codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0"><NOEMBED><XMP>'); + else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.3" CODE = "pointblast.class" WIDTH = 400 HEIGHT = 400 scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html"><NOEMBED><XMP>'); +//--></SCRIPT> +<APPLET CODE = "pointblast.class" WIDTH = 400 HEIGHT = 400></XMP> +<PARAM NAME = CODE VALUE = "pointblast.class" >
+ +<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3"> +<PARAM NAME="scriptable" VALUE="false"> + +</APPLET> + +</NOEMBED></EMBED></OBJECT> + + +<!-- +<APPLET CODE = "pointblast.class" WIDTH = 400 HEIGHT = 400>
+
+
+</APPLET> +--> +<!--"END_CONVERTED_APPLET"-->
+
+<hr>
+</body>
+</html>
diff --git a/demos/RonsDemos/polyoff.html b/demos/RonsDemos/polyoff.html new file mode 100644 index 0000000..78ba14d --- /dev/null +++ b/demos/RonsDemos/polyoff.html @@ -0,0 +1,23 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
+ <title>Polyoff by Silicon Graphics; ported to Java by Ron Cemer</title>
+</head>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+Polyoff applet
+<br>Originially written by Silicon Graphics
+<br>Ported to Java by Ron Cemer
+<br>Use the Java Console in your browser to see messages generated by this applet.
+<br>Click inside the window, then press any of the following keys:
+<br>Arrows: rotate the object
+<br>t/T: decrease/increase translation distance
+<br>f/F: decrease/increase polygon offset factor
+<br>u/U: decrease/increase polygon offset units
+<br>
+<applet code="polyoff.class" width=400 height=400>
+</applet>
+<hr>
+</body>
+</html>
diff --git a/demos/RonsDemos/polyoff.java b/demos/RonsDemos/polyoff.java new file mode 100644 index 0000000..a79a398 --- /dev/null +++ b/demos/RonsDemos/polyoff.java @@ -0,0 +1,332 @@ +/**
+ * @(#) polyoff.java
+ * @(#) author: Silicon Graphics, Inc. (converted to Java by Ron Cemer)
+ */
+
+/*
+ * Copyright (c) 1993-1997, Silicon Graphics, Inc.
+ * ALL RIGHTS RESERVED
+ * Permission to use, copy, modify, and distribute this software for
+ * any purpose and without fee is hereby granted, provided that the above
+ * copyright notice appear in all copies and that both the copyright notice
+ * and this permission notice appear in supporting documentation, and that
+ * the name of Silicon Graphics, Inc. not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission.
+ *
+ * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
+ * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
+ * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
+ * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
+ * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
+ * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
+ * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
+ * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
+ * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * US Government Users Restricted Rights
+ * Use, duplication, or disclosure by the Government is subject to
+ * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
+ * (c)(1)(ii) of the Rights in Technical Data and Computer Software
+ * clause at DFARS 252.227-7013 and/or in similar or successor
+ * clauses in the FAR or the DOD or NASA FAR Supplement.
+ * Unpublished-- rights reserved under the copyright laws of the
+ * United States. Contractor/manufacturer is Silicon Graphics,
+ * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
+ *
+ * OpenGL(R) is a registered trademark of Silicon Graphics, Inc.
+ */
+
+/*
+ * This program demonstrates polygon offset to draw a shaded
+ * polygon and its wireframe counterpart without ugly visual
+ * artifacts ("stitching").
+ */
+
+import java.applet.*;
+import java.awt.*;
+import java.awt.event.*;
+import java.lang.*;
+import java.util.*;
+import java.io.*;
+import java.util.*;
+import gl4java.GLContext;
+import gl4java.awt.GLCanvas;
+
+public class polyoff extends Applet
+{
+ polyoffCanvas canvas = null;
+
+
+ /* Initialize the applet */
+
+
+ public void init()
+ {
+ Dimension d = getSize();
+ setLayout(new BorderLayout());
+ canvas = new polyoffCanvas(d.width, d.height);
+ canvas.requestFocus();
+ add("Center", canvas);
+ }
+
+
+ /* Start the applet */
+
+
+ public void start()
+ {
+ }
+
+
+ /* Stop the applet */
+
+
+ public void stop()
+ {
+ }
+
+
+ /* Destroy the applet */
+
+
+ public void destroy()
+ {
+ canvas.cvsDispose();
+ }
+
+
+ /* Local GLCanvas extension class */
+
+
+ private class polyoffCanvas extends GLCanvas
+ implements KeyListener, MouseListener
+ {
+ private int list;
+ private int spinx = 0;
+ private int spiny = 0;
+ private float tdist = 0.0f;
+ private float polyfactor = 1.0f;
+ private float polyunits = 1.0f;
+
+ public polyoffCanvas(int w, int h)
+ {
+ super(w, h);
+ GLContext.gljNativeDebug = false;
+ GLContext.gljClassDebug = false;
+ }
+
+ public void preInit()
+ {
+ doubleBuffer = true;
+ stereoView = false;
+ }
+
+ public void init()
+ {
+ System.out.println("init(): " + this);
+ reshape(getSize().width, getSize().height);
+
+ /* specify initial properties
+ * create display list with sphere
+ * initialize lighting and depth buffer
+ */
+
+ float light_ambient[] = { 0.0f, 0.0f, 0.0f, 1.0f };
+ float light_diffuse[] = { 1.0f, 1.0f, 1.0f, 1.0f };
+ float light_specular[] = { 1.0f, 1.0f, 1.0f, 1.0f };
+ float light_position[] = { 1.0f, 1.0f, 1.0f, 0.0f };
+
+ float global_ambient[] = { 0.2f, 0.2f, 0.2f, 1.0f };
+
+ gl.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
+
+ list = gl.glGenLists(1);
+ gl.glNewList (list, GL_COMPILE);
+
+ int qobj = glu.gluNewQuadric();
+ glu.gluQuadricOrientation(qobj,GLU_OUTSIDE);
+ glu.gluQuadricNormals(qobj,GLU_SMOOTH);
+ glu.gluQuadricTexture(qobj,false);
+ glu.gluSphere(qobj,1.0f,20,12);
+ glu.gluDeleteQuadric(qobj);
+
+ gl.glEndList();
+
+ gl.glEnable(GL_DEPTH_TEST);
+
+ gl.glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient);
+ gl.glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse);
+ gl.glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular);
+ gl.glLightfv(GL_LIGHT0, GL_POSITION, light_position);
+ gl.glLightModelfv (GL_LIGHT_MODEL_AMBIENT, global_ambient);
+
+ glj.gljCheckGL();
+
+ addKeyListener(this);
+ addMouseListener(this);
+ }
+
+ public void cvsDispose()
+ {
+ System.out.println("destroy(): " + this);
+ removeKeyListener(this);
+ super.cvsDispose();
+ }
+
+ public void reshape(int width, int height)
+ {
+ gl.glViewport(0,0,width,height);
+ gl.glMatrixMode(GL_PROJECTION);
+ gl.glLoadIdentity();
+ glu.gluPerspective(45.0,(double)width/(double)height,1.0,10.0);
+ gl.glMatrixMode (GL_MODELVIEW);
+ gl.glLoadIdentity();
+ glu.gluLookAt (0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
+ }
+
+ public void display()
+ {
+ if (glj.gljMakeCurrent() == false) return;
+
+ float mat_ambient[] = { 0.8f, 0.8f, 0.8f, 1.0f };
+ float mat_diffuse[] = { 1.0f, 0.0f, 0.5f, 1.0f };
+ float mat_specular[] = { 1.0f, 1.0f, 1.0f, 1.0f };
+ float gray[] = { 0.8f, 0.8f, 0.8f, 1.0f };
+ float black[] = { 0.0f, 0.0f, 0.0f, 1.0f };
+
+ gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ gl.glPushMatrix();
+ gl.glTranslatef(0.0f, 0.0f, tdist);
+ gl.glRotatef((float)spinx, 1.0f, 0.0f, 0.0f);
+ gl.glRotatef((float)spiny, 0.0f, 1.0f, 0.0f);
+
+ gl.glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, gray);
+ gl.glMaterialfv(GL_FRONT, GL_SPECULAR, black);
+ gl.glMaterialf(GL_FRONT, GL_SHININESS, 0.0f);
+ gl.glEnable(GL_LIGHTING);
+ gl.glEnable(GL_LIGHT0);
+ gl.glEnable(GL_POLYGON_OFFSET_FILL);
+ gl.glPolygonOffset(polyfactor, polyunits);
+ gl.glCallList (list);
+ gl.glDisable(GL_POLYGON_OFFSET_FILL);
+
+ gl.glDisable(GL_LIGHTING);
+ gl.glDisable(GL_LIGHT0);
+ gl.glColor3f(1.0f, 1.0f, 1.0f);
+ gl.glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
+ gl.glCallList (list);
+ gl.glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
+
+ gl.glPopMatrix();
+ gl.glFlush();
+
+ glj.gljSwap();
+ glj.gljCheckGL();
+ glj.gljFree();
+ }
+
+ // Methods required for the implementation of KeyListener
+ public void keyPressed(KeyEvent e)
+ {
+ switch (e.getKeyCode())
+ {
+ case KeyEvent.VK_LEFT:
+ int j = (spiny-5);
+ while (j < 0) j += 360;
+ spiny = j;
+ repaint();
+ break;
+ case KeyEvent.VK_RIGHT:
+ spiny = (spiny + 5) % 360;
+ repaint();
+ break;
+ case KeyEvent.VK_UP:
+ int i = (spinx-5);
+ while (i < 0) i += 360;
+ spinx = i;
+ repaint();
+ break;
+ case KeyEvent.VK_DOWN:
+ spinx = (spinx + 5) % 360;
+ repaint();
+ break;
+ }
+ }
+
+ public void keyReleased(KeyEvent e)
+ {
+ }
+
+ public void keyTyped(KeyEvent e)
+ {
+ switch ((char)e.getKeyChar())
+ {
+ case 'T':
+ if (tdist < 4.0f)
+ {
+ tdist += 0.5f;
+ System.out.println("translation distance is " + tdist);
+ repaint();
+ }
+ break;
+ case 't':
+ if (tdist > -5.0f)
+ {
+ tdist -= 0.5f;
+ System.out.println("translation distance is " + tdist);
+ repaint();
+ }
+ break;
+ case 'F':
+ polyfactor += 0.1f;
+ System.out.println("polyfactor is " + polyfactor);
+ repaint();
+ break;
+ case 'f':
+ polyfactor -= 0.1f;
+ System.out.println("polyfactor is " + polyfactor);
+ repaint();
+ break;
+ case 'U':
+ polyunits += 1.0f;
+ System.out.println("polyunits is " + polyunits);
+ repaint();
+ break;
+ case 'u':
+ polyunits -= 1.0f;
+ System.out.println("polyunits is " + polyunits);
+ repaint();
+ break;
+ }
+ }
+
+ // Methods required for the implementation of MouseListener
+ public void mouseEntered( MouseEvent evt )
+ {
+ Component comp = evt.getComponent();
+ if( comp.equals(this ) )
+ {
+ requestFocus();
+ }
+ }
+
+ public void mouseExited( MouseEvent evt )
+ { }
+ public void mousePressed( MouseEvent evt )
+ { }
+ public void mouseReleased( MouseEvent evt )
+ { }
+ public void mouseClicked( MouseEvent evt )
+ {
+ Component comp = evt.getComponent();
+ if( comp.equals(this ) )
+ {
+ requestFocus();
+ }
+ }
+ }
+}
diff --git a/demos/RonsDemos/polyoff_plugin13.html b/demos/RonsDemos/polyoff_plugin13.html new file mode 100644 index 0000000..aab6878 --- /dev/null +++ b/demos/RonsDemos/polyoff_plugin13.html @@ -0,0 +1,54 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
+ <title>Polyoff by Silicon Graphics; ported to Java by Ron Cemer</title>
+</head>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+Polyoff applet
+<br>Originially written by Silicon Graphics
+<br>Ported to Java by Ron Cemer
+<br>Use the Java Console in your browser to see messages generated by this applet.
+<br>Click inside the window, then press any of the following keys:
+<br>Arrows: rotate the object
+<br>t/T: decrease/increase translation distance
+<br>f/F: decrease/increase polygon offset factor
+<br>u/U: decrease/increase polygon offset units
+<br>
+<!--"CONVERTED_APPLET"-->
+<!-- CONVERTER VERSION 1.3 --> +<SCRIPT LANGUAGE="JavaScript"><!-- + var _info = navigator.userAgent; var _ns = false; + var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0); +//--></SCRIPT> +<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!-- + var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0))); +//--></SCRIPT></COMMENT> + +<SCRIPT LANGUAGE="JavaScript"><!-- + if (_ie == true) document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = 400 HEIGHT = 400 codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0"><NOEMBED><XMP>'); + else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.3" CODE = "polyoff.class" WIDTH = 400 HEIGHT = 400 scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html"><NOEMBED><XMP>'); +//--></SCRIPT> +<APPLET CODE = "polyoff.class" WIDTH = 400 HEIGHT = 400></XMP> +<PARAM NAME = CODE VALUE = "polyoff.class" >
+ +<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3"> +<PARAM NAME="scriptable" VALUE="false"> + +</APPLET> + +</NOEMBED></EMBED></OBJECT> + + +<!-- +<APPLET CODE = "polyoff.class" WIDTH = 400 HEIGHT = 400>
+
+
+</APPLET> +--> +<!--"END_CONVERTED_APPLET"-->
+
+<hr>
+</body>
+</html>
diff --git a/demos/RonsDemos/quadric.html b/demos/RonsDemos/quadric.html new file mode 100644 index 0000000..d104772 --- /dev/null +++ b/demos/RonsDemos/quadric.html @@ -0,0 +1,17 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
+ <title>Quadric by Silicon Graphics; ported to Java by Ron Cemer</title>
+</head>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+Quadric applet
+<br>Originially written by Silicon Graphics
+<br>Ported to Java by Ron Cemer
+<br>
+<applet code="quadric.class" width=400 height=400>
+</applet>
+<hr>
+</body>
+</html>
diff --git a/demos/RonsDemos/quadric.java b/demos/RonsDemos/quadric.java new file mode 100644 index 0000000..932f428 --- /dev/null +++ b/demos/RonsDemos/quadric.java @@ -0,0 +1,250 @@ +/**
+ * @(#) quadric.java
+ * @(#) author: Silicon Graphics, Inc. (converted to Java by Ron Cemer)
+ */
+
+/*
+ * Copyright (c) 1993-1997, Silicon Graphics, Inc.
+ * ALL RIGHTS RESERVED
+ * Permission to use, copy, modify, and distribute this software for
+ * any purpose and without fee is hereby granted, provided that the above
+ * copyright notice appear in all copies and that both the copyright notice
+ * and this permission notice appear in supporting documentation, and that
+ * the name of Silicon Graphics, Inc. not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission.
+ *
+ * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
+ * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
+ * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
+ * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
+ * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
+ * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
+ * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
+ * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
+ * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * US Government Users Restricted Rights
+ * Use, duplication, or disclosure by the Government is subject to
+ * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
+ * (c)(1)(ii) of the Rights in Technical Data and Computer Software
+ * clause at DFARS 252.227-7013 and/or in similar or successor
+ * clauses in the FAR or the DOD or NASA FAR Supplement.
+ * Unpublished-- rights reserved under the copyright laws of the
+ * United States. Contractor/manufacturer is Silicon Graphics,
+ * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
+ *
+ * OpenGL(R) is a registered trademark of Silicon Graphics, Inc.
+ */
+
+/*
+ * This program demonstrates the use of some of the gluQuadric*
+ * routines. Quadric objects are created with some quadric
+ * properties and the callback routine to handle errors.
+ * Note that the cylinder has no top or bottom and the circle
+ * has a hole in it.
+ */
+
+import java.applet.*;
+import java.awt.*;
+import java.awt.event.*;
+import java.lang.*;
+import java.util.*;
+import java.io.*;
+import java.util.*;
+import gl4java.GLContext;
+import gl4java.awt.GLCanvas;
+
+public class quadric extends Applet
+{
+ quadricCanvas canvas = null;
+
+
+ /* Initialize the applet */
+
+
+ public void init()
+ {
+ Dimension d = getSize();
+ setLayout(new BorderLayout());
+ canvas = new quadricCanvas(d.width, d.height);
+ add("Center", canvas);
+ }
+
+
+ /* Start the applet */
+
+
+ public void start()
+ {
+ }
+
+
+ /* Stop the applet */
+
+
+ public void stop()
+ {
+ }
+
+
+ /* Destroy the applet */
+
+
+ public void destroy()
+ {
+ canvas.cvsDispose();
+ }
+
+
+ /* Local GLCanvas extension class */
+
+
+ private class quadricCanvas extends GLCanvas
+ {
+ int startList;
+
+ public quadricCanvas(int w, int h)
+ {
+ super(w, h);
+ GLContext.gljNativeDebug = false;
+ GLContext.gljClassDebug = false;
+ }
+
+ public void preInit()
+ {
+ doubleBuffer = true;
+ stereoView = false;
+ }
+
+ public void init()
+ {
+ System.out.println("init(): " + this);
+ reshape(getSize().width, getSize().height);
+
+ int qobj;
+ float mat_ambient[] = { 0.5f, 0.5f, 0.5f, 1.0f };
+ float mat_specular[] = { 1.0f, 1.0f, 1.0f, 1.0f };
+ float mat_shininess[] = { 50.0f };
+ float light_position[] = { 1.0f, 1.0f, 1.0f, 0.0f };
+ float model_ambient[] = { 0.5f, 0.5f, 0.5f, 1.0f };
+
+ gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
+
+ gl.glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient);
+ gl.glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
+ gl.glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess);
+ gl.glLightfv(GL_LIGHT0, GL_POSITION, light_position);
+ gl.glLightModelfv(GL_LIGHT_MODEL_AMBIENT, model_ambient);
+
+ gl.glEnable(GL_LIGHTING);
+ gl.glEnable(GL_LIGHT0);
+ gl.glEnable(GL_DEPTH_TEST);
+
+ /* Create 4 display lists, each with a different quadric object.
+ * Different drawing styles and surface normal specifications
+ * are demonstrated.
+ */
+ startList = gl.glGenLists(4);
+ qobj = glu.gluNewQuadric();
+
+ glu.gluQuadricDrawStyle(qobj, GLU_FILL); /* smooth shaded */
+ glu.gluQuadricNormals(qobj, GLU_SMOOTH);
+ gl.glNewList(startList, GL_COMPILE);
+ glu.gluSphere(qobj, 0.75f, 15, 10);
+ gl.glEndList();
+
+ glu.gluQuadricDrawStyle(qobj, GLU_FILL); /* flat shaded */
+ glu.gluQuadricNormals(qobj, GLU_FLAT);
+ gl.glNewList(startList+1, GL_COMPILE);
+ glu.gluCylinder(qobj, 0.5f, 0.3f, 1.0f, 15, 5);
+ gl.glEndList();
+
+ glu.gluQuadricDrawStyle(qobj, GLU_LINE); /* all polygons wireframe */
+ glu.gluQuadricNormals(qobj, GLU_NONE);
+ gl.glNewList(startList+2, GL_COMPILE);
+ glu.gluDisk(qobj, 0.25f, 1.0f, 20, 4);
+ gl.glEndList();
+
+ glu.gluQuadricDrawStyle(qobj, GLU_SILHOUETTE); /* boundary only */
+ glu.gluQuadricNormals(qobj, GLU_NONE);
+ gl.glNewList(startList+3, GL_COMPILE);
+ glu.gluPartialDisk(qobj, 0.0f, 1.0f, 20, 4, 0.0f, 225.0f);
+ gl.glEndList();
+
+ glu.gluDeleteQuadric(qobj);
+
+ glj.gljCheckGL();
+ }
+
+ public void cvsDispose()
+ {
+ System.out.println("destroy(): " + this);
+ super.cvsDispose();
+ }
+
+ public void reshape(int width, int height)
+ {
+ gl.glViewport(0,0,width,height);
+ gl.glMatrixMode(GL_PROJECTION);
+ gl.glLoadIdentity();
+ if (width <= height)
+ gl.glOrtho
+ (-2.5f,
+ 2.5f,
+ -2.5f*(float)height/(float)width,
+ 2.5f*(float)height/(float)width,
+ -10.0f,
+ 10.0f);
+ else
+ gl.glOrtho
+ (-2.5f*(float)width/(float)height,
+ 2.5f*(float)width/(float)height,
+ -2.5f,
+ 2.5f,
+ -10.0f,
+ 10.0f);
+ gl.glMatrixMode(GL_MODELVIEW);
+ gl.glLoadIdentity();
+ }
+
+ public void display()
+ {
+ if (glj.gljMakeCurrent() == false) return;
+
+ gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ gl.glPushMatrix();
+
+ gl.glEnable(GL_LIGHTING);
+ gl.glShadeModel(GL_SMOOTH);
+ gl.glTranslatef(-1.0f, -1.0f, 0.0f);
+ gl.glCallList(startList);
+
+ gl.glShadeModel(GL_FLAT);
+ gl.glTranslatef(0.0f, 2.0f, 0.0f);
+ gl.glPushMatrix();
+ gl.glRotatef(300.0f, 1.0f, 0.0f, 0.0f);
+ gl.glCallList(startList+1);
+ gl.glPopMatrix();
+
+ gl.glDisable(GL_LIGHTING);
+ gl.glColor3f(0.0f, 1.0f, 1.0f);
+ gl.glTranslatef(2.0f, -2.0f, 0.0f);
+ gl.glCallList(startList+2);
+
+ gl.glColor3f(1.0f, 1.0f, 0.0f);
+ gl.glTranslatef(0.0f, 2.0f, 0.0f);
+ gl.glCallList(startList+3);
+
+ gl.glPopMatrix();
+ gl.glFlush();
+
+ glj.gljSwap();
+ glj.gljCheckGL();
+ glj.gljFree();
+ }
+ }
+}
diff --git a/demos/RonsDemos/quadric_plugin13.html b/demos/RonsDemos/quadric_plugin13.html new file mode 100644 index 0000000..9d4db49 --- /dev/null +++ b/demos/RonsDemos/quadric_plugin13.html @@ -0,0 +1,48 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
+ <title>Quadric by Silicon Graphics; ported to Java by Ron Cemer</title>
+</head>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+Quadric applet
+<br>Originially written by Silicon Graphics
+<br>Ported to Java by Ron Cemer
+<br>
+<!--"CONVERTED_APPLET"-->
+<!-- CONVERTER VERSION 1.3 --> +<SCRIPT LANGUAGE="JavaScript"><!-- + var _info = navigator.userAgent; var _ns = false; + var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0); +//--></SCRIPT> +<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!-- + var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0))); +//--></SCRIPT></COMMENT> + +<SCRIPT LANGUAGE="JavaScript"><!-- + if (_ie == true) document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = 400 HEIGHT = 400 codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0"><NOEMBED><XMP>'); + else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.3" CODE = "quadric.class" WIDTH = 400 HEIGHT = 400 scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html"><NOEMBED><XMP>'); +//--></SCRIPT> +<APPLET CODE = "quadric.class" WIDTH = 400 HEIGHT = 400></XMP> +<PARAM NAME = CODE VALUE = "quadric.class" >
+ +<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3"> +<PARAM NAME="scriptable" VALUE="false"> + +</APPLET> + +</NOEMBED></EMBED></OBJECT> + + +<!-- +<APPLET CODE = "quadric.class" WIDTH = 400 HEIGHT = 400>
+
+
+</APPLET> +--> +<!--"END_CONVERTED_APPLET"-->
+
+<hr>
+</body>
+</html>
diff --git a/demos/RonsDemos/reflect.html b/demos/RonsDemos/reflect.html new file mode 100644 index 0000000..3ade9b6 --- /dev/null +++ b/demos/RonsDemos/reflect.html @@ -0,0 +1,22 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
+ <title>Reflect by Brian Paul; ported to Java by Ron Cemer</title>
+</head>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+Reflect applet
+<br>Originially written by Brian Paul
+<br>Ported to Java by Ron Cemer
+<br>
+<hr>You can rotate the view by holding the left mouse button down and
+<br>dragging the mouse within the applet's window.
+<br>If you hold the right button down instead, the view will rotate
+<br>around the Z axis.
+<br>
+<applet code="reflect.class" width=400 height=400>
+</applet>
+<hr>
+</body>
+</html>
diff --git a/demos/RonsDemos/reflect.java b/demos/RonsDemos/reflect.java new file mode 100644 index 0000000..e857881 --- /dev/null +++ b/demos/RonsDemos/reflect.java @@ -0,0 +1,424 @@ +/**
+ * @(#) reflect.java
+ * @(#) author: Brian Paul (converted to Java by Ron Cemer)
+ */
+
+/*
+ * Demo of a reflective, texture-mapped surface with OpenGL.
+ * Brian Paul August 14, 1995 This file is in the public domain.
+ *
+ * Hardware texture mapping is highly recommended!
+ *
+ * The basic steps are:
+ * 1. Render the reflective object (a polygon) from the normal viewpoint,
+ * setting the stencil planes = 1.
+ * 2. Render the scene from a special viewpoint: the viewpoint which
+ * is on the opposite side of the reflective plane. Only draw where
+ * stencil = 1. This draws the objects in the reflective surface.
+ * 3. Render the scene from the original viewpoint. This draws the
+ * objects in the normal fashion. Use blending when drawing
+ * the reflective, textured surface.
+ *
+ * This is a very crude demo. It could be much better.
+ */
+
+/*
+ * Dirk Reiners ([email protected]) made some modifications to this code.
+ *
+ * August 1996 - A few optimizations by Brian
+ */
+
+/*
+ * April, 1997 - Added Mark Kilgard's changes.
+ */
+
+import java.applet.*;
+import java.awt.*;
+import java.awt.event.*;
+import java.lang.*;
+import java.util.*;
+import java.io.*;
+import java.util.*;
+
+import gl4java.GLContext;
+import gl4java.awt.GLAnimCanvas;
+import gl4java.applet.SimpleGLAnimApplet1;
+
+public class reflect extends SimpleGLAnimApplet1
+{
+ /* Initialize the applet */
+
+
+ public void init()
+ {
+ super.init();
+ Dimension d = getSize();
+ canvas = new reflectCanvas(d.width, d.height);
+ add("Center", canvas);
+ }
+
+
+ /* Local GLAnimCanvas extension class */
+
+
+ private class reflectCanvas extends GLAnimCanvas implements MouseListener, MouseMotionListener
+ {
+ private static final float M_PI = 3.14159265359f;
+ private static final float DEG2RAD = (M_PI/180.0f);
+ private static final int MAX_OBJECTS = 2;
+
+ private final float light_pos[] = { 0.0f, 20.0f, 0.0f, 1.0f };
+
+ private int textureid = 0;
+
+ private int table_list;
+ private int objects_list[];
+
+ private float spin, xrot, yrot;
+
+ private MatrixFuncs mtxfuncs = null;
+ private int prevMouseX, prevMouseY;
+ private boolean mouseRButtonDown = false;
+
+ public reflectCanvas(int w, int h)
+ {
+ super(w, h);
+ GLContext.gljNativeDebug = false;
+ GLContext.gljClassDebug = false;
+ setAnimateFps(60.0f);
+
+ mtxfuncs = new MatrixFuncs();
+ objects_list = new int[MAX_OBJECTS];
+ }
+
+ public void preInit()
+ {
+ doubleBuffer = true;
+ stereoView = false;
+ stencilBits = 3;
+ }
+
+ public void init()
+ {
+ System.out.println("init(): " + this);
+ reshape(getSize().width, getSize().height);
+
+ make_table();
+ make_objects();
+
+ int texIdBuf[] = new int[1];
+ gl.glGenTextures(1, texIdBuf);
+ textureid = texIdBuf[0];
+
+ gl.glBindTexture(GL_TEXTURE_2D,textureid);
+
+ HardCodedTexture texture = new DemoTex1();
+ gl.glTexImage2D
+ (GL_TEXTURE_2D,
+ 0,
+ texture.getComponents(),
+ texture.getWidth(),
+ texture.getHeight(),
+ 0,
+ texture.getFormat(),
+ texture.getType(),
+ texture.getBits());
+
+ gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
+ gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
+ gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+
+ gl.glBindTexture(GL_TEXTURE_2D,0);
+
+ spin = 0.0f;
+ xrot = 30.0f;
+ yrot = 50.0f;
+
+ gl.glShadeModel(GL_FLAT);
+
+ gl.glEnable(GL_LIGHT0);
+ gl.glEnable(GL_LIGHTING);
+
+ gl.glClearColor(0.5f, 0.5f, 0.5f, 1.0f);
+
+ gl.glEnable(GL_NORMALIZE);
+
+ glj.gljCheckGL();
+
+ addMouseListener(this);
+ addMouseMotionListener(this);
+ }
+
+ public void doCleanup()
+ {
+ System.out.println("destroy(): " + this);
+ removeMouseListener(this);
+ removeMouseMotionListener(this);
+ }
+
+ public void reshape(int width, int height)
+ {
+ float aspect = (float)width / (float)height;
+
+ gl.glViewport(0,0,width,height);
+ gl.glMatrixMode(GL_PROJECTION);
+ gl.glLoadIdentity();
+ gl.glFrustum(-aspect, aspect, -1.0f, 1.0f, 4.0f, 300.0f);
+ gl.glMatrixMode(GL_MODELVIEW);
+ gl.glLoadIdentity();
+ }
+
+ public void display()
+ {
+ if (glj.gljMakeCurrent() == false) return;
+
+ spin += 0.8f;
+ yrot += 1.2f;
+ if (yrot >= 360.0f) yrot -= 360.0f;
+
+ float dist = 20.0f;
+ float eyex, eyey, eyez;
+
+ gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
+
+ eyex = dist * (float)Math.cos(yrot*DEG2RAD) * (float)Math.cos(xrot*DEG2RAD);
+ eyez = dist * (float)Math.sin(yrot*DEG2RAD) * (float)Math.cos(xrot*DEG2RAD);
+ eyey = dist * (float)Math.sin(xrot*DEG2RAD);
+
+ /* view from top */
+ gl.glPushMatrix();
+
+ glu.gluLookAt(eyex,eyey,eyez,0.0f,0.0f,0.0f,0.0f,1.0f,0.0f);
+
+ gl.glLightfv(GL_LIGHT0, GL_POSITION, light_pos);
+
+ /* draw table into stencil planes (non-textured for speed) */
+ gl.glEnable(GL_STENCIL_TEST);
+ gl.glDisable(GL_DEPTH_TEST);
+ gl.glStencilFunc(GL_ALWAYS, 1, 0xffffffff);
+ gl.glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE);
+ gl.glColorMask(false, false, false, false);
+ draw_table();
+ gl.glColorMask(true, true, true, true);
+
+ gl.glEnable(GL_DEPTH_TEST);
+
+ /* render view from below (reflected viewport) */
+ /* only draw where stencil==1 */
+ if (eyey > 0.0f)
+ {
+ gl.glPushMatrix();
+
+ gl.glStencilFunc(GL_EQUAL, 1, 0xffffffff); /* draw if ==1 */
+ gl.glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
+ gl.glScalef(1.0f, -1.0f, 1.0f);
+
+ /* Reposition light in reflected space. */
+ gl.glLightfv(GL_LIGHT0, GL_POSITION, light_pos);
+
+ draw_objects(eyex, eyey, eyez);
+ gl.glPopMatrix();
+
+ /* Restore light's original unreflected position. */
+ gl.glLightfv(GL_LIGHT0, GL_POSITION, light_pos);
+ }
+
+ /* draw table into color planes (textured this time) */
+ gl.glDisable(GL_STENCIL_TEST);
+
+ gl.glEnable(GL_BLEND);
+ gl.glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+
+ gl.glBindTexture(GL_TEXTURE_2D,textureid);
+ gl.glEnable(GL_TEXTURE_2D);
+ draw_table();
+ gl.glDisable(GL_TEXTURE_2D);
+ gl.glBindTexture(GL_TEXTURE_2D,0);
+ gl.glDisable(GL_BLEND);
+
+ /* view from top */
+ gl.glPushMatrix();
+
+ draw_objects(eyex, eyey, eyez);
+
+ gl.glPopMatrix();
+
+ gl.glPopMatrix();
+
+ glj.gljSwap();
+ glj.gljCheckGL();
+ glj.gljFree();
+
+ //if (!isSuspended()) repaint(); // Animate at full speed.
+ }
+
+ private void make_table()
+ {
+ float table_mat[] = { 1.0f, 1.0f, 1.0f, 0.6f };
+ float gray[] = { 0.4f, 0.4f, 0.4f, 1.0f };
+
+ table_list = gl.glGenLists(1);
+ gl.glNewList(table_list,GL_COMPILE);
+
+ /* load table's texture */
+ gl.glMaterialfv(GL_FRONT,GL_AMBIENT_AND_DIFFUSE,table_mat);
+ gl.glMaterialfv(GL_FRONT,GL_DIFFUSE,table_mat);
+ gl.glMaterialfv(GL_FRONT,GL_AMBIENT,gray);
+
+ /* draw textured square for the table */
+ gl.glPushMatrix();
+ gl.glScalef(4.0f, 4.0f, 4.0f);
+ gl.glBegin(GL_POLYGON);
+ gl.glNormal3f(0.0f, 1.0f, 0.0f);
+ gl.glTexCoord2f(0.0f, 0.0f); gl.glVertex3f(-1.0f, 0.0f, 1.0f);
+ gl.glTexCoord2f(1.0f, 0.0f); gl.glVertex3f( 1.0f, 0.0f, 1.0f);
+ gl.glTexCoord2f(1.0f, 1.0f); gl.glVertex3f( 1.0f, 0.0f, -1.0f);
+ gl.glTexCoord2f(0.0f, 1.0f); gl.glVertex3f(-1.0f, 0.0f, -1.0f);
+ gl.glEnd();
+ gl.glPopMatrix();
+
+ gl.glEndList();
+ }
+
+ private void make_objects()
+ {
+ int q;
+
+ float cyan[] = { 0.0f, 1.0f, 1.0f, 1.0f };
+ float green[] = { 0.2f, 1.0f, 0.2f, 1.0f };
+ float black[] = { 0.0f, 0.0f, 0.0f, 0.0f };
+
+ q = glu.gluNewQuadric();
+ glu.gluQuadricDrawStyle(q, GLU_FILL);
+ glu.gluQuadricNormals(q, GLU_SMOOTH);
+
+ objects_list[0] = gl.glGenLists(1);
+ gl.glNewList(objects_list[0], GL_COMPILE);
+ gl.glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, cyan );
+ gl.glMaterialfv(GL_FRONT, GL_EMISSION, black );
+ glu.gluCylinder(q, 0.5f, 0.5f, 1.0f, 15, 10);
+ gl.glEndList();
+
+ objects_list[1] = gl.glGenLists(1);
+ gl.glNewList(objects_list[1], GL_COMPILE);
+ gl.glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green);
+ gl.glMaterialfv(GL_FRONT, GL_EMISSION, black);
+ glu.gluCylinder(q, 1.5, 0.0f, 2.5f, 15, 10);
+ gl.glEndList();
+ }
+
+
+ private void draw_objects(float eyex, float eyey, float eyez)
+ {
+ gl.glPushMatrix();
+ gl.glTranslatef(1.0f, 1.5f, 0.0f);
+ gl.glRotatef(spin, 1.0f, 0.5f, 0.0f);
+ gl.glRotatef(0.5f*spin, 0.0f, 0.5f, 1.0f);
+ gl.glCallList(objects_list[0]);
+ gl.glPopMatrix();
+
+ gl.glPushMatrix();
+ gl.glTranslatef(-1.0f, 0.85f+3.0f*(float)Math.abs((float)Math.cos(0.01f*spin)),0.0f);
+ gl.glRotatef(0.5f*spin, 0.0f, 0.5f, 1.0f);
+ gl.glRotatef(spin, 1.0f, 0.5f, 0.0f);
+ gl.glScalef(0.5f, 0.5f, 0.5f);
+ gl.glCallList(objects_list[1]);
+ gl.glPopMatrix();
+ }
+
+ private void draw_table()
+ {
+ gl.glCallList(table_list);
+ }
+
+ float[] MatrixTransform(float m[], float vx, float vy, float vz, float vw)
+ {
+ float v[] = new float[4];
+ float nx, ny, nz, nw, ninvw;
+
+ nx = ((vx*m[0])+(vy*m[4])+(vz*m[ 8])+(vw*m[12]));
+ ny = ((vx*m[1])+(vy*m[5])+(vz*m[ 9])+(vw*m[13]));
+ nz = ((vx*m[2])+(vy*m[6])+(vz*m[10])+(vw*m[14]));
+ nw = ((vx*m[3])+(vy*m[7])+(vz*m[11])+(vw*m[15]));
+ if ( (nw != 0.0f) && (nw != 1.0f) )
+ {
+ ninvw = 1.0f/nw;
+ nx *= ninvw;
+ ny *= ninvw;
+ nz *= ninvw;
+ }
+ v[0] = nx;
+ v[1] = ny;
+ v[2] = nz;
+ v[3] = 1.0f;
+ return(v);
+ }
+
+ // Methods required for the implementation of MouseListener
+ public void mouseEntered( MouseEvent evt )
+ {
+ }
+
+ public void mouseExited( MouseEvent evt )
+ {
+ }
+
+ public void mousePressed( MouseEvent evt )
+ {
+ prevMouseX = evt.getX();
+ prevMouseY = evt.getY();
+ if ((evt.getModifiers() & evt.BUTTON3_MASK) != 0)
+ {
+ mouseRButtonDown = true;
+ evt.consume();
+ }
+ }
+
+ public void mouseReleased( MouseEvent evt )
+ {
+ if ((evt.getModifiers() & evt.BUTTON3_MASK) != 0)
+ {
+ mouseRButtonDown = false;
+ evt.consume();
+ }
+ }
+
+ public void mouseClicked( MouseEvent evt )
+ {
+ }
+
+ // Methods required for the implementation of MouseMotionListener
+ public void mouseDragged( MouseEvent evt )
+ {
+ int x = evt.getX();
+ int y = evt.getY();
+ float thetaX = (float)(x-prevMouseX)*(360.0f/(float)getSize().width);
+ float thetaY = (float)(prevMouseY-y)*(360.0f/(float)getSize().height);
+ float mtxbuf[] = new float[16];
+ float mtxbuf2[] = new float[16];
+
+ prevMouseX = x;
+ prevMouseY = y;
+ if ( (thetaX != 0.0f) || (thetaY != 0.0f) )
+ {
+// This is a special hack for this applet only, due to
+// the fact that we are not using a rotation matrix!!!
+ yrot += thetaX;
+ while (yrot < 0.0f) yrot += 360.0f;
+ while (yrot >= 360.0f) yrot -= 360.0f;
+
+ xrot -= thetaY;
+ if (xrot > 90.0f)
+ xrot = 90.0f;
+ else if (xrot < -90.0f)
+ xrot = -90.0f;
+ }
+ evt.consume();
+ }
+
+ public void mouseMoved( MouseEvent evt )
+ {
+ }
+ }
+}
diff --git a/demos/RonsDemos/reflect_plugin13.html b/demos/RonsDemos/reflect_plugin13.html new file mode 100644 index 0000000..306e8d6 --- /dev/null +++ b/demos/RonsDemos/reflect_plugin13.html @@ -0,0 +1,53 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
+ <title>Reflect by Brian Paul; ported to Java by Ron Cemer</title>
+</head>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+Reflect applet
+<br>Originially written by Brian Paul
+<br>Ported to Java by Ron Cemer
+<br>
+<hr>You can rotate the view by holding the left mouse button down and
+<br>dragging the mouse within the applet's window.
+<br>If you hold the right button down instead, the view will rotate
+<br>around the Z axis.
+<br>
+<!--"CONVERTED_APPLET"-->
+<!-- CONVERTER VERSION 1.3 --> +<SCRIPT LANGUAGE="JavaScript"><!-- + var _info = navigator.userAgent; var _ns = false; + var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0); +//--></SCRIPT> +<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!-- + var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0))); +//--></SCRIPT></COMMENT> + +<SCRIPT LANGUAGE="JavaScript"><!-- + if (_ie == true) document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = 400 HEIGHT = 400 codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0"><NOEMBED><XMP>'); + else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.3" CODE = "reflect.class" WIDTH = 400 HEIGHT = 400 scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html"><NOEMBED><XMP>'); +//--></SCRIPT> +<APPLET CODE = "reflect.class" WIDTH = 400 HEIGHT = 400></XMP> +<PARAM NAME = CODE VALUE = "reflect.class" >
+ +<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3"> +<PARAM NAME="scriptable" VALUE="false"> + +</APPLET> + +</NOEMBED></EMBED></OBJECT> + + +<!-- +<APPLET CODE = "reflect.class" WIDTH = 400 HEIGHT = 400>
+
+
+</APPLET> +--> +<!--"END_CONVERTED_APPLET"-->
+
+<hr>
+</body>
+</html>
diff --git a/demos/RonsDemos/renormal.html b/demos/RonsDemos/renormal.html new file mode 100644 index 0000000..c0aa238 --- /dev/null +++ b/demos/RonsDemos/renormal.html @@ -0,0 +1,18 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
+ <title>Renormal by Brian Paul; ported to Java by Ron Cemer</title>
+</head>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+Renormal applet
+<br>Originially written by Brian Paul
+<br>Ported to Java by Ron Cemer
+<br>
+<hr>
+<applet code="renormal.class" width=400 height=400>
+</applet>
+<hr>
+</body>
+</html>
diff --git a/demos/RonsDemos/renormal.java b/demos/RonsDemos/renormal.java new file mode 100644 index 0000000..783bf15 --- /dev/null +++ b/demos/RonsDemos/renormal.java @@ -0,0 +1,112 @@ +/**
+ * @(#) renormal.java
+ * @(#) author: Brian Paul (converted to Java by Ron Cemer)
+ */
+
+import java.applet.*;
+import java.awt.*;
+import java.awt.event.*;
+import java.lang.*;
+import java.util.*;
+import java.io.*;
+import java.util.*;
+
+import gl4java.GLContext;
+import gl4java.awt.GLAnimCanvas;
+import gl4java.applet.SimpleGLAnimApplet1;
+
+public class renormal extends SimpleGLAnimApplet1
+{
+ /* Initialize the applet */
+
+
+ public void init()
+ {
+ super.init();
+ Dimension d = getSize();
+ canvas = new renormalCanvas(d.width, d.height);
+ add("Center", canvas);
+ }
+
+
+ /* Local GLAnimCanvas extension class */
+
+
+ private class renormalCanvas extends GLAnimCanvas
+ {
+ private static final float M_PI = 3.14159265359f;
+ private float Phi = 0.0f;
+
+ public renormalCanvas(int w, int h)
+ {
+ super(w, h);
+ GLContext.gljNativeDebug = false;
+ GLContext.gljClassDebug = false;
+ setAnimateFps(30.0);
+ }
+
+ public void preInit()
+ {
+ doubleBuffer = true;
+ stereoView = false;
+ }
+
+ public void init()
+ {
+ System.out.println("init(): " + this);
+ reshape(getSize().width, getSize().height);
+
+ float mat[] = { 0.8f, 0.8f, 0.0f, 1.0f };
+ float pos[] = { -1.0f, 1.0f, 1.0f, 0.0f };
+
+ /* setup lighting, etc */
+ gl.glEnable(GL_LIGHTING);
+ gl.glEnable(GL_LIGHT0);
+ gl.glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, mat);
+ gl.glLightfv(GL_LIGHT0, GL_POSITION, pos);
+ gl.glEnable(GL_CULL_FACE);
+ gl.glEnable(GL_NORMALIZE);
+
+ glj.gljCheckGL();
+ }
+
+ public void reshape(int width, int height)
+ {
+ gl.glViewport(0,0,width,height);
+ gl.glMatrixMode(GL_PROJECTION);
+ gl.glLoadIdentity();
+ gl.glFrustum(-1.0f, 1.0f, -1.0f, 1.0f, 5.0f, 25.0f);
+ gl.glMatrixMode(GL_MODELVIEW);
+ gl.glLoadIdentity();
+ gl.glTranslatef(0.0f, 0.0f, -15.0f);
+ }
+
+ public void display()
+ {
+ if (glj.gljMakeCurrent() == false) return;
+
+ Phi += 0.05f;
+ while (Phi >= (M_PI*2.0f)) Phi -= (M_PI*2.0f);
+
+ float scale = 0.6f + (0.5f * (float)Math.sin(Phi));
+ gl.glClear(GL_COLOR_BUFFER_BIT);
+ gl.glPushMatrix();
+ gl.glScalef(scale, scale, scale);
+
+ int qobj = glu.gluNewQuadric();
+ glu.gluQuadricOrientation(qobj,GLU_OUTSIDE);
+ glu.gluQuadricNormals(qobj,GLU_SMOOTH);
+ glu.gluQuadricTexture(qobj,false);
+ glu.gluSphere(qobj,2.0f,40,40);
+ glu.gluDeleteQuadric(qobj);
+
+ gl.glPopMatrix();
+
+ glj.gljSwap();
+ glj.gljCheckGL();
+ glj.gljFree();
+
+ //if (!isSuspended()) repaint(); // Animate at full speed.
+ }
+ }
+}
diff --git a/demos/RonsDemos/renormal_plugin13.html b/demos/RonsDemos/renormal_plugin13.html new file mode 100644 index 0000000..d40bb7b --- /dev/null +++ b/demos/RonsDemos/renormal_plugin13.html @@ -0,0 +1,49 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
+ <title>Renormal by Brian Paul; ported to Java by Ron Cemer</title>
+</head>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+Renormal applet
+<br>Originially written by Brian Paul
+<br>Ported to Java by Ron Cemer
+<br>
+<hr>
+<!--"CONVERTED_APPLET"-->
+<!-- CONVERTER VERSION 1.3 --> +<SCRIPT LANGUAGE="JavaScript"><!-- + var _info = navigator.userAgent; var _ns = false; + var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0); +//--></SCRIPT> +<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!-- + var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0))); +//--></SCRIPT></COMMENT> + +<SCRIPT LANGUAGE="JavaScript"><!-- + if (_ie == true) document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = 400 HEIGHT = 400 codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0"><NOEMBED><XMP>'); + else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.3" CODE = "renormal.class" WIDTH = 400 HEIGHT = 400 scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html"><NOEMBED><XMP>'); +//--></SCRIPT> +<APPLET CODE = "renormal.class" WIDTH = 400 HEIGHT = 400></XMP> +<PARAM NAME = CODE VALUE = "renormal.class" >
+ +<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3"> +<PARAM NAME="scriptable" VALUE="false"> + +</APPLET> + +</NOEMBED></EMBED></OBJECT> + + +<!-- +<APPLET CODE = "renormal.class" WIDTH = 400 HEIGHT = 400>
+
+
+</APPLET> +--> +<!--"END_CONVERTED_APPLET"-->
+
+<hr>
+</body>
+</html>
diff --git a/demos/RonsDemos/rings.html b/demos/RonsDemos/rings.html new file mode 100644 index 0000000..a393253 --- /dev/null +++ b/demos/RonsDemos/rings.html @@ -0,0 +1,18 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
+ <title>Rings by Philip Winston; ported to Java by Ron Cemer</title>
+</head>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+Rings applet
+<br>Originially written by Philip Winston
+<br>Ported to Java by Ron Cemer
+<br>Right-click within the window for a menu of commands.
+<br>
+<applet code="rings.class" width=400 height=400>
+</applet>
+<hr>
+</body>
+</html>
diff --git a/demos/RonsDemos/rings.java b/demos/RonsDemos/rings.java new file mode 100644 index 0000000..8a08bb5 --- /dev/null +++ b/demos/RonsDemos/rings.java @@ -0,0 +1,406 @@ +/**
+ * @(#) rings.java
+ * @(#) author: Philip Winston (converted to Java by Ron Cemer)
+ */
+
+/*
+ * Homework 4, Part 1: perspective, hierarchical coords, moving eye pos.
+ *
+ * Do a slow zoom on a bunch of rings (ala Superman III?)
+ *
+ * Philip Winston - 2/21/95
+ * http://www.cs.hmc.edu/people/pwinston
+ *
+ */
+
+import java.applet.*;
+import java.awt.*;
+import java.awt.event.*;
+import java.lang.*;
+import java.util.*;
+import java.io.*;
+import java.util.*;
+import gl4java.GLContext;
+import gl4java.awt.GLAnimCanvas;
+import gl4java.applet.SimpleGLAnimApplet1;
+
+public class rings extends SimpleGLAnimApplet1
+{
+ /* Initialize the applet */
+
+
+ public void init()
+ {
+ super.init();
+ Dimension d = getSize();
+ canvas = new ringsCanvas(d.width, d.height);
+ add("Center", canvas);
+ }
+
+
+ /* Local GLAnimCanvas extension class */
+
+
+ private class ringsCanvas extends GLAnimCanvas
+ implements MouseListener, ActionListener
+ {
+ private final double M_PI = 3.14159265;
+ private final String MENU_STARTOVER = "Start Over";
+ private final String MENU_ZOOM_OUT = "Zoom Out";
+ private final String MENU_START_RINGS = "Start rings";
+ private final String MENU_STOP_RINGS = "Stop rings";
+ private final String MENU_START_FADE = "Start fade";
+ private final String MENU_STOP_FADE = "Stop fade";
+ private final int CONE = 1, TORUS = 2, INNERMAT = 3, OUTTERMAT = 4;
+ private final double STEPS = 30.0;
+
+ private PopupMenu menu = null;
+ private boolean menu_showing = false;
+ private boolean save_suspended = false;
+ private boolean Fade = true; /* Start moving out */
+ private float Axis = 0.0f;
+ private float AxisInc = (float)(2.0 * M_PI / STEPS);
+ private float InnerRad, OutterRad, Tilt, Trans, TransCone, Dist;
+
+ public ringsCanvas(int w, int h)
+ {
+ super(w, h);
+ GLContext.gljNativeDebug = false;
+ GLContext.gljClassDebug = false;
+ setAnimateFps(30.0);
+ }
+
+ public void preInit()
+ {
+ doubleBuffer = true;
+ stereoView = false;
+ }
+
+ public void init()
+ {
+ System.out.println("init(): " + this);
+ reshape(getSize().width, getSize().height);
+
+ float sinoftilt;
+ InnerRad = 0.70f;
+ OutterRad = 5.0f;
+ Tilt = 15.0f;
+ Dist = 10.0f;
+ sinoftilt = (float)Math.sin(Tilt * M_PI*2.0/360.0);
+ Trans = (float)
+ ((2.0f*OutterRad + InnerRad) * sinoftilt +
+ InnerRad +
+ ((1 - sinoftilt) * InnerRad) - (InnerRad * 0.1));
+ TransCone = Trans + (OutterRad * sinoftilt + InnerRad);
+ /* I used code from the book's accnot.c as a starting
+ point for lighting. I have one positional light in
+ center, then one directional */
+ float light0_position[] = { 1.0f, 0.2f, 1.0f, 0.0f };
+ float light1_position[] = { 0.0f, 0.0f, 0.0f, 1.0f };
+ float light1_diffuse[] = { 1.0f, 1.0f, 1.0f, 1.0f };
+ float light1_specular[] = { 1.0f, 1.0f, 1.0f, 1.0f };
+ float lm_ambient[] = { 0.2f, 0.2f, 0.2f, 1.0f };
+
+ gl.glEnable(GL_NORMALIZE);
+ gl.glMatrixMode(GL_PROJECTION);
+ gl.glLoadIdentity();
+ gl.glMatrixMode(GL_MODELVIEW);
+ gl.glLoadIdentity();
+
+ gl.glLightfv(GL_LIGHT0, GL_POSITION, light0_position);
+ gl.glLightfv(GL_LIGHT1, GL_POSITION, light1_position);
+ gl.glLightfv(GL_LIGHT1, GL_DIFFUSE, light1_diffuse);
+ gl.glLightfv(GL_LIGHT1, GL_SPECULAR, light1_specular);
+ gl.glLightf(GL_LIGHT1, GL_LINEAR_ATTENUATION, 0.2f);
+ gl.glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lm_ambient);
+
+ gl.glEnable(GL_LIGHTING);
+ gl.glEnable(GL_LIGHT0);
+ gl.glEnable(GL_LIGHT1);
+
+ gl.glDepthFunc(GL_LESS);
+ gl.glEnable(GL_DEPTH_TEST);
+
+ // Make display lists
+
+ float cone_diffuse[] = { 0.0f, 0.7f, 0.7f, 1.0f };
+ float mat1_ambient[] = { 1.0f, 1.0f, 1.0f, 1.0f };
+ float mat2_ambient[] = { 0.0f, 0.0f, 0.0f, 0.0f };
+ float torus1_diffuse[] = { 0.7f, 0.7f, 0.0f, 1.0f };
+ float torus2_diffuse[] = { 0.3f, 0.0f, 0.0f, 1.0f };
+ float mat1_specular[] = { 1.0f, 1.0f, 1.0f, 1.0f };
+ float mat2_specular[] = { 0.5f, 0.5f, 0.5f, 1.0f };
+
+ gl.glNewList(INNERMAT, GL_COMPILE);
+ gl.glMaterialfv(GL_FRONT, GL_SPECULAR, mat1_specular);
+ gl.glMaterialf(GL_FRONT, GL_SHININESS, 50.0f);
+ gl.glMaterialfv(GL_FRONT, GL_DIFFUSE, torus1_diffuse);
+ gl.glMaterialfv(GL_FRONT, GL_AMBIENT, mat1_ambient);
+ gl.glEndList();
+
+ gl.glNewList(OUTTERMAT, GL_COMPILE);
+ gl.glMaterialfv(GL_FRONT, GL_SPECULAR, mat2_specular);
+ gl.glMaterialf(GL_FRONT, GL_SHININESS, 25.0f);
+ gl.glMaterialfv(GL_FRONT, GL_DIFFUSE, torus2_diffuse);
+ gl.glMaterialfv(GL_FRONT, GL_AMBIENT, mat2_ambient);
+ gl.glEndList();
+
+ gl.glNewList(CONE, GL_COMPILE);
+ gl.glMaterialfv(GL_FRONT, GL_DIFFUSE, cone_diffuse);
+ gl.glPushMatrix();
+ gl.glTranslatef(0, -TransCone, 0);
+ gl.glRotatef(90, 1, 0, 0);
+ glutSolidCone(OutterRad, 10, 8, 8);
+ gl.glPopMatrix();
+ gl.glEndList();
+
+ gl.glNewList(TORUS, GL_COMPILE);
+ gl.glPushMatrix();
+ gl.glRotatef(90, 1, 0, 0);
+ glutSolidTorus(InnerRad, OutterRad, 15, 25);
+ gl.glPopMatrix();
+ gl.glEndList();
+
+ glj.gljCheckGL();
+
+ menu = new PopupMenu("Options");
+ menu.add(MENU_STARTOVER);
+ menu.add(MENU_ZOOM_OUT);
+ menu.add(MENU_START_RINGS);
+ menu.add(MENU_STOP_RINGS);
+ menu.add(MENU_START_FADE);
+ menu.add(MENU_STOP_FADE);
+ menu.addActionListener(this);
+ add(menu);
+
+ addMouseListener(this);
+ }
+
+ public void doCleanup()
+ {
+ System.out.println("destroy(): " + this);
+ removeMouseListener(this);
+ menu.removeActionListener(this);
+ }
+
+ public void reshape(int width, int height)
+ {
+ gl.glViewport(0,0,width,height);
+ }
+
+ public void display()
+ {
+ if (glj.gljMakeCurrent() == false) return;
+
+ Axis += AxisInc;
+
+ if ( (Dist < 15.0f) && (Fade) ) /* start slow */
+ Dist += 0.1f;
+ else if ( (Dist < 800.0f) && (Fade) ) /* don't go back too far */
+ Dist *= 1.005f;
+
+ gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+ gl.glMatrixMode(GL_PROJECTION);
+ gl.glLoadIdentity();
+ gl.glFrustum(-1.0f,1.0f,-1.0f,1.0f,10.0f,1000.0f);
+ glu.gluLookAt(0.0f,0.0f,Dist,0.0f,0.0f,0.0f,0.0f,1.0f,0.0f);
+
+ gl.glMatrixMode(GL_MODELVIEW);
+
+ gl.glCallList(INNERMAT);
+ DrawRings(Axis);
+ gl.glCallList(CONE);
+
+ gl.glCallList(OUTTERMAT);
+ gl.glPushMatrix();
+ gl.glScalef(10, 10, 10);
+ DrawRings(Axis/3.0f);
+ gl.glPopMatrix();
+
+ glj.gljSwap();
+ glj.gljCheckGL();
+ glj.gljFree();
+
+ //if (!isSuspended()) repaint(); // Animate at full speed.
+ }
+
+ // Methods required for the implementation of MouseListener
+ public void mouseEntered(MouseEvent evt)
+ {
+ }
+
+ public void mouseExited(MouseEvent evt)
+ {
+ }
+
+ public void mousePressed(MouseEvent evt)
+ {
+ // If user presses right mouse button within canvas area,
+ // suspend animation and pop up menu.
+ // If menu was already popped up and user presses either
+ // mouse button within canvas area, resume animation
+ // because the menu will have been removed automatically.
+ if (!menu_showing)
+ {
+ if ((evt.getModifiers() & evt.BUTTON3_MASK) != 0)
+ {
+ menu_showing = true;
+ save_suspended = isSuspended();
+ if (!save_suspended)
+ {
+ setSuspended(true);
+ repaint(100);
+ try
+ {
+ Thread.currentThread().sleep(200);
+ }
+ catch (Exception e)
+ { }
+ }
+ menu.show(this,evt.getX(),evt.getY());
+ }
+ }
+ else
+ {
+ menu_showing = false;
+ setSuspended(save_suspended);
+ }
+ }
+
+ public void mouseReleased(MouseEvent evt)
+ {
+ }
+
+ public void mouseClicked(MouseEvent evt)
+ {
+ }
+
+ // Method required for the implementation of ActionListener
+ public void actionPerformed(ActionEvent evt)
+ {
+ String c = evt.getActionCommand();
+ if (c.equals(MENU_STARTOVER))
+ {
+ Dist = 10.0f;
+ Axis = 0.0f;
+ Fade = true;
+ AxisInc = (float)(2.0 * M_PI / STEPS);
+ }
+ else if (c.equals(MENU_ZOOM_OUT))
+ {
+ Dist = 800.0f;
+ }
+ else if (c.equals(MENU_START_RINGS))
+ {
+ AxisInc = (float)(2.0 * M_PI / STEPS);
+ }
+ else if (c.equals(MENU_STOP_RINGS))
+ {
+ AxisInc = 0.0f;
+ }
+ else if (c.equals(MENU_START_FADE))
+ {
+ Fade = true;
+ }
+ else if (c.equals(MENU_STOP_FADE))
+ {
+ Fade = false;
+ }
+ if (menu_showing)
+ {
+ menu_showing = false;
+ setSuspended(save_suspended);
+ }
+ }
+
+ /* Draw three rings, rotated and translate so they look cool */
+ private void DrawRings(float axis)
+ {
+ float x = (float)Math.sin(axis), y = (float)Math.cos(axis);
+ gl.glPushMatrix();
+ gl.glTranslatef(0.0f, Trans, 0.0f);
+ gl.glRotatef(Tilt, x, 0.0f, y);
+ gl.glCallList(TORUS);
+ gl.glPopMatrix();
+ gl.glPushMatrix();
+ gl.glRotatef(-Tilt, x, 0.0f, y);
+ gl.glCallList(TORUS);
+ gl.glPopMatrix();
+ gl.glPushMatrix();
+ gl.glTranslatef(0.0f, -Trans, 0.0f);
+ gl.glRotatef(Tilt, x, 0.0f, y);
+ gl.glCallList(TORUS);
+ gl.glPopMatrix();
+ }
+
+ // Imported from glut.
+ private void glutSolidTorus
+ (float innerRadius,
+ float outerRadius,
+ int nsides,
+ int rings)
+ {
+ doughnut(innerRadius, outerRadius, nsides, rings);
+ }
+
+ // Imported from glut.
+ private void glutSolidCone
+ (float base,
+ float height,
+ int slices,
+ int stacks)
+ {
+ int qobj = glu.gluNewQuadric();
+
+ glu.gluQuadricDrawStyle(qobj,GLU_FILL);
+ glu.gluQuadricNormals(qobj,GLU_SMOOTH);
+ glu.gluCylinder(qobj,base,0.0f,height,slices,stacks);
+ glu.gluDeleteQuadric(qobj);
+ }
+
+ // Imported from glut.
+ private void doughnut(float r, float R, int nsides, int rings)
+ {
+ int i, j;
+ float theta, phi, theta1;
+ float cosTheta, sinTheta;
+ float cosTheta1, sinTheta1;
+ float ringDelta, sideDelta;
+
+ ringDelta = 2.0f * (float)M_PI / rings;
+ sideDelta = 2.0f * (float)M_PI / nsides;
+
+ theta = 0.0f;
+ cosTheta = 1.0f;
+ sinTheta = 0.0f;
+ for (i = rings - 1; i >= 0; i--)
+ {
+ theta1 = theta + ringDelta;
+ cosTheta1 = (float)Math.cos(theta1);
+ sinTheta1 = (float)Math.sin(theta1);
+ gl.glBegin(GL_QUAD_STRIP);
+ phi = 0.0f;
+ for (j = nsides; j >= 0; j--)
+ {
+ float cosPhi, sinPhi, dist;
+
+ phi += sideDelta;
+ cosPhi = (float)Math.cos(phi);
+ sinPhi = (float)Math.sin(phi);
+ dist = R + r * cosPhi;
+
+ gl.glNormal3f(cosTheta1 * cosPhi, -sinTheta1 * cosPhi, sinPhi);
+ gl.glVertex3f(cosTheta1 * dist, -sinTheta1 * dist, r * sinPhi);
+ gl.glNormal3f(cosTheta * cosPhi, -sinTheta * cosPhi, sinPhi);
+ gl.glVertex3f(cosTheta * dist, -sinTheta * dist, r * sinPhi);
+ }
+ gl.glEnd();
+ theta = theta1;
+ cosTheta = cosTheta1;
+ sinTheta = sinTheta1;
+ }
+ }
+ }
+}
diff --git a/demos/RonsDemos/rings_plugin13.html b/demos/RonsDemos/rings_plugin13.html new file mode 100644 index 0000000..48ac24c --- /dev/null +++ b/demos/RonsDemos/rings_plugin13.html @@ -0,0 +1,49 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
+ <title>Rings by Philip Winston; ported to Java by Ron Cemer</title>
+</head>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+Rings applet
+<br>Originially written by Philip Winston
+<br>Ported to Java by Ron Cemer
+<br>Right-click within the window for a menu of commands.
+<br>
+<!--"CONVERTED_APPLET"-->
+<!-- CONVERTER VERSION 1.3 --> +<SCRIPT LANGUAGE="JavaScript"><!-- + var _info = navigator.userAgent; var _ns = false; + var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0); +//--></SCRIPT> +<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!-- + var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0))); +//--></SCRIPT></COMMENT> + +<SCRIPT LANGUAGE="JavaScript"><!-- + if (_ie == true) document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = 400 HEIGHT = 400 codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0"><NOEMBED><XMP>'); + else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.3" CODE = "rings.class" WIDTH = 400 HEIGHT = 400 scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html"><NOEMBED><XMP>'); +//--></SCRIPT> +<APPLET CODE = "rings.class" WIDTH = 400 HEIGHT = 400></XMP> +<PARAM NAME = CODE VALUE = "rings.class" >
+ +<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3"> +<PARAM NAME="scriptable" VALUE="false"> + +</APPLET> + +</NOEMBED></EMBED></OBJECT> + + +<!-- +<APPLET CODE = "rings.class" WIDTH = 400 HEIGHT = 400>
+
+
+</APPLET> +--> +<!--"END_CONVERTED_APPLET"-->
+
+<hr>
+</body>
+</html>
diff --git a/demos/RonsDemos/sappletviewer.bat b/demos/RonsDemos/sappletviewer.bat new file mode 100755 index 0000000..90f7666 --- /dev/null +++ b/demos/RonsDemos/sappletviewer.bat @@ -0,0 +1 @@ +appletviewer.exe -J-Djava.security.policy=gl4java.policy %*
diff --git a/demos/RonsDemos/sappletviewer.sh b/demos/RonsDemos/sappletviewer.sh new file mode 100755 index 0000000..7add0f7 --- /dev/null +++ b/demos/RonsDemos/sappletviewer.sh @@ -0,0 +1,3 @@ +#! /bin/sh + +appletviewer -J-Djava.security.policy=gl4java.policy $* diff --git a/demos/RonsDemos/scube.html b/demos/RonsDemos/scube.html new file mode 100644 index 0000000..b889faf --- /dev/null +++ b/demos/RonsDemos/scube.html @@ -0,0 +1,27 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
+ <title>Scube by David G Yu/Mark J. Kilgard/Silicon Graphics; ported to Java by Ron Cemer</title>
+</head>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+Scube applet
+<br>Originially written by David G Yu/Mark J. Kilgard/Silicon Graphics
+<br>Ported to Java by Ron Cemer
+<br>Click inside the window, then press any of the following keys:
+<br>L/l: toggle lighting
+<br>S/s: toggle SGI logo on/off
+<br>Q/q: toggle between quads and polygons for drawing
+<br>F/f: toggle fog
+<br>1: linear fog mode
+<br>2: exponential fog mode
+<br>3: exponential squared fog mode
+<br>p/P: toggle motion (pause/resume)
+<br>spacebar: single-step while paused
+<br>
+<applet code="scube.class" width=400 height=400>
+</applet>
+<hr>
+</body>
+</html>
diff --git a/demos/RonsDemos/scube.java b/demos/RonsDemos/scube.java new file mode 100644 index 0000000..f06cc4e --- /dev/null +++ b/demos/RonsDemos/scube.java @@ -0,0 +1,590 @@ +/**
+ * @(#) scube.java
+ * @(#) author: David G Yu/Mark J. Kilgard/Silicon Graphics (converted to Java by Ron Cemer)
+ */
+
+/* Copyright (c) Mark J. Kilgard, 1994. */
+
+/**
+ * (c) Copyright 1993, 1994, Silicon Graphics, Inc.
+ * ALL RIGHTS RESERVED
+ * Permission to use, copy, modify, and distribute this software for
+ * any purpose and without fee is hereby granted, provided that the above
+ * copyright notice appear in all copies and that both the copyright notice
+ * and this permission notice appear in supporting documentation, and that
+ * the name of Silicon Graphics, Inc. not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission.
+ *
+ * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
+ * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
+ * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
+ * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
+ * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
+ * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
+ * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
+ * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
+ * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * US Government Users Restricted Rights
+ * Use, duplication, or disclosure by the Government is subject to
+ * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
+ * (c)(1)(ii) of the Rights in Technical Data and Computer Software
+ * clause at DFARS 252.227-7013 and/or in similar or successor
+ * clauses in the FAR or the DOD or NASA FAR Supplement.
+ * Unpublished-- rights reserved under the copyright laws of the
+ * United States. Contractor/manufacturer is Silicon Graphics,
+ * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
+ *
+ * OpenGL(TM) is a trademark of Silicon Graphics, Inc.
+ */
+
+/*
+ * 1992 David G Yu -- Silicon Graphics Computer Systems
+ */
+
+import java.applet.*;
+import java.awt.*;
+import java.awt.event.*;
+import java.lang.*;
+import java.util.*;
+import java.io.*;
+import java.util.*;
+import gl4java.GLContext;
+import gl4java.awt.GLAnimCanvas;
+import gl4java.applet.SimpleGLAnimApplet1;
+
+public class scube extends SimpleGLAnimApplet1
+{
+
+ /* Initialize the applet */
+
+
+ public void init()
+ {
+ super.init();
+ Dimension d = getSize();
+ canvas = new scubeCanvas(d.width, d.height);
+ add("Center", canvas);
+ }
+
+
+ /* Local GLAnimCanvas extension class */
+
+
+ private class scubeCanvas extends GLAnimCanvas
+ implements KeyListener, MouseListener
+ {
+ private static final int
+ GREY=0,RED=1,GREEN=2,BLUE=3,CYAN=4,MAGENTA=5,YELLOW=6,BLACK=7;
+
+ private float materialColor[][] =
+ {
+ {0.8f, 0.8f, 0.8f, 1.0f},
+ {0.8f, 0.0f, 0.0f, 1.0f},
+ {0.0f, 0.8f, 0.0f, 1.0f},
+ {0.0f, 0.0f, 0.8f, 1.0f},
+ {0.0f, 0.8f, 0.8f, 1.0f},
+ {0.8f, 0.0f, 0.8f, 1.0f},
+ {0.8f, 0.8f, 0.0f, 1.0f},
+ {0.0f, 0.0f, 0.0f, 0.6f},
+ };
+
+ private float lightPos[] = {2.0f, 4.0f, 2.0f, 1.0f};
+ private float lightAmb[] = {0.2f, 0.2f, 0.2f, 1.0f};
+ private float lightDiff[] = {0.8f, 0.8f, 0.8f, 1.0f};
+ private float lightSpec[] = {0.4f, 0.4f, 0.4f, 1.0f};
+
+ private float groundPlane[] = {0.0f, 1.0f, 0.0f, 1.499f};
+ private float backPlane[] = {0.0f, 0.0f, 1.0f, 0.899f};
+
+ private float fogColor[] = {0.0f, 0.0f, 0.0f, 0.0f};
+ private float fogIndex[] = {0.0f};
+
+ private byte shadowPattern[] =
+ {
+ (byte)0xaa, (byte)0xaa, (byte)0xaa, (byte)0xaa, (byte)0x55, (byte)0x55, (byte)0x55, (byte)0x55, /* 50% Grey */
+ (byte)0xaa, (byte)0xaa, (byte)0xaa, (byte)0xaa, (byte)0x55, (byte)0x55, (byte)0x55, (byte)0x55,
+ (byte)0xaa, (byte)0xaa, (byte)0xaa, (byte)0xaa, (byte)0x55, (byte)0x55, (byte)0x55, (byte)0x55,
+ (byte)0xaa, (byte)0xaa, (byte)0xaa, (byte)0xaa, (byte)0x55, (byte)0x55, (byte)0x55, (byte)0x55,
+ (byte)0xaa, (byte)0xaa, (byte)0xaa, (byte)0xaa, (byte)0x55, (byte)0x55, (byte)0x55, (byte)0x55,
+ (byte)0xaa, (byte)0xaa, (byte)0xaa, (byte)0xaa, (byte)0x55, (byte)0x55, (byte)0x55, (byte)0x55,
+ (byte)0xaa, (byte)0xaa, (byte)0xaa, (byte)0xaa, (byte)0x55, (byte)0x55, (byte)0x55, (byte)0x55,
+ (byte)0xaa, (byte)0xaa, (byte)0xaa, (byte)0xaa, (byte)0x55, (byte)0x55, (byte)0x55, (byte)0x55,
+ (byte)0xaa, (byte)0xaa, (byte)0xaa, (byte)0xaa, (byte)0x55, (byte)0x55, (byte)0x55, (byte)0x55,
+ (byte)0xaa, (byte)0xaa, (byte)0xaa, (byte)0xaa, (byte)0x55, (byte)0x55, (byte)0x55, (byte)0x55,
+ (byte)0xaa, (byte)0xaa, (byte)0xaa, (byte)0xaa, (byte)0x55, (byte)0x55, (byte)0x55, (byte)0x55,
+ (byte)0xaa, (byte)0xaa, (byte)0xaa, (byte)0xaa, (byte)0x55, (byte)0x55, (byte)0x55, (byte)0x55,
+ (byte)0xaa, (byte)0xaa, (byte)0xaa, (byte)0xaa, (byte)0x55, (byte)0x55, (byte)0x55, (byte)0x55,
+ (byte)0xaa, (byte)0xaa, (byte)0xaa, (byte)0xaa, (byte)0x55, (byte)0x55, (byte)0x55, (byte)0x55,
+ (byte)0xaa, (byte)0xaa, (byte)0xaa, (byte)0xaa, (byte)0x55, (byte)0x55, (byte)0x55, (byte)0x55,
+ (byte)0xaa, (byte)0xaa, (byte)0xaa, (byte)0xaa, (byte)0x55, (byte)0x55, (byte)0x55, (byte)0x55
+ };
+
+ private byte sgiPattern[] =
+ {
+ (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, /* SGI Logo */
+ (byte)0xff, (byte)0xbd, (byte)0xff, (byte)0x83, (byte)0xff, (byte)0x5a, (byte)0xff, (byte)0xef,
+ (byte)0xfe, (byte)0xdb, (byte)0x7f, (byte)0xef, (byte)0xfd, (byte)0xdb, (byte)0xbf, (byte)0xef,
+ (byte)0xfb, (byte)0xdb, (byte)0xdf, (byte)0xef, (byte)0xf7, (byte)0xdb, (byte)0xef, (byte)0xef,
+ (byte)0xfb, (byte)0xdb, (byte)0xdf, (byte)0xef, (byte)0xfd, (byte)0xdb, (byte)0xbf, (byte)0x83,
+ (byte)0xce, (byte)0xdb, (byte)0x73, (byte)0xff, (byte)0xb7, (byte)0x5a, (byte)0xed, (byte)0xff,
+ (byte)0xbb, (byte)0xdb, (byte)0xdd, (byte)0xc7, (byte)0xbd, (byte)0xdb, (byte)0xbd, (byte)0xbb,
+ (byte)0xbe, (byte)0xbd, (byte)0x7d, (byte)0xbb, (byte)0xbf, (byte)0x7e, (byte)0xfd, (byte)0xb3,
+ (byte)0xbe, (byte)0xe7, (byte)0x7d, (byte)0xbf, (byte)0xbd, (byte)0xdb, (byte)0xbd, (byte)0xbf,
+ (byte)0xbb, (byte)0xbd, (byte)0xdd, (byte)0xbb, (byte)0xb7, (byte)0x7e, (byte)0xed, (byte)0xc7,
+ (byte)0xce, (byte)0xdb, (byte)0x73, (byte)0xff, (byte)0xfd, (byte)0xdb, (byte)0xbf, (byte)0xff,
+ (byte)0xfb, (byte)0xdb, (byte)0xdf, (byte)0x87, (byte)0xf7, (byte)0xdb, (byte)0xef, (byte)0xfb,
+ (byte)0xf7, (byte)0xdb, (byte)0xef, (byte)0xfb, (byte)0xfb, (byte)0xdb, (byte)0xdf, (byte)0xfb,
+ (byte)0xfd, (byte)0xdb, (byte)0xbf, (byte)0xc7, (byte)0xfe, (byte)0xdb, (byte)0x7f, (byte)0xbf,
+ (byte)0xff, (byte)0x5a, (byte)0xff, (byte)0xbf, (byte)0xff, (byte)0xbd, (byte)0xff, (byte)0xc3,
+ (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff
+ };
+
+ private float cube_vertexes[][][] =
+ {
+ {
+ {-1.0f, -1.0f, -1.0f, 1.0f},
+ {-1.0f, -1.0f, 1.0f, 1.0f},
+ {-1.0f, 1.0f, 1.0f, 1.0f},
+ {-1.0f, 1.0f, -1.0f, 1.0f}
+ },
+ {
+ {1.0f, 1.0f, 1.0f, 1.0f},
+ {1.0f, -1.0f, 1.0f, 1.0f},
+ {1.0f, -1.0f, -1.0f, 1.0f},
+ {1.0f, 1.0f, -1.0f, 1.0f}
+ },
+ {
+ {-1.0f, -1.0f, -1.0f, 1.0f},
+ {1.0f, -1.0f, -1.0f, 1.0f},
+ {1.0f, -1.0f, 1.0f, 1.0f},
+ {-1.0f, -1.0f, 1.0f, 1.0f}
+ },
+ {
+ {1.0f, 1.0f, 1.0f, 1.0f},
+ {1.0f, 1.0f, -1.0f, 1.0f},
+ {-1.0f, 1.0f, -1.0f, 1.0f},
+ {-1.0f, 1.0f, 1.0f, 1.0f}
+ },
+ {
+ {-1.0f, -1.0f, -1.0f, 1.0f},
+ {-1.0f, 1.0f, -1.0f, 1.0f},
+ {1.0f, 1.0f, -1.0f, 1.0f},
+ {1.0f, -1.0f, -1.0f, 1.0f}
+ },
+ {
+ {1.0f, 1.0f, 1.0f, 1.0f},
+ {-1.0f, 1.0f, 1.0f, 1.0f},
+ {-1.0f, -1.0f, 1.0f, 1.0f},
+ {1.0f, -1.0f, 1.0f, 1.0f}
+ }
+ };
+
+ private float cube_normals[][] =
+ {
+ {-1.0f, 0.0f, 0.0f, 0.0f},
+ {1.0f, 0.0f, 0.0f, 0.0f},
+ {0.0f, -1.0f, 0.0f, 0.0f},
+ {0.0f, 1.0f, 0.0f, 0.0f},
+ {0.0f, 0.0f, -1.0f, 0.0f},
+ {0.0f, 0.0f, 1.0f, 0.0f}
+ };
+
+ private boolean useLighting = true;
+ private boolean useFog = false;
+ private boolean useLogo = false;
+ private boolean useQuads = true;
+ private int tick = -1;
+
+ public scubeCanvas(int w, int h)
+ {
+ super(w, h);
+ GLContext.gljNativeDebug = false;
+ GLContext.gljClassDebug = false;
+ setAnimateFps(30.0);
+ }
+
+ public void preInit()
+ {
+ doubleBuffer = true;
+ stereoView = false;
+ }
+
+ public void init()
+ {
+ System.out.println("init(): " + this);
+ reshape(getSize().width, getSize().height);
+
+ /* setup context */
+ gl.glMatrixMode(GL_PROJECTION);
+ gl.glLoadIdentity();
+ gl.glFrustum(-1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 3.0f);
+
+ gl.glMatrixMode(GL_MODELVIEW);
+ gl.glLoadIdentity();
+ gl.glTranslatef(0.0f, 0.0f, -2.0f);
+
+ gl.glEnable(GL_DEPTH_TEST);
+
+ if (useLighting) gl.glEnable(GL_LIGHTING);
+ gl.glEnable(GL_LIGHT0);
+ gl.glLightfv(GL_LIGHT0, GL_POSITION, lightPos);
+ gl.glLightfv(GL_LIGHT0, GL_AMBIENT, lightAmb);
+ gl.glLightfv(GL_LIGHT0, GL_DIFFUSE, lightDiff);
+ gl.glLightfv(GL_LIGHT0, GL_SPECULAR, lightSpec);
+
+ gl.glEnable(GL_NORMALIZE);
+
+ if (useFog) gl.glEnable(GL_FOG);
+ gl.glFogfv(GL_FOG_COLOR, fogColor);
+ gl.glFogfv(GL_FOG_INDEX, fogIndex);
+ gl.glFogf(GL_FOG_MODE, GL_EXP);
+ gl.glFogf(GL_FOG_DENSITY, 0.5f);
+ gl.glFogf(GL_FOG_START, 1.0f);
+ gl.glFogf(GL_FOG_END, 3.0f);
+
+ gl.glEnable(GL_CULL_FACE);
+ gl.glCullFace(GL_BACK);
+
+ gl.glShadeModel(GL_SMOOTH);
+
+ gl.glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ if (useLogo)
+ gl.glPolygonStipple(sgiPattern);
+ else
+ gl.glPolygonStipple(shadowPattern);
+
+ gl.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
+ gl.glClearIndex(0);
+ gl.glClearDepth(1);
+
+ glj.gljCheckGL();
+
+ addKeyListener(this);
+ addMouseListener(this);
+ }
+
+ public void doCleanup()
+ {
+ System.out.println("destroy(): " + this);
+ removeKeyListener(this);
+ }
+
+ public void reshape(int width, int height)
+ {
+ gl.glViewport(0,0,width,height);
+
+// Put any custom reshape code here.
+
+ }
+
+ public void display()
+ {
+ if (glj.gljMakeCurrent() == false) return;
+
+ if (!isSuspended()) inctick();
+
+ float cubeXform[] = new float[16];
+
+ gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+ gl.glPushMatrix();
+ gl.glTranslatef(0.0f, -1.5f, 0.0f);
+ gl.glRotatef(-90.0f, 1f, 0f, 0f);
+ gl.glScalef(2.0f, 2.0f, 2.0f);
+
+ drawCheck(6, 6, BLUE, YELLOW); /* draw ground */
+ gl.glPopMatrix();
+
+ gl.glPushMatrix();
+ gl.glTranslatef(0.0f, 0.0f, -0.9f);
+ gl.glScalef(2.0f, 2.0f, 2.0f);
+
+ drawCheck(6, 6, BLUE, YELLOW); /* draw back */
+ gl.glPopMatrix();
+
+ gl.glPushMatrix();
+ gl.glTranslatef(0.0f, 0.2f, 0.0f);
+ gl.glScalef(0.3f, 0.3f, 0.3f);
+ gl.glRotatef((360.0f / (30 * 1)) * tick, 1f, 0f, 0f);
+ gl.glRotatef((360.0f / (30 * 2)) * tick, 0f, 1f, 0f);
+ gl.glRotatef((360.0f / (30 * 4)) * tick, 0f, 0f, 1f);
+ gl.glScalef(1.0f, 2.0f, 1.0f);
+ gl.glGetFloatv(GL_MODELVIEW_MATRIX, cubeXform);
+
+ drawCube(RED); /* draw cube */
+ gl.glPopMatrix();
+
+ gl.glDepthMask(false);
+ gl.glEnable(GL_POLYGON_STIPPLE);
+ if (useFog) gl.glDisable(GL_FOG);
+ gl.glPushMatrix();
+ myShadowMatrix(groundPlane, lightPos);
+ gl.glTranslatef(0.0f, 0.0f, 2.0f);
+ gl.glMultMatrixf(cubeXform);
+
+ drawCube(BLACK); /* draw ground shadow */
+ gl.glPopMatrix();
+
+ gl.glPushMatrix();
+ myShadowMatrix(backPlane, lightPos);
+ gl.glTranslatef(0.0f, 0.0f, 2.0f);
+ gl.glMultMatrixf(cubeXform);
+
+ drawCube(BLACK); /* draw back shadow */
+ gl.glPopMatrix();
+
+ gl.glDepthMask(true);
+ gl.glDisable(GL_POLYGON_STIPPLE);
+ if (useFog) gl.glEnable(GL_FOG);
+
+ glj.gljSwap();
+ glj.gljCheckGL();
+ glj.gljFree();
+
+ //if (!isSuspended()) repaint(); // Animate at full speed.
+ }
+
+ // Methods required for the implementation of KeyListener
+ public void keyPressed(KeyEvent e)
+ {
+ }
+
+ public void keyReleased(KeyEvent e)
+ {
+ }
+
+ public void keyTyped(KeyEvent e)
+ {
+ if (glj.gljMakeCurrent() == false) return;
+ boolean dorepaint = false;
+ switch ((char)e.getKeyChar())
+ {
+ case 'L':
+ case 'l':
+ useLighting = !useLighting;
+ if (useLighting)
+ gl.glEnable(GL_LIGHTING);
+ else
+ gl.glDisable(GL_LIGHTING);
+ dorepaint = isSuspended();
+ break;
+ case 'S':
+ case 's':
+ useLogo = !useLogo;
+ if (useLogo)
+ gl.glPolygonStipple(sgiPattern);
+ else
+ gl.glPolygonStipple(shadowPattern);
+ dorepaint = isSuspended();
+ break;
+ case 'Q':
+ case 'q':
+ useQuads = !useQuads;
+ dorepaint = isSuspended();
+ break;
+ case 'F':
+ case 'f':
+ useFog = !useFog;
+ if (useFog)
+ gl.glEnable(GL_FOG);
+ else
+ gl.glDisable(GL_FOG);
+ dorepaint = isSuspended();
+ break;
+ case '1':
+ gl.glFogf(GL_FOG_MODE, GL_LINEAR);
+ dorepaint = isSuspended();
+ break;
+ case '2':
+ gl.glFogf(GL_FOG_MODE, GL_EXP);
+ dorepaint = isSuspended();
+ break;
+ case '3':
+ gl.glFogf(GL_FOG_MODE, GL_EXP2);
+ dorepaint = isSuspended();
+ break;
+ case 'P':
+ case 'p':
+ setSuspended(!isSuspended());
+ break;
+ case ' ':
+ if (isSuspended())
+ {
+ inctick();
+ dorepaint = true;
+ }
+ break;
+ }
+ glj.gljFree();
+ if (dorepaint) repaint();
+ }
+
+ private void inctick()
+ {
+ tick++;
+ if (tick >= 120) tick = 0;
+ }
+
+ private void setColor(int c)
+ {
+ if (useLighting)
+ gl.glMaterialfv
+ (GL_FRONT_AND_BACK,
+ GL_AMBIENT_AND_DIFFUSE,
+ materialColor[c]);
+ else
+ gl.glColor4fv(materialColor[c]);
+ }
+
+ private void drawCube(int color)
+ {
+ setColor(color);
+
+ for (int i = 0; i < 6; ++i)
+ {
+ gl.glNormal3fv(cube_normals[i]);
+ gl.glBegin(GL_POLYGON);
+ gl.glVertex4fv(cube_vertexes[i][0]);
+ gl.glVertex4fv(cube_vertexes[i][1]);
+ gl.glVertex4fv(cube_vertexes[i][2]);
+ gl.glVertex4fv(cube_vertexes[i][3]);
+ gl.glEnd();
+ }
+ }
+
+ private boolean check_initialized = false;
+ private boolean check_usedLighting = false;
+ private boolean check_usedQuads = false;
+ private int checklist = 0;
+
+ private void drawCheck(int w, int h, int evenColor, int oddColor)
+ {
+ if ( (!check_initialized)
+ || (check_usedLighting != useLighting)
+ || (check_usedQuads != useQuads) )
+ {
+ float square_normal[] = {0.0f, 0.0f, 1.0f, 0.0f};
+ float square[][] = new float[4][4];
+ int i, j;
+
+ if (checklist == 0) checklist = gl.glGenLists(1);
+ gl.glNewList(checklist, GL_COMPILE_AND_EXECUTE);
+ if (useQuads)
+ {
+ gl.glNormal3fv(square_normal);
+ gl.glBegin(GL_QUADS);
+ }
+ for (j = 0; j < h; ++j)
+ {
+ for (i = 0; i < w; ++i)
+ {
+ square[0][0] = -1.0f + 2.0f / w * i;
+ square[0][1] = -1.0f + 2.0f / h * (j + 1);
+ square[0][2] = 0.0f;
+ square[0][3] = 1.0f;
+
+ square[1][0] = -1.0f + 2.0f / w * i;
+ square[1][1] = -1.0f + 2.0f / h * j;
+ square[1][2] = 0.0f;
+ square[1][3] = 1.0f;
+
+ square[2][0] = -1.0f + 2.0f / w * (i + 1);
+ square[2][1] = -1.0f + 2.0f / h * j;
+ square[2][2] = 0.0f;
+ square[2][3] = 1.0f;
+
+ square[3][0] = -1.0f + 2.0f / w * (i + 1);
+ square[3][1] = -1.0f + 2.0f / h * (j + 1);
+ square[3][2] = 0.0f;
+ square[3][3] = 1.0f;
+
+ if ( ((i & 1) != 0) ^ ((j & 1) != 0) )
+ setColor(oddColor);
+ else
+ setColor(evenColor);
+
+ if (!useQuads)gl.glBegin(GL_POLYGON);
+ gl.glVertex4fv(square[0]);
+ gl.glVertex4fv(square[1]);
+ gl.glVertex4fv(square[2]);
+ gl.glVertex4fv(square[3]);
+ if (!useQuads) gl.glEnd();
+ }
+ }
+
+ if (useQuads) gl.glEnd();
+ gl.glEndList();
+
+ check_initialized = true;
+ check_usedLighting = useLighting;
+ check_usedQuads = useQuads;
+ }
+ else
+ gl.glCallList(checklist);
+ }
+
+ private void myShadowMatrix(float ground[], float light[])
+ {
+ float dot;
+ float shadowMat[] = new float[4*4];
+
+ dot =
+ ground[0] * light[0] +
+ ground[1] * light[1] +
+ ground[2] * light[2] +
+ ground[3] * light[3];
+
+ shadowMat[0] = dot - light[0] * ground[0];
+ shadowMat[4] = -light[0] * ground[1];
+ shadowMat[8] = -light[0] * ground[2];
+ shadowMat[12] = -light[0] * ground[3];
+
+ shadowMat[1] = -light[1] * ground[0];
+ shadowMat[5] = dot - light[1] * ground[1];
+ shadowMat[9] = -light[1] * ground[2];
+ shadowMat[13] = -light[1] * ground[3];
+
+ shadowMat[2] = -light[2] * ground[0];
+ shadowMat[6] = -light[2] * ground[1];
+ shadowMat[10] = dot - light[2] * ground[2];
+ shadowMat[14] = -light[2] * ground[3];
+
+ shadowMat[3] = -light[3] * ground[0];
+ shadowMat[7] = -light[3] * ground[1];
+ shadowMat[11] = -light[3] * ground[2];
+ shadowMat[15] = dot - light[3] * ground[3];
+
+ gl.glMultMatrixf(shadowMat);
+ }
+
+ // Methods required for the implementation of MouseListener
+ public void mouseEntered( MouseEvent evt )
+ {
+ Component comp = evt.getComponent();
+ if( comp.equals(this ) )
+ {
+ requestFocus();
+ }
+ }
+
+ public void mouseExited( MouseEvent evt )
+ { }
+ public void mousePressed( MouseEvent evt )
+ { }
+ public void mouseReleased( MouseEvent evt )
+ { }
+ public void mouseClicked( MouseEvent evt )
+ {
+ Component comp = evt.getComponent();
+ if( comp.equals(this ) )
+ {
+ requestFocus();
+ }
+ }
+ }
+}
diff --git a/demos/RonsDemos/scube_plugin13.html b/demos/RonsDemos/scube_plugin13.html new file mode 100644 index 0000000..660f48f --- /dev/null +++ b/demos/RonsDemos/scube_plugin13.html @@ -0,0 +1,58 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
+ <title>Scube by David G Yu/Mark J. Kilgard/Silicon Graphics; ported to Java by Ron Cemer</title>
+</head>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+Scube applet
+<br>Originially written by David G Yu/Mark J. Kilgard/Silicon Graphics
+<br>Ported to Java by Ron Cemer
+<br>Click inside the window, then press any of the following keys:
+<br>L/l: toggle lighting
+<br>S/s: toggle SGI logo on/off
+<br>Q/q: toggle between quads and polygons for drawing
+<br>F/f: toggle fog
+<br>1: linear fog mode
+<br>2: exponential fog mode
+<br>3: exponential squared fog mode
+<br>p/P: toggle motion (pause/resume)
+<br>spacebar: single-step while paused
+<br>
+<!--"CONVERTED_APPLET"-->
+<!-- CONVERTER VERSION 1.3 --> +<SCRIPT LANGUAGE="JavaScript"><!-- + var _info = navigator.userAgent; var _ns = false; + var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0); +//--></SCRIPT> +<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!-- + var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0))); +//--></SCRIPT></COMMENT> + +<SCRIPT LANGUAGE="JavaScript"><!-- + if (_ie == true) document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = 400 HEIGHT = 400 codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0"><NOEMBED><XMP>'); + else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.3" CODE = "scube.class" WIDTH = 400 HEIGHT = 400 scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html"><NOEMBED><XMP>'); +//--></SCRIPT> +<APPLET CODE = "scube.class" WIDTH = 400 HEIGHT = 400></XMP> +<PARAM NAME = CODE VALUE = "scube.class" >
+ +<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3"> +<PARAM NAME="scriptable" VALUE="false"> + +</APPLET> + +</NOEMBED></EMBED></OBJECT> + + +<!-- +<APPLET CODE = "scube.class" WIDTH = 400 HEIGHT = 400>
+
+
+</APPLET> +--> +<!--"END_CONVERTED_APPLET"-->
+
+<hr>
+</body>
+</html>
diff --git a/demos/RonsDemos/shadowvol.html b/demos/RonsDemos/shadowvol.html new file mode 100644 index 0000000..e709826 --- /dev/null +++ b/demos/RonsDemos/shadowvol.html @@ -0,0 +1,18 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
+ <title>Shadowvol by Tom McReynolds, SGI; ported to Java by Ron Cemer</title>
+</head>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+Shadowvol applet
+<br>Originially written by Tom McReynolds, SGI
+<br>Ported to Java by Ron Cemer
+<br>Click inside the window to cycle the shadow and lighting mode.
+<br>
+<applet code="shadowvol.class" width=400 height=400>
+</applet>
+<hr>
+</body>
+</html>
diff --git a/demos/RonsDemos/shadowvol.java b/demos/RonsDemos/shadowvol.java new file mode 100644 index 0000000..f40f20b --- /dev/null +++ b/demos/RonsDemos/shadowvol.java @@ -0,0 +1,458 @@ +/**
+ * @(#) shadowvol.java
+ * @(#) author: Tom McReynolds, SGI (converted to Java by Ron Cemer)
+ */
+
+/* Shadows: Shadow maps */
+/* Demonstrate shadow volumes */
+
+import java.applet.*;
+import java.awt.*;
+import java.awt.event.*;
+import java.lang.*;
+import java.util.*;
+import java.io.*;
+import java.util.*;
+import gl4java.GLContext;
+import gl4java.awt.GLCanvas;
+
+public class shadowvol extends Applet
+{
+ private static final int SPHERE = 1, CONE = 2, LIGHT = 3, SHADOWVOL = 4;
+ private static final int X = 0, Y = 1, Z = 2;
+ private static final int NONE = 0, NOLIGHT = 1, VOLUME = 2, SHADOW = 3;
+ private static final int TEXDIM = 256;
+
+ shadowvolCanvas canvas = null;
+
+
+ /* Initialize the applet */
+
+
+ public void init()
+ {
+ Dimension d = getSize();
+ setLayout(new BorderLayout());
+ canvas = new shadowvolCanvas(d.width, d.height);
+ add("Center", canvas);
+ }
+
+
+ /* Start the applet */
+
+
+ public void start()
+ {
+ }
+
+
+ /* Stop the applet */
+
+
+ public void stop()
+ {
+ }
+
+
+ /* Destroy the applet */
+
+
+ public void destroy()
+ {
+ canvas.cvsDispose();
+ }
+
+ private class ShadObj
+ {
+ float[] vertices;
+ float[] normal;
+ int n;
+ }
+
+
+ /* Local GLCanvas extension class */
+
+
+ private class shadowvolCanvas extends GLCanvas implements MouseListener
+ {
+ private float shadVerts[] =
+ {
+ 30.0f, 30.0f, -350.0f,
+ 60.0f, 20.0f, -340.0f,
+ 40.0f, 40.0f, -400.0f
+ };
+ private float shadNormal[] =
+ {
+ 1.0f, 10.f, 1.0f
+ };
+ private float leftwallshadow[] = new float[16];
+ private float floorshadow[] = new float[16];
+ private float lightpos[] = { 50.0f, 50.0f, -340.0f, 1.0f };
+ private ShadObj shadower = new ShadObj();
+ private int rendermode = SHADOW;
+
+ public shadowvolCanvas(int w, int h)
+ {
+ super(w, h);
+ GLContext.gljNativeDebug = false;
+ GLContext.gljClassDebug = false;
+ }
+
+ public void preInit()
+ {
+ doubleBuffer = true;
+ stereoView = false;
+ stencilBits = 3;
+ }
+
+ public void init()
+ {
+ System.out.println("init(): " + this);
+ reshape(getSize().width, getSize().height);
+
+ byte tex[];
+ int sphere, cone, base;
+ float sphere_mat[] = {1.0f, 0.5f, 0.0f, 1.0f};
+ float cone_mat[] = {0.0f, 0.5f, 1.0f, 1.0f};
+
+ /* turn on features */
+ gl.glEnable(GL_DEPTH_TEST);
+ gl.glEnable(GL_LIGHTING);
+ gl.glEnable(GL_LIGHT0);
+ gl.glEnable(GL_CULL_FACE);
+
+ /* place light 0 in the right place */
+ gl.glLightfv(GL_LIGHT0, GL_POSITION, lightpos);
+
+ /* remove back faces to speed things up */
+ gl.glCullFace(GL_BACK);
+
+ gl.glTexParameteri
+ (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+
+ /* make display lists for sphere and cone; for efficiency */
+
+ gl.glNewList(SPHERE, GL_COMPILE);
+ sphere = glu.gluNewQuadric();
+ gl.glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, sphere_mat);
+ glu.gluSphere(sphere, 20.0f, 20, 20);
+ glu.gluDeleteQuadric(sphere);
+ gl.glEndList();
+
+ gl.glNewList(CONE, GL_COMPILE);
+ cone = glu.gluNewQuadric();
+ base = glu.gluNewQuadric();
+ gl.glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, cone_mat);
+ gl.glRotatef(-90.0f, 1.0f, 0.0f, 0.0f);
+ glu.gluDisk(base, 0., 20., 20, 1);
+ glu.gluCylinder(cone, 20., 0., 60., 20, 20);
+ glu.gluDeleteQuadric(cone);
+ glu.gluDeleteQuadric(base);
+ gl.glEndList();
+
+ gl.glNewList(LIGHT, GL_COMPILE);
+ sphere = glu.gluNewQuadric();
+ gl.glPushMatrix();
+ gl.glTranslatef(lightpos[X], lightpos[Y], lightpos[Z]);
+ gl.glDisable(GL_LIGHTING);
+ gl.glColor3f(0.9f, 0.9f, 0.6f);
+ glu.gluSphere(sphere, 5.0f, 20, 20);
+ gl.glEnable(GL_LIGHTING);
+ gl.glPopMatrix();
+ glu.gluDeleteQuadric(sphere);
+ gl.glEndList();
+
+ /* load pattern for current 2d texture */
+ tex = make_texture(TEXDIM, TEXDIM);
+ gl.glTexImage2D
+ (GL_TEXTURE_2D,
+ 0,
+ 1,
+ TEXDIM,
+ TEXDIM,
+ 0,
+ GL_RED,
+ GL_UNSIGNED_BYTE,
+ tex);
+ tex = null;
+
+ shadower.vertices = shadVerts;
+ shadower.normal = shadNormal;
+ shadower.n = shadVerts.length/3;
+
+ makeShadowVolume(shadower, lightpos, 10.f, SHADOWVOL);
+
+ glj.gljCheckGL();
+
+ addMouseListener(this);
+ }
+
+ public void cvsDispose()
+ {
+ System.out.println("destroy(): " + this);
+ removeMouseListener(this);
+ super.cvsDispose();
+ }
+
+ public void reshape(int width, int height)
+ {
+ gl.glViewport(0,0,width,height);
+ /* draw a perspective scene */
+ gl.glMatrixMode(GL_PROJECTION);
+ gl.glFrustum(-100.0f, 100.0f, -100.0f, 100.0f, 320.0f, 640.0f);
+ gl.glMatrixMode(GL_MODELVIEW);
+ }
+
+ public void display()
+ {
+ if (glj.gljMakeCurrent() == false) return;
+
+
+
+
+ gl.glClear
+ (GL_COLOR_BUFFER_BIT |
+ GL_DEPTH_BUFFER_BIT |
+ GL_STENCIL_BUFFER_BIT);
+ switch (rendermode)
+ {
+ case NONE:
+ render(shadower);
+ break;
+ case NOLIGHT:
+ gl.glDisable(GL_LIGHT0);
+ render(shadower);
+ gl.glEnable(GL_LIGHT0);
+ break;
+ case VOLUME:
+ render(shadower);
+ gl.glCallList(SHADOWVOL);
+ break;
+ case SHADOW:
+ gl.glColorMask(false, false, false, false);
+ render(shadower); /* render scene in depth buffer */
+ gl.glEnable(GL_STENCIL_TEST);
+ gl.glDepthMask(false);
+ gl.glStencilFunc(GL_ALWAYS, 0, 0);
+ gl.glStencilOp(GL_KEEP, GL_KEEP, GL_INCR);
+ gl.glCullFace(GL_BACK); /* increment using front face of shadow volume */
+ gl.glCallList(SHADOWVOL);
+ gl.glStencilOp(GL_KEEP, GL_KEEP, GL_DECR);
+ gl.glCullFace(GL_FRONT); /* increment using front face of shadow volume */
+ gl.glCallList(SHADOWVOL);
+ gl.glDepthMask(true);
+ gl.glColorMask(true, true, true, true);
+ gl.glCullFace(GL_BACK);
+ gl.glDepthFunc(GL_LEQUAL);
+ gl.glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
+ gl.glStencilFunc(GL_EQUAL, 1, 1); /* draw shadowed part */
+ gl.glDisable(GL_LIGHT0);
+ render(shadower);
+ gl.glStencilFunc(GL_EQUAL, 0, 1); /* draw lit part */
+ gl.glEnable(GL_LIGHT0);
+ render(shadower);
+ gl.glDepthFunc(GL_LESS);
+ gl.glDisable(GL_STENCIL_TEST);
+ break;
+ }
+
+ glj.gljSwap();
+ glj.gljCheckGL();
+ glj.gljFree();
+ }
+
+ // Methods required for the implementation of MouseListener
+ public void mouseEntered( MouseEvent evt )
+ {
+ }
+
+ public void mouseExited( MouseEvent evt )
+ {
+ }
+
+ public void mousePressed( MouseEvent evt )
+ {
+ rendermode++;
+ if (rendermode > SHADOW) rendermode = NONE;
+ repaint();
+ }
+
+ public void mouseReleased( MouseEvent evt )
+ {
+ }
+
+ public void mouseClicked( MouseEvent evt )
+ {
+ }
+
+ private byte[] make_texture(int maxs, int maxt)
+ {
+ byte texture[] = new byte[maxs*maxt];
+ for (int t = 0; t < maxt; t++)
+ {
+ for (int s = 0; s < maxs; s++)
+ {
+ texture[s + maxs * t] =
+ ( (((s >> 4) & 0x1) != 0) ^ (((t >> 4) & 0x1) != 0) ) ?
+ (byte)0xff :
+ (byte)0;
+ }
+ }
+ return texture;
+ }
+
+ /* simple way to extend a point to build shadow volume */
+ private void extend(float newvertex[], float light[], float vertex[], float t)
+ {
+ float delta[] = new float[3];
+
+ delta[X] = vertex[X] - light[X];
+ delta[Y] = vertex[Y] - light[Y];
+ delta[Z] = vertex[Z] - light[Z];
+
+ newvertex[X] = light[X] + delta[X] * t;
+ newvertex[Y] = light[Y] + delta[Y] * t;
+ newvertex[Z] = light[Z] + delta[Z] * t;
+ }
+
+ /* Create a shadow volume in a display list */
+ /* XXX light should have 4 compoents */
+ void makeShadowVolume(ShadObj shadower, float light[], float t, int dlist)
+ {
+ float v[] = new float[3], newv[] = new float[3];
+ int j;
+
+ gl.glNewList(dlist, GL_COMPILE);
+ gl.glDisable(GL_LIGHTING);
+ gl.glBegin(GL_QUADS);
+ /* for debugging */
+ gl.glColor3f(0.2f, 0.8f, 0.4f);
+ for (int i = 0; i < shadower.n; i++)
+ {
+ j = ((i + 1) % shadower.n);
+ v[0] = shadower.vertices[i * 3];
+ v[1] = shadower.vertices[(i * 3) + 1];
+ v[2] = shadower.vertices[(i * 3) + 2];
+ gl.glVertex3fv(v);
+ extend(newv, light, v, t);
+ gl.glVertex3fv(newv);
+ v[0] = shadower.vertices[j * 3];
+ v[1] = shadower.vertices[(j * 3) + 1];
+ v[2] = shadower.vertices[(j * 3) + 2];
+ extend(newv, light, v, t);
+ gl.glVertex3fv(newv);
+ gl.glVertex3fv(v);
+ }
+ gl.glEnd();
+ gl.glEnable(GL_LIGHTING);
+ gl.glEndList();
+ }
+
+ private void sphere()
+ {
+ gl.glPushMatrix();
+ gl.glTranslatef(60.0f, -50.0f, -360.0f);
+ gl.glCallList(SPHERE);
+ gl.glPopMatrix();
+ }
+
+ private void cone()
+ {
+ gl.glPushMatrix();
+ gl.glTranslatef(-40.0f, -40.0f, -400.0f);
+ gl.glCallList(CONE);
+ gl.glPopMatrix();
+ }
+
+ /* render while jittering the shadows */
+ private void render(ShadObj obj)
+ {
+ float shad_mat[] = {10.f, 0.1f, 0.1f, 1.0f};
+ float v[] = new float[3];
+ /* material properties for objects in scene */
+ float wall_mat[] = {1.0f, 1.0f, 1.0f, 1.0f};
+ /* Note: wall vertices are ordered so they are all
+ front facing this lets me do back face culling to
+ speed things up. */
+
+ gl.glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, wall_mat);
+
+ /* floor */
+ /* make the floor textured */
+ gl.glEnable(GL_TEXTURE_2D);
+
+ /* Since we want to turn texturing on for floor only, we have
+ to make floor a separate glBegin()/glEnd() sequence. You
+ can't turn texturing on and off between begin and end calls */
+ gl.glBegin(GL_QUADS);
+ gl.glNormal3f(0.0f, 1.0f, 0.0f);
+ gl.glTexCoord2i(0, 0);
+ gl.glVertex3f(-100.0f, -100.0f, -320.0f);
+ gl.glTexCoord2i(1, 0);
+ gl.glVertex3f(100.0f, -100.0f, -320.0f);
+ gl.glTexCoord2i(1, 1);
+ gl.glVertex3f(100.0f, -100.0f, -520.0f);
+ gl.glTexCoord2i(0, 1);
+ gl.glVertex3f(-100.0f, -100.0f, -520.0f);
+ gl.glEnd();
+
+ gl.glDisable(GL_TEXTURE_2D);
+
+ /* walls */
+
+ gl.glBegin(GL_QUADS);
+ /* left wall */
+ gl.glNormal3f(1.0f, 0.0f, 0.0f);
+ gl.glVertex3f(-100.0f, -100.0f, -320.0f);
+ gl.glVertex3f(-100.0f, -100.0f, -520.0f);
+ gl.glVertex3f(-100.0f, 100.0f, -520.0f);
+ gl.glVertex3f(-100.0f, 100.0f, -320.0f);
+
+ /* right wall */
+ gl.glNormal3f(-1.0f, 0.0f, 0.0f);
+ gl.glVertex3f(100.0f, -100.0f, -320.0f);
+ gl.glVertex3f(100.0f, 100.0f, -320.0f);
+ gl.glVertex3f(100.0f, 100.0f, -520.0f);
+ gl.glVertex3f(100.0f, -100.0f, -520.0f);
+
+ /* ceiling */
+ gl.glNormal3f(0.0f, -1.0f, 0.0f);
+ gl.glVertex3f(-100.0f, 100.0f, -320.0f);
+ gl.glVertex3f(-100.0f, 100.0f, -520.0f);
+ gl.glVertex3f(100.0f, 100.0f, -520.0f);
+ gl.glVertex3f(100.0f, 100.0f, -320.0f);
+
+ /* back wall */
+ gl.glNormal3f(0.0f, 0.0f, 1.0f);
+ gl.glVertex3f(-100.0f, -100.0f, -520.0f);
+ gl.glVertex3f(100.0f, -100.0f, -520.0f);
+ gl.glVertex3f(100.0f, 100.0f, -520.0f);
+ gl.glVertex3f(-100.0f, 100.0f, -520.0f);
+
+ gl.glEnd();
+
+ cone();
+
+ sphere();
+
+ gl.glCallList(LIGHT);
+
+ /* draw shadowing object */
+ gl.glMaterialfv
+ (GL_FRONT_AND_BACK,
+ GL_AMBIENT_AND_DIFFUSE,
+ shad_mat);
+ gl.glBegin(GL_POLYGON);
+ gl.glNormal3fv(obj.normal);
+ for (int i = 0; i < obj.n; i++)
+ {
+ int j = i * 3;
+ v[0] = obj.vertices[j];
+ v[1] = obj.vertices[j+1];
+ v[2] = obj.vertices[j+2];
+ gl.glVertex3fv(v);
+ }
+ gl.glEnd();
+ }
+ }
+}
diff --git a/demos/RonsDemos/shadowvol_plugin13.html b/demos/RonsDemos/shadowvol_plugin13.html new file mode 100644 index 0000000..ed62530 --- /dev/null +++ b/demos/RonsDemos/shadowvol_plugin13.html @@ -0,0 +1,49 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
+ <title>Shadowvol by Tom McReynolds, SGI; ported to Java by Ron Cemer</title>
+</head>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+Shadowvol applet
+<br>Originially written by Tom McReynolds, SGI
+<br>Ported to Java by Ron Cemer
+<br>Click inside the window to cycle the shadow and lighting mode.
+<br>
+<!--"CONVERTED_APPLET"-->
+<!-- CONVERTER VERSION 1.3 --> +<SCRIPT LANGUAGE="JavaScript"><!-- + var _info = navigator.userAgent; var _ns = false; + var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0); +//--></SCRIPT> +<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!-- + var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0))); +//--></SCRIPT></COMMENT> + +<SCRIPT LANGUAGE="JavaScript"><!-- + if (_ie == true) document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = 400 HEIGHT = 400 codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0"><NOEMBED><XMP>'); + else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.3" CODE = "shadowvol.class" WIDTH = 400 HEIGHT = 400 scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html"><NOEMBED><XMP>'); +//--></SCRIPT> +<APPLET CODE = "shadowvol.class" WIDTH = 400 HEIGHT = 400></XMP> +<PARAM NAME = CODE VALUE = "shadowvol.class" >
+ +<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3"> +<PARAM NAME="scriptable" VALUE="false"> + +</APPLET> + +</NOEMBED></EMBED></OBJECT> + + +<!-- +<APPLET CODE = "shadowvol.class" WIDTH = 400 HEIGHT = 400>
+
+
+</APPLET> +--> +<!--"END_CONVERTED_APPLET"-->
+
+<hr>
+</body>
+</html>
diff --git a/demos/RonsDemos/softshadow.html b/demos/RonsDemos/softshadow.html new file mode 100644 index 0000000..be13230 --- /dev/null +++ b/demos/RonsDemos/softshadow.html @@ -0,0 +1,19 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
+ <title>Softshadow by Tom McReynolds, SGI; ported to Java by Ron Cemer</title>
+</head>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+Softshadow applet
+<br>Originially written by Tom McReynolds, SGI
+<br>Ported to Java by Ron Cemer
+<br>Click inside the window to enable/disable shadows.
+<br>NOTE: WHEN SHADOWS ARE ENABLED, IT MAY TAKE A FEW SECONDS TO DRAW THE SCENE.
+<br>
+<applet code="softshadow.class" width=400 height=400>
+</applet>
+<hr>
+</body>
+</html>
diff --git a/demos/RonsDemos/softshadow.java b/demos/RonsDemos/softshadow.java new file mode 100644 index 0000000..0d9e8ef --- /dev/null +++ b/demos/RonsDemos/softshadow.java @@ -0,0 +1,528 @@ +/**
+ * @(#) softshadow.java
+ * @(#) author: Tom McReynolds, SGI (converted to Java by Ron Cemer)
+ */
+
+/* Using the accumulation buffer for soft shadows. */
+/* Demonstrate the use of accumulation buffer to create soft shadows */
+
+import java.applet.*;
+import java.awt.*;
+import java.awt.event.*;
+import java.lang.*;
+import java.util.*;
+import java.io.*;
+import java.util.*;
+import gl4java.GLContext;
+import gl4java.awt.GLCanvas;
+
+public class softshadow extends Applet
+{
+ private static final int SPHERE=1, CONE=2, LIGHT=3, LEFTWALL=4, FLOOR=5;
+ private static final int X = 0, Y = 1, Z = 2;
+ private static final int A = 0, B = 1, C = 2, D = 3;
+ private static final int NONE = 0, SHADOW = 1;
+ private static final int TEXDIM = 256;
+
+ softshadowCanvas canvas = null;
+
+
+ /* Initialize the applet */
+
+
+ public void init()
+ {
+ Dimension d = getSize();
+ setLayout(new BorderLayout());
+ canvas = new softshadowCanvas(d.width, d.height);
+ add("Center", canvas);
+ }
+
+
+ /* Start the applet */
+
+
+ public void start()
+ {
+ }
+
+
+ /* Stop the applet */
+
+
+ public void stop()
+ {
+ }
+
+
+ /* Destroy the applet */
+
+
+ private class ShadObj
+ {
+ float[] vertices;
+ float[] normal;
+ int n;
+ }
+
+
+ /* Local GLCanvas extension class */
+
+
+ private class softshadowCanvas extends GLCanvas implements MouseListener
+ {
+ private float leftwallshadow[] = new float[16];
+ private float floorshadow[] = new float[16];
+ private float lightpos[] = { 50.0f, 50.0f, -320.0f, 1.0f };
+ private int rendermode = SHADOW;
+
+ public softshadowCanvas(int w, int h)
+ {
+ super(w, h);
+ GLContext.gljNativeDebug = false;
+ GLContext.gljClassDebug = false;
+ }
+
+ public void preInit()
+ {
+ doubleBuffer = true;
+ stereoView = false;
+ stencilBits = 3;
+ accumSize = 8;
+ }
+
+ public void init()
+ {
+ System.out.println("init(): " + this);
+ reshape(getSize().width, getSize().height);
+
+ /* turn on features */
+ gl.glEnable(GL_DEPTH_TEST);
+ gl.glEnable(GL_LIGHTING);
+ gl.glEnable(GL_LIGHT0);
+
+ /* make shadow matricies */
+
+ float v0[] = new float[3];
+ float v1[] = new float[3];
+ float v2[] = new float[3];
+
+ /* 3 points on floor */
+ v0[X] = -100.0f;
+ v0[Y] = -100.0f;
+ v0[Z] = -320.0f;
+ v1[X] = 100.0f;
+ v1[Y] = -100.0f;
+ v1[Z] = -320.0f;
+ v2[X] = 100.0f;
+ v2[Y] = -100.0f;
+ v2[Z] = -520.0f;
+
+ float plane[] = new float[4];
+ findplane(plane, v0, v1, v2);
+ shadowmatrix(floorshadow, plane, lightpos);
+
+ /* 3 points on left wall */
+ v0[X] = -100.0f;
+ v0[Y] = -100.0f;
+ v0[Z] = -320.0f;
+ v1[X] = -100.0f;
+ v1[Y] = -100.0f;
+ v1[Z] = -520.0f;
+ v2[X] = -100.0f;
+ v2[Y] = 100.0f;
+ v2[Z] = -520.0f;
+
+ findplane(plane, v0, v1, v2);
+ shadowmatrix(leftwallshadow, plane, lightpos);
+
+ /* place light 0 in the right place */
+ gl.glLightfv(GL_LIGHT0, GL_POSITION, lightpos);
+
+ /* remove back faces to speed things up */
+ gl.glCullFace(GL_BACK);
+
+ gl.glTexParameteri
+ (GL_TEXTURE_2D,
+ GL_TEXTURE_MIN_FILTER,
+ GL_NEAREST);
+
+ /* make display lists for sphere and cone; for efficiency */
+
+ int sphere, cone, base;
+
+ gl.glNewList(SPHERE, GL_COMPILE);
+ sphere = glu.gluNewQuadric();
+ glu.gluSphere(sphere, 20.f, 20, 20);
+ glu.gluDeleteQuadric(sphere);
+ gl.glEndList();
+
+ gl.glNewList(LIGHT, GL_COMPILE);
+ sphere = glu.gluNewQuadric();
+ glu.gluSphere(sphere, 5.f, 20, 20);
+ glu.gluDeleteQuadric(sphere);
+ gl.glEndList();
+
+ gl.glNewList(CONE, GL_COMPILE);
+ cone = glu.gluNewQuadric();
+ base = glu.gluNewQuadric();
+ gl.glRotatef(-90.f, 1.f, 0.f, 0.f);
+ glu.gluDisk(base, 0., 20., 20, 1);
+ glu.gluCylinder(cone, 20., 0., 60., 20, 20);
+ glu.gluDeleteQuadric(cone);
+ glu.gluDeleteQuadric(base);
+ gl.glEndList();
+
+ gl.glNewList(FLOOR, GL_COMPILE);
+ gl.glEndList();
+
+ gl.glNewList(LEFTWALL, GL_COMPILE);
+ gl.glEndList();
+
+ byte tex[] = make_texture(TEXDIM, TEXDIM);
+ gl.glTexImage2D
+ (GL_TEXTURE_2D,
+ 0,
+ 1,
+ TEXDIM,
+ TEXDIM,
+ 0,
+ GL_RED,
+ GL_UNSIGNED_BYTE,
+ tex);
+ tex = null;
+
+ glj.gljCheckGL();
+
+ addMouseListener(this);
+ }
+
+ public void cvsDispose()
+ {
+ System.out.println("destroy(): " + this);
+ removeMouseListener(this);
+ super.cvsDispose();
+ }
+
+ public void reshape(int width, int height)
+ {
+ gl.glViewport(0,0,width,height);
+ /* draw a perspective scene */
+ gl.glMatrixMode(GL_PROJECTION);
+ gl.glFrustum(-100.0f, 100.0f, -100.0f, 100.0f, 320.0f, 640.0f);
+ gl.glMatrixMode(GL_MODELVIEW);
+ }
+
+ public void display()
+ {
+ if (glj.gljMakeCurrent() == false) return;
+
+
+ int dx, dy, dz;
+
+ dy = 0;
+ /* jitter the light around */
+ if (rendermode == SHADOW)
+ {
+ gl.glClear(GL_ACCUM_BUFFER_BIT);
+ for (dz = -4; dz < 5; dz += 2)
+ {
+ for (dx = -4; dx < 5; dx += 2)
+ {
+ render((float)dx, (float)dy, (float)dz);
+ gl.glAccum(GL_ACCUM, 1.0f / 25.0f);
+ }
+ }
+ gl.glAccum(GL_RETURN, 1.0f);
+ }
+ else
+ render(0.0f, 0.0f, 0.0f);
+
+ glj.gljSwap();
+ glj.gljCheckGL();
+ glj.gljFree();
+ }
+
+ // Methods required for the implementation of MouseListener
+ public void mouseEntered( MouseEvent evt )
+ {
+ }
+
+ public void mouseExited( MouseEvent evt )
+ {
+ }
+
+ public void mousePressed( MouseEvent evt )
+ {
+ rendermode++;
+ if (rendermode > SHADOW) rendermode = NONE;
+ repaint();
+ }
+
+ public void mouseReleased( MouseEvent evt )
+ {
+ }
+
+ public void mouseClicked( MouseEvent evt )
+ {
+ }
+
+ private byte[] make_texture(int maxs, int maxt)
+ {
+ byte texture[] = new byte[maxs*maxt];
+ for (int t = 0; t < maxt; t++)
+ {
+ for (int s = 0; s < maxs; s++)
+ {
+ texture[s + maxs * t] =
+ ( (((s >> 4) & 0x1) != 0) ^ (((t >> 4) & 0x1) != 0) ) ?
+ (byte)0xff :
+ (byte)0;
+ }
+ }
+ return texture;
+ }
+
+ /* create a matrix that will project the desired shadow */
+ void shadowmatrix(float shadowMat[], float groundplane[], float lightpos[])
+ {
+ float dot;
+
+ /* find dot product between light position vector
+ and ground plane normal */
+ dot =
+ groundplane[0] * lightpos[0] +
+ groundplane[1] * lightpos[1] +
+ groundplane[2] * lightpos[2] +
+ groundplane[3] * lightpos[3];
+
+ shadowMat[0] = dot - lightpos[0] * groundplane[0];
+ shadowMat[4] = -lightpos[0] * groundplane[1];
+ shadowMat[8] = -lightpos[0] * groundplane[2];
+ shadowMat[12] = -lightpos[0] * groundplane[3];
+
+ shadowMat[1] = -lightpos[1] * groundplane[0];
+ shadowMat[5] = dot - lightpos[1] * groundplane[1];
+ shadowMat[9] = -lightpos[1] * groundplane[2];
+ shadowMat[13] = -lightpos[1] * groundplane[3];
+
+ shadowMat[2] = -lightpos[2] * groundplane[0];
+ shadowMat[6] = -lightpos[2] * groundplane[1];
+ shadowMat[10] = dot - lightpos[2] * groundplane[2];
+ shadowMat[14] = -lightpos[2] * groundplane[3];
+
+ shadowMat[3] = -lightpos[3] * groundplane[0];
+ shadowMat[7] = -lightpos[3] * groundplane[1];
+ shadowMat[11] = -lightpos[3] * groundplane[2];
+ shadowMat[15] = dot - lightpos[3] * groundplane[3];
+ }
+
+ /* find the plane equation given 3 points */
+ void findplane(float plane[], float v0[], float v1[], float v2[])
+ {
+ float vec0[] = new float[3], vec1[] = new float[3];
+
+ /* need 2 vectors to find cross product */
+ vec0[X] = v1[X] - v0[X];
+ vec0[Y] = v1[Y] - v0[Y];
+ vec0[Z] = v1[Z] - v0[Z];
+
+ vec1[X] = v2[X] - v0[X];
+ vec1[Y] = v2[Y] - v0[Y];
+ vec1[Z] = v2[Z] - v0[Z];
+
+ /* find cross product to get A, B, and C of plane equation */
+ plane[A] = vec0[Y] * vec1[Z] - vec0[Z] * vec1[Y];
+ plane[B] = -(vec0[X] * vec1[Z] - vec0[Z] * vec1[X]);
+ plane[C] = vec0[X] * vec1[Y] - vec0[Y] * vec1[X];
+ plane[D] = -(plane[A]*v0[X] + plane[B]*v0[Y] + plane[C]*v0[Z]);
+ }
+
+ private void sphere()
+ {
+ gl.glPushMatrix();
+ gl.glTranslatef(60.0f, -50.0f, -360.0f);
+ gl.glCallList(SPHERE);
+ gl.glPopMatrix();
+ }
+
+ private void cone()
+ {
+ gl.glPushMatrix();
+ gl.glTranslatef(-40.0f, -40.0f, -400.0f);
+ gl.glCallList(CONE);
+ gl.glPopMatrix();
+ }
+
+ /* render while jittering the shadows */
+ private void render(float dx, float dy, float dz)
+ {
+ float v[] = new float[3];
+ /* material properties for objects in scene */
+ float wall_mat[] = {1.0f, 1.0f, 1.0f, 1.0f};
+ float sphere_mat[] = {1.0f, 0.5f, 0.0f, 1.0f};
+ float cone_mat[] = {0.0f, 0.5f, 1.0f, 1.0f};
+
+ gl.glClear
+ (GL_DEPTH_BUFFER_BIT |
+ GL_COLOR_BUFFER_BIT |
+ GL_STENCIL_BUFFER_BIT);
+
+ /* Note: wall vertices are ordered so they are all
+ front facing this lets me do back face culling to
+ speed things up. */
+
+ gl.glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, wall_mat);
+
+ /* floor */
+ /* make the floor textured */
+ gl.glEnable(GL_TEXTURE_2D);
+
+ /* Since we want to turn texturing on for floor only, we have
+ to make floor a separate glBegin()/glEnd() sequence. You
+ can't turn texturing on and off between begin and end calls */
+ gl.glBegin(GL_QUADS);
+ gl.glNormal3f(0.0f, 1.0f, 0.0f);
+ gl.glTexCoord2i(0, 0);
+ gl.glVertex3f(-100.0f, -100.0f, -320.0f);
+ gl.glTexCoord2i(1, 0);
+ gl.glVertex3f(100.0f, -100.0f, -320.0f);
+ gl.glTexCoord2i(1, 1);
+ gl.glVertex3f(100.0f, -100.0f, -520.0f);
+ gl.glTexCoord2i(0, 1);
+ gl.glVertex3f(-100.0f, -100.0f, -520.0f);
+ gl.glEnd();
+
+ gl.glDisable(GL_TEXTURE_2D);
+
+
+
+ if (rendermode == SHADOW)
+ {
+ gl.glDisable(GL_DEPTH_TEST);
+ gl.glDisable(GL_LIGHTING);
+ gl.glColor3f(0.f, 0.f, 0.f); /* shadow color */
+
+ gl.glPushMatrix();
+ gl.glMultMatrixf(floorshadow);
+ gl.glTranslatef(dx, dy, dz);
+ cone();
+ gl.glPopMatrix();
+
+ gl.glPushMatrix();
+ gl.glMultMatrixf(floorshadow);
+ gl.glTranslatef(dx, dy, dz);
+ sphere();
+ gl.glPopMatrix();
+ gl.glEnable(GL_DEPTH_TEST);
+ gl.glEnable(GL_LIGHTING);
+ }
+
+
+ /* walls */
+
+ if (rendermode == SHADOW)
+ {
+ gl.glEnable(GL_STENCIL_TEST);
+ gl.glStencilFunc(GL_ALWAYS, 1, 0);
+ gl.glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
+ }
+ /* left wall */
+ gl.glBegin(GL_QUADS);
+ gl.glNormal3f(1.0f, 0.0f, 0.0f);
+ gl.glVertex3f(-100.0f, -100.0f, -320.0f);
+ gl.glVertex3f(-100.0f, -100.0f, -520.0f);
+ gl.glVertex3f(-100.0f, 100.0f, -520.0f);
+ gl.glVertex3f(-100.0f, 100.0f, -320.0f);
+ gl.glEnd();
+
+ if (rendermode == SHADOW)
+ {
+ gl.glStencilFunc(GL_EQUAL, 1, 1);
+ gl.glDisable(GL_DEPTH_TEST);
+ gl.glDisable(GL_LIGHTING);
+ gl.glColor3f(0.0f, 0.0f, 0.0f); /* shadow color */
+ gl.glDisable(GL_DEPTH_TEST);
+ gl.glPushMatrix();
+ gl.glMultMatrixf(leftwallshadow);
+ gl.glTranslatef(dx, dy, dz);
+ cone();
+ gl.glPopMatrix();
+ gl.glEnable(GL_DEPTH_TEST);
+ gl.glDisable(GL_STENCIL_TEST);
+ gl.glEnable(GL_DEPTH_TEST);
+ gl.glEnable(GL_LIGHTING);
+ }
+
+ gl.glBegin(GL_QUADS);
+
+ /* right wall */
+ gl.glNormal3f(-1.0f, 0.0f, 0.0f);
+ gl.glVertex3f(100.0f, -100.0f, -320.0f);
+ gl.glVertex3f(100.0f, 100.0f, -320.0f);
+ gl.glVertex3f(100.0f, 100.0f, -520.0f);
+ gl.glVertex3f(100.0f, -100.0f, -520.0f);
+
+ /* ceiling */
+ gl.glNormal3f(0.0f, -1.0f, 0.0f);
+ gl.glVertex3f(-100.0f, 100.0f, -320.0f);
+ gl.glVertex3f(-100.0f, 100.0f, -520.0f);
+ gl.glVertex3f(100.0f, 100.0f, -520.0f);
+ gl.glVertex3f(100.0f, 100.0f, -320.0f);
+
+ /* back wall */
+ gl.glNormal3f(0.0f, 0.0f, 1.0f);
+ gl.glVertex3f(-100.0f, -100.0f, -520.0f);
+ gl.glVertex3f(100.0f, -100.0f, -520.0f);
+ gl.glVertex3f(100.0f, 100.0f, -520.0f);
+ gl.glVertex3f(-100.0f, 100.0f, -520.0f);
+
+ gl.glEnd();
+
+ gl.glPushMatrix();
+ gl.glTranslatef(lightpos[X], lightpos[Y], lightpos[Z]);
+ gl.glDisable(GL_LIGHTING);
+ gl.glColor3f(1.0f, 1.0f, 0.7f);
+ gl.glCallList(LIGHT);
+ gl.glEnable(GL_LIGHTING);
+ gl.glPopMatrix();
+
+ gl.glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, cone_mat);
+ cone();
+
+ gl.glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, sphere_mat);
+ sphere();
+ }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ /* simple way to extend a point to build shadow volume */
+ private void extend(float newvertex[], float light[], float vertex[], float t)
+ {
+ float delta[] = new float[3];
+
+ delta[X] = vertex[X] - light[X];
+ delta[Y] = vertex[Y] - light[Y];
+ delta[Z] = vertex[Z] - light[Z];
+
+ newvertex[X] = light[X] + delta[X] * t;
+ newvertex[Y] = light[Y] + delta[Y] * t;
+ newvertex[Z] = light[Z] + delta[Z] * t;
+ }
+
+ }
+}
diff --git a/demos/RonsDemos/softshadow_plugin13.html b/demos/RonsDemos/softshadow_plugin13.html new file mode 100644 index 0000000..48eb0d3 --- /dev/null +++ b/demos/RonsDemos/softshadow_plugin13.html @@ -0,0 +1,50 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
+ <title>Softshadow by Tom McReynolds, SGI; ported to Java by Ron Cemer</title>
+</head>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+Softshadow applet
+<br>Originially written by Tom McReynolds, SGI
+<br>Ported to Java by Ron Cemer
+<br>Click inside the window to enable/disable shadows.
+<br>NOTE: WHEN SHADOWS ARE ENABLED, IT MAY TAKE A FEW SECONDS TO DRAW THE SCENE.
+<br>
+<!--"CONVERTED_APPLET"-->
+<!-- CONVERTER VERSION 1.3 --> +<SCRIPT LANGUAGE="JavaScript"><!-- + var _info = navigator.userAgent; var _ns = false; + var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0); +//--></SCRIPT> +<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!-- + var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0))); +//--></SCRIPT></COMMENT> + +<SCRIPT LANGUAGE="JavaScript"><!-- + if (_ie == true) document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = 400 HEIGHT = 400 codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0"><NOEMBED><XMP>'); + else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.3" CODE = "softshadow.class" WIDTH = 400 HEIGHT = 400 scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html"><NOEMBED><XMP>'); +//--></SCRIPT> +<APPLET CODE = "softshadow.class" WIDTH = 400 HEIGHT = 400></XMP> +<PARAM NAME = CODE VALUE = "softshadow.class" >
+ +<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3"> +<PARAM NAME="scriptable" VALUE="false"> + +</APPLET> + +</NOEMBED></EMBED></OBJECT> + + +<!-- +<APPLET CODE = "softshadow.class" WIDTH = 400 HEIGHT = 400>
+
+
+</APPLET> +--> +<!--"END_CONVERTED_APPLET"-->
+
+<hr>
+</body>
+</html>
diff --git a/demos/RonsDemos/spots.html b/demos/RonsDemos/spots.html new file mode 100644 index 0000000..cd61548 --- /dev/null +++ b/demos/RonsDemos/spots.html @@ -0,0 +1,17 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
+ <title>Spots by Mark J. Kilgard; ported to Java by Ron Cemer</title>
+</head>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+Spots applet
+<br>Originially written by Mark J. Kilgard
+<br>Ported to Java by Ron Cemer
+<br>
+<applet code="spots.class" width=400 height=400>
+</applet>
+<hr>
+</body>
+</html>
diff --git a/demos/RonsDemos/spots.java b/demos/RonsDemos/spots.java new file mode 100644 index 0000000..60a1813 --- /dev/null +++ b/demos/RonsDemos/spots.java @@ -0,0 +1,384 @@ +/**
+ * @(#) [place applet name here].java
+ * @(#) author: [place author here] (converted to Java by Ron Cemer)
+ */
+
+/* Copyright (c) Mark J. Kilgard, 1994. */
+
+/**
+ * (c) Copyright 1993, 1994, Silicon Graphics, Inc.
+ * ALL RIGHTS RESERVED
+ * Permission to use, copy, modify, and distribute this software for
+ * any purpose and without fee is hereby granted, provided that the above
+ * copyright notice appear in all copies and that both the copyright notice
+ * and this permission notice appear in supporting documentation, and that
+ * the name of Silicon Graphics, Inc. not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission.
+ *
+ * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
+ * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
+ * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
+ * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
+ * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
+ * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
+ * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
+ * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
+ * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * US Government Users Restricted Rights
+ * Use, duplication, or disclosure by the Government is subject to
+ * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
+ * (c)(1)(ii) of the Rights in Technical Data and Computer Software
+ * clause at DFARS 252.227-7013 and/or in similar or successor
+ * clauses in the FAR or the DOD or NASA FAR Supplement.
+ * Unpublished-- rights reserved under the copyright laws of the
+ * United States. Contractor/manufacturer is Silicon Graphics,
+ * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
+ *
+ * OpenGL(TM) is a trademark of Silicon Graphics, Inc.
+ */
+
+import java.applet.*;
+import java.awt.*;
+import java.awt.event.*;
+import java.lang.*;
+import java.util.*;
+import java.io.*;
+import java.util.*;
+import gl4java.GLContext;
+import gl4java.awt.GLAnimCanvas;
+import gl4java.applet.SimpleGLAnimApplet1;
+
+public class spots extends SimpleGLAnimApplet1
+{
+ /* Initialize the applet */
+
+
+ public void init()
+ {
+ super.init();
+ Dimension d = getSize();
+ canvas = new spotsCanvas(d.width, d.height);
+ add("Center", canvas);
+ }
+
+
+ private class Light
+ {
+ public float amb[] = new float[4];
+ public float diff[] = new float[4];
+ public float spec[] = new float[4];
+ public float pos[] = new float[4];
+ public float spotDir[] = new float[3];
+ public float spotExp;
+ public float spotCutoff;
+ public float atten[] = new float[3];
+ public float trans[] = new float[3];
+ public float rot[] = new float[3];
+ public float swing[] = new float[3];
+ public float arc[] = new float[3];
+ public float arcIncr[] = new float[3];
+
+ public Light
+ (float ambr, float ambg, float ambb, float amba,
+ float diffr, float diffg, float diffb, float diffa,
+ float specr, float specg, float specb, float speca,
+ float posx, float posy, float posz, float posw,
+ float dirx, float diry, float dirz,
+ float exp,
+ float cutoff,
+ float attenr, float atteng, float attenb,
+ float transx, float transy, float transz,
+ float rotx, float roty, float rotz,
+ float swingx, float swingy, float swingz,
+ float arcx, float arcy, float arcz,
+ float arcincrx, float arcincry, float arcincrz)
+ {
+ amb[0] = ambr;
+ amb[1] = ambg;
+ amb[2] = ambb;
+ amb[3] = amba;
+ diff[0] = diffr;
+ diff[1] = diffg;
+ diff[2] = diffb;
+ diff[3] = diffa;
+ spec[0] = specr;
+ spec[1] = specg;
+ spec[2] = specb;
+ spec[3] = speca;
+ pos[0] = posx;
+ pos[1] = posy;
+ pos[2] = posz;
+ pos[3] = posw;
+ spotDir[0] = dirx;
+ spotDir[1] = diry;
+ spotDir[2] = dirz;
+ spotExp = exp;
+ spotCutoff = cutoff;
+ atten[0] = attenr;
+ atten[1] = atteng;
+ atten[2] = attenb;
+ trans[0] = transx;
+ trans[1] = transy;
+ trans[2] = transz;
+ rot[0] = rotx;
+ rot[1] = roty;
+ rot[2] = rotz;
+ swing[0] = swingx;
+ swing[1] = swingy;
+ swing[2] = swingz;
+ arc[0] = arcx;
+ arc[1] = arcy;
+ arc[2] = arcz;
+ arcIncr[0] = arcincrx;
+ arcIncr[1] = arcincry;
+ arcIncr[2] = arcincrz;
+ }
+ }
+
+
+ /* Local GLAnimCanvas extension class */
+
+
+ private class spotsCanvas extends GLAnimCanvas
+ {
+ private final double M_PI = 3.14159265;
+ private final double TWO_PI = (2.0*M_PI);
+ private final int NUM_LIGHTS = 3;
+
+ private boolean useSAME_AMB_SPEC = true;
+ private float modelAmb[] = {0.2f, 0.2f, 0.2f, 1.0f};
+ private float matAmb[] = {0.2f, 0.2f, 0.2f, 1.0f};
+ private float matDiff[] = {0.8f, 0.8f, 0.8f, 1.0f};
+ private float matSpec[] = {0.4f, 0.4f, 0.4f, 1.0f};
+ private float matEmission[] = {0.0f, 0.0f, 0.0f, 1.0f};
+ private Light[] spots =
+ {
+ new Light
+ (0.2f, 0.0f, 0.0f, 1.0f, /* ambient */
+ 0.8f, 0.0f, 0.0f, 1.0f, /* diffuse */
+ 0.4f, 0.0f, 0.0f, 1.0f, /* specular */
+ 0.0f, 0.0f, 0.0f, 1.0f, /* position */
+ 0.0f, -1.0f, 0.0f, /* direction */
+ 20.0f,
+ 60.0f, /* exponent, cutoff */
+ 1.0f, 0.0f, 0.0f, /* attenuation */
+ 0.0f, 1.25f, 0.0f, /* translation */
+ 0.0f, 0.0f, 0.0f, /* rotation */
+ 20.0f, 0.0f, 40.0f, /* swing */
+ 0.0f, 0.0f, 0.0f, /* arc */
+ (float)(TWO_PI / 70.0), 0.0f, (float)(TWO_PI / 140.0)), /* arc increment */
+ new Light
+ (0.0f, 0.2f, 0.0f, 1.0f, /* ambient */
+ 0.0f, 0.8f, 0.0f, 1.0f, /* diffuse */
+ 0.0f, 0.4f, 0.0f, 1.0f, /* specular */
+ 0.0f, 0.0f, 0.0f, 1.0f, /* position */
+ 0.0f, -1.0f, 0.0f, /* direction */
+ 20.0f,
+ 60.0f, /* exponent, cutoff */
+ 1.0f, 0.0f, 0.0f, /* attenuation */
+ 0.0f, 1.25f, 0.0f, /* translation */
+ 0.0f, 0.0f, 0.0f, /* rotation */
+ 20.0f, 0.0f, 40.0f, /* swing */
+ 0.0f, 0.0f, 0.0f, /* arc */
+ (float)(TWO_PI / 120.0), 0.0f, (float)(TWO_PI / 60.0)), /* arc increment */
+ new Light
+ (0.0f, 0.0f, 0.2f, 1.0f, /* ambient */
+ 0.0f, 0.0f, 0.8f, 1.0f, /* diffuse */
+ 0.0f, 0.0f, 0.4f, 1.0f, /* specular */
+ 0.0f, 0.0f, 0.0f, 1.0f, /* position */
+ 0.0f, -1.0f, 0.0f, /* direction */
+ 20.0f,
+ 60.0f, /* exponent, cutoff */
+ 1.0f, 0.0f, 0.0f, /* attenuation */
+ 0.0f, 1.25f, 0.0f, /* translation */
+ 0.0f, 0.0f, 0.0f, /* rotation */
+ 20.0f, 0.0f, 40.0f, /* swing */
+ 0.0f, 0.0f, 0.0f, /* arc */
+ (float)(TWO_PI / 50.0), 0.0f, (float)(TWO_PI / 100.0)), /* arc increment */
+ };
+ float spin = 0.0f;
+
+ public spotsCanvas(int w, int h)
+ {
+ super(w, h);
+ GLContext.gljNativeDebug = false;
+ GLContext.gljClassDebug = false;
+ setAnimateFps(30.0);
+ }
+
+ public void preInit()
+ {
+ doubleBuffer = true;
+ stereoView = false;
+ }
+
+ public void init()
+ {
+ System.out.println("init(): " + this);
+ reshape(getSize().width, getSize().height);
+
+ gl.glMatrixMode(GL_PROJECTION);
+ gl.glFrustum(-1.0f, 1.0f, -1.0f, 1.0f, 2.0f, 6.0f);
+
+ gl.glMatrixMode(GL_MODELVIEW);
+ gl.glTranslatef(0.0f, 0.0f, -3.0f);
+ gl.glRotatef(45.0f, 1.0f, 0.0f, 0.0f);
+
+ gl.glEnable(GL_LIGHTING);
+ gl.glEnable(GL_NORMALIZE);
+
+ gl.glLightModelfv(GL_LIGHT_MODEL_AMBIENT, modelAmb);
+ gl.glLightModelf(GL_LIGHT_MODEL_LOCAL_VIEWER, 1.0f);
+ gl.glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, 0.0f);
+
+ gl.glMaterialfv(GL_FRONT, GL_AMBIENT, matAmb);
+ gl.glMaterialfv(GL_FRONT, GL_DIFFUSE, matDiff);
+ gl.glMaterialfv(GL_FRONT, GL_SPECULAR, matSpec);
+ gl.glMaterialfv(GL_FRONT, GL_EMISSION, matEmission);
+ gl.glMaterialf(GL_FRONT, GL_SHININESS, 10.0f);
+
+ initLights();
+
+ glj.gljCheckGL();
+ }
+
+ public void reshape(int width, int height)
+ {
+ gl.glViewport(0,0,width,height);
+ }
+
+ public void display()
+ {
+ if (glj.gljMakeCurrent() == false) return;
+
+ spin += 0.5f;
+ if (spin > 360.0f) spin -= 360.0f;
+
+ gl.glClear(GL_COLOR_BUFFER_BIT);
+
+ gl.glPushMatrix();
+ gl.glRotatef(spin, 0.0f, 1.0f, 0.0f);
+
+ aimLights();
+ setLights();
+
+ gl.glPushMatrix();
+ gl.glRotatef(-90.0f, 1.0f, 0.0f, 0.0f);
+ gl.glScalef(1.9f, 1.9f, 1.0f);
+ gl.glTranslatef(-0.5f, -0.5f, 0.0f);
+ drawPlane(16, 16);
+ gl.glPopMatrix();
+
+ drawLights();
+ gl.glPopMatrix();
+
+ glj.gljSwap();
+ glj.gljCheckGL();
+ glj.gljFree();
+
+ //if (!isSuspended()) repaint(); // Animate at full speed.
+ }
+
+ private void initLights()
+ {
+ for (int k = 0; k < NUM_LIGHTS; ++k)
+ {
+ int lt = GL_LIGHT0 + k;
+ Light light = spots[k];
+ gl.glEnable(lt);
+ gl.glLightfv(lt, GL_AMBIENT, light.amb);
+ gl.glLightfv(lt, GL_DIFFUSE, light.diff);
+ if (useSAME_AMB_SPEC)
+ gl.glLightfv(lt, GL_SPECULAR, light.amb);
+ else
+ gl.glLightfv(lt, GL_SPECULAR, light.spec);
+ gl.glLightf(lt, GL_SPOT_EXPONENT, light.spotExp);
+ gl.glLightf(lt, GL_SPOT_CUTOFF, light.spotCutoff);
+ gl.glLightf(lt, GL_CONSTANT_ATTENUATION, light.atten[0]);
+ gl.glLightf(lt, GL_LINEAR_ATTENUATION, light.atten[1]);
+ gl.glLightf(lt, GL_QUADRATIC_ATTENUATION, light.atten[2]);
+ }
+ }
+
+ private void aimLights()
+ {
+ for (int k = 0; k < NUM_LIGHTS; ++k)
+ {
+ Light light = spots[k];
+ light.rot[0] = light.swing[0] * (float)Math.sin(light.arc[0]);
+ light.arc[0] += light.arcIncr[0];
+ if (light.arc[0] > TWO_PI)
+ light.arc[0] -= TWO_PI;
+ light.rot[1] = light.swing[1] * (float)Math.sin(light.arc[1]);
+ light.arc[1] += light.arcIncr[1];
+ if (light.arc[1] > TWO_PI)
+ light.arc[1] -= TWO_PI;
+ light.rot[2] = light.swing[2] * (float)Math.sin(light.arc[2]);
+ light.arc[2] += light.arcIncr[2];
+ if (light.arc[2] > TWO_PI)
+ light.arc[2] -= TWO_PI;
+ }
+ }
+
+ private void setLights()
+ {
+ for (int k = 0; k < NUM_LIGHTS; ++k)
+ {
+ int lt = GL_LIGHT0 + k;
+ Light light = spots[k];
+ gl.glPushMatrix();
+ gl.glTranslatef(light.trans[0], light.trans[1], light.trans[2]);
+ gl.glRotatef(light.rot[0], 1, 0, 0);
+ gl.glRotatef(light.rot[1], 0, 1, 0);
+ gl.glRotatef(light.rot[2], 0, 0, 1);
+ gl.glLightfv(lt, GL_POSITION, light.pos);
+ gl.glLightfv(lt, GL_SPOT_DIRECTION, light.spotDir);
+ gl.glPopMatrix();
+ }
+ }
+
+ private void drawLights()
+ {
+ gl.glDisable(GL_LIGHTING);
+ for (int k = 0; k < NUM_LIGHTS; ++k)
+ {
+ Light light = spots[k];
+ gl.glColor4fv(light.diff);
+ gl.glPushMatrix();
+ gl.glTranslatef(light.trans[0], light.trans[1], light.trans[2]);
+ gl.glRotatef(light.rot[0], 1, 0, 0);
+ gl.glRotatef(light.rot[1], 0, 1, 0);
+ gl.glRotatef(light.rot[2], 0, 0, 1);
+ gl.glBegin(GL_LINES);
+ gl.glVertex3f(light.pos[0], light.pos[1], light.pos[2]);
+ gl.glVertex3f(light.spotDir[0], light.spotDir[1], light.spotDir[2]);
+ gl.glEnd();
+ gl.glPopMatrix();
+ }
+ gl.glEnable(GL_LIGHTING);
+ }
+
+ private void drawPlane(int w, int h)
+ {
+ int i, j;
+ float dw = 1.0f / (float)w;
+ float dh = 1.0f / (float)h;
+ gl.glNormal3f(0.0f, 0.0f, 1.0f);
+ for (j = 0; j < h; ++j)
+ {
+ gl.glBegin(GL_TRIANGLE_STRIP);
+ for (i = 0; i <= w; ++i)
+ {
+ gl.glVertex2f(dw * i, dh * (j + 1));
+ gl.glVertex2f(dw * i, dh * j);
+ }
+ gl.glEnd();
+ }
+ }
+ }
+}
diff --git a/demos/RonsDemos/spots_plugin13.html b/demos/RonsDemos/spots_plugin13.html new file mode 100644 index 0000000..c5cfb39 --- /dev/null +++ b/demos/RonsDemos/spots_plugin13.html @@ -0,0 +1,48 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
+ <title>Spots by Mark J. Kilgard; ported to Java by Ron Cemer</title>
+</head>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+Spots applet
+<br>Originially written by Mark J. Kilgard
+<br>Ported to Java by Ron Cemer
+<br>
+<!--"CONVERTED_APPLET"-->
+<!-- CONVERTER VERSION 1.3 --> +<SCRIPT LANGUAGE="JavaScript"><!-- + var _info = navigator.userAgent; var _ns = false; + var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0); +//--></SCRIPT> +<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!-- + var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0))); +//--></SCRIPT></COMMENT> + +<SCRIPT LANGUAGE="JavaScript"><!-- + if (_ie == true) document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = 400 HEIGHT = 400 codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0"><NOEMBED><XMP>'); + else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.3" CODE = "spots.class" WIDTH = 400 HEIGHT = 400 scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html"><NOEMBED><XMP>'); +//--></SCRIPT> +<APPLET CODE = "spots.class" WIDTH = 400 HEIGHT = 400></XMP> +<PARAM NAME = CODE VALUE = "spots.class" >
+ +<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3"> +<PARAM NAME="scriptable" VALUE="false"> + +</APPLET> + +</NOEMBED></EMBED></OBJECT> + + +<!-- +<APPLET CODE = "spots.class" WIDTH = 400 HEIGHT = 400>
+
+
+</APPLET> +--> +<!--"END_CONVERTED_APPLET"-->
+
+<hr>
+</body>
+</html>
diff --git a/demos/RonsDemos/star.html b/demos/RonsDemos/star.html new file mode 100644 index 0000000..7ab40ee --- /dev/null +++ b/demos/RonsDemos/star.html @@ -0,0 +1,22 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
+ <title>Star by Silicon Graphics; ported to Java by Ron Cemer</title>
+</head>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+Star applet
+<br>Originially written by Silicon Graphics
+<br>Ported to Java by Ron Cemer
+<br>
+<hr>By clicking inside the window, you can change the behavior of the
+<br>stars. There are two modes: normal and "weird". Each time
+you
+<br>click inside the window, the current mode will change.
+<br>
+<applet code="star.class" width=400 height=400>
+</applet>
+<hr>
+</body>
+</html>
diff --git a/demos/RonsDemos/star.java b/demos/RonsDemos/star.java new file mode 100644 index 0000000..3017b51 --- /dev/null +++ b/demos/RonsDemos/star.java @@ -0,0 +1,349 @@ +/**
+ * @(#) star.java
+ * @(#) author: Silicon Graphics (converted to Java by Ron Cemer)
+ */
+
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+import java.applet.*;
+import java.awt.*;
+import java.awt.event.*;
+import java.lang.*;
+import java.util.*;
+import java.io.*;
+import java.util.*;
+import gl4java.GLContext;
+import gl4java.awt.GLAnimCanvas;
+import gl4java.applet.SimpleGLAnimApplet1;
+
+public class star extends SimpleGLAnimApplet1
+{
+ /* Initialize the applet */
+
+
+ public void init()
+ {
+ super.init();
+ Dimension d = getSize();
+ canvas = new starCanvas(d.width, d.height);
+ add("Center", canvas);
+ }
+
+
+ /* Local GLAnimCanvas extension class */
+
+
+ private class starCanvas extends GLAnimCanvas implements MouseListener
+ {
+ private static final float M_PI = 3.14159265359f;
+ private static final int NORMAL = 0, WEIRD = 1;
+ private static final int STREAK = 0, CIRCLE = 1;
+ private static final int MAXSTARS = 400;
+ private static final int MAXPOS = 10000;
+ private static final int MAXWARP = 10;
+ private static final int MAXANGLES = 6000;
+ private int windW, windH;
+ private int flag = NORMAL;
+ private int starCount = MAXSTARS / 2;
+ private float speed = 1.0f;
+ private int nitro = 0;
+ private starRec stars[];
+ private float sinTable[];
+ private Random rand = null;
+
+ private class starRec
+ {
+ protected int type;
+ protected float x[], y[], z[];
+ protected float offsetX, offsetY, offsetR, rotation;
+
+ public starRec()
+ {
+ x = new float[2];
+ y = new float[2];
+ z = new float[2];
+ }
+ }
+
+ public starCanvas(int w, int h)
+ {
+ super(w, h);
+ GLContext.gljNativeDebug = false;
+ GLContext.gljClassDebug = false;
+ setAnimateFps(30.0);
+
+ stars = new starRec[MAXSTARS];
+ sinTable = new float[MAXANGLES];
+ }
+
+ public void preInit()
+ {
+ doubleBuffer = true;
+ stereoView = false;
+ }
+
+ public void init()
+ {
+ System.out.println("init(): " + this);
+ reshape(getSize().width, getSize().height);
+
+ Date dt = new Date();
+ rand = new Random(dt.getTime());
+
+ int n;
+ for (n = 0; n < MAXSTARS; n++)
+ NewStar(n, 100);
+ float angle = 0.0f;
+ for (n = 0; n < MAXANGLES ; n++)
+ {
+ sinTable[n] = (float)Math.sin(angle);
+ angle += M_PI / (MAXANGLES / 2.0f);
+ }
+ gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
+ gl.glDisable(GL_DITHER);
+
+ glj.gljCheckGL();
+
+ addMouseListener(this);
+ }
+
+ public void doCleanup()
+ {
+ System.out.println("destroy(): " + this);
+ removeMouseListener(this);
+ }
+
+ public void reshape(int width, int height)
+ {
+ windW = width;
+ windH = height;
+
+ gl.glViewport(0,0,width,height);
+ gl.glMatrixMode(GL_PROJECTION);
+ gl.glLoadIdentity();
+ glu.gluOrtho2D(-0.5,(double)width+0.5,-0.5,(double)height+0.5);
+ gl.glMatrixMode(GL_MODELVIEW);
+ }
+
+ public void display()
+ {
+ if (glj.gljMakeCurrent() == false) return;
+
+ MoveStars();
+ ShowStars();
+ if (nitro > 0)
+ {
+ speed = (float)(nitro / 10) + 1.0f;
+ if (speed > MAXWARP) speed = MAXWARP;
+ if (++nitro > MAXWARP*10) nitro = -nitro;
+ }
+ else if (nitro < 0)
+ {
+ nitro++;
+ speed = (float)(-nitro / 10) + 1.0f;
+ if (speed > MAXWARP) speed = MAXWARP;
+ }
+
+ glj.gljSwap();
+ glj.gljCheckGL();
+ glj.gljFree();
+
+ //if (!isSuspended()) repaint(); // Animate at full speed.
+ }
+
+ private float Sin(float angle)
+ {
+ int ang;
+ ang = (int)angle;
+ while (ang < 0) ang += MAXANGLES;
+ while (ang >= MAXANGLES) ang -= MAXANGLES;
+ return (sinTable[ang]);
+ }
+
+ private float Cos(float angle)
+ {
+ return Sin(angle+(((float)MAXANGLES)*0.25f));
+ }
+
+ private void NewStar(int n, int d)
+ {
+ stars[n] = new starRec();
+ if (rand.nextInt() % 4 == 0)
+ stars[n].type = CIRCLE;
+ else
+ stars[n].type = STREAK;
+ stars[n].x[0] = (float)(rand.nextInt() % MAXPOS - MAXPOS / 2);
+ stars[n].y[0] = (float)(rand.nextInt() % MAXPOS - MAXPOS / 2);
+ stars[n].z[0] = (float)(rand.nextInt() % MAXPOS + d);
+ if ( (rand.nextInt() % 4 == 0) && (flag == WEIRD) )
+ {
+ stars[n].offsetX = (float)(rand.nextInt() % 100 - 100 / 2);
+ stars[n].offsetY = (float)(rand.nextInt() % 100 - 100 / 2);
+ stars[n].offsetR = (float)(rand.nextInt() % 25 - 25 / 2);
+ }
+ else
+ {
+ stars[n].offsetX = 0.0f;
+ stars[n].offsetY = 0.0f;
+ stars[n].offsetR = 0.0f;
+ }
+ }
+
+ private void RotatePoint(float[] x, float[] y, float rotation)
+ {
+ float tmpX, tmpY;
+
+ tmpX = x[0] * Cos(rotation) - y[0] * Sin(rotation);
+ tmpY = y[0] * Cos(rotation) + x[0] * Sin(rotation);
+ x[0] = tmpX;
+ y[0] = tmpY;
+ }
+
+ private void MoveStars()
+ {
+ float offset;
+ int n;
+
+ offset = speed * 60.0f;
+
+ for (n = 0; n < starCount; n++)
+ {
+ stars[n].x[1] = stars[n].x[0];
+ stars[n].y[1] = stars[n].y[0];
+ stars[n].z[1] = stars[n].z[0];
+ stars[n].x[0] += stars[n].offsetX;
+ stars[n].y[0] += stars[n].offsetY;
+ stars[n].z[0] -= offset;
+ int rot = (int)(stars[n].rotation = stars[n].offsetR);
+ while (rot < 0) rot += MAXANGLES;
+ while (rot >= MAXANGLES) rot -= MAXANGLES;
+ stars[n].rotation = (float)rot;
+ }
+ }
+
+ private boolean StarPoint(int n)
+ {
+ float x0, y0, x1, y1, width;
+ float xbuf[] = new float[1], ybuf[] = new float[1];
+ int i;
+
+ x0 = stars[n].x[0] * windW / stars[n].z[0];
+ y0 = stars[n].y[0] * windH / stars[n].z[0];
+ xbuf[0] = x0;
+ ybuf[0] = y0;
+ RotatePoint(xbuf, ybuf, stars[n].rotation);
+ x0 = xbuf[0];
+ y0 = ybuf[0];
+ x0 += windW / 2.0f;
+ y0 += windH / 2.0f;
+
+ if ( (x0 >= 0.0f) && (x0 < windW) && (y0 >= 0.0f) && (y0 < windH) )
+ {
+ if (stars[n].type == STREAK)
+ {
+ x1 = stars[n].x[1] * windW / stars[n].z[1];
+ y1 = stars[n].y[1] * windH / stars[n].z[1];
+ xbuf[0] = x1;
+ ybuf[0] = y1;
+ RotatePoint(xbuf, ybuf, stars[n].rotation);
+ x1 = xbuf[0];
+ y1 = ybuf[0];
+ x1 += windW / 2.0f;
+ y1 += windH / 2.0f;
+
+ gl.glLineWidth(MAXPOS/100.0f/stars[n].z[0]+1.0f);
+ gl.glColor3f(1.0f, (MAXWARP-speed)/MAXWARP, (MAXWARP-speed)/MAXWARP);
+ if (Math.abs(x0-x1) < 1.0f && Math.abs(y0-y1) < 1.0f)
+ {
+ gl.glBegin(GL_POINTS);
+ gl.glVertex2f(x0, y0);
+ gl.glEnd();
+ }
+ else
+ {
+ gl.glBegin(GL_LINES);
+ gl.glVertex2f(x0, y0);
+ gl.glVertex2f(x1, y1);
+ gl.glEnd();
+ }
+ }
+ else
+ {
+ width = MAXPOS / 10.0f / stars[n].z[0] + 1.0f;
+ gl.glColor3f(1.0f, 0.0f, 0.0f);
+ gl.glBegin(GL_POLYGON);
+ for (i = 0; i < 8; i++)
+ {
+ float x = x0 + width * Cos((float)i*MAXANGLES/8.0f);
+ float y = y0 + width * Sin((float)i*MAXANGLES/8.0f);
+ gl.glVertex2f(x, y);
+ };
+ gl.glEnd();
+ }
+
+ return true;
+ }
+ return false;
+ }
+
+ private void ShowStars()
+ {
+ gl.glClear(GL_COLOR_BUFFER_BIT);
+ for (int n = 0; n < starCount; n++)
+ {
+ if ( (stars[n].z[0] > speed)
+ || ( (stars[n].z[0] > 0.0f) && (speed < MAXWARP) ) )
+ {
+ if (!StarPoint(n))
+ NewStar(n, MAXPOS);
+ }
+ else
+ NewStar(n, MAXPOS);
+ }
+ }
+
+ // Methods required for the implementation of MouseListener
+ public void mouseEntered( MouseEvent evt )
+ {
+ }
+
+ public void mouseExited( MouseEvent evt )
+ {
+ }
+
+ public void mousePressed( MouseEvent evt )
+ {
+ flag = (flag == NORMAL) ? WEIRD : NORMAL;
+ }
+
+ public void mouseReleased( MouseEvent evt )
+ {
+ }
+
+ public void mouseClicked( MouseEvent evt )
+ {
+ }
+ }
+}
diff --git a/demos/RonsDemos/star_plugin13.html b/demos/RonsDemos/star_plugin13.html new file mode 100644 index 0000000..8a3f8e1 --- /dev/null +++ b/demos/RonsDemos/star_plugin13.html @@ -0,0 +1,53 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
+ <title>Star by Silicon Graphics; ported to Java by Ron Cemer</title>
+</head>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+Star applet
+<br>Originially written by Silicon Graphics
+<br>Ported to Java by Ron Cemer
+<br>
+<hr>By clicking inside the window, you can change the behavior of the
+<br>stars. There are two modes: normal and "weird". Each time
+you
+<br>click inside the window, the current mode will change.
+<br>
+<!--"CONVERTED_APPLET"-->
+<!-- CONVERTER VERSION 1.3 --> +<SCRIPT LANGUAGE="JavaScript"><!-- + var _info = navigator.userAgent; var _ns = false; + var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0); +//--></SCRIPT> +<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!-- + var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0))); +//--></SCRIPT></COMMENT> + +<SCRIPT LANGUAGE="JavaScript"><!-- + if (_ie == true) document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = 400 HEIGHT = 400 codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0"><NOEMBED><XMP>'); + else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.3" CODE = "star.class" WIDTH = 400 HEIGHT = 400 scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html"><NOEMBED><XMP>'); +//--></SCRIPT> +<APPLET CODE = "star.class" WIDTH = 400 HEIGHT = 400></XMP> +<PARAM NAME = CODE VALUE = "star.class" >
+ +<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3"> +<PARAM NAME="scriptable" VALUE="false"> + +</APPLET> + +</NOEMBED></EMBED></OBJECT> + + +<!-- +<APPLET CODE = "star.class" WIDTH = 400 HEIGHT = 400>
+
+
+</APPLET> +--> +<!--"END_CONVERTED_APPLET"-->
+
+<hr>
+</body>
+</html>
diff --git a/demos/RonsDemos/steam.html b/demos/RonsDemos/steam.html new file mode 100644 index 0000000..b02826e --- /dev/null +++ b/demos/RonsDemos/steam.html @@ -0,0 +1,22 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
+ <title>Steam by Troy Robinette; ported to Java by Ron Cemer</title>
+</head>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+Steam applet
+<br>Originially written by Troy Robinette
+<br>Ported to Java by Ron Cemer
+<br>Right click within the window for a menu of options.
+<br>Left-click within the window, then press any of the following keys:
+<br>Arrow keys rotate the model.
+<br>+ and - keys speed up or slow down the simulation.
+<br>While paused, a and z keys single-step forward and backward.
+<br>
+<applet code="steam.class" width=400 height=400>
+</applet>
+<hr>
+</body>
+</html>
diff --git a/demos/RonsDemos/steam.java b/demos/RonsDemos/steam.java new file mode 100644 index 0000000..3f19f7e --- /dev/null +++ b/demos/RonsDemos/steam.java @@ -0,0 +1,791 @@ +/**
+ * @(#) steam.java
+ * @(#) author: Troy Robinette (converted to Java by Ron Cemer)
+ */
+
+import java.applet.*;
+import java.awt.*;
+import java.awt.event.*;
+import java.lang.*;
+import java.util.*;
+import java.io.*;
+import java.util.*;
+import gl4java.GLContext;
+import gl4java.awt.GLAnimCanvas;
+import gl4java.applet.SimpleGLAnimApplet1;
+
+/**
+ Description: Interactive 3D graphics, Assignment #1
+ Miniature Steam Engine Simulation.
+ Author: Troy Robinette
+ Date: 29/9/95
+ Email: [email protected]
+ Notes: - Transparence doesn't quite work. The color of the
+ underlying object doesn't show through.
+ - Also only the front side of the transparent objects are
+ transparent.
+**/
+
+public class steam extends SimpleGLAnimApplet1
+{
+ private static final float boxnormals[][] =
+ {
+ {-1.0f, 0.0f, 0.0f},
+ {0.0f, 1.0f, 0.0f},
+ {1.0f, 0.0f, 0.0f},
+ {0.0f, -1.0f, 0.0f},
+ {0.0f, 0.0f, 1.0f},
+ {0.0f, 0.0f, -1.0f}
+ };
+ private static final int boxfaces[][] =
+ {
+ {0, 1, 2, 3},
+ {3, 2, 6, 7},
+ {7, 6, 5, 4},
+ {4, 5, 1, 0},
+ {5, 6, 2, 1},
+ {7, 4, 0, 3}
+ };
+
+ /* Initialize the applet */
+
+
+ public void init()
+ {
+ super.init();
+ Dimension d = getSize();
+ canvas = new steamCanvas(d.width, d.height);
+ canvas.requestFocus();
+ add("Center", canvas);
+ }
+
+
+ /* Local GLAnimCanvas extension class */
+
+
+ private class steamCanvas extends GLAnimCanvas
+ implements MouseListener, ActionListener, KeyListener
+ {
+ /* Dimensions of texture image. */
+ private final int IMAGE_WIDTH = 64;
+ private final int IMAGE_HEIGHT = 64;
+ /* Step to be taken for each rotation. */
+ private final int ANGLE_STEP = 10;
+ /* Magic numbers for relationship b/w cylinder head and crankshaft. */
+ private final float MAGNITUDE = 120.0f;
+ private final float PHASE = 270.112f;
+ private final float FREQ_DIV = 58.0f;
+ private final float ARC_LENGTH = 2.7f;
+ private final float ARC_RADIUS = 0.15f;
+ /* Rotation angles */
+ private float view_h = 270.0f, view_v = 0.0f;
+ private float head_angle = 0.0f;
+ private int crank_angle = 0;
+ /* Crank rotation step. */
+ private float crank_step = 5.0f;
+ /* Toggles */
+ private boolean filled = true;
+ private boolean textured = false, transparent = false;
+ /* Storage for the angle look up table and the texture map */
+ private float head_look_up_table[] = new float[360];
+ private byte image[] = new byte[IMAGE_WIDTH*IMAGE_HEIGHT*3];
+ /* Indentifiers for each Display list */
+ private int list_piston_filled = 1;
+ private int list_piston_texture = 2;
+ private int list_flywheel_filled = 4;
+ private int list_flywheel_texture = 8;
+ /* Variable used in the creaton of glu objects */
+ int obj; // (GLU quadric object)
+
+ private PopupMenu menu = null;
+ private boolean menu_showing = false;
+ private boolean save_suspended = false;
+
+ private final String MENU_FILLED = "Filled";
+ private final String MENU_WIREFRAME = "Wireframe";
+ private final String MENU_TEXTURED = "Textured";
+ private final String MENU_UNTEXTURED = "Untextured";
+ private final String MENU_TRANSPARENT = "Transparent";
+ private final String MENU_OPAQUE = "Opaque";
+ private final String MENU_RIGHT_LIGHT_ON = "Right light on";
+ private final String MENU_RIGHT_LIGHT_OFF = "Right light off";
+ private final String MENU_LEFT_LIGHT_ON = "Left light on";
+ private final String MENU_LEFT_LIGHT_OFF = "Left light off";
+ private final String MENU_PAUSE = "Pause (use a and z to step)";
+ private final String MENU_RESUME = "Resume animation";
+ private final String MENU_SPEED_UP = "Speed up (+)";
+ private final String MENU_SLOW_DOWN = "Slow down (-)";
+
+ public steamCanvas(int w, int h)
+ {
+ super(w, h);
+ GLContext.gljNativeDebug = false;
+ GLContext.gljClassDebug = false;
+ setAnimateFps(30.0);
+ }
+
+ public void preInit()
+ {
+ doubleBuffer = true;
+ stereoView = false;
+ }
+
+ public void init()
+ {
+ System.out.println("init(): " + this);
+ reshape(getSize().width, getSize().height);
+
+ float mat_specular[] = {1.0f, 1.0f, 1.0f, 1.0f};
+ float mat_shininess[] = {50.0f};
+ float light_position0[] = {1.0f, 1.0f, 1.0f, 0.0f};
+ float light_position1[] = {-1.0f, 1.0f, 1.0f, 0.0f};
+ float light_diffuse1[] = {1.0f,1.0f,1.0f,1.0f};
+ float light_specular1[] = {1.0f,1.0f,1.0f,1.0f};
+
+ gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
+
+ obj = glu.gluNewQuadric();
+ make_table();
+ make_image();
+
+ /* Set up Texturing */
+ gl.glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+ gl.glTexImage2D
+ (GL_TEXTURE_2D,
+ 0,
+ 3,
+ IMAGE_WIDTH,
+ IMAGE_HEIGHT,
+ 0,
+ GL_RGB,
+ GL_UNSIGNED_BYTE,
+ image);
+ gl.glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
+ gl.glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
+ gl.glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ gl.glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ gl.glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+
+ /* Set up Lighting */
+ gl.glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
+ gl.glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess);
+ gl.glLightfv(GL_LIGHT0, GL_POSITION, light_position0);
+ gl.glLightfv(GL_LIGHT1, GL_POSITION, light_position1);
+ gl.glLightfv(GL_LIGHT1, GL_DIFFUSE, light_diffuse1);
+ gl.glLightfv(GL_LIGHT1, GL_SPECULAR, light_specular1);
+
+ /* Initial render mode is with full shading and LIGHT 0
+ enabled. */
+ gl.glEnable(GL_LIGHTING);
+ gl.glEnable(GL_LIGHT0);
+ gl.glDisable(GL_LIGHT1);
+ gl.glDepthFunc(GL_LEQUAL);
+ gl.glEnable(GL_DEPTH_TEST);
+ gl.glDisable(GL_ALPHA_TEST);
+
+ gl.glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
+ gl.glEnable(GL_COLOR_MATERIAL);
+ gl.glShadeModel(GL_SMOOTH);
+
+ /* Initialise display lists */
+ gl.glNewList(list_piston_filled, GL_COMPILE);
+ draw_piston();
+ gl.glEndList();
+ gl.glNewList(list_flywheel_filled, GL_COMPILE);
+ draw_flywheel();
+ gl.glEndList();
+
+ glu.gluQuadricTexture(obj, true);
+ gl.glNewList(list_piston_texture, GL_COMPILE);
+ draw_piston();
+ gl.glEndList();
+ gl.glNewList(list_flywheel_texture, GL_COMPILE);
+ draw_flywheel();
+ gl.glEndList();
+ glu.gluQuadricTexture(obj, false);
+
+ glj.gljCheckGL();
+
+ menu = new PopupMenu("Options");
+ menu.add(MENU_FILLED);
+ menu.add(MENU_WIREFRAME);
+ menu.add(MENU_TEXTURED);
+ menu.add(MENU_UNTEXTURED);
+ menu.add(MENU_TRANSPARENT);
+ menu.add(MENU_OPAQUE);
+ menu.add(MENU_RIGHT_LIGHT_ON);
+ menu.add(MENU_RIGHT_LIGHT_OFF);
+ menu.add(MENU_LEFT_LIGHT_ON);
+ menu.add(MENU_LEFT_LIGHT_OFF);
+ menu.add(MENU_PAUSE);
+ menu.add(MENU_RESUME);
+ menu.add(MENU_SPEED_UP);
+ menu.add(MENU_SLOW_DOWN);
+ menu.addActionListener(this);
+ add(menu);
+
+ addMouseListener(this);
+ addKeyListener(this);
+ }
+
+ public void doCleanup()
+ {
+ System.out.println("destroy(): " + this);
+ removeMouseListener(this);
+ menu.removeActionListener(this);
+ removeKeyListener(this);
+ }
+
+ public void reshape(int width, int height)
+ {
+ gl.glViewport(0,0,width,height);
+ gl.glMatrixMode(GL_PROJECTION);
+ gl.glLoadIdentity();
+ glu.gluPerspective(65.0f, (float)width/(float)height, 1.0f, 20.0f);
+ gl.glMatrixMode(GL_MODELVIEW);
+ gl.glLoadIdentity();
+ gl.glTranslatef(0.0f, 0.0f, -5.0f); /* viewing transform */
+ gl.glScalef(1.5f, 1.5f, 1.5f);
+ }
+
+ public void display()
+ {
+ if (glj.gljMakeCurrent() == false) return;
+
+ if (!isSuspended())
+ {
+ crank_angle += crank_step;
+ while (crank_angle >= 360) crank_angle -= 360;
+ while (crank_angle < 0) crank_angle += 360;
+ head_angle = head_look_up_table[crank_angle];
+ }
+
+ /* Main display code. Clears the drawing buffer and if
+ transparency is set, displays the model twice, 1st time
+ accepting those fragments with an ALPHA value of 1 only,
+ then with DEPTH_BUFFER writing disabled for those with
+ other values. */
+
+ int pass;
+ gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+ gl.glPushMatrix();
+ if (transparent)
+ {
+ gl.glEnable(GL_ALPHA_TEST);
+ pass = 2;
+ }
+ else
+ {
+ gl.glDisable(GL_ALPHA_TEST);
+ pass = 0;
+ }
+
+ /* Rotate the whole model */
+ gl.glRotatef(view_h, 0.0f, 1.0f, 0.0f);
+ gl.glRotatef(view_v, 1.0f, 0.0f, 0.0f);
+
+ do
+ {
+ if (pass == 2)
+ {
+ gl.glAlphaFunc(GL_EQUAL, 1);
+ gl.glDepthMask(true);
+ pass = 1;
+ }
+ else if (pass != 0)
+ {
+ gl.glAlphaFunc(GL_NOTEQUAL, 1);
+ gl.glDepthMask(false);
+ pass = 0;
+ }
+
+ draw_engine_pole();
+
+ gl.glPushMatrix();
+ gl.glTranslatef(0.5f, 1.4f, 0.0f);
+ draw_cylinder_head();
+ gl.glPopMatrix();
+
+ gl.glPushMatrix();
+ gl.glTranslatef(0.0f, -0.8f, 0.0f);
+ draw_crank();
+ gl.glPopMatrix();
+ } while (pass > 0);
+
+ gl.glDepthMask(true);
+ gl.glPopMatrix();
+
+ glj.gljSwap();
+ glj.gljCheckGL();
+ glj.gljFree();
+
+ //if (!isSuspended()) repaint(); // Animate at full speed.
+ }
+
+ // Methods required for the implementation of MouseListener
+ public void mouseEntered( MouseEvent evt )
+ {
+ Component comp = evt.getComponent();
+ if( comp.equals(this ) )
+ {
+ requestFocus();
+ }
+ }
+
+ public void mouseClicked( MouseEvent evt )
+ {
+ Component comp = evt.getComponent();
+ if( comp.equals(this ) )
+ {
+ requestFocus();
+ }
+ }
+
+ public void mouseExited(MouseEvent evt)
+ {
+ }
+
+ public void mousePressed(MouseEvent evt)
+ {
+ // If user presses right mouse button within canvas area,
+ // suspend animation and pop up menu.
+ // If menu was already popped up and user presses either
+ // mouse button within canvas area, resume animation
+ // because the menu will have been removed automatically.
+ if (!menu_showing)
+ {
+ if ((evt.getModifiers() & evt.BUTTON3_MASK) != 0)
+ {
+ menu_showing = true;
+ save_suspended = isSuspended();
+ if (!save_suspended)
+ {
+ setSuspended(true);
+ repaint(100);
+ try
+ {
+ Thread.currentThread().sleep(200);
+ }
+ catch (Exception e)
+ { }
+ }
+ menu.show(this,evt.getX(),evt.getY());
+ }
+ }
+ else
+ {
+ menu_showing = false;
+ setSuspended(save_suspended);
+ }
+ }
+
+ public void mouseReleased(MouseEvent evt)
+ {
+ }
+
+ // Method required for the implementation of ActionListener
+ public void actionPerformed(ActionEvent evt)
+ {
+ if (glj.gljMakeCurrent() == false) return;
+ boolean dorepaint = false;
+ String c = evt.getActionCommand();
+ if (c.equals(MENU_FILLED))
+ {
+ filled = true;
+ gl.glShadeModel(GL_SMOOTH);
+ gl.glEnable(GL_LIGHTING);
+ gl.glEnable(GL_DEPTH_TEST);
+ gl.glEnable(GL_COLOR_MATERIAL);
+ glu.gluQuadricNormals(obj, GLU_SMOOTH);
+ glu.gluQuadricDrawStyle(obj, GLU_FILL);
+ // Conditionally re-enable texturing.
+ if (textured)
+ {
+ gl.glEnable(GL_TEXTURE_2D);
+ glu.gluQuadricTexture(obj, true);
+ }
+ dorepaint = true;
+ }
+ else if (c.equals(MENU_WIREFRAME))
+ {
+ filled = false;
+ gl.glShadeModel(GL_FLAT);
+ gl.glDisable(GL_LIGHTING);
+ gl.glDisable(GL_DEPTH_TEST);
+ gl.glDisable(GL_COLOR_MATERIAL);
+ glu.gluQuadricNormals(obj, GLU_NONE);
+ glu.gluQuadricDrawStyle(obj, GLU_LINE);
+ glu.gluQuadricTexture(obj, false);
+ // Be sure texturing is disabled.
+ gl.glDisable(GL_TEXTURE_2D);
+ glu.gluQuadricTexture(obj, false);
+ dorepaint = true;
+ }
+ else if (c.equals(MENU_TEXTURED))
+ {
+ textured = true;
+ if (filled)
+ {
+ gl.glEnable(GL_TEXTURE_2D);
+ glu.gluQuadricTexture(obj, true);
+ dorepaint = true;
+ }
+ }
+ else if (c.equals(MENU_UNTEXTURED))
+ {
+ textured = false;
+ gl.glDisable(GL_TEXTURE_2D);
+ glu.gluQuadricTexture(obj, false);
+ dorepaint = true;
+ }
+ else if (c.equals(MENU_TRANSPARENT))
+ {
+ transparent = true;
+ dorepaint = true;
+ }
+ else if (c.equals(MENU_OPAQUE))
+ {
+ transparent = false;
+ dorepaint = true;
+ }
+ else if (c.equals(MENU_RIGHT_LIGHT_ON))
+ {
+ gl.glEnable(GL_LIGHT0);
+ dorepaint = true;
+ }
+ else if (c.equals(MENU_RIGHT_LIGHT_OFF))
+ {
+ gl.glDisable(GL_LIGHT0);
+ dorepaint = true;
+ }
+ else if (c.equals(MENU_LEFT_LIGHT_ON))
+ {
+ gl.glEnable(GL_LIGHT1);
+ dorepaint = true;
+ }
+ else if (c.equals(MENU_LEFT_LIGHT_OFF))
+ {
+ gl.glDisable(GL_LIGHT1);
+ dorepaint = true;
+ }
+ else if (c.equals(MENU_PAUSE))
+ {
+ if (menu_showing)
+ save_suspended = true;
+ else
+ setSuspended(true);
+ }
+ else if (c.equals(MENU_RESUME))
+ {
+ if (menu_showing)
+ save_suspended = false;
+ else
+ setSuspended(false);
+ }
+ else if (c.equals(MENU_SPEED_UP))
+ {
+ crank_step++;
+ if (crank_step > 45) crank_step = 45;
+ }
+ else if (c.equals(MENU_SLOW_DOWN))
+ {
+ crank_step--;
+ if (crank_step < 1) crank_step = 1;
+ }
+ if (menu_showing)
+ {
+ menu_showing = false;
+ setSuspended(save_suspended);
+ }
+ glj.gljFree();
+ if (dorepaint) repaint();
+ }
+
+ // Methods required for the implementation of KeyListener
+ public void keyPressed(KeyEvent e)
+ {
+ switch (e.getKeyCode())
+ {
+ case KeyEvent.VK_LEFT:
+ view_h -= ANGLE_STEP;
+ while (view_h < 0) view_h += 360;
+ repaint();
+ break;
+ case KeyEvent.VK_RIGHT:
+ view_h += ANGLE_STEP;
+ while (view_h >= 360) view_h -= 360;
+ repaint();
+ break;
+ case KeyEvent.VK_UP:
+ view_v += ANGLE_STEP;
+ while (view_v >= 360) view_v -= 360;
+ repaint();
+ break;
+ case KeyEvent.VK_DOWN:
+ view_v -= ANGLE_STEP;
+ while (view_v < 0) view_v += 360;
+ repaint();
+ break;
+ }
+ }
+
+ public void keyReleased(KeyEvent e)
+ {
+ }
+
+ public void keyTyped(KeyEvent e)
+ {
+ if (glj.gljMakeCurrent() == false) return;
+ boolean dorepaint = false;
+ switch ((char)e.getKeyChar())
+ {
+ case 'a':
+ case 'A':
+ if (!isSuspended()) break;
+ crank_angle += crank_step;
+ while (crank_angle >= 360) crank_angle -= 360;
+ head_angle = head_look_up_table[crank_angle];
+ dorepaint = true;
+ break;
+ case 'z':
+ case 'Z':
+ if (!isSuspended()) break;
+ crank_angle -= crank_step;
+ while (crank_angle < 0) crank_angle += 360;
+ head_angle = head_look_up_table[crank_angle];
+ dorepaint = true;
+ break;
+ case '+':
+ crank_step++;
+ if (crank_step > 45) crank_step = 45;
+ break;
+ case '-':
+ crank_step--;
+ if (crank_step < 1) crank_step = 1;
+ break;
+ }
+ glj.gljFree();
+ if (dorepaint) repaint();
+ }
+
+ /* Draws a box by scaling a glut cube of size 1.
+ Also checks the filled toggle to see which rendering
+ style to use. NB Texture doesn't work correctly due
+ to the cube being scaled. */
+ private void myBox(float x, float y, float z)
+ {
+ gl.glPushMatrix();
+ gl.glScalef(x, y, z);
+ if (filled)
+ glutSolidCube(1);
+ else
+ glutWireCube(1);
+ gl.glPopMatrix();
+ }
+
+ /* Draws a cylinder using glu function, drawing flat discs
+ at each end, to give the appearence of it being solid. */
+ private void myCylinder
+ (int object, float outerRadius, float innerRadius, float length)
+ {
+ gl.glPushMatrix();
+ glu.gluCylinder(object, outerRadius, outerRadius, length, 20, 1);
+ gl.glPushMatrix();
+ gl.glRotatef(180.0f, 0.0f, 1.0f, 0.0f);
+ glu.gluDisk(object, innerRadius, outerRadius, 20, 1);
+ gl.glPopMatrix();
+ gl.glTranslatef(0.0f, 0.0f, length);
+ glu.gluDisk(object, innerRadius, outerRadius, 20, 1);
+ gl.glPopMatrix();
+ }
+
+ /* Draws a piston. */
+ private void draw_piston()
+ {
+ gl.glPushMatrix();
+ gl.glColor4f(0.3f, 0.6f, 0.9f, 1.0f);
+ gl.glPushMatrix();
+ gl.glRotatef(90.0f, 0.0f, 1.0f, 0.0f);
+ gl.glTranslatef(0.0f, 0.0f, -0.07f);
+ myCylinder(obj, 0.125f, 0.06f, 0.12f);
+ gl.glPopMatrix();
+ gl.glRotatef(-90.0f, 1.0f, 0.0f, 0.0f);
+ gl.glTranslatef(0.0f, 0.0f, 0.05f);
+ myCylinder(obj, 0.06f, 0.0f, 0.6f);
+ gl.glTranslatef(0.0f, 0.0f, 0.6f);
+ myCylinder(obj, 0.2f, 0.0f, 0.5f);
+ gl.glPopMatrix();
+ }
+
+ /* Draws the engine pole and the
+ pivot pole for the cylinder head. */
+ private void draw_engine_pole()
+ {
+ gl.glPushMatrix();
+ gl.glColor4f(0.9f, 0.9f, 0.9f, 1.0f);
+ myBox(0.5f, 3.0f, 0.5f);
+ gl.glColor3f(0.5f, 0.1f, 0.5f);
+ gl.glRotatef(90.0f, 0.0f, 1.0f, 0.0f);
+ gl.glTranslatef(0.0f, 0.9f, -0.4f);
+ myCylinder(obj, 0.1f, 0.0f, 2);
+ gl.glPopMatrix();
+ }
+
+ /* Draws the cylinder head at the appropreate angle, doing
+ the necessary translations for the rotation. */
+ private void draw_cylinder_head()
+ {
+ gl.glPushMatrix();
+ gl.glColor4f(0.5f, 1.0f, 0.5f, 0.1f);
+ gl.glRotatef(90.0f, 1.0f, 0.0f, 0.0f);
+ gl.glTranslatef(0.0f, 0.0f, 0.4f);
+ gl.glRotatef(head_angle, 1.0f, 0.0f, 0.0f);
+ gl.glTranslatef(0.0f, 0.0f, -0.4f);
+ myCylinder(obj, 0.23f, 0.21f, 1.6f);
+ gl.glRotatef(180.0f, 1.0f, 0.0f, 0.0f);
+ glu.gluDisk(obj, 0.0f, 0.23f, 20, 1);
+ gl.glPopMatrix();
+ }
+
+ /* Draws the flywheel. */
+ private void draw_flywheel()
+ {
+ gl.glPushMatrix();
+ gl.glColor4f(0.5f, 0.5f, 1.0f, 1.0f);
+ gl.glRotatef(90.0f, 0.0f, 1.0f, 0.0f);
+ myCylinder(obj, 0.625f, 0.08f, 0.5f);
+ gl.glPopMatrix();
+ }
+
+/* Draws the crank bell, and the pivot pin for the piston. Also calls the
+ appropreate display list of a piston doing the nesacary rotations before
+ hand. */
+ private void draw_crankbell()
+ {
+ gl.glPushMatrix();
+ gl.glColor4f(1.0f, 0.5f, 0.5f, 1.0f);
+ gl.glRotatef(90.0f, 0.0f, 1.0f, 0.0f);
+ myCylinder(obj, 0.3f, 0.08f, 0.12f);
+
+ gl.glColor4f(0.5f, 0.1f, 0.5f, 1.0f);
+ gl.glTranslatef(0.0f, 0.2f, 0.0f);
+ myCylinder(obj, 0.06f, 0.0f, 0.34f);
+
+ gl.glTranslatef(0.0f, 0.0f, 0.22f);
+ gl.glRotatef(90.0f, 0.0f, 1.0f, 0.0f);
+ gl.glRotatef(((float)crank_angle)-head_angle, 1.0f, 0.0f, 0.0f);
+ if (filled)
+ {
+ if (textured)
+ gl.glCallList(list_piston_texture);
+ else
+ gl.glCallList(list_piston_filled);
+ }
+ else
+ draw_piston();
+ gl.glPopMatrix();
+ }
+
+ /* Draws the complete crank. Piston also gets drawn through
+ the crank bell function. */
+ private void draw_crank()
+ {
+ gl.glPushMatrix();
+ gl.glRotatef(crank_angle, 1.0f, 0.0f, 0.0f);
+
+ gl.glPushMatrix();
+ gl.glRotatef(90.0f, 0.0f, 1.0f, 0.0f);
+ gl.glTranslatef(0.0f, 0.0f, -1.0f);
+ myCylinder(obj, 0.08f, 0.0f, 1.4f);
+ gl.glPopMatrix();
+
+ gl.glPushMatrix();
+ gl.glTranslatef(0.28f, 0.0f, 0.0f);
+ draw_crankbell();
+ gl.glPopMatrix();
+
+ gl.glPushMatrix();
+ gl.glTranslatef(-0.77f, 0.0f, 0.0f);
+ if (filled)
+ {
+ if (textured)
+ gl.glCallList(list_flywheel_texture);
+ else
+ gl.glCallList(list_flywheel_filled);
+ }
+ else
+ draw_flywheel();
+ gl.glPopMatrix();
+ gl.glPopMatrix();
+ }
+
+ /* Makes a simple checkered pattern image. (Copied from the
+ redbook example "checker.c".) */
+ private void make_image()
+ {
+ int c, idx = 0;
+ for (int i = 0; i < IMAGE_WIDTH; i++)
+ {
+ for (int j = 0; j < IMAGE_HEIGHT; j++)
+ {
+ c = ((((i & 0x8) == 0) ^ ((j & 0x8)) == 0)) ? 255 : 0;
+ image[idx++] = (byte)c;
+ image[idx++] = (byte)c;
+ image[idx++] = (byte)c;
+ }
+ }
+ }
+
+ /* Makes the head lookup table for all possible crank angles. */
+ private void make_table()
+ {
+ for (int i = 0; i < 360; i++)
+ {
+ float rads = PHASE-(((float)i)/FREQ_DIV);
+ head_look_up_table[i] =
+ MAGNITUDE *
+ (float)Math.atan
+ ((ARC_RADIUS*Math.sin(rads)) /
+ (ARC_LENGTH-(ARC_RADIUS*Math.cos(rads))));
+ }
+ }
+
+ // Imported from glut.
+ private void glutWireCube(float size)
+ {
+ drawBox(size, GL_LINE_LOOP);
+ }
+
+ // Imported from glut.
+ private void glutSolidCube(float size)
+ {
+ drawBox(size, GL_QUADS);
+ }
+
+ // Imported from glut.
+ private void drawBox(float size, int type)
+ {
+ float v[][] = new float[8][3];
+ int i;
+
+ v[0][0] = v[1][0] = v[2][0] = v[3][0] = -size / 2;
+ v[4][0] = v[5][0] = v[6][0] = v[7][0] = size / 2;
+ v[0][1] = v[1][1] = v[4][1] = v[5][1] = -size / 2;
+ v[2][1] = v[3][1] = v[6][1] = v[7][1] = size / 2;
+ v[0][2] = v[3][2] = v[4][2] = v[7][2] = -size / 2;
+ v[1][2] = v[2][2] = v[5][2] = v[6][2] = size / 2;
+
+ for (i = 5; i >= 0; i--)
+ {
+ gl.glBegin(type);
+ gl.glNormal3fv(boxnormals[i]);
+ gl.glVertex3fv(v[boxfaces[i][0]]);
+ gl.glVertex3fv(v[boxfaces[i][1]]);
+ gl.glVertex3fv(v[boxfaces[i][2]]);
+ gl.glVertex3fv(v[boxfaces[i][3]]);
+ gl.glEnd();
+ }
+ }
+ }
+}
diff --git a/demos/RonsDemos/steam_plugin13.html b/demos/RonsDemos/steam_plugin13.html new file mode 100644 index 0000000..252422e --- /dev/null +++ b/demos/RonsDemos/steam_plugin13.html @@ -0,0 +1,53 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
+ <title>Steam by Troy Robinette; ported to Java by Ron Cemer</title>
+</head>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+Steam applet
+<br>Originially written by Troy Robinette
+<br>Ported to Java by Ron Cemer
+<br>Right click within the window for a menu of options.
+<br>Left-click within the window, then press any of the following keys:
+<br>Arrow keys rotate the model.
+<br>+ and - keys speed up or slow down the simulation.
+<br>While paused, a and z keys single-step forward and backward.
+<br>
+<!--"CONVERTED_APPLET"-->
+<!-- CONVERTER VERSION 1.3 --> +<SCRIPT LANGUAGE="JavaScript"><!-- + var _info = navigator.userAgent; var _ns = false; + var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0); +//--></SCRIPT> +<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!-- + var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0))); +//--></SCRIPT></COMMENT> + +<SCRIPT LANGUAGE="JavaScript"><!-- + if (_ie == true) document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = 400 HEIGHT = 400 codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0"><NOEMBED><XMP>'); + else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.3" CODE = "steam.class" WIDTH = 400 HEIGHT = 400 scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html"><NOEMBED><XMP>'); +//--></SCRIPT> +<APPLET CODE = "steam.class" WIDTH = 400 HEIGHT = 400></XMP> +<PARAM NAME = CODE VALUE = "steam.class" >
+ +<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3"> +<PARAM NAME="scriptable" VALUE="false"> + +</APPLET> + +</NOEMBED></EMBED></OBJECT> + + +<!-- +<APPLET CODE = "steam.class" WIDTH = 400 HEIGHT = 400>
+
+
+</APPLET> +--> +<!--"END_CONVERTED_APPLET"-->
+
+<hr>
+</body>
+</html>
diff --git a/demos/RonsDemos/surface.html b/demos/RonsDemos/surface.html new file mode 100644 index 0000000..fa384a5 --- /dev/null +++ b/demos/RonsDemos/surface.html @@ -0,0 +1,18 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
+ <title>Surface by Silicon Graphics; ported to Java by Ron Cemer</title>
+</head>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+Surface applet
+<br>Originially written by Silicon Graphics
+<br>Ported to Java by Ron Cemer
+<br>Click inside the window to toggle visibility of the control points.
+<br>
+<applet code="surface.class" width=400 height=400>
+</applet>
+<hr>
+</body>
+</html>
diff --git a/demos/RonsDemos/surface.java b/demos/RonsDemos/surface.java new file mode 100644 index 0000000..2d959b8 --- /dev/null +++ b/demos/RonsDemos/surface.java @@ -0,0 +1,263 @@ +/**
+ * @(#) surface.java
+ * @(#) author: Silicon Graphics (converted to Java by Ron Cemer)
+ */
+
+/*
+ * Copyright (c) 1993-1997, Silicon Graphics, Inc.
+ * ALL RIGHTS RESERVED
+ * Permission to use, copy, modify, and distribute this software for
+ * any purpose and without fee is hereby granted, provided that the above
+ * copyright notice appear in all copies and that both the copyright notice
+ * and this permission notice appear in supporting documentation, and that
+ * the name of Silicon Graphics, Inc. not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission.
+ *
+ * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
+ * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
+ * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
+ * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
+ * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
+ * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
+ * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
+ * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
+ * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * US Government Users Restricted Rights
+ * Use, duplication, or disclosure by the Government is subject to
+ * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
+ * (c)(1)(ii) of the Rights in Technical Data and Computer Software
+ * clause at DFARS 252.227-7013 and/or in similar or successor
+ * clauses in the FAR or the DOD or NASA FAR Supplement.
+ * Unpublished-- rights reserved under the copyright laws of the
+ * United States. Contractor/manufacturer is Silicon Graphics,
+ * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
+ *
+ * OpenGL(R) is a registered trademark of Silicon Graphics, Inc.
+ */
+
+/*
+ * This program draws a NURBS surface in the shape of a
+ * symmetrical hill. The 'c' keyboard key allows you to
+ * toggle the visibility of the control points themselves.
+ * Note that some of the control points are hidden by the
+ * surface itself.
+ */
+
+import java.applet.*;
+import java.awt.*;
+import java.awt.event.*;
+import java.lang.*;
+import java.util.*;
+import java.io.*;
+import java.util.*;
+import gl4java.GLContext;
+import gl4java.awt.GLCanvas;
+
+public class surface extends Applet
+{
+ surfaceCanvas canvas = null;
+
+
+ /* Initialize the applet */
+
+
+ public void init()
+ {
+ Dimension d = getSize();
+ setLayout(new BorderLayout());
+ canvas = new surfaceCanvas(d.width, d.height);
+ add("Center", canvas);
+ }
+
+
+ /* Start the applet */
+
+
+ public void start()
+ {
+ }
+
+
+ /* Stop the applet */
+
+
+ public void stop()
+ {
+ }
+
+
+ /* Destroy the applet */
+
+
+
+ /* Local GLCanvas extension class */
+
+
+ private class surfaceCanvas extends GLCanvas implements MouseListener
+ {
+ float ctlpoints[] = new float [4*4*3];
+ boolean showPoints = false;
+ int theNurb;
+
+ public surfaceCanvas(int w, int h)
+ {
+ super(w, h);
+ GLContext.gljNativeDebug = false;
+ GLContext.gljClassDebug = false;
+ }
+
+ public void preInit()
+ {
+ doubleBuffer = true;
+ stereoView = false;
+ }
+
+ public void init()
+ {
+ System.out.println("init(): " + this);
+ reshape(getSize().width, getSize().height);
+
+ float mat_diffuse[] = { 0.7f, 0.7f, 0.7f, 1.0f };
+ float mat_specular[] = { 1.0f, 1.0f, 1.0f, 1.0f };
+ float mat_shininess[] = { 100.0f };
+
+ gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
+ gl.glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse);
+ gl.glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
+ gl.glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess);
+
+ gl.glEnable(GL_LIGHTING);
+ gl.glEnable(GL_LIGHT0);
+ gl.glEnable(GL_DEPTH_TEST);
+ gl.glEnable(GL_AUTO_NORMAL);
+ gl.glEnable(GL_NORMALIZE);
+
+ init_surface();
+
+ theNurb = glu.gluNewNurbsRenderer();
+ glu.gluNurbsProperty(theNurb, GLU_SAMPLING_TOLERANCE, 25.0f);
+ glu.gluNurbsProperty(theNurb, GLU_DISPLAY_MODE, GLU_FILL);
+
+ glj.gljCheckGL();
+
+ addMouseListener(this);
+ }
+
+ public void cvsDispose()
+ {
+ System.out.println("destroy(): " + this);
+ removeMouseListener(this);
+ super.cvsDispose();
+ }
+
+ public void reshape(int width, int height)
+ {
+ gl.glViewport(0,0,width,height);
+ gl.glMatrixMode(GL_PROJECTION);
+ gl.glLoadIdentity();
+ glu.gluPerspective(45.0f,(double)width/(double)height,3.0f,8.0f);
+ gl.glMatrixMode(GL_MODELVIEW);
+ gl.glLoadIdentity();
+ gl.glTranslatef(0.0f, 0.0f, -5.0f);
+ }
+
+ public void display()
+ {
+ if (glj.gljMakeCurrent() == false) return;
+
+ float knots[] = {0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f};
+ int i, j;
+
+ gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+ gl.glPushMatrix();
+ gl.glRotatef(330.0f, 1.0f,0.0f,0.0f);
+ gl.glScalef (0.5f, 0.5f, 0.5f);
+
+ glu.gluBeginSurface(theNurb);
+ glu.gluNurbsSurface
+ (theNurb,
+ 8,
+ knots,
+ 8,
+ knots,
+ (4 * 3),
+ 3,
+ ctlpoints,
+ 4,
+ 4,
+ GL_MAP2_VERTEX_3);
+ glu.gluEndSurface(theNurb);
+
+ if (showPoints)
+ {
+ gl.glPointSize(5.0f);
+ gl.glDisable(GL_LIGHTING);
+ gl.glColor3f(1.0f, 1.0f, 0.0f);
+ gl.glBegin(GL_POINTS);
+ for (i = 0; i < 4; i++)
+ {
+ for (j = 0; j < 4; j++)
+ {
+ gl.glVertex3f
+ (ctlpoints[(i*12)+(j*3)+0],
+ ctlpoints[(i*12)+(j*3)+1],
+ ctlpoints[(i*12)+(j*3)+2]);
+ }
+ }
+ gl.glEnd();
+ gl.glEnable(GL_LIGHTING);
+ }
+ gl.glPopMatrix();
+ gl.glFlush();
+
+ glj.gljSwap();
+ glj.gljCheckGL();
+ glj.gljFree();
+ }
+
+ private void init_surface()
+ {
+ for (int u = 0; u < 4; u++)
+ {
+ for (int v = 0; v < 4; v++)
+ {
+ ctlpoints[(u*12)+(v*3)+0] = 2.0f*((float)u - 1.5f);
+ ctlpoints[(u*12)+(v*3)+1] = 2.0f*((float)v - 1.5f);
+ if ( (u == 1 || u == 2) && (v == 1 || v == 2) )
+ ctlpoints[(u*12)+(v*3)+2] = 3.0f;
+ else
+ ctlpoints[(u*12)+(v*3)+2] = -3.0f;
+ }
+ }
+ }
+
+ // Methods required for the implementation of MouseListener
+ public void mouseEntered( MouseEvent evt )
+ {
+ }
+
+ public void mouseExited( MouseEvent evt )
+ {
+ }
+
+ public void mousePressed( MouseEvent evt )
+ {
+ showPoints = !showPoints;
+ repaint();
+ }
+
+ public void mouseReleased( MouseEvent evt )
+ {
+ }
+
+ public void mouseClicked( MouseEvent evt )
+ {
+ }
+ }
+}
diff --git a/demos/RonsDemos/surface_plugin13.html b/demos/RonsDemos/surface_plugin13.html new file mode 100644 index 0000000..711d650 --- /dev/null +++ b/demos/RonsDemos/surface_plugin13.html @@ -0,0 +1,49 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
+ <title>Surface by Silicon Graphics; ported to Java by Ron Cemer</title>
+</head>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+Surface applet
+<br>Originially written by Silicon Graphics
+<br>Ported to Java by Ron Cemer
+<br>Click inside the window to toggle visibility of the control points.
+<br>
+<!--"CONVERTED_APPLET"-->
+<!-- CONVERTER VERSION 1.3 --> +<SCRIPT LANGUAGE="JavaScript"><!-- + var _info = navigator.userAgent; var _ns = false; + var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0); +//--></SCRIPT> +<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!-- + var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0))); +//--></SCRIPT></COMMENT> + +<SCRIPT LANGUAGE="JavaScript"><!-- + if (_ie == true) document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = 400 HEIGHT = 400 codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0"><NOEMBED><XMP>'); + else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.3" CODE = "surface.class" WIDTH = 400 HEIGHT = 400 scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html"><NOEMBED><XMP>'); +//--></SCRIPT> +<APPLET CODE = "surface.class" WIDTH = 400 HEIGHT = 400></XMP> +<PARAM NAME = CODE VALUE = "surface.class" >
+ +<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3"> +<PARAM NAME="scriptable" VALUE="false"> + +</APPLET> + +</NOEMBED></EMBED></OBJECT> + + +<!-- +<APPLET CODE = "surface.class" WIDTH = 400 HEIGHT = 400>
+
+
+</APPLET> +--> +<!--"END_CONVERTED_APPLET"-->
+
+<hr>
+</body>
+</html>
diff --git a/demos/RonsDemos/teapots.html b/demos/RonsDemos/teapots.html new file mode 100644 index 0000000..834c206 --- /dev/null +++ b/demos/RonsDemos/teapots.html @@ -0,0 +1,17 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
+ <title>Teapots by Silicon Graphics; ported to Java by Ron Cemer</title>
+</head>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+Teapots applet
+<br>Originially written by Silicon Graphics
+<br>Ported to Java by Ron Cemer
+<br>
+<applet code="teapots.class" width=400 height=400>
+</applet>
+<hr>
+</body>
+</html>
diff --git a/demos/RonsDemos/teapots.java b/demos/RonsDemos/teapots.java new file mode 100644 index 0000000..c59945a --- /dev/null +++ b/demos/RonsDemos/teapots.java @@ -0,0 +1,465 @@ +/**
+ * @(#) teapots.java
+ * @(#) author: Silicon Graphics, Inc. (converted to Java by Ron Cemer)
+ */
+
+/*
+ * Copyright (c) 1993-1997, Silicon Graphics, Inc.
+ * ALL RIGHTS RESERVED
+ * Permission to use, copy, modify, and distribute this software for
+ * any purpose and without fee is hereby granted, provided that the above
+ * copyright notice appear in all copies and that both the copyright notice
+ * and this permission notice appear in supporting documentation, and that
+ * the name of Silicon Graphics, Inc. not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission.
+ *
+ * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
+ * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
+ * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
+ * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
+ * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
+ * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
+ * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
+ * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
+ * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * US Government Users Restricted Rights
+ * Use, duplication, or disclosure by the Government is subject to
+ * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
+ * (c)(1)(ii) of the Rights in Technical Data and Computer Software
+ * clause at DFARS 252.227-7013 and/or in similar or successor
+ * clauses in the FAR or the DOD or NASA FAR Supplement.
+ * Unpublished-- rights reserved under the copyright laws of the
+ * United States. Contractor/manufacturer is Silicon Graphics,
+ * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
+ *
+ * OpenGL(R) is a registered trademark of Silicon Graphics, Inc.
+ */
+
+/*
+ * This program demonstrates lots of material properties.
+ * A single light source illuminates the objects.
+ */
+
+import java.applet.*;
+import java.awt.*;
+import java.awt.event.*;
+import java.lang.*;
+import java.util.*;
+import java.io.*;
+import java.util.*;
+import gl4java.GLContext;
+import gl4java.awt.GLCanvas;
+
+public class teapots extends Applet
+{
+ // Data for drawing teapots:
+ /* Rim, body, lid, and bottom data must be reflected in x and
+ y; handle and spout data across the y axis only. */
+ private static final int patchdata[][] =
+ {
+ /* rim */
+ {102, 103, 104, 105, 4, 5, 6, 7, 8, 9, 10, 11,
+ 12, 13, 14, 15},
+ /* body */
+ {12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+ 24, 25, 26, 27},
+ {24, 25, 26, 27, 29, 30, 31, 32, 33, 34, 35, 36,
+ 37, 38, 39, 40},
+ /* lid */
+ {96, 96, 96, 96, 97, 98, 99, 100, 101, 101, 101,
+ 101, 0, 1, 2, 3,},
+ {0, 1, 2, 3, 106, 107, 108, 109, 110, 111, 112,
+ 113, 114, 115, 116, 117},
+ /* bottom */
+ {118, 118, 118, 118, 124, 122, 119, 121, 123, 126,
+ 125, 120, 40, 39, 38, 37},
+ /* handle */
+ {41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
+ 53, 54, 55, 56},
+ {53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
+ 28, 65, 66, 67},
+ /* spout */
+ {68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
+ 80, 81, 82, 83},
+ {80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91,
+ 92, 93, 94, 95}
+ };
+ private static final float cpdata[][] =
+ {
+ {0.2f, 0.0f, 2.7f}, {0.2f, -0.112f, 2.7f}, {0.112f, -0.2f, 2.7f}, {0.0f,
+ -0.2f, 2.7f}, {1.3375f, 0.0f, 2.53125f}, {1.3375f, -0.749f, 2.53125f},
+ {0.749f, -1.3375f, 2.53125f}, {0.0f, -1.3375f, 2.53125f}, {1.4375f,
+ 0.0f, 2.53125f}, {1.4375f, -0.805f, 2.53125f}, {0.805f, -1.4375f,
+ 2.53125f}, {0.0f, -1.4375f, 2.53125f}, {1.5f, 0.0f, 2.4f}, {1.5f, -0.84f,
+ 2.4f}, {0.84f, -1.5f, 2.4f}, {0.0f, -1.5f, 2.4f}, {1.75f, 0.0f, 1.875f},
+ {1.75f, -0.98f, 1.875f}, {0.98f, -1.75f, 1.875f}, {0.0f, -1.75f,
+ 1.875f}, {2f, 0.0f, 1.35f}, {2f, -1.12f, 1.35f}, {1.12f, -2f, 1.35f},
+ {0.0f, -2f, 1.35f}, {2f, 0.0f, 0.9f}, {2f, -1.12f, 0.9f}, {1.12f, -2f,
+ 0.9f}, {0.0f, -2f, 0.9f}, {-2f, 0.0f, 0.9f}, {2f, 0.0f, 0.45f}, {2f, -1.12f,
+ 0.45f}, {1.12f, -2f, 0.45f}, {0.0f, -2f, 0.45f}, {1.5f, 0.0f, 0.225f},
+ {1.5f, -0.84f, 0.225f}, {0.84f, -1.5f, 0.225f}, {0.0f, -1.5f, 0.225f},
+ {1.5f, 0.0f, 0.15f}, {1.5f, -0.84f, 0.15f}, {0.84f, -1.5f, 0.15f}, {0.0f,
+ -1.5f, 0.15f}, {-1.6f, 0.0f, 2.025f}, {-1.6f, -0.3f, 2.025f}, {-1.5f,
+ -0.3f, 2.25f}, {-1.5f, 0.0f, 2.25f}, {-2.3f, 0.0f, 2.025f}, {-2.3f, -0.3f,
+ 2.025f}, {-2.5f, -0.3f, 2.25f}, {-2.5f, 0.0f, 2.25f}, {-2.7f, 0.0f,
+ 2.025f}, {-2.7f, -0.3f, 2.025f}, {-3f, -0.3f, 2.25f}, {-3f, 0.0f,
+ 2.25f}, {-2.7f, 0.0f, 1.8f}, {-2.7f, -0.3f, 1.8f}, {-3f, -0.3f, 1.8f},
+ {-3f, 0.0f, 1.8f}, {-2.7f, 0.0f, 1.575f}, {-2.7f, -0.3f, 1.575f}, {-3f,
+ -0.3f, 1.35f}, {-3f, 0.0f, 1.35f}, {-2.5f, 0.0f, 1.125f}, {-2.5f, -0.3f,
+ 1.125f}, {-2.65f, -0.3f, 0.9375f}, {-2.65f, 0.0f, 0.9375f}, {-2f,
+ -0.3f, 0.9f}, {-1.9f, -0.3f, 0.6f}, {-1.9f, 0.0f, 0.6f}, {1.7f, 0.0f,
+ 1.425f}, {1.7f, -0.66f, 1.425f}, {1.7f, -0.66f, 0.6f}, {1.7f, 0.0f,
+ 0.6f}, {2.6f, 0.0f, 1.425f}, {2.6f, -0.66f, 1.425f}, {3.1f, -0.66f,
+ 0.825f}, {3.1f, 0.0f, 0.825f}, {2.3f, 0.0f, 2.1f}, {2.3f, -0.25f, 2.1f},
+ {2.4f, -0.25f, 2.025f}, {2.4f, 0.0f, 2.025f}, {2.7f, 0.0f, 2.4f}, {2.7f,
+ -0.25f, 2.4f}, {3.3f, -0.25f, 2.4f}, {3.3f, 0.0f, 2.4f}, {2.8f, 0.0f,
+ 2.475f}, {2.8f, -0.25f, 2.475f}, {3.525f, -0.25f, 2.49375f},
+ {3.525f, 0.0f, 2.49375f}, {2.9f, 0.0f, 2.475f}, {2.9f, -0.15f, 2.475f},
+ {3.45f, -0.15f, 2.5125f}, {3.45f, 0.0f, 2.5125f}, {2.8f, 0.0f, 2.4f},
+ {2.8f, -0.15f, 2.4f}, {3.2f, -0.15f, 2.4f}, {3.2f, 0.0f, 2.4f}, {0.0f, 0.0f,
+ 3.15f}, {0.8f, 0.0f, 3.15f}, {0.8f, -0.45f, 3.15f}, {0.45f, -0.8f,
+ 3.15f}, {0.0f, -0.8f, 3.15f}, {0.0f, 0.0f, 2.85f}, {1.4f, 0.0f, 2.4f}, {1.4f,
+ -0.784f, 2.4f}, {0.784f, -1.4f, 2.4f}, {0.0f, -1.4f, 2.4f}, {0.4f, 0.0f,
+ 2.55f}, {0.4f, -0.224f, 2.55f}, {0.224f, -0.4f, 2.55f}, {0.0f, -0.4f,
+ 2.55f}, {1.3f, 0.0f, 2.55f}, {1.3f, -0.728f, 2.55f}, {0.728f, -1.3f,
+ 2.55f}, {0.0f, -1.3f, 2.55f}, {1.3f, 0.0f, 2.4f}, {1.3f, -0.728f, 2.4f},
+ {0.728f, -1.3f, 2.4f}, {0.0f, -1.3f, 2.4f}, {0.0f, 0.0f, 0.0f}, {1.425f,
+ -0.798f, 0.0f}, {1.5f, 0.0f, 0.075f}, {1.425f, 0.0f, 0.0f}, {0.798f, -1.425f,
+ 0.0f}, {0.0f, -1.5f, 0.075f}, {0.0f, -1.425f, 0.0f}, {1.5f, -0.84f, 0.075f},
+ {0.84f, -1.5f, 0.075f}
+ };
+ private static final float tex[] =
+ {
+ 0.0f, 0.0f,
+ 1.0f, 0.0f,
+ 0.0f, 1.0f,
+ 1.0f, 1.0f
+ };
+
+ teapotsCanvas canvas = null;
+
+
+ /* Initialize the applet */
+
+
+ public void init()
+ {
+ Dimension d = getSize();
+ setLayout(new BorderLayout());
+ canvas = new teapotsCanvas(d.width, d.height);
+ add("Center", canvas);
+ }
+
+
+ /* Start the applet */
+
+
+ public void start()
+ {
+ }
+
+
+ /* Stop the applet */
+
+
+ public void stop()
+ {
+ }
+
+ public static void main( String args[] )
+ {
+ Frame mainFrame = new Frame("teapots");
+
+ teapots applet = new teapots();
+
+ applet.setSize(400, 400);
+ applet.init();
+ applet.start();
+
+ mainFrame.add(applet);
+
+ mainFrame.pack();
+ mainFrame.setVisible(true);
+ }
+
+
+ /* Local GLCanvas extension class */
+
+
+ private class teapotsCanvas extends GLCanvas
+ {
+ int teapotList;
+
+ public teapotsCanvas(int w, int h)
+ {
+ super(w, h);
+ GLContext.gljNativeDebug = false;
+ GLContext.gljClassDebug = false;
+ }
+
+ public void preInit()
+ {
+ doubleBuffer = true;
+ stereoView = false;
+ }
+
+ public void init()
+ {
+ System.out.println("init(): " + this);
+ reshape(getSize().width, getSize().height);
+
+ float ambient[] = {0.0f, 0.0f, 0.0f, 1.0f};
+ float diffuse[] = {1.0f, 1.0f, 1.0f, 1.0f};
+ float specular[] = {1.0f, 1.0f, 1.0f, 1.0f};
+ float position[] = {0.0f, 3.0f, 3.0f, 0.0f};
+
+ float lmodel_ambient[] = {0.2f, 0.2f, 0.2f, 1.0f};
+ float local_view[] = {0.0f};
+
+ gl.glLightfv(GL_LIGHT0, GL_AMBIENT, ambient);
+ gl.glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse);
+ gl.glLightfv(GL_LIGHT0, GL_POSITION, position);
+ gl.glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient);
+ gl.glLightModelfv(GL_LIGHT_MODEL_LOCAL_VIEWER, local_view);
+
+ gl.glFrontFace(GL_CW);
+ gl.glEnable(GL_LIGHTING);
+ gl.glEnable(GL_LIGHT0);
+ gl.glEnable(GL_AUTO_NORMAL);
+ gl.glEnable(GL_NORMALIZE);
+ gl.glEnable(GL_DEPTH_TEST);
+ /* be efficient--make teapot display list */
+ teapotList = gl.glGenLists(1);
+ gl.glNewList(teapotList, GL_COMPILE);
+ glutSolidTeapot(1.0);
+ gl.glEndList();
+
+ glj.gljCheckGL();
+ }
+
+ public void reshape(int width, int height)
+ {
+ gl.glViewport(0,0,width,height);
+ gl.glMatrixMode(GL_PROJECTION);
+ gl.glLoadIdentity();
+ if (width <= height)
+ gl.glOrtho
+ (0.0f,
+ 16.0f,
+ 0.0f,
+ 16.0f*(float)height/(float)width,
+ -10.0f,
+ 10.0f);
+ else
+ gl.glOrtho
+ (0.0f,
+ 16.0f*(float)width/(float)height,
+ 0.0f,
+ 16.0,
+ -10.0f,
+ 10.0f);
+ gl.glMatrixMode(GL_MODELVIEW);
+ }
+
+ public void display()
+ {
+ if (glj.gljMakeCurrent() == false) return;
+
+ /**
+ * First column: emerald, jade, obsidian, pearl, ruby, turquoise
+ * 2nd column: brass, bronze, chrome, copper, gold, silver
+ * 3rd column: black, cyan, green, red, white, yellow plastic
+ * 4th column: black, cyan, green, red, white, yellow rubber
+ */
+ gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ renderTeapot
+ (2.0f, 17.0f, 0.0215f, 0.1745f, 0.0215f,
+ 0.07568f, 0.61424f, 0.07568f, 0.633f, 0.727811f, 0.633f, 0.6f);
+ renderTeapot
+ (2.0f, 14.0f, 0.135f, 0.2225f, 0.1575f,
+ 0.54f, 0.89f, 0.63f, 0.316228f, 0.316228f, 0.316228f, 0.1f);
+ renderTeapot
+ (2.0f, 11.0f, 0.05375f, 0.05f, 0.06625f,
+ 0.18275f, 0.17f, 0.22525f, 0.332741f, 0.328634f, 0.346435f, 0.3f);
+ renderTeapot
+ (2.0f, 8.0f, 0.25f, 0.20725f, 0.20725f,
+ 1f, 0.829f, 0.829f, 0.296648f, 0.296648f, 0.296648f, 0.088f);
+ renderTeapot
+ (2.0f, 5.0f, 0.1745f, 0.01175f, 0.01175f,
+ 0.61424f, 0.04136f, 0.04136f, 0.727811f, 0.626959f, 0.626959f, 0.6f);
+ renderTeapot
+ (2.0f, 2.0f, 0.1f, 0.18725f, 0.1745f,
+ 0.396f, 0.74151f, 0.69102f, 0.297254f, 0.30829f, 0.306678f, 0.1f);
+ renderTeapot
+ (6.0f, 17.0f, 0.329412f, 0.223529f, 0.027451f,
+ 0.780392f, 0.568627f, 0.113725f, 0.992157f, 0.941176f, 0.807843f,
+ 0.21794872f);
+ renderTeapot
+ (6.0f, 14.0f, 0.2125f, 0.1275f, 0.054f,
+ 0.714f, 0.4284f, 0.18144f, 0.393548f, 0.271906f, 0.166721f, 0.2f);
+ renderTeapot
+ (6.0f, 11.0f, 0.25f, 0.25f, 0.25f,
+ 0.4f, 0.4f, 0.4f, 0.774597f, 0.774597f, 0.774597f, 0.6f);
+ renderTeapot
+ (6.0f, 8.0f, 0.19125f, 0.0735f, 0.0225f,
+ 0.7038f, 0.27048f, 0.0828f, 0.256777f, 0.137622f, 0.086014f, 0.1f);
+ renderTeapot
+ (6.0f, 5.0f, 0.24725f, 0.1995f, 0.0745f,
+ 0.75164f, 0.60648f, 0.22648f, 0.628281f, 0.555802f, 0.366065f, 0.4f);
+ renderTeapot
+ (6.0f, 2.0f, 0.19225f, 0.19225f, 0.19225f,
+ 0.50754f, 0.50754f, 0.50754f, 0.508273f, 0.508273f, 0.508273f, 0.4f);
+ renderTeapot
+ (10.0f, 17.0f, 0.0f, 0.0f, 0.0f, 0.01f, 0.01f, 0.01f,
+ 0.50f, 0.50f, 0.50f, .25f);
+ renderTeapot
+ (10.0f, 14.0f, 0.0f, 0.1f, 0.06f, 0.0f, 0.50980392f, 0.50980392f,
+ 0.50196078f, 0.50196078f, 0.50196078f, .25f);
+ renderTeapot
+ (10.0f, 11.0f, 0.0f, 0.0f, 0.0f,
+ 0.1f, 0.35f, 0.1f, 0.45f, 0.55f, 0.45f, .25f);
+ renderTeapot
+ (10.0f, 8.0f, 0.0f, 0.0f, 0.0f, 0.5f, 0.0f, 0.0f,
+ 0.7f, 0.6f, 0.6f, .25f);
+ renderTeapot
+ (10.0f, 5.0f, 0.0f, 0.0f, 0.0f, 0.55f, 0.55f, 0.55f,
+ 0.70f, 0.70f, 0.70f, .25f);
+ renderTeapot
+ (10.0f, 2.0f, 0.0f, 0.0f, 0.0f, 0.5f, 0.5f, 0.0f,
+ 0.60f, 0.60f, 0.50f, .25f);
+ renderTeapot
+ (14.0f, 17.0f, 0.02f, 0.02f, 0.02f, 0.01f, 0.01f, 0.01f,
+ 0.4f, 0.4f, 0.4f, .078125f);
+ renderTeapot
+ (14.0f, 14.0f, 0.0f, 0.05f, 0.05f, 0.4f, 0.5f, 0.5f,
+ 0.04f, 0.7f, 0.7f, .078125f);
+ renderTeapot
+ (14.0f, 11.0f, 0.0f, 0.05f, 0.0f, 0.4f, 0.5f, 0.4f,
+ 0.04f, 0.7f, 0.04f, .078125f);
+ renderTeapot
+ (14.0f, 8.0f, 0.05f, 0.0f, 0.0f, 0.5f, 0.4f, 0.4f,
+ 0.7f, 0.04f, 0.04f, .078125f);
+ renderTeapot
+ (14.0f, 5.0f, 0.05f, 0.05f, 0.05f, 0.5f, 0.5f, 0.5f,
+ 0.7f, 0.7f, 0.7f, .078125f);
+ renderTeapot
+ (14.0f, 2.0f, 0.05f, 0.05f, 0.0f, 0.5f, 0.5f, 0.4f,
+ 0.7f, 0.7f, 0.04f, .078125f);
+ gl.glFlush();
+
+ glj.gljSwap();
+ glj.gljCheckGL();
+ glj.gljFree();
+ }
+
+ /*
+ * Move object into position. Use 3rd through 12th
+ * parameters to specify the material property. Draw a teapot.
+ */
+ private void renderTeapot
+ (float x,
+ float y,
+ float ambr,
+ float ambg,
+ float ambb,
+ float difr,
+ float difg,
+ float difb,
+ float specr,
+ float specg,
+ float specb,
+ float shine)
+ {
+ float mat[] = new float[4];
+
+ gl.glPushMatrix();
+ gl.glTranslatef(x, y, 0.0f);
+ mat[0] = ambr; mat[1] = ambg; mat[2] = ambb; mat[3] = 1.0f;
+ gl.glMaterialfv(GL_FRONT, GL_AMBIENT, mat);
+ mat[0] = difr; mat[1] = difg; mat[2] = difb;
+ gl.glMaterialfv(GL_FRONT, GL_DIFFUSE, mat);
+ mat[0] = specr; mat[1] = specg; mat[2] = specb;
+ gl.glMaterialfv(GL_FRONT, GL_SPECULAR, mat);
+ gl.glMaterialf(GL_FRONT, GL_SHININESS, shine * 128.0f);
+ gl.glCallList(teapotList);
+ gl.glPopMatrix();
+ }
+
+ // Imported from glut.
+ private void glutSolidTeapot(double scale)
+ {
+ teapot(14, scale, GL_FILL);
+ }
+
+ // Imported from glut.
+ private void teapot(int grid, double scale, int type)
+ {
+ float p[] = new float[4*4*3];
+ float q[] = new float[4*4*3];
+ float r[] = new float[4*4*3];
+ float s[] = new float[4*4*3];
+ float sc = (float)(0.5*scale);
+
+ gl.glPushAttrib(GL_ENABLE_BIT | GL_EVAL_BIT);
+ gl.glEnable(GL_AUTO_NORMAL);
+ gl.glEnable(GL_NORMALIZE);
+ gl.glEnable(GL_MAP2_VERTEX_3);
+ gl.glEnable(GL_MAP2_TEXTURE_COORD_2);
+ gl.glPushMatrix();
+ gl.glRotatef(270.0f, 1.0f, 0.0f, 0.0f);
+ gl.glScalef(sc, sc, sc);
+ gl.glTranslatef(0.0f, 0.0f, -1.5f);
+ for (int i = 0; i < 10; i++)
+ {
+ for (int j = 0; j < 4; j++)
+ {
+ for (int k = 0; k < 4; k++)
+ {
+ for (int l = 0; l < 3; l++)
+ {
+ p[(j*12)+(k*3)+l] = cpdata[patchdata[i][j * 4 + k]][l];
+ q[(j*12)+(k*3)+l] = cpdata[patchdata[i][j * 4 + (3 - k)]][l];
+ if (l == 1)
+ q[(j*12)+(k*3)+l] *= -1.0f;
+ if (i < 6)
+ {
+ r[(j*12)+(k*3)+l] =
+ cpdata[patchdata[i][j * 4 + (3 - k)]][l];
+ if (l == 0)
+ r[(j*12)+(k*3)+l] *= -1.0f;
+ s[(j*12)+(k*3)+l] =
+ cpdata[patchdata[i][j * 4 + k]][l];
+ if (l == 0)
+ s[(j*12)+(k*3)+l] *= -1.0f;
+ if (l == 1)
+ s[(j*12)+(k*3)+l] *= -1.0f;
+ }
+ }
+ }
+ }
+ gl.glMap2f
+ (GL_MAP2_TEXTURE_COORD_2, 0, 1, 2, 2, 0, 1, 4, 2, tex);
+ gl.glMap2f
+ (GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4, p);
+ gl.glMapGrid2f(grid, 0.0f, 1.0f, grid, 0.0f, 1.0f);
+ gl.glEvalMesh2(type, 0, grid, 0, grid);
+ gl.glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4, q);
+ gl.glEvalMesh2(type, 0, grid, 0, grid);
+ if (i < 6)
+ {
+ gl.glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4, r);
+ gl.glEvalMesh2(type, 0, grid, 0, grid);
+ gl.glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4, s);
+ gl.glEvalMesh2(type, 0, grid, 0, grid);
+ }
+ }
+ gl.glPopMatrix();
+ gl.glPopAttrib();
+ }
+ }
+}
diff --git a/demos/RonsDemos/teapots_plugin13.html b/demos/RonsDemos/teapots_plugin13.html new file mode 100644 index 0000000..19ee75d --- /dev/null +++ b/demos/RonsDemos/teapots_plugin13.html @@ -0,0 +1,48 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
+ <title>Teapots by Silicon Graphics; ported to Java by Ron Cemer</title>
+</head>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+Teapots applet
+<br>Originially written by Silicon Graphics
+<br>Ported to Java by Ron Cemer
+<br>
+<!--"CONVERTED_APPLET"-->
+<!-- CONVERTER VERSION 1.3 --> +<SCRIPT LANGUAGE="JavaScript"><!-- + var _info = navigator.userAgent; var _ns = false; + var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0); +//--></SCRIPT> +<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!-- + var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0))); +//--></SCRIPT></COMMENT> + +<SCRIPT LANGUAGE="JavaScript"><!-- + if (_ie == true) document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = 400 HEIGHT = 400 codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0"><NOEMBED><XMP>'); + else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.3" CODE = "teapots.class" WIDTH = 400 HEIGHT = 400 scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html"><NOEMBED><XMP>'); +//--></SCRIPT> +<APPLET CODE = "teapots.class" WIDTH = 400 HEIGHT = 400></XMP> +<PARAM NAME = CODE VALUE = "teapots.class" >
+ +<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3"> +<PARAM NAME="scriptable" VALUE="false"> + +</APPLET> + +</NOEMBED></EMBED></OBJECT> + + +<!-- +<APPLET CODE = "teapots.class" WIDTH = 400 HEIGHT = 400>
+
+
+</APPLET> +--> +<!--"END_CONVERTED_APPLET"-->
+
+<hr>
+</body>
+</html>
diff --git a/demos/RonsDemos/texgen.html b/demos/RonsDemos/texgen.html new file mode 100644 index 0000000..859d220 --- /dev/null +++ b/demos/RonsDemos/texgen.html @@ -0,0 +1,22 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
+ <title>Texgen by Silicon Graphics; ported to Java by Ron Cemer</title>
+</head>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+Texgen applet
+<br>Originially written by Silicon Graphics
+<br>Ported to Java by Ron Cemer
+<br>Click inside the window, then press any of the following keys:
+<br>e/E: generate eye linear texture coordinates
+<br>o/O: generate object linear texture coordinates
+<br>s/S: use a slanted plane for texture coordinate generation
+<br>x/X: use a flat plane (x = 0) for texture coordinate generation
+<br>
+<applet code="texgen.class" width=400 height=400>
+</applet>
+<hr>
+</body>
+</html>
diff --git a/demos/RonsDemos/texgen.java b/demos/RonsDemos/texgen.java new file mode 100644 index 0000000..bbc3288 --- /dev/null +++ b/demos/RonsDemos/texgen.java @@ -0,0 +1,478 @@ +/**
+ * @(#) texgen.java
+ * @(#) author: Silicon Graphics, Inc. (converted to Java by Ron Cemer)
+ */
+
+/*
+ * Copyright (c) 1993-1997, Silicon Graphics, Inc.
+ * ALL RIGHTS RESERVED
+ * Permission to use, copy, modify, and distribute this software for
+ * any purpose and without fee is hereby granted, provided that the above
+ * copyright notice appear in all copies and that both the copyright notice
+ * and this permission notice appear in supporting documentation, and that
+ * the name of Silicon Graphics, Inc. not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission.
+ *
+ * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
+ * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
+ * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
+ * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
+ * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
+ * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
+ * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
+ * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
+ * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * US Government Users Restricted Rights
+ * Use, duplication, or disclosure by the Government is subject to
+ * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
+ * (c)(1)(ii) of the Rights in Technical Data and Computer Software
+ * clause at DFARS 252.227-7013 and/or in similar or successor
+ * clauses in the FAR or the DOD or NASA FAR Supplement.
+ * Unpublished-- rights reserved under the copyright laws of the
+ * United States. Contractor/manufacturer is Silicon Graphics,
+ * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
+ *
+ * OpenGL(R) is a registered trademark of Silicon Graphics, Inc.
+ */
+
+/* This program draws a texture mapped teapot with
+ * automatically generated texture coordinates. The
+ * texture is rendered as stripes on the teapot.
+ * Initially, the object is drawn with texture coordinates
+ * based upon the object coordinates of the vertex
+ * and distance from the plane x = 0. Pressing the 'e'
+ * key changes the coordinate generation to eye coordinates
+ * of the vertex. Pressing the 'o' key switches it back
+ * to the object coordinates. Pressing the 's' key
+ * changes the plane to a slanted one (x + y + z = 0).
+ * Pressing the 'x' key switches it back to x = 0.
+ */
+
+import java.applet.*;
+import java.awt.*;
+import java.awt.event.*;
+import java.lang.*;
+import java.util.*;
+import java.io.*;
+import java.util.*;
+import gl4java.GLContext;
+import gl4java.awt.GLCanvas;
+
+public class texgen extends Applet
+{
+ // Data for drawing teapots:
+ /* Rim, body, lid, and bottom data must be reflected in x and
+ y; handle and spout data across the y axis only. */
+ private static final int patchdata[][] =
+ {
+ /* rim */
+ {102, 103, 104, 105, 4, 5, 6, 7, 8, 9, 10, 11,
+ 12, 13, 14, 15},
+ /* body */
+ {12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+ 24, 25, 26, 27},
+ {24, 25, 26, 27, 29, 30, 31, 32, 33, 34, 35, 36,
+ 37, 38, 39, 40},
+ /* lid */
+ {96, 96, 96, 96, 97, 98, 99, 100, 101, 101, 101,
+ 101, 0, 1, 2, 3,},
+ {0, 1, 2, 3, 106, 107, 108, 109, 110, 111, 112,
+ 113, 114, 115, 116, 117},
+ /* bottom */
+ {118, 118, 118, 118, 124, 122, 119, 121, 123, 126,
+ 125, 120, 40, 39, 38, 37},
+ /* handle */
+ {41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
+ 53, 54, 55, 56},
+ {53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
+ 28, 65, 66, 67},
+ /* spout */
+ {68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
+ 80, 81, 82, 83},
+ {80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91,
+ 92, 93, 94, 95}
+ };
+ private static final float cpdata[][] =
+ {
+ {0.2f, 0.0f, 2.7f}, {0.2f, -0.112f, 2.7f}, {0.112f, -0.2f, 2.7f}, {0.0f,
+ -0.2f, 2.7f}, {1.3375f, 0.0f, 2.53125f}, {1.3375f, -0.749f, 2.53125f},
+ {0.749f, -1.3375f, 2.53125f}, {0.0f, -1.3375f, 2.53125f}, {1.4375f,
+ 0.0f, 2.53125f}, {1.4375f, -0.805f, 2.53125f}, {0.805f, -1.4375f,
+ 2.53125f}, {0.0f, -1.4375f, 2.53125f}, {1.5f, 0.0f, 2.4f}, {1.5f, -0.84f,
+ 2.4f}, {0.84f, -1.5f, 2.4f}, {0.0f, -1.5f, 2.4f}, {1.75f, 0.0f, 1.875f},
+ {1.75f, -0.98f, 1.875f}, {0.98f, -1.75f, 1.875f}, {0.0f, -1.75f,
+ 1.875f}, {2f, 0.0f, 1.35f}, {2f, -1.12f, 1.35f}, {1.12f, -2f, 1.35f},
+ {0.0f, -2f, 1.35f}, {2f, 0.0f, 0.9f}, {2f, -1.12f, 0.9f}, {1.12f, -2f,
+ 0.9f}, {0.0f, -2f, 0.9f}, {-2f, 0.0f, 0.9f}, {2f, 0.0f, 0.45f}, {2f, -1.12f,
+ 0.45f}, {1.12f, -2f, 0.45f}, {0.0f, -2f, 0.45f}, {1.5f, 0.0f, 0.225f},
+ {1.5f, -0.84f, 0.225f}, {0.84f, -1.5f, 0.225f}, {0.0f, -1.5f, 0.225f},
+ {1.5f, 0.0f, 0.15f}, {1.5f, -0.84f, 0.15f}, {0.84f, -1.5f, 0.15f}, {0.0f,
+ -1.5f, 0.15f}, {-1.6f, 0.0f, 2.025f}, {-1.6f, -0.3f, 2.025f}, {-1.5f,
+ -0.3f, 2.25f}, {-1.5f, 0.0f, 2.25f}, {-2.3f, 0.0f, 2.025f}, {-2.3f, -0.3f,
+ 2.025f}, {-2.5f, -0.3f, 2.25f}, {-2.5f, 0.0f, 2.25f}, {-2.7f, 0.0f,
+ 2.025f}, {-2.7f, -0.3f, 2.025f}, {-3f, -0.3f, 2.25f}, {-3f, 0.0f,
+ 2.25f}, {-2.7f, 0.0f, 1.8f}, {-2.7f, -0.3f, 1.8f}, {-3f, -0.3f, 1.8f},
+ {-3f, 0.0f, 1.8f}, {-2.7f, 0.0f, 1.575f}, {-2.7f, -0.3f, 1.575f}, {-3f,
+ -0.3f, 1.35f}, {-3f, 0.0f, 1.35f}, {-2.5f, 0.0f, 1.125f}, {-2.5f, -0.3f,
+ 1.125f}, {-2.65f, -0.3f, 0.9375f}, {-2.65f, 0.0f, 0.9375f}, {-2f,
+ -0.3f, 0.9f}, {-1.9f, -0.3f, 0.6f}, {-1.9f, 0.0f, 0.6f}, {1.7f, 0.0f,
+ 1.425f}, {1.7f, -0.66f, 1.425f}, {1.7f, -0.66f, 0.6f}, {1.7f, 0.0f,
+ 0.6f}, {2.6f, 0.0f, 1.425f}, {2.6f, -0.66f, 1.425f}, {3.1f, -0.66f,
+ 0.825f}, {3.1f, 0.0f, 0.825f}, {2.3f, 0.0f, 2.1f}, {2.3f, -0.25f, 2.1f},
+ {2.4f, -0.25f, 2.025f}, {2.4f, 0.0f, 2.025f}, {2.7f, 0.0f, 2.4f}, {2.7f,
+ -0.25f, 2.4f}, {3.3f, -0.25f, 2.4f}, {3.3f, 0.0f, 2.4f}, {2.8f, 0.0f,
+ 2.475f}, {2.8f, -0.25f, 2.475f}, {3.525f, -0.25f, 2.49375f},
+ {3.525f, 0.0f, 2.49375f}, {2.9f, 0.0f, 2.475f}, {2.9f, -0.15f, 2.475f},
+ {3.45f, -0.15f, 2.5125f}, {3.45f, 0.0f, 2.5125f}, {2.8f, 0.0f, 2.4f},
+ {2.8f, -0.15f, 2.4f}, {3.2f, -0.15f, 2.4f}, {3.2f, 0.0f, 2.4f}, {0.0f, 0.0f,
+ 3.15f}, {0.8f, 0.0f, 3.15f}, {0.8f, -0.45f, 3.15f}, {0.45f, -0.8f,
+ 3.15f}, {0.0f, -0.8f, 3.15f}, {0.0f, 0.0f, 2.85f}, {1.4f, 0.0f, 2.4f}, {1.4f,
+ -0.784f, 2.4f}, {0.784f, -1.4f, 2.4f}, {0.0f, -1.4f, 2.4f}, {0.4f, 0.0f,
+ 2.55f}, {0.4f, -0.224f, 2.55f}, {0.224f, -0.4f, 2.55f}, {0.0f, -0.4f,
+ 2.55f}, {1.3f, 0.0f, 2.55f}, {1.3f, -0.728f, 2.55f}, {0.728f, -1.3f,
+ 2.55f}, {0.0f, -1.3f, 2.55f}, {1.3f, 0.0f, 2.4f}, {1.3f, -0.728f, 2.4f},
+ {0.728f, -1.3f, 2.4f}, {0.0f, -1.3f, 2.4f}, {0.0f, 0.0f, 0.0f}, {1.425f,
+ -0.798f, 0.0f}, {1.5f, 0.0f, 0.075f}, {1.425f, 0.0f, 0.0f}, {0.798f, -1.425f,
+ 0.0f}, {0.0f, -1.5f, 0.075f}, {0.0f, -1.425f, 0.0f}, {1.5f, -0.84f, 0.075f},
+ {0.84f, -1.5f, 0.075f}
+ };
+ private static final float tex[] =
+ {
+ 0.0f, 0.0f,
+ 1.0f, 0.0f,
+ 0.0f, 1.0f,
+ 1.0f, 1.0f
+ };
+
+ texgenCanvas canvas = null;
+
+
+ /* Initialize the applet */
+
+
+ public void init()
+ {
+ Dimension d = getSize();
+ setLayout(new BorderLayout());
+ canvas = new texgenCanvas(d.width, d.height);
+ canvas.requestFocus();
+ add("Center", canvas);
+ }
+
+
+ /* Start the applet */
+
+
+ public void start()
+ {
+ }
+
+
+ /* Stop the applet */
+
+
+ public void stop()
+ {
+ }
+
+
+
+
+ /* Local GLCanvas extension class */
+
+
+ private class texgenCanvas extends GLCanvas
+ implements KeyListener, MouseListener
+ {
+ private static final int stripeImageWidth = 32;
+ private byte stripeImage[] = new byte[4*stripeImageWidth];
+ private int texName;
+
+ /* planes for texture coordinate generation */
+ private float xequalzero[] = {1.0f, 0.0f, 0.0f, 0.0f};
+ private float slanted[] = {1.0f, 1.0f, 1.0f, 0.0f};
+ private float currentCoeff[];
+ private int currentPlane;
+ private int currentGenMode;
+
+ public texgenCanvas(int w, int h)
+ {
+ super(w, h);
+ GLContext.gljNativeDebug = false;
+ GLContext.gljClassDebug = false;
+ }
+
+ public void preInit()
+ {
+ doubleBuffer = true;
+ stereoView = false;
+ }
+
+ public void init()
+ {
+ System.out.println("init(): " + this);
+ reshape(getSize().width, getSize().height);
+
+ gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
+ gl.glEnable(GL_DEPTH_TEST);
+ gl.glShadeModel(GL_SMOOTH);
+
+ makeStripeImage();
+ gl.glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+
+ int tnbuf[] = new int[1];
+ gl.glGenTextures(1, tnbuf);
+ texName = tnbuf[0];
+ gl.glBindTexture(GL_TEXTURE_1D, texName);
+ gl.glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_REPEAT);
+ gl.glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ gl.glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ gl.glTexImage1D
+ (GL_TEXTURE_1D,
+ 0,
+ GL_RGBA,
+ stripeImageWidth,
+ 0,
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ stripeImage);
+ gl.glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+ currentCoeff = xequalzero;
+ currentGenMode = GL_OBJECT_LINEAR;
+ currentPlane = GL_OBJECT_PLANE;
+ gl.glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, currentGenMode);
+ gl.glTexGenfv(GL_S, currentPlane, currentCoeff);
+
+ gl.glEnable(GL_TEXTURE_GEN_S);
+ gl.glEnable(GL_TEXTURE_1D);
+ gl.glEnable(GL_CULL_FACE);
+ gl.glEnable(GL_LIGHTING);
+ gl.glEnable(GL_LIGHT0);
+ gl.glEnable(GL_AUTO_NORMAL);
+ gl.glEnable(GL_NORMALIZE);
+ gl.glFrontFace(GL_CW);
+ gl.glCullFace(GL_BACK);
+ gl.glMaterialf(GL_FRONT, GL_SHININESS, 64.0f);
+
+ glj.gljCheckGL();
+
+ addKeyListener(this);
+ addMouseListener(this);
+ }
+
+ public void cvsDispose()
+ {
+ System.out.println("destroy(): " + this);
+ removeKeyListener(this);
+ super.cvsDispose();
+ }
+
+ public void reshape(int width, int height)
+ {
+ gl.glViewport(0,0,width,height);
+ gl.glMatrixMode(GL_PROJECTION);
+ gl.glLoadIdentity();
+ if (width <= height)
+ gl.glOrtho
+ (-3.5f,3.5f,-3.5f*(float)height/(float)width,
+ 3.5f*(float)height/(float)width,-3.5f,3.5f);
+ else
+ gl.glOrtho
+ (-3.5f*(float)width/(float)height,
+ 3.5f*(float)width/(float)height,-3.5f,3.5f,-3.5f,3.5f);
+ gl.glMatrixMode(GL_MODELVIEW);
+ gl.glLoadIdentity();
+ gl.glMatrixMode(GL_PROJECTION);
+ gl.glLoadIdentity();
+ if (width <= height)
+ gl.glOrtho
+ (-3.5f,3.5f,-3.5f*(float)height/(float)width,
+ 3.5f*(float)height/(float)width,-3.5f,3.5f);
+ else
+ gl.glOrtho
+ (-3.5f*(float)width/(float)height,
+ 3.5f*(float)width/(float)height,-3.5f,3.5f,-3.5f,3.5f);
+ gl.glMatrixMode(GL_MODELVIEW);
+ gl.glLoadIdentity();
+ }
+
+ public void display()
+ {
+ if (glj.gljMakeCurrent() == false) return;
+
+ gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+ gl.glPushMatrix ();
+ gl.glRotatef(45.0f, 0.0f, 0.0f, 1.0f);
+ gl.glBindTexture(GL_TEXTURE_1D, texName);
+ glutSolidTeapot(2.0f);
+ gl.glPopMatrix();
+ gl.glFlush();
+
+ glj.gljSwap();
+ glj.gljCheckGL();
+ glj.gljFree();
+ }
+
+ // Methods required for the implementation of KeyListener
+ public void keyPressed(KeyEvent e)
+ {
+ }
+
+ public void keyReleased(KeyEvent e)
+ {
+ }
+
+ public void keyTyped(KeyEvent e)
+ {
+ if (glj.gljMakeCurrent() == false) return;
+ boolean dorepaint = false;
+ switch ((char)e.getKeyChar())
+ {
+ case 'e':
+ case 'E':
+ currentGenMode = GL_EYE_LINEAR;
+ currentPlane = GL_EYE_PLANE;
+ gl.glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, currentGenMode);
+ gl.glTexGenfv(GL_S, currentPlane, currentCoeff);
+ dorepaint = true;
+ break;
+ case 'o':
+ case 'O':
+ currentGenMode = GL_OBJECT_LINEAR;
+ currentPlane = GL_OBJECT_PLANE;
+ gl.glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, currentGenMode);
+ gl.glTexGenfv(GL_S, currentPlane, currentCoeff);
+ dorepaint = true;
+ break;
+ case 's':
+ case 'S':
+ currentCoeff = slanted;
+ gl.glTexGenfv(GL_S, currentPlane, currentCoeff);
+ dorepaint = true;
+ break;
+ case 'x':
+ case 'X':
+ currentCoeff = xequalzero;
+ gl.glTexGenfv(GL_S, currentPlane, currentCoeff);
+ dorepaint = true;
+ break;
+ }
+ glj.gljFree();
+ if (dorepaint) repaint();
+ }
+
+ private void makeStripeImage()
+ {
+ for (int j = 0; j < stripeImageWidth; j++)
+ {
+ stripeImage[4*j] = (byte)((j<=4) ? 255 : 0);
+ stripeImage[4*j+1] = (byte)((j>4) ? 255 : 0);
+ stripeImage[4*j+2] = (byte)0;
+ stripeImage[4*j+3] = (byte)255;
+ }
+ }
+
+ // Imported from glut.
+ private void glutSolidTeapot(double scale)
+ {
+ teapot(14, scale, GL_FILL);
+ }
+
+ // Imported from glut.
+ private void teapot(int grid, double scale, int type)
+ {
+ float p[] = new float[4*4*3];
+ float q[] = new float[4*4*3];
+ float r[] = new float[4*4*3];
+ float s[] = new float[4*4*3];
+ float sc = (float)(0.5*scale);
+
+ gl.glPushAttrib(GL_ENABLE_BIT | GL_EVAL_BIT);
+ gl.glEnable(GL_AUTO_NORMAL);
+ gl.glEnable(GL_NORMALIZE);
+ gl.glEnable(GL_MAP2_VERTEX_3);
+ gl.glEnable(GL_MAP2_TEXTURE_COORD_2);
+ gl.glPushMatrix();
+ gl.glRotatef(270.0f, 1.0f, 0.0f, 0.0f);
+ gl.glScalef(sc, sc, sc);
+ gl.glTranslatef(0.0f, 0.0f, -1.5f);
+ for (int i = 0; i < 10; i++)
+ {
+ for (int j = 0; j < 4; j++)
+ {
+ for (int k = 0; k < 4; k++)
+ {
+ for (int l = 0; l < 3; l++)
+ {
+ p[(j*12)+(k*3)+l] = cpdata[patchdata[i][j * 4 + k]][l];
+ q[(j*12)+(k*3)+l] = cpdata[patchdata[i][j * 4 + (3 - k)]][l];
+ if (l == 1)
+ q[(j*12)+(k*3)+l] *= -1.0f;
+ if (i < 6)
+ {
+ r[(j*12)+(k*3)+l] =
+ cpdata[patchdata[i][j * 4 + (3 - k)]][l];
+ if (l == 0)
+ r[(j*12)+(k*3)+l] *= -1.0f;
+ s[(j*12)+(k*3)+l] =
+ cpdata[patchdata[i][j * 4 + k]][l];
+ if (l == 0)
+ s[(j*12)+(k*3)+l] *= -1.0f;
+ if (l == 1)
+ s[(j*12)+(k*3)+l] *= -1.0f;
+ }
+ }
+ }
+ }
+ gl.glMap2f
+ (GL_MAP2_TEXTURE_COORD_2, 0, 1, 2, 2, 0, 1, 4, 2, tex);
+ gl.glMap2f
+ (GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4, p);
+ gl.glMapGrid2f(grid, 0.0f, 1.0f, grid, 0.0f, 1.0f);
+ gl.glEvalMesh2(type, 0, grid, 0, grid);
+ gl.glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4, q);
+ gl.glEvalMesh2(type, 0, grid, 0, grid);
+ if (i < 6)
+ {
+ gl.glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4, r);
+ gl.glEvalMesh2(type, 0, grid, 0, grid);
+ gl.glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4, s);
+ gl.glEvalMesh2(type, 0, grid, 0, grid);
+ }
+ }
+ gl.glPopMatrix();
+ gl.glPopAttrib();
+ }
+
+ // Methods required for the implementation of MouseListener
+ public void mouseEntered( MouseEvent evt )
+ {
+ Component comp = evt.getComponent();
+ if( comp.equals(this ) )
+ {
+ requestFocus();
+ }
+ }
+
+ public void mouseExited( MouseEvent evt )
+ { }
+ public void mousePressed( MouseEvent evt )
+ { }
+ public void mouseReleased( MouseEvent evt )
+ { }
+ public void mouseClicked( MouseEvent evt )
+ {
+ Component comp = evt.getComponent();
+ if( comp.equals(this ) )
+ {
+ requestFocus();
+ }
+ }
+ }
+}
diff --git a/demos/RonsDemos/texgen_plugin13.html b/demos/RonsDemos/texgen_plugin13.html new file mode 100644 index 0000000..f776b4c --- /dev/null +++ b/demos/RonsDemos/texgen_plugin13.html @@ -0,0 +1,53 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
+ <title>Texgen by Silicon Graphics; ported to Java by Ron Cemer</title>
+</head>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+Texgen applet
+<br>Originially written by Silicon Graphics
+<br>Ported to Java by Ron Cemer
+<br>Click inside the window, then press any of the following keys:
+<br>e/E: generate eye linear texture coordinates
+<br>o/O: generate object linear texture coordinates
+<br>s/S: use a slanted plane for texture coordinate generation
+<br>x/X: use a flat plane (x = 0) for texture coordinate generation
+<br>
+<!--"CONVERTED_APPLET"-->
+<!-- CONVERTER VERSION 1.3 --> +<SCRIPT LANGUAGE="JavaScript"><!-- + var _info = navigator.userAgent; var _ns = false; + var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0); +//--></SCRIPT> +<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!-- + var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0))); +//--></SCRIPT></COMMENT> + +<SCRIPT LANGUAGE="JavaScript"><!-- + if (_ie == true) document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = 400 HEIGHT = 400 codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0"><NOEMBED><XMP>'); + else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.3" CODE = "texgen.class" WIDTH = 400 HEIGHT = 400 scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html"><NOEMBED><XMP>'); +//--></SCRIPT> +<APPLET CODE = "texgen.class" WIDTH = 400 HEIGHT = 400></XMP> +<PARAM NAME = CODE VALUE = "texgen.class" >
+ +<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3"> +<PARAM NAME="scriptable" VALUE="false"> + +</APPLET> + +</NOEMBED></EMBED></OBJECT> + + +<!-- +<APPLET CODE = "texgen.class" WIDTH = 400 HEIGHT = 400>
+
+
+</APPLET> +--> +<!--"END_CONVERTED_APPLET"-->
+
+<hr>
+</body>
+</html>
diff --git a/demos/RonsDemos/texobj.html b/demos/RonsDemos/texobj.html new file mode 100644 index 0000000..63f7d5b --- /dev/null +++ b/demos/RonsDemos/texobj.html @@ -0,0 +1,18 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
+ <title>Texobj by Brian Paul; ported to Java by Ron Cemer</title>
+</head>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+Texobj applet
+<br>Originially written by Brian Paul
+<br>Ported to Java by Ron Cemer
+<br>
+<hr>
+<applet code="texobj.class" width=400 height=400>
+</applet>
+<hr>
+</body>
+</html>
diff --git a/demos/RonsDemos/texobj.java b/demos/RonsDemos/texobj.java new file mode 100644 index 0000000..49923a0 --- /dev/null +++ b/demos/RonsDemos/texobj.java @@ -0,0 +1,233 @@ +/**
+ * @(#) texobj.java
+ * @(#) author: Brian Paul (converted to Java by Ron Cemer)
+ */
+
+import java.applet.*;
+import java.awt.*;
+import java.awt.event.*;
+import java.lang.*;
+import java.util.*;
+import java.io.*;
+import java.util.*;
+
+import gl4java.GLContext;
+import gl4java.awt.GLAnimCanvas;
+import gl4java.applet.SimpleGLAnimApplet1;
+
+public class texobj extends SimpleGLAnimApplet1
+{
+
+ /* Initialize the applet */
+
+
+ public void init()
+ {
+ super.init();
+ Dimension d = getSize();
+ canvas = new texobjCanvas(d.width, d.height);
+ add("Center", canvas);
+ }
+
+
+ /* Local GLAnimCanvas extension class */
+
+
+ private class texobjCanvas extends GLAnimCanvas
+ {
+ private int TexObj[];
+ float Angle = 0.0f;
+
+ public texobjCanvas(int w, int h)
+ {
+ super(w, h);
+ GLContext.gljNativeDebug = false;
+ GLContext.gljClassDebug = false;
+ setAnimateFps(30.0);
+
+ TexObj = new int[2];
+ }
+
+ public void preInit()
+ {
+ doubleBuffer = true;
+ stereoView = false;
+ }
+
+ public void init()
+ {
+ System.out.println("init(): " + this);
+ reshape(getSize().width, getSize().height);
+
+ int width = 8, height = 8;
+ byte tex1[] =
+ {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 1, 0, 0, 0,
+ 0, 0, 0, 1, 1, 0, 0, 0,
+ 0, 0, 0, 0, 1, 0, 0, 0,
+ 0, 0, 0, 0, 1, 0, 0, 0,
+ 0, 0, 0, 0, 1, 0, 0, 0,
+ 0, 0, 0, 1, 1, 1, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0
+ };
+ byte tex2[] =
+ {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 2, 2, 0, 0, 0,
+ 0, 0, 2, 0, 0, 2, 0, 0,
+ 0, 0, 0, 0, 0, 2, 0, 0,
+ 0, 0, 0, 0, 2, 0, 0, 0,
+ 0, 0, 0, 2, 0, 0, 0, 0,
+ 0, 0, 2, 2, 2, 2, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0
+ };
+ byte tex[] = new byte[64*3];
+ int i, j;
+
+ gl.glDisable(GL_DITHER);
+
+ /* Setup texturing */
+ gl.glEnable(GL_TEXTURE_2D);
+ gl.glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_DECAL);
+ gl.glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_FASTEST);
+
+ /* generate texture object IDs */
+ gl.glGenTextures(2, TexObj);
+
+ /* setup first texture object */
+ gl.glBindTexture(GL_TEXTURE_2D, TexObj[0]);
+ /* red on white */
+ for (i = 0; i < height; i++)
+ {
+ for (j = 0; j < width; j++)
+ {
+ int p = i*width+j;
+ if ((tex1[(height-i-1)*width+j]) != (byte)0)
+ {
+ tex[p*3] = (byte)255;
+ tex[(p*3)+1] = (byte)0;
+ tex[(p*3)+2] = (byte)0;
+ }
+ else
+ {
+ tex[p*3] = (byte)255;
+ tex[(p*3)+1] = (byte)255;
+ tex[(p*3)+2] = (byte)255;
+ }
+ }
+ }
+ gl.glTexImage2D
+ (GL_TEXTURE_2D,
+ 0,
+ 3,
+ width,
+ height,
+ 0,
+ GL_RGB,
+ GL_UNSIGNED_BYTE,
+ tex);
+ gl.glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
+ gl.glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
+ gl.glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT);
+ gl.glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT);
+ /* end of texture object */
+
+ /* setup second texture object */
+ gl.glBindTexture(GL_TEXTURE_2D,TexObj[1]);
+ /* green on blue */
+ for (i = 0; i < height; i++)
+ {
+ for (j = 0; j < width; j++)
+ {
+ int p = i*width+j;
+ if ((tex2[(height-i-1)*width+j]) != (byte)0)
+ {
+ tex[p*3] = (byte)0;
+ tex[(p*3)+1] = (byte)255;
+ tex[(p*3)+2] = (byte)0;
+ }
+ else
+ {
+ tex[p*3] = (byte)0;
+ tex[(p*3)+1] = (byte)0;
+ tex[(p*3)+2] = (byte)255;
+ }
+ }
+ }
+ gl.glTexImage2D
+ (GL_TEXTURE_2D,
+ 0,
+ 3,
+ width,
+ height,
+ 0,
+ GL_RGB,
+ GL_UNSIGNED_BYTE,
+ tex);
+ gl.glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
+ gl.glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
+ gl.glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT);
+ gl.glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT);
+ /* end texture object */
+
+ glj.gljCheckGL();
+ }
+
+ public void reshape(int width, int height)
+ {
+ gl.glViewport(0,0,width,height);
+
+ gl.glMatrixMode(GL_PROJECTION);
+ gl.glLoadIdentity();
+ gl.glFrustum(-2.0, 2.0, -2.0, 2.0, 6.0, 20.0);
+ gl.glMatrixMode(GL_MODELVIEW);
+ gl.glLoadIdentity();
+ gl.glTranslatef(0.0f, 0.0f, -8.0f);
+ }
+
+ public void display()
+ {
+ if (glj.gljMakeCurrent() == false) return;
+
+ Angle += 0.2f;
+
+ gl.glDepthFunc(GL_EQUAL);
+ gl.glClear(GL_COLOR_BUFFER_BIT);
+
+ gl.glColor3f(1.0f, 1.0f, 1.0f);
+
+ /* draw first polygon */
+ gl.glPushMatrix();
+ gl.glTranslatef(-1.0f, 0.0f, 0.0f);
+ gl.glRotatef(Angle, 0.0f, 0.0f, 1.0f);
+ gl.glBindTexture(GL_TEXTURE_2D, TexObj[0]);
+ gl.glBegin(GL_POLYGON);
+ gl.glTexCoord2f(0.0f, 0.0f); gl.glVertex2f(-1.0f, -1.0f);
+ gl.glTexCoord2f(1.0f, 0.0f); gl.glVertex2f( 1.0f, -1.0f);
+ gl.glTexCoord2f(1.0f, 1.0f); gl.glVertex2f( 1.0f, 1.0f);
+ gl.glTexCoord2f(0.0f, 1.0f); gl.glVertex2f(-1.0f, 1.0f);
+ gl.glEnd();
+ gl.glPopMatrix();
+
+ /* draw second polygon */
+ gl.glPushMatrix();
+ gl.glTranslatef(1.0f, 0.0f, 0.0f);
+ gl.glRotatef(Angle-90.0f, 0.0f, 1.0f, 0.0f);
+ gl.glBindTexture(GL_TEXTURE_2D, TexObj[1]);
+ gl.glBegin(GL_POLYGON);
+ gl.glTexCoord2f(0.0f, 0.0f); gl.glVertex2f(-1.0f, -1.0f);
+ gl.glTexCoord2f(1.0f, 0.0f); gl.glVertex2f( 1.0f, -1.0f);
+ gl.glTexCoord2f(1.0f, 1.0f); gl.glVertex2f( 1.0f, 1.0f);
+ gl.glTexCoord2f(0.0f, 1.0f); gl.glVertex2f(-1.0f, 1.0f);
+ gl.glEnd();
+ gl.glPopMatrix();
+
+ glj.gljSwap();
+ glj.gljCheckGL();
+ glj.gljFree();
+
+ //if (!isSuspended()) repaint(); // Animate at full speed.
+ }
+ }
+}
diff --git a/demos/RonsDemos/texobj_plugin13.html b/demos/RonsDemos/texobj_plugin13.html new file mode 100644 index 0000000..30f3829 --- /dev/null +++ b/demos/RonsDemos/texobj_plugin13.html @@ -0,0 +1,49 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
+ <title>Texobj by Brian Paul; ported to Java by Ron Cemer</title>
+</head>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+Texobj applet
+<br>Originially written by Brian Paul
+<br>Ported to Java by Ron Cemer
+<br>
+<hr>
+<!--"CONVERTED_APPLET"-->
+<!-- CONVERTER VERSION 1.3 --> +<SCRIPT LANGUAGE="JavaScript"><!-- + var _info = navigator.userAgent; var _ns = false; + var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0); +//--></SCRIPT> +<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!-- + var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0))); +//--></SCRIPT></COMMENT> + +<SCRIPT LANGUAGE="JavaScript"><!-- + if (_ie == true) document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = 400 HEIGHT = 400 codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0"><NOEMBED><XMP>'); + else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.3" CODE = "texobj.class" WIDTH = 400 HEIGHT = 400 scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html"><NOEMBED><XMP>'); +//--></SCRIPT> +<APPLET CODE = "texobj.class" WIDTH = 400 HEIGHT = 400></XMP> +<PARAM NAME = CODE VALUE = "texobj.class" >
+ +<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3"> +<PARAM NAME="scriptable" VALUE="false"> + +</APPLET> + +</NOEMBED></EMBED></OBJECT> + + +<!-- +<APPLET CODE = "texobj.class" WIDTH = 400 HEIGHT = 400>
+
+
+</APPLET> +--> +<!--"END_CONVERTED_APPLET"-->
+
+<hr>
+</body>
+</html>
diff --git a/demos/RonsDemos/text3d.html b/demos/RonsDemos/text3d.html new file mode 100644 index 0000000..40d67ac --- /dev/null +++ b/demos/RonsDemos/text3d.html @@ -0,0 +1,17 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
+ <title>Text3d by Robert J. Doyle, Jr.; ported to Java by Ron Cemer</title>
+</head>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+Text3d applet
+<br>Originially written by Robert J. Doyle, Jr.
+<br>Ported to Java by Ron Cemer
+<br>
+<applet code="text3d.class" width=400 height=400>
+</applet>
+<hr>
+</body>
+</html>
diff --git a/demos/RonsDemos/text3d.java b/demos/RonsDemos/text3d.java new file mode 100644 index 0000000..ed40bee --- /dev/null +++ b/demos/RonsDemos/text3d.java @@ -0,0 +1,682 @@ +/**
+ * @(#) text3d.java
+ * @(#) author: Robert J. Doyle, Jr. (converted to Java by Ron Cemer)
+ */
+
+import java.applet.*;
+import java.awt.*;
+import java.awt.event.*;
+import java.lang.*;
+import java.util.*;
+import java.io.*;
+import java.util.*;
+import gl4java.GLContext;
+import gl4java.awt.GLAnimCanvas;
+import gl4java.applet.SimpleGLAnimApplet1;
+
+public class text3d extends SimpleGLAnimApplet1
+{
+ private static final float letterM[][] =
+ {
+ {-3.125000f, 0.000000f, 0.000000f},
+ {-3.125000f, 6.208000f, 0.000000f},
+ {-1.233000f, 6.208000f, 0.000000f},
+ {0.003000f, 1.484000f, 0.000000f},
+ {1.223000f, 6.208000f, 0.000000f},
+ {3.123000f, 6.208000f, 0.000000f},
+ {3.123000f, 0.000000f, 0.000000f},
+ {1.923000f, 0.000000f, 0.000000f},
+ {1.923000f, 5.010000f, 0.000000f},
+ {0.659000f, 0.000000f, 0.000000f},
+ {-0.649000f, 0.000000f, 0.000000f},
+ {-1.925000f, 5.010000f, 0.000000f},
+ {-1.925000f, 0.000000f, 0.000000f}
+ };
+ private static final int letterMtris[][] =
+ {
+ { 1, 0, 12 },
+ { 1, 12, 11 },
+ { 1, 11, 2 },
+ { 2, 11, 3 },
+ { 11, 10, 3 },
+ { 3, 10, 9 },
+ { 3, 9, 8 },
+ { 3, 8, 4 },
+ { 4, 8, 5 },
+ { 5, 8, 7 },
+ { 5, 7, 6 },
+ };
+ private static final float letterO[][] =
+ {
+ {-3.038000f, 3.102000f, 0.0f},
+ {-2.974000f, 3.874000f, 0.0f},
+ {-2.827000f, 4.440000f, 0.0f},
+ {-2.802000f, 4.508000f, 0.0f},
+ {-2.544000f, 5.042000f, 0.0f},
+ {-2.502000f, 5.110000f, 0.0f},
+ {-2.223000f, 5.479000f, 0.0f},
+ {-2.132000f, 5.576000f, 0.0f},
+ {-1.784000f, 5.869000f, 0.0f},
+ {-1.678000f, 5.940000f, 0.0f},
+ {-1.260000f, 6.155000f, 0.0f},
+ {-1.148000f, 6.198000f, 0.0f},
+ {-0.677000f, 6.321000f, 0.0f},
+ {-0.638000f, 6.328000f, 0.0f},
+ {-0.002000f, 6.378000f, 0.0f},
+ {0.634000f, 6.328000f, 0.0f},
+ {1.107000f, 6.210000f, 0.0f},
+ {1.144000f, 6.198000f, 0.0f},
+ {1.570000f, 6.002000f, 0.0f},
+ {1.674000f, 5.940000f, 0.0f},
+ {2.038000f, 5.661000f, 0.0f},
+ {2.128000f, 5.576000f, 0.0f},
+ {2.428000f, 5.217000f, 0.0f},
+ {2.504000f, 5.104000f, 0.0f},
+ {2.762000f, 4.598000f, 0.0f},
+ {2.798000f, 4.508000f, 0.0f},
+ {2.960000f, 3.913000f, 0.0f},
+ {2.970000f, 3.862000f, 0.0f},
+ {3.034000f, 3.102000f, 0.0f},
+ {2.970000f, 2.342000f, 0.0f},
+ {2.815000f, 1.745000f, 0.0f},
+ {2.798000f, 1.696000f, 0.0f},
+ {2.554000f, 1.182000f, 0.0f},
+ {2.504000f, 1.100000f, 0.0f},
+ {2.221000f, 0.726000f, 0.0f},
+ {2.128000f, 0.628000f, 0.0f},
+ {1.776000f, 0.332000f, 0.0f},
+ {1.674000f, 0.264000f, 0.0f},
+ {1.256000f, 0.049000f, 0.0f},
+ {1.144000f, 0.006000f, 0.0f},
+ {0.672000f, -0.117000f, 0.0f},
+ {0.634000f, -0.124000f, 0.0f},
+ {-0.002000f, -0.174000f, 0.0f},
+ {-0.638000f, -0.124000f, 0.0f},
+ {-1.112000f, -0.006000f, 0.0f},
+ {-1.148000f, 0.006000f, 0.0f},
+ {-1.576000f, 0.202000f, 0.0f},
+ {-1.678000f, 0.264000f, 0.0f},
+ {-2.041000f, 0.540000f, 0.0f},
+ {-2.132000f, 0.628000f, 0.0f},
+ {-2.430000f, 0.983000f, 0.0f},
+ {-2.502000f, 1.094000f, 0.0f},
+ {-2.773000f, 1.622000f, 0.0f},
+ {-2.802000f, 1.696000f, 0.0f},
+ {-2.962000f, 2.258000f, 0.0f},
+ {-2.974000f, 2.330000f, 0.0f},
+ {-1.736000f, 3.102000f, 1.0f}, // Begin new strip
+ {-1.710000f, 3.578000f, 0.0f},
+ {-1.644000f, 3.934000f, 0.0f},
+ {-1.503000f, 4.328000f, 0.0f},
+ {-1.494000f, 4.346000f, 0.0f},
+ {-1.352000f, 4.593000f, 0.0f},
+ {-1.306000f, 4.656000f, 0.0f},
+ {-1.120000f, 4.857000f, 0.0f},
+ {-1.040000f, 4.926000f, 0.0f},
+ {-0.825000f, 5.067000f, 0.0f},
+ {-0.726000f, 5.116000f, 0.0f},
+ {-0.480000f, 5.200000f, 0.0f},
+ {-0.402000f, 5.218000f, 0.0f},
+ {-0.041000f, 5.257000f, 0.0f},
+ {-0.002000f, 5.258000f, 0.0f},
+ {0.361000f, 5.227000f, 0.0f},
+ {0.400000f, 5.220000f, 0.0f},
+ {0.650000f, 5.147000f, 0.0f},
+ {0.726000f, 5.116000f, 0.0f},
+ {0.950000f, 4.990000f, 0.0f},
+ {1.038000f, 4.926000f, 0.0f},
+ {1.239000f, 4.736000f, 0.0f},
+ {1.306000f, 4.656000f, 0.0f},
+ {1.462000f, 4.413000f, 0.0f},
+ {1.498000f, 4.342000f, 0.0f},
+ {1.635000f, 3.964000f, 0.0f},
+ {1.644000f, 3.934000f, 0.0f},
+ {1.710000f, 3.568000f, 0.0f},
+ {1.736000f, 3.102000f, 0.0f},
+ {1.710000f, 2.636000f, 0.0f},
+ {1.642000f, 2.268000f, 0.0f},
+ {1.508000f, 1.886000f, 0.0f},
+ {1.496000f, 1.860000f, 0.0f},
+ {1.351000f, 1.610000f, 0.0f},
+ {1.304000f, 1.546000f, 0.0f},
+ {1.115000f, 1.343000f, 0.0f},
+ {1.036000f, 1.276000f, 0.0f},
+ {0.823000f, 1.135000f, 0.0f},
+ {0.724000f, 1.086000f, 0.0f},
+ {0.480000f, 1.001000f, 0.0f},
+ {0.400000f, 0.984000f, 0.0f},
+ {0.035000f, 0.946000f, 0.0f},
+ {-0.002000f, 0.946000f, 0.0f},
+ {-0.368000f, 0.979000f, 0.0f},
+ {-0.402000f, 0.986000f, 0.0f},
+ {-0.653000f, 1.057000f, 0.0f},
+ {-0.726000f, 1.088000f, 0.0f},
+ {-0.952000f, 1.213000f, 0.0f},
+ {-1.040000f, 1.278000f, 0.0f},
+ {-1.240000f, 1.467000f, 0.0f},
+ {-1.306000f, 1.548000f, 0.0f},
+ {-1.460000f, 1.788000f, 0.0f},
+ {-1.494000f, 1.858000f, 0.0f},
+ {-1.639000f, 2.251000f, 0.0f},
+ {-1.644000f, 2.270000f, 0.0f},
+ {-1.710000f, 2.626000f, 0.0f}
+ };
+ private static final int letterOtris[][] =
+ {
+ { 0, 56, 1 },
+ { 1, 56, 57 },
+ { 1, 57, 2 },
+ { 2, 57, 58 },
+ { 2, 58, 3 },
+ { 3, 58, 59 },
+ { 3, 59, 4 },
+ { 4, 59, 60 },
+ { 4, 60, 5 },
+ { 5, 60, 61 },
+ { 5, 61, 6 },
+ { 6, 61, 62 },
+ { 6, 62, 7 },
+ { 7, 62, 63 },
+ { 7, 63, 8 },
+ { 8, 63, 64 },
+ { 8, 64, 9 },
+ { 9, 64, 65 },
+ { 9, 65, 10 },
+ { 10, 65, 66 },
+ { 10, 66, 11 },
+ { 11, 66, 67 },
+ { 11, 67, 12 },
+ { 12, 67, 68 },
+ { 12, 68, 13 },
+ { 13, 68, 69 },
+ { 13, 69, 14 },
+ { 14, 69, 70 },
+ { 14, 70, 15 },
+ { 15, 70, 71 },
+ { 15, 71, 16 },
+ { 16, 71, 72 },
+ { 16, 72, 17 },
+ { 17, 72, 73 },
+ { 17, 73, 18 },
+ { 18, 73, 74 },
+ { 18, 74, 19 },
+ { 19, 74, 75 },
+ { 19, 75, 20 },
+ { 20, 75, 76 },
+ { 20, 76, 21 },
+ { 21, 76, 77 },
+ { 21, 77, 22 },
+ { 22, 77, 78 },
+ { 22, 78, 23 },
+ { 23, 78, 79 },
+ { 23, 79, 24 },
+ { 24, 79, 80 },
+ { 24, 80, 25 },
+ { 25, 80, 81 },
+ { 25, 81, 26 },
+ { 26, 81, 82 },
+ { 26, 82, 27 },
+ { 27, 82, 83 },
+ { 27, 83, 28 },
+ { 28, 83, 84 },
+ { 28, 84, 29 },
+ { 29, 84, 85 },
+ { 29, 85, 30 },
+ { 30, 85, 86 },
+ { 30, 86, 31 },
+ { 31, 86, 87 },
+ { 31, 87, 32 },
+ { 32, 87, 88 },
+ { 32, 88, 33 },
+ { 33, 88, 89 },
+ { 33, 89, 34 },
+ { 34, 89, 90 },
+ { 34, 90, 35 },
+ { 35, 90, 91 },
+ { 35, 91, 36 },
+ { 36, 91, 92 },
+ { 36, 92, 37 },
+ { 37, 92, 93 },
+ { 37, 93, 38 },
+ { 38, 93, 94 },
+ { 38, 94, 39 },
+ { 39, 94, 95 },
+ { 39, 95, 40 },
+ { 40, 95, 96 },
+ { 40, 96, 41 },
+ { 41, 96, 97 },
+ { 41, 97, 42 },
+ { 42, 97, 98 },
+ { 42, 98, 43 },
+ { 43, 98, 99 },
+ { 43, 99, 44 },
+ { 44, 99, 100 },
+ { 44, 100, 45 },
+ { 45, 100, 101 },
+ { 45, 101, 46 },
+ { 46, 101, 102 },
+ { 46, 102, 47 },
+ { 47, 102, 103 },
+ { 47, 103, 48 },
+ { 48, 103, 104 },
+ { 48, 104, 49 },
+ { 49, 104, 105 },
+ { 49, 105, 50 },
+ { 50, 105, 106 },
+ { 50, 106, 51 },
+ { 51, 106, 107 },
+ { 51, 107, 52 },
+ { 52, 107, 108 },
+ { 52, 108, 53 },
+ { 53, 108, 109 },
+ { 53, 109, 54 },
+ { 54, 109, 110 },
+ { 54, 110, 55 },
+ { 55, 110, 111 },
+ { 55, 111, 0 },
+ { 0, 111, 56 },
+ };
+ private static final float letterT[][] =
+ {
+ {-0.640000f, 0.000000f, 0.0f},
+ {-0.640000f, 5.104000f, 0.0f},
+ {-2.476000f, 5.104000f, 0.0f},
+ {-2.476000f, 6.208000f, 0.0f},
+ {2.476000f, 6.208000f, 0.0f},
+ {2.476000f, 5.104000f, 0.0f},
+ {0.640000f, 5.104000f, 0.0f},
+ {0.640000f, 0.000000f, 0.0f}
+ };
+ private static final int letterTtris[][] =
+ {
+ { 1, 0, 7 },
+ { 1, 7, 6 },
+ { 3, 2, 1 },
+ { 3, 1, 6 },
+ { 3, 6, 4 },
+ { 4, 6, 5 },
+ };
+ private static final float letterH[][] =
+ {
+ {-2.570000f, 0.000000f, 0.0f},
+ {-2.570000f, 6.208000f, 0.0f},
+ {-1.282000f, 6.208000f, 0.0f},
+ {-1.282000f, 3.900000f, 0.0f},
+ {1.280000f, 3.900000f, 0.0f},
+ {1.280000f, 6.208000f, 0.0f},
+ {2.568000f, 6.208000f, 0.0f},
+ {2.568000f, 0.000000f, 0.0f},
+ {1.280000f, 0.000000f, 0.0f},
+ {1.280000f, 2.760000f, 0.0f},
+ {-1.282000f, 2.760000f, 0.0f},
+ {-1.282000f, 0.000000f, 0.0f}
+ };
+ private static final int letterHtris[][] =
+ {
+ { 1, 0, 11 },
+ { 1, 11, 10 },
+ { 1, 10, 3 },
+ { 1, 3, 2 },
+ { 3, 10, 9 },
+ { 3, 9, 4 },
+ { 6, 5, 4 },
+ { 6, 4, 9 },
+ { 6, 9, 8 },
+ { 6, 8, 7 },
+ };
+
+
+ /* Initialize the applet */
+
+
+ public void init()
+ {
+ super.init();
+ Dimension d = getSize();
+ canvas = new text3dCanvas(d.width, d.height);
+ add("Center", canvas);
+ }
+
+
+ /* Local GLAnimCanvas extension class */
+
+
+ private class text3dCanvas extends GLAnimCanvas
+ {
+ private final int
+ M_SIDE = 1, M_EDGE = 2, M_WHOLE = 3,
+ O_SIDE = 4, O_EDGE = 5, O_WHOLE = 6,
+ T_SIDE = 7, T_EDGE = 8, T_WHOLE = 9,
+ H_SIDE = 10, H_EDGE = 11, H_WHOLE = 12,
+ REPEAT_SIDE = 13, REPEAT_EDGE = 14, REPEAT1 = 15,
+ REPEAT2_SIDE = 16, REPEAT2_EDGE = 17, REPEAT2 = 18,
+ REPEAT3_SIDE = 19, REPEAT3_EDGE = 20, REPEAT3 = 21,
+ REPEAT4_SIDE = 22, REPEAT4_EDGE = 23, REPEAT4 = 24;
+ private float sideColor[] = {0.0f, 0.0f, 0.5f, 1.0f};
+ private float edgeColor[] = {0.7f, 0.7f, 0.0f, 1.0f};
+ private float shininess[] = {128.0f};
+ private float mat_specular[] = {0.7f, 0.7f, 0.7f, 1.0f};
+ private float width = 0.0f, width2 = 2.0f;
+
+ public text3dCanvas(int w, int h)
+ {
+ super(w, h);
+ GLContext.gljNativeDebug = false;
+ GLContext.gljClassDebug = false;
+ setAnimateFps(30.0);
+ }
+
+ public void preInit()
+ {
+ doubleBuffer = true;
+ stereoView = false;
+ accumSize = 8;
+ }
+
+ public void init()
+ {
+ System.out.println("init(): " + this);
+ reshape(getSize().width, getSize().height);
+
+ int count1 = letterM.length;
+ int count2 = letterO.length;
+ int count3 = letterT.length;
+ int count4 = letterH.length;
+
+ int i;
+
+ float light_ambient[] = { 1.0f, 1.0f, 1.0f, 1.0f };
+ float light_diffuse[] = { 1.0f, 1.0f, 1.0f, 1.0f };
+ float light_specular[] = { 1.0f, 1.0f, 1.0f, 1.0f };
+ /* light_position is NOT default value */
+ float light_position[] = { -1.0f, -1.0f, 1.0f, 0.0f };
+
+ gl.glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient);
+ gl.glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse);
+ gl.glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular);
+ gl.glLightfv(GL_LIGHT0, GL_POSITION, light_position);
+
+ gl.glEnable(GL_LIGHTING);
+ gl.glEnable(GL_LIGHT0);
+ gl.glDepthFunc(GL_LESS);
+ gl.glEnable(GL_DEPTH_TEST);
+
+ gl.glDrawBuffer(GL_FRONT_AND_BACK);
+ gl.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
+ gl.glClear(GL_COLOR_BUFFER_BIT);
+ gl.glClear(GL_ACCUM_BUFFER_BIT);
+ gl.glDrawBuffer(GL_BACK);
+
+ /* Zero position of text */
+
+ for(i = 0; i < count1; i++)
+ letterM[i][1] -= 3.175f;
+ for(i = 0; i < count2; i++)
+ letterO[i][1] -= 3.175f;
+ for(i = 0; i < count3; i++)
+ letterT[i][1] -= 3.175f;
+ for(i = 0; i < count4; i++)
+ letterH[i][1] -= 3.175f;
+
+ glj.gljCheckGL();
+ }
+
+ public void reshape(int width, int height)
+ {
+ gl.glViewport(0,0,width,height);
+ gl.glMatrixMode(GL_PROJECTION);
+ gl.glLoadIdentity();
+ gl.glFrustum(-7.0f, 7.0f, -7.0f, 7.0f, 6.0f, 20.0f);
+ gl.glMatrixMode(GL_MODELVIEW);
+ }
+
+ public void display()
+ {
+ if (glj.gljMakeCurrent() == false) return;
+
+ int i, j;
+ float xPos = -0.34f;
+ gl.glLoadIdentity();
+ gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+ gl.glTranslatef(0.0f, 0.0f, -10.0f);
+
+ extrudeSolidFromPolygon
+ (letterM, letterMtris, width2, REPEAT_SIDE, REPEAT_EDGE, REPEAT1);
+ extrudeSolidFromPolygon
+ (letterO, letterOtris, width2, REPEAT2_SIDE, REPEAT2_EDGE, REPEAT2);
+ extrudeSolidFromPolygon
+ (letterT, letterTtris, width2, REPEAT3_SIDE, REPEAT3_EDGE, REPEAT3);
+ extrudeSolidFromPolygon
+ (letterH, letterHtris, width2, REPEAT4_SIDE, REPEAT4_EDGE, REPEAT4);
+
+ for (j = 1; j < 5; j++)
+ {
+ width = 0.0f;
+ glj.gljCheckGL();
+ for (i = 0; i < 10; i++)
+ {
+ gl.glPushMatrix();
+ repeat(j);
+ gl.glPopMatrix();
+ gl.glPushMatrix();
+ gl.glRotatef(90.0f, 0.0f, 1.0f, 0.0f);
+ switch (j)
+ {
+ case 1:
+ extrudeSolidFromPolygon
+ (letterM, letterMtris, width, M_SIDE, M_EDGE, M_WHOLE);
+ gl.glCallList(M_WHOLE);
+ break;
+ case 2:
+ extrudeSolidFromPolygon
+ (letterO, letterOtris, width, O_SIDE, O_EDGE, O_WHOLE);
+ gl.glCallList(O_WHOLE);
+ break;
+ case 3:
+ extrudeSolidFromPolygon
+ (letterT, letterTtris, width, T_SIDE, T_EDGE, T_WHOLE);
+ gl.glCallList(T_WHOLE);
+ break;
+ case 4:
+ extrudeSolidFromPolygon
+ (letterH, letterHtris, width, H_SIDE, H_EDGE, H_WHOLE);
+ gl.glCallList(H_WHOLE);
+ break;
+ }
+ glj.gljSwap();
+
+ gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ width += 0.2f;
+ gl.glPopMatrix();
+ }
+ for (i = 0; i < 45 ; i++)
+ {
+ gl.glPushMatrix();
+ repeat(j);
+ gl.glPopMatrix();
+
+ gl.glPushMatrix();
+ gl.glRotatef(90.0f - (2.0f * i), 0.0f, 1.0f, 0.0f);
+ switch (j)
+ {
+ case 1:
+ gl.glCallList(M_WHOLE);
+ break;
+ case 2:
+ gl.glCallList(O_WHOLE);
+ break;
+ case 3:
+ gl.glCallList(T_WHOLE);
+ break;
+ case 4:
+ gl.glCallList(H_WHOLE);
+ break;
+ }
+ glj.gljSwap();
+ gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ gl.glPopMatrix();
+ }
+ for (i = 1; i < 32 ; i++)
+ {
+ gl.glPushMatrix();
+ repeat(j);
+ gl.glPopMatrix();
+
+ gl.glPushMatrix();
+ gl.glTranslatef(i * xPos, i * 0.3f, i * -0.3f);
+ switch (j)
+ {
+ case 1:
+ gl.glCallList(M_WHOLE);
+ break;
+ case 2:
+ gl.glCallList(O_WHOLE);
+ break;
+ case 3:
+ gl.glCallList(T_WHOLE);
+ break;
+ case 4:
+ gl.glCallList(H_WHOLE);
+ break;
+ }
+ glj.gljSwap();
+ gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ gl.glPopMatrix();
+ }
+ if (j == 1)
+ xPos += 0.25f;
+ else
+ xPos += 0.21f;
+ }
+ gl.glFlush();
+
+ glj.gljCheckGL();
+ glj.gljFree();
+
+ //if (!isSuspended()) repaint(); // Animate at full speed.
+ }
+
+ /* Mark Kilgard's tessellation code from the "dino" demos.
+ Bug fixes and re-write without GLU tesselator
+ by Ronald B. Cemer */
+ private void extrudeSolidFromPolygon
+ (float data[][],
+ int outlineTriIndices[][],
+ float thickness,
+ int side,
+ int edge,
+ int whole)
+ {
+ double dx, dy, len;
+ int i, j0, j1, j2;
+ int min, max, range;
+ float x0, y0, x1, y1;
+ int count = data.length;
+ int tricount = outlineTriIndices.length;
+
+ gl.glNewList(side, GL_COMPILE);
+ gl.glShadeModel(GL_SMOOTH);
+ gl.glBegin(GL_TRIANGLES);
+ for (i = 0; i < tricount; i++)
+ {
+ j0 = outlineTriIndices[i][0];
+ j1 = outlineTriIndices[i][1];
+ j2 = outlineTriIndices[i][2];
+ gl.glVertex3f(data[j0][0],data[j0][1],0.0f);
+ gl.glVertex3f(data[j1][0],data[j1][1],0.0f);
+ gl.glVertex3f(data[j2][0],data[j2][1],0.0f);
+ }
+ gl.glEnd();
+ gl.glEndList();
+
+ gl.glNewList(edge, GL_COMPILE);
+ for (min = max = 0; min < count; min = max)
+ {
+ for (max = min+1; max < count; max++)
+ if (data[max][2] != 0.0f) break;
+ range = max-min;
+ gl.glBegin(GL_QUAD_STRIP);
+ for (i = min; i <= max; i++)
+ {
+ j0 = i;
+ j1 = i+1;
+ if (j0 >= max) j0 -= range;
+ if (j1 >= max) j1 -= range;
+ x0 = data[j0][0];
+ y0 = data[j0][1];
+ x1 = data[j1][0];
+ y1 = data[j1][1];
+ gl.glVertex3f(x0, y0, 0.0f);
+ gl.glVertex3f(x0, y0, thickness);
+ // Normals
+ dx = y1 - y0;
+ dy = x0 - x1;
+ len = Math.sqrt(dx * dx + dy * dy);
+ gl.glNormal3f((float)(dx / len), (float)(dy / len), 0.0f);
+ }
+ gl.glEnd();
+ }
+ gl.glEndList();
+
+ gl.glNewList(whole, GL_COMPILE);
+ gl.glFrontFace(GL_CW);
+
+ gl.glMaterialfv(GL_FRONT, GL_DIFFUSE, edgeColor);
+ gl.glMaterialfv(GL_FRONT, GL_SHININESS, shininess);
+ gl.glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
+ gl.glCallList(edge);
+
+ gl.glMaterialfv(GL_FRONT, GL_DIFFUSE, sideColor);
+ gl.glMaterialfv(GL_FRONT, GL_SHININESS, shininess);
+ gl.glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
+ gl.glNormal3f(0.0f, 0.0f, -1.0f);
+ gl.glCallList(side);
+ gl.glPushMatrix();
+ gl.glTranslatef(0.0f, 0.0f, thickness);
+ gl.glFrontFace(GL_CCW);
+ gl.glNormal3f(0.0f, 0.0f, 1.0f);
+ gl.glCallList(side);
+ gl.glPopMatrix();
+
+ gl.glEndList();
+ }
+
+ private void repeat(int j)
+ {
+ if (j == 2)
+ {
+ gl.glPushMatrix();
+ gl.glTranslatef((31.0f * -0.34f) , 9.3f, -9.6f);
+ gl.glCallList(REPEAT1);
+ gl.glPopMatrix();
+ }
+ if (j == 3)
+ {
+ gl.glPushMatrix();
+ gl.glTranslatef(31.0f * -0.34f, 9.3f, -9.6f);
+ gl.glCallList(REPEAT1);
+ gl.glPopMatrix();
+ gl.glPushMatrix();
+ gl.glTranslatef(31.0f * -0.09f, 9.3f, -9.6f);
+ gl.glCallList(REPEAT2);
+ gl.glPopMatrix();
+ }
+ if (j == 4)
+ {
+ gl.glPushMatrix();
+ gl.glTranslatef(31.0f * -0.34f, 9.3f, -9.6f);
+ gl.glCallList(REPEAT1);
+ gl.glPopMatrix();
+ gl.glPushMatrix();
+ gl.glTranslatef(31.0f * -0.09f, 9.3f, -9.6f);
+ gl.glCallList(REPEAT2);
+ gl.glPopMatrix();
+ gl.glPushMatrix();
+ gl.glTranslatef(31.0f * 0.12f, 9.3f, -9.6f);
+ gl.glCallList(REPEAT3);
+ gl.glPopMatrix();
+ }
+ }
+ }
+}
diff --git a/demos/RonsDemos/text3d_plugin13.html b/demos/RonsDemos/text3d_plugin13.html new file mode 100644 index 0000000..79c5976 --- /dev/null +++ b/demos/RonsDemos/text3d_plugin13.html @@ -0,0 +1,48 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
+ <title>Text3d by Robert J. Doyle, Jr.; ported to Java by Ron Cemer</title>
+</head>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+Text3d applet
+<br>Originially written by Robert J. Doyle, Jr.
+<br>Ported to Java by Ron Cemer
+<br>
+<!--"CONVERTED_APPLET"-->
+<!-- CONVERTER VERSION 1.3 --> +<SCRIPT LANGUAGE="JavaScript"><!-- + var _info = navigator.userAgent; var _ns = false; + var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0); +//--></SCRIPT> +<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!-- + var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0))); +//--></SCRIPT></COMMENT> + +<SCRIPT LANGUAGE="JavaScript"><!-- + if (_ie == true) document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = 400 HEIGHT = 400 codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0"><NOEMBED><XMP>'); + else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.3" CODE = "text3d.class" WIDTH = 400 HEIGHT = 400 scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html"><NOEMBED><XMP>'); +//--></SCRIPT> +<APPLET CODE = "text3d.class" WIDTH = 400 HEIGHT = 400></XMP> +<PARAM NAME = CODE VALUE = "text3d.class" >
+ +<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3"> +<PARAM NAME="scriptable" VALUE="false"> + +</APPLET> + +</NOEMBED></EMBED></OBJECT> + + +<!-- +<APPLET CODE = "text3d.class" WIDTH = 400 HEIGHT = 400>
+
+
+</APPLET> +--> +<!--"END_CONVERTED_APPLET"-->
+
+<hr>
+</body>
+</html>
diff --git a/demos/SwingDemos/CrossColorJPanel.java b/demos/SwingDemos/CrossColorJPanel.java new file mode 100644 index 0000000..44a6492 --- /dev/null +++ b/demos/SwingDemos/CrossColorJPanel.java @@ -0,0 +1,55 @@ +import java.awt.*; +import javax.swing.*; +import gl4java.*; +import gl4java.swing.*; + +public class CrossColorJPanel extends GLJPanel +{ + public CrossColorJPanel( ) + { + super(); + } + + + public void init() { + reshape(getSize().width, getSize().height); + } + + public void display() + { + System.out.println("i"); + int i; + + gl.glPushMatrix(); + gl.glClear(GL_COLOR_BUFFER_BIT); + + gl.glBegin(GLEnum.GL_LINES); + gl.glColor4f(0f, 0f, 1f, 1f); + gl.glVertex3i( 0, 0, 0); + gl.glVertex3i( 10, 10, 0); + + gl.glColor4f(0f, 1f, 0f, 1f); + gl.glVertex3i( 0, 10, 0); + gl.glVertex3i( 10, 0, 0); + + gl.glColor4f(1f, 0f, 0f, 1f); + gl.glVertex3i( 0, 5, 0); + gl.glVertex3i( 10, 5, 0); + + gl.glColor4f(1f, 1f, 1f, 1f); + gl.glVertex3i( 5, 0, 0); + gl.glVertex3i( 5, 10, 0); + gl.glEnd(); + + gl.glPopMatrix(); + } + + public void reshape( int width, int height ) + { + gl.glViewport(0, 0, width, height); + gl.glMatrixMode(GL_PROJECTION); + gl.glLoadIdentity(); + gl.glOrtho(0, 10, 0, 10, -50.0,50.0); + gl.glMatrixMode(GL_MODELVIEW); + } +} diff --git a/demos/SwingDemos/DrawColoredPrimitivesJPanel.java b/demos/SwingDemos/DrawColoredPrimitivesJPanel.java new file mode 100644 index 0000000..66fc849 --- /dev/null +++ b/demos/SwingDemos/DrawColoredPrimitivesJPanel.java @@ -0,0 +1,79 @@ +/**
+ * @(#) DrawColoredPrimitives.java
+ * @(#) author: Joe Zimmerman (converted to Java by Sven Goethel)
+ */
+
+/* This program is free software under the license of LGPL */
+
+import java.applet.*;
+import java.awt.*;
+import java.awt.event.*;
+import java.lang.*;
+import java.util.*;
+import java.io.*;
+import java.util.*;
+import gl4java.GLContext;
+import gl4java.swing.*;
+
+public class DrawColoredPrimitivesJPanel extends GLAnimJPanel
+{
+ float rotate;
+
+ float LightAmbient[] = { 0.75f, 0.75f, 0.75f, 1.5f};
+ float LightDiffuse[] = { 1.0f, 1.0f, 1.0f, 0.9f};
+ float LightSpecular[] = { 0.8f, 0.8f, 0.8f, 1.0f};
+
+ public DrawColoredPrimitivesJPanel()
+ {
+ super(false);
+ setAnimateFps(30.0);
+ }
+
+ public void preInit()
+ {
+ stereoView = false;
+ }
+
+ public void init()
+ {
+ reshape(getSize().width, getSize().height);
+
+ gl.glEnable(GL_LIGHT0);
+ gl.glLightfv(GL_LIGHT0, GL_AMBIENT, LightAmbient);
+ gl.glLightfv(GL_LIGHT0, GL_DIFFUSE, LightDiffuse);
+ gl.glLightfv(GL_LIGHT0, GL_SPECULAR, LightSpecular);
+
+ glj.gljCheckGL();
+ }
+
+ public void reshape(int width, int height)
+ {
+ gl.glMatrixMode(GL_PROJECTION);
+ gl.glLoadIdentity();
+ glu.gluPerspective(45, (float)width/(float)height, 1, 700);
+ gl.glMatrixMode(GL_MODELVIEW);
+ gl.glLoadIdentity();
+ gl.glViewport(0,0,width,height);
+ }
+
+ public void display()
+ {
+ gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+ gl.glMatrixMode(GL_MODELVIEW);
+ gl.glLoadIdentity();
+
+ gl.glColor4f(1, 1, 1, 1);
+
+ rotate++;
+
+ gl.glTranslatef(0, 0, -5);
+ gl.glRotatef(rotate, 0, 1, 0);
+ gl.glBegin(GL_POLYGON);
+ gl.glNormal3f( 1, 0, 0);
+ gl.glColor4f(1, 0, 0, 1); gl.glVertex3f( 0, 1, 0);
+ gl.glColor4f(0, 1, 0, 1); gl.glVertex3f(-1, -1, 0);
+ gl.glColor4f(0, 0, 1, 1); gl.glVertex3f( 1, -1, 0);
+ gl.glEnd();
+ }
+}
diff --git a/demos/SwingDemos/GLSwingDemoApplet.java b/demos/SwingDemos/GLSwingDemoApplet.java new file mode 100755 index 0000000..33b0d95 --- /dev/null +++ b/demos/SwingDemos/GLSwingDemoApplet.java @@ -0,0 +1,168 @@ +import java.applet.*; +import java.awt.*; +import java.awt.event.*; +import java.awt.Dimension; +import javax.swing.*; +import gl4java.*; +import gl4java.swing.*; +import gl4java.utils.glut.*; +import gl4java.utils.glut.fonts.*; + +public class GLSwingDemoApplet extends SimpleGLJApplet1 + implements GLEnum, GLUEnum, ActionListener, ItemListener +{ + String[] dataSize = {"offscreen-size: component", + "offscreen-size: 10x10", + "offscreen-size: 50x50", + "offscreen-size: 100x100", + "offscreen-size: 500x500", + "offscreen-size: 1000x1000"}; + + Dimension[] dimSize = { null, + new Dimension(10,10), + new Dimension(50,50), + new Dimension(100,100), + new Dimension(500,500), + new Dimension(1000,1000)}; + + + String[] data = {"CrossColorJPanel", + "GearsJPanel", + "DrawColoredPrimitivesJPanel", + "TessJPanel"}; + + JPanel masterPanel = null; + JComboBox glChoice = null; + JComboBox glOffScrnSize = null; + boolean isAnApplet = true; + + public void init() + { + super.init(); + if(isAnApplet==false) + { + GLContext.gljNativeDebug = true; + GLContext.gljClassDebug = true; + } + + masterPanel = new JPanel (new BorderLayout()); + getContentPane().add("Center",masterPanel); + canvas = new CrossColorJPanel(); + masterPanel.add("Center", canvas); + + JPanel np = new JPanel(); + masterPanel.add("North", np); + glChoice = new JComboBox(data); + glChoice.addItemListener(this); + np.add(glChoice); + glOffScrnSize = new JComboBox(dataSize); + glOffScrnSize.addItemListener(this); + np.add(glOffScrnSize); + + JButton b1, b2; + masterPanel.add("East", (b1 = new JButton("E"))); + b1.setActionCommand("east"); + b1.addActionListener(this); + masterPanel.add("West", (b2 = new JButton("W"))); + b2.setActionCommand("west"); + b2.addActionListener(this); + + JCheckBox c1; + masterPanel.add("South", (c1 = new JCheckBox("SouthButton", true))); + c1.addItemListener(this); + } + + public static void main(java.lang.String[] args) { + try { + boolean withAWT=false; + + if(args.length>0 && args[0].equals("withAWT")) + withAWT=true; + Frame mainFrame = new Frame("test1"); + + GLSwingDemoApplet applet=new GLSwingDemoApplet(); + + applet.isAnApplet=false; + applet.init(); + applet.start(); + + mainFrame.add(applet); + applet.setSize(480, 480); + + if(withAWT) + { + gears applet2 = new gears(); + applet2.setSize(300, 300); + applet2.init(); + applet2.start(); + mainFrame.add(applet2); + applet2.setSize(300, 300); + } + mainFrame.pack(); + mainFrame.setVisible(true); + + } catch (Throwable exception) { + System.err.println("Exception occurred in main()"); + exception.printStackTrace(System.out); + } + } + + public void actionPerformed(ActionEvent e) { + if (e.getActionCommand().equals("east")) { + System.out.println("East pressed"); + } else if (e.getActionCommand().equals("west")) { + System.out.println("West pressed"); + } + } + + public void itemStateChanged(ItemEvent e) { + Object source = e.getItemSelectable(); + Object item = e.getItem(); + System.out.println("item changed: "+source); + + if(glChoice!=null && + glChoice.equals(e.getItemSelectable()) && + e.getStateChange()==ItemEvent.SELECTED && + (item instanceof String)==true + ) + { + String clazzName = (String)item; + try { + Object obj = + Class.forName(clazzName).newInstance(); + if(obj instanceof GLJPanel) + { + if(canvas!=null) + { + masterPanel.remove(canvas); + canvas.cvsDispose(); + } + canvas = (GLJPanel)obj; + canvas.setVisible(true); + masterPanel.add("Center", canvas); + masterPanel.invalidate(); + masterPanel.validate(); + masterPanel.repaint(); + glOffScrnSize.setSelectedIndex(0); + } + if(obj instanceof GLAnimJPanel) + { + ((GLAnimJPanel)obj).start(); + } + } catch (Exception ex) { + System.out.println("Exception during loading: "+ + clazzName); + System.out.println(ex); + } + } else + if(glOffScrnSize!=null && canvas!=null && + glOffScrnSize.equals(e.getItemSelectable()) && + e.getStateChange()==ItemEvent.SELECTED && + (item instanceof String)==true + ) + { + int idx = glOffScrnSize.getSelectedIndex(); + canvas.setOffScreenSize(dimSize[idx]); + } + } +} diff --git a/demos/SwingDemos/GearsJPanel.java b/demos/SwingDemos/GearsJPanel.java new file mode 100644 index 0000000..3d03111 --- /dev/null +++ b/demos/SwingDemos/GearsJPanel.java @@ -0,0 +1,382 @@ +/**
+ * @(#) GearsJPanel.java
+ * @(#) author: Brian Paul (converted to Java by Ron Cemer & Sven Goethel)
+ */
+
+import java.applet.*;
+import java.awt.*;
+import java.awt.event.*;
+import java.lang.*;
+import java.util.*;
+import java.io.*;
+import java.util.*;
+import gl4java.GLContext;
+import gl4java.swing.*;
+
+public class GearsJPanel extends GLAnimJPanel
+ implements MouseListener, MouseMotionListener
+{
+ private static final float M_PI = 3.14159265359f;
+ private int gear1, gear2, gear3;
+ private float angle = 0.0f;
+
+ private MatrixFuncs mtxfuncs = null;
+ private int prevMouseX, prevMouseY;
+ private boolean mouseRButtonDown = false;
+ private float rot_matrix[] =
+ {
+ 1.0f, 0.0f, 0.0f, 0.0f,
+ 0.0f, 1.0f, 0.0f, 0.0f,
+ 0.0f, 0.0f, 1.0f, 0.0f,
+ 0.0f, 0.0f, 0.0f, 1.0f
+ };
+
+ public GearsJPanel()
+ {
+ super();
+ setAnimateFps(30.0);
+
+ mtxfuncs = new MatrixFuncs();
+ }
+
+ public void init()
+ {
+ System.out.println("init(): " + this);
+ reshape(getSize().width, getSize().height);
+
+ setInitialRotation();
+
+ float pos[] = { 5.0f, 5.0f, 10.0f, 0.0f };
+ float red[] = { 0.8f, 0.1f, 0.0f, 1.0f };
+ float green[] = { 0.0f, 0.8f, 0.2f, 1.0f };
+ float blue[] = { 0.2f, 0.2f, 1.0f, 1.0f };
+
+ gl.glLightfv(GL_LIGHT0, GL_POSITION, pos);
+ gl.glEnable(GL_CULL_FACE);
+ gl.glEnable(GL_LIGHTING);
+ gl.glEnable(GL_LIGHT0);
+ gl.glEnable(GL_DEPTH_TEST);
+
+ /* make the gears */
+ gear1 = gl.glGenLists(1);
+ gl.glNewList(gear1, GL_COMPILE);
+ gl.glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red);
+ gear(1.0f, 4.0f, 1.0f, 20, 0.7f);
+ gl.glEndList();
+
+ gear2 = gl.glGenLists(1);
+ gl.glNewList(gear2, GL_COMPILE);
+ gl.glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green);
+ gear(0.5f, 2.0f, 2.0f, 10, 0.7f);
+ gl.glEndList();
+
+ gear3 = gl.glGenLists(1);
+ gl.glNewList(gear3, GL_COMPILE);
+ gl.glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue);
+ gear(1.3f, 2.0f, 0.5f, 10, 0.7f);
+ gl.glEndList();
+
+ gl.glEnable(GL_NORMALIZE);
+
+ glj.gljCheckGL();
+
+ addMouseListener(this);
+ addMouseMotionListener(this);
+ }
+
+ public void doCleanup()
+ {
+ System.out.println("destroy(): " + this);
+ removeMouseListener(this);
+ removeMouseMotionListener(this);
+ }
+
+ public void reshape(int width, int height)
+ {
+ float h = (float)height / (float)width;
+
+ gl.glViewport(0,0,width,height);
+ gl.glMatrixMode(GL_PROJECTION);
+ gl.glLoadIdentity();
+ gl.glFrustum(-1.0f, 1.0f, -h, h, 5.0f, 60.0f);
+ gl.glMatrixMode(GL_MODELVIEW);
+ gl.glLoadIdentity();
+ gl.glTranslatef(0.0f, 0.0f, -40.0f);
+ }
+
+ public void display()
+ {
+ angle += 0.5f;
+
+ gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+ gl.glPushMatrix();
+ gl.glMultMatrixf(rot_matrix);
+
+ gl.glPushMatrix();
+ gl.glTranslatef(-3.0f, -2.0f, 0.0f);
+ gl.glRotatef(angle, 0.0f, 0.0f, 1.0f);
+ gl.glCallList(gear1);
+ gl.glPopMatrix();
+
+ gl.glPushMatrix();
+ gl.glTranslatef(3.1f, -2.0f, 0.0f);
+ gl.glRotatef(-2.0f * angle - 9.0f, 0.0f, 0.0f, 1.0f);
+ gl.glCallList(gear2);
+ gl.glPopMatrix();
+
+ gl.glPushMatrix();
+ gl.glTranslatef(-3.1f, 4.2f, 0.0f);
+ gl.glRotatef(-2.0f * angle - 25.0f, 0.0f, 0.0f, 1.0f);
+ gl.glCallList(gear3);
+ gl.glPopMatrix();
+
+ gl.glPopMatrix();
+
+ glj.gljCheckGL();
+ }
+
+ private void gear
+ (float inner_radius,
+ float outer_radius,
+ float width,
+ int teeth,
+ float tooth_depth)
+ {
+ int i;
+ float r0, r1, r2;
+ float angle, da;
+ float u, v, len;
+
+ r0 = inner_radius;
+ r1 = outer_radius - tooth_depth / 2.0f;
+ r2 = outer_radius + tooth_depth / 2.0f;
+
+ da = 2.0f * M_PI / teeth / 4.0f;
+
+ gl.glShadeModel(GL_FLAT);
+
+ gl.glNormal3f(0.0f, 0.0f, 1.0f);
+
+ /* draw front face */
+ gl.glBegin(GL_QUAD_STRIP);
+ for (i = 0; i <= teeth; i++)
+ {
+ angle = i * 2.0f * M_PI / teeth;
+ gl.glVertex3f(r0 * (float)Math.cos(angle), r0 * (float)Math.sin(angle), width * 0.5f);
+ gl.glVertex3f(r1 * (float)Math.cos(angle), r1 * (float)Math.sin(angle), width * 0.5f);
+ gl.glVertex3f(r0 * (float)Math.cos(angle), r0 * (float)Math.sin(angle), width * 0.5f);
+ gl.glVertex3f(r1 * (float)Math.cos(angle + 3.0f * da), r1 * (float)Math.sin(angle + 3.0f * da), width * 0.5f);
+ }
+ gl.glEnd();
+
+ /* draw front sides of teeth */
+ gl.glBegin(GL_QUADS);
+ da = 2.0f * M_PI / teeth / 4.0f;
+ for (i = 0; i < teeth; i++)
+ {
+ angle = i * 2.0f * M_PI / teeth;
+ gl.glVertex3f(r1 * (float)Math.cos(angle), r1 * (float)Math.sin(angle), width * 0.5f);
+ gl.glVertex3f(r2 * (float)Math.cos(angle + da), r2 * (float)Math.sin(angle + da), width * 0.5f);
+ gl.glVertex3f(r2 * (float)Math.cos(angle + 2.0f * da), r2 * (float)Math.sin(angle + 2.0f * da), width * 0.5f);
+ gl.glVertex3f(r1 * (float)Math.cos(angle + 3.0f * da), r1 * (float)Math.sin(angle + 3.0f * da), width * 0.5f);
+ }
+ gl.glEnd();
+
+ gl.glNormal3f(0.0f, 0.0f, -1.0f);
+
+ /* draw back face */
+ gl.glBegin(GL_QUAD_STRIP);
+ for (i = 0; i <= teeth; i++)
+ {
+ angle = i * 2.0f * M_PI / teeth;
+ gl.glVertex3f(r1 * (float)Math.cos(angle), r1 * (float)Math.sin(angle), -width * 0.5f);
+ gl.glVertex3f(r0 * (float)Math.cos(angle), r0 * (float)Math.sin(angle), -width * 0.5f);
+ gl.glVertex3f(r1 * (float)Math.cos(angle + 3 * da), r1 * (float)Math.sin(angle + 3 * da), -width * 0.5f);
+ gl.glVertex3f(r0 * (float)Math.cos(angle), r0 * (float)Math.sin(angle), -width * 0.5f);
+ }
+ gl.glEnd();
+
+ /* draw back sides of teeth */
+ gl.glBegin(GL_QUADS);
+ da = 2.0f * M_PI / teeth / 4.0f;
+ for (i = 0; i < teeth; i++)
+ {
+ angle = i * 2.0f * M_PI / teeth;
+ gl.glVertex3f(r1 * (float)Math.cos(angle + 3 * da), r1 * (float)Math.sin(angle + 3 * da), -width * 0.5f);
+ gl.glVertex3f(r2 * (float)Math.cos(angle + 2 * da), r2 * (float)Math.sin(angle + 2 * da), -width * 0.5f);
+ gl.glVertex3f(r2 * (float)Math.cos(angle + da), r2 * (float)Math.sin(angle + da), -width * 0.5f);
+ gl.glVertex3f(r1 * (float)Math.cos(angle), r1 * (float)Math.sin(angle), -width * 0.5f);
+ }
+ gl.glEnd();
+
+ /* draw outward faces of teeth */
+ gl.glBegin(GL_QUAD_STRIP);
+ for (i = 0; i < teeth; i++)
+ {
+ angle = i * 2.0f * M_PI / teeth;
+ gl.glVertex3f(r1 * (float)Math.cos(angle), r1 * (float)Math.sin(angle), width * 0.5f);
+ gl.glVertex3f(r1 * (float)Math.cos(angle), r1 * (float)Math.sin(angle), -width * 0.5f);
+ u = r2 * (float)Math.cos(angle + da) - r1 * (float)Math.cos(angle);
+ v = r2 * (float)Math.sin(angle + da) - r1 * (float)Math.sin(angle);
+ len = (float)Math.sqrt(u * u + v * v);
+ u /= len;
+ v /= len;
+ gl.glNormal3f(v, -u, 0.0f);
+ gl.glVertex3f(r2 * (float)Math.cos(angle + da), r2 * (float)Math.sin(angle + da), width * 0.5f);
+ gl.glVertex3f(r2 * (float)Math.cos(angle + da), r2 * (float)Math.sin(angle + da), -width * 0.5f);
+ gl.glNormal3f((float)Math.cos(angle), (float)Math.sin(angle), 0.0f);
+ gl.glVertex3f(r2 * (float)Math.cos(angle + 2 * da), r2 * (float)Math.sin(angle + 2 * da), width * 0.5f);
+ gl.glVertex3f(r2 * (float)Math.cos(angle + 2 * da), r2 * (float)Math.sin(angle + 2 * da), -width * 0.5f);
+ u = r1 * (float)Math.cos(angle + 3 * da) - r2 * (float)Math.cos(angle + 2 * da);
+ v = r1 * (float)Math.sin(angle + 3 * da) - r2 * (float)Math.sin(angle + 2 * da);
+ gl.glNormal3f(v, -u, 0.0f);
+ gl.glVertex3f(r1 * (float)Math.cos(angle + 3 * da), r1 * (float)Math.sin(angle + 3 * da), width * 0.5f);
+ gl.glVertex3f(r1 * (float)Math.cos(angle + 3 * da), r1 * (float)Math.sin(angle + 3 * da), -width * 0.5f);
+ gl.glNormal3f((float)Math.cos(angle), (float)Math.sin(angle), 0.0f);
+ }
+ gl.glVertex3f(r1 * (float)Math.cos(0), r1 * (float)Math.sin(0), width * 0.5f);
+ gl.glVertex3f(r1 * (float)Math.cos(0), r1 * (float)Math.sin(0), -width * 0.5f);
+ gl.glEnd();
+
+ gl.glShadeModel(GL_SMOOTH);
+
+ /* draw inside radius cylinder */
+ gl.glBegin(GL_QUAD_STRIP);
+ for (i = 0; i <= teeth; i++)
+ {
+ angle = i * 2.0f * M_PI / teeth;
+ gl.glNormal3f(-(float)Math.cos(angle), -(float)Math.sin(angle), 0.0f);
+ gl.glVertex3f(r0 * (float)Math.cos(angle), r0 * (float)Math.sin(angle), -width * 0.5f);
+ gl.glVertex3f(r0 * (float)Math.cos(angle), r0 * (float)Math.sin(angle), width * 0.5f);
+ }
+ gl.glEnd();
+ }
+
+ // Reset the rotation matrix to the default view.
+ private void setInitialRotation()
+ {
+ float mtxbuf[] = new float[16];
+ float mtxbuf2[] = new float[16];
+
+ mtxfuncs.rotateAroundY(30.0f,mtxbuf);
+ mtxfuncs.rotateAroundX(20.0f,mtxbuf2);
+ mtxfuncs.multiplyMatrices(mtxbuf2,mtxbuf,rot_matrix);
+ fixRotationMatrix();
+ }
+
+ private void fixRotationMatrix()
+ {
+ // Fix any problems with the rotation matrix.
+ rot_matrix[3] =
+ rot_matrix[7] =
+ rot_matrix[11] =
+ rot_matrix[12] =
+ rot_matrix[13] =
+ rot_matrix[14] = 0.0f;
+ rot_matrix[15] = 1.0f;
+ float fac;
+ if ((fac = (float)Math.sqrt
+ ((rot_matrix[0]*rot_matrix[0]) +
+ (rot_matrix[4]*rot_matrix[4]) +
+ (rot_matrix[8]*rot_matrix[8]))) != 1.0f)
+ {
+ if (fac != 0.0f)
+ {
+ fac = 1.0f/fac;
+ rot_matrix[0] *= fac;
+ rot_matrix[4] *= fac;
+ rot_matrix[8] *= fac;
+ }
+ }
+ if ((fac = (float)Math.sqrt
+ ((rot_matrix[1]*rot_matrix[1]) +
+ (rot_matrix[5]*rot_matrix[5]) +
+ (rot_matrix[9]*rot_matrix[9]))) != 1.0f)
+ {
+ if (fac != 0.0f)
+ {
+ fac = 1.0f/fac;
+ rot_matrix[1] *= fac;
+ rot_matrix[5] *= fac;
+ rot_matrix[9] *= fac;
+ }
+ }
+ if ((fac = (float)Math.sqrt
+ ((rot_matrix[2]*rot_matrix[2]) +
+ (rot_matrix[6]*rot_matrix[6]) +
+ (rot_matrix[10]*rot_matrix[10]))) != 1.0f)
+ {
+ if (fac != 0.0f)
+ {
+ fac = 1.0f/fac;
+ rot_matrix[2] *= fac;
+ rot_matrix[6] *= fac;
+ rot_matrix[10] *= fac;
+ }
+ }
+ }
+
+ // Methods required for the implementation of MouseListener
+ public void mouseEntered( MouseEvent evt )
+ {
+ }
+
+ public void mouseExited( MouseEvent evt )
+ {
+ }
+
+ public void mousePressed( MouseEvent evt )
+ {
+ prevMouseX = evt.getX();
+ prevMouseY = evt.getY();
+ if ((evt.getModifiers() & evt.BUTTON3_MASK) != 0)
+ {
+ mouseRButtonDown = true;
+ evt.consume();
+ }
+ }
+
+ public void mouseReleased( MouseEvent evt )
+ {
+ if ((evt.getModifiers() & evt.BUTTON3_MASK) != 0)
+ {
+ mouseRButtonDown = false;
+ evt.consume();
+ }
+ }
+
+ public void mouseClicked( MouseEvent evt )
+ {
+ }
+
+ // Methods required for the implementation of MouseMotionListener
+ public void mouseDragged( MouseEvent evt )
+ {
+ int x = evt.getX();
+ int y = evt.getY();
+ float thetaX = (float)(x-prevMouseX)*(360.0f/(float)getSize().width);
+ float thetaY = (float)(prevMouseY-y)*(360.0f/(float)getSize().height);
+ float mtxbuf[] = new float[16];
+ float mtxbuf2[] = new float[16];
+
+ prevMouseX = x;
+ prevMouseY = y;
+ if ( (thetaX != 0.0f) || (thetaY != 0.0f) )
+ {
+ mtxfuncs.rotateAroundY(((float)thetaX),mtxbuf);
+ if (mouseRButtonDown)
+ mtxfuncs.rotateAroundZ(thetaY,mtxbuf2);
+ else
+ mtxfuncs.rotateAroundX(-thetaY,mtxbuf2);
+ mtxfuncs.multiplyMatrices(mtxbuf2,mtxbuf,mtxbuf);
+ mtxfuncs.multiplyMatrices(rot_matrix,mtxbuf,rot_matrix);
+ fixRotationMatrix();
+ }
+ evt.consume();
+ }
+
+ public void mouseMoved( MouseEvent evt )
+ {
+ }
+}
diff --git a/demos/SwingDemos/InternalGLFrameDemo1.java b/demos/SwingDemos/InternalGLFrameDemo1.java new file mode 100644 index 0000000..ea5cada --- /dev/null +++ b/demos/SwingDemos/InternalGLFrameDemo1.java @@ -0,0 +1,248 @@ +import javax.swing.*; +import javax.swing.event.*; + +import java.awt.event.*; +import java.awt.*; + +import gl4java.swing.*; +import gl4java.*; + +public class InternalGLFrameDemo1 extends JFrame { + JDesktopPane desktop = null; + + public InternalGLFrameDemo1() { + super("InternalGLFrameDemo1"); + + //Make the big window be indented 50 pixels from each edge + //of the screen. + int inset = 50; + Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); + setBounds(inset, inset, + screenSize.width/2 - inset*2, + screenSize.height/2*3-inset*2); + + //Quit this app when the big window closes. + addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + System.exit(0); + } + }); + + //Set up the GUI. + desktop = new JDesktopPane(); //a specialized layered pane + createFrame(); //Create first window + setContentPane(desktop); + setJMenuBar(createMenuBar()); + + //Make dragging faster: + desktop.putClientProperty("JDesktopPane.dragMode", "outline"); + } + + protected JMenuBar createMenuBar() { + JMenuBar menuBar = new JMenuBar(); + + JMenu menu = new JMenu("Document"); + menu.setMnemonic(KeyEvent.VK_D); + JMenuItem menuItem = new JMenuItem("New"); + menuItem.setMnemonic(KeyEvent.VK_N); + menuItem.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + createFrame(); + } + }); + menu.add(menuItem); + menuBar.add(menu); + + return menuBar; + } + + protected void createFrame() { + InternalGLFrame frame = new InternalGLFrame("CrossColorJPanel"); + frame.setVisible(true); //necessary as of kestrel + desktop.add(frame); + try { + frame.setSelected(true); + } catch (java.beans.PropertyVetoException e) {} + } + + public static void main(String[] args) { + GLContext.gljNativeDebug = true; + GLContext.gljClassDebug = true; + InternalGLFrameDemo1 frame = new InternalGLFrameDemo1(); + frame.setVisible(true); + } + + static int openFrameCount = 0; + static final int xOffset = 30, yOffset = 30; + static InternalGLFrame activeIF = null; + + public class InternalGLFrame extends JInternalFrame + implements ItemListener, InternalFrameListener + { + String[] data = {"CrossColorJPanel", + "GearsJPanel", + "DrawColoredPrimitivesJPanel", + "TessJPanel"}; + String[] dataSize = {"offscreen-size: component", + "offscreen-size: 10x10", + "offscreen-size: 50x50", + "offscreen-size: 100x100", + "offscreen-size: 500x500", + "offscreen-size: 1000x1000"}; + + Dimension[] dimSize = { null, + new Dimension(10,10), + new Dimension(50,50), + new Dimension(100,100), + new Dimension(500,500), + new Dimension(1000,1000)}; + + + GLJPanel canvas = null; + JComboBox glChoice = null; + JComboBox glOffScrnSize = null; + JComponent master = null; + + public InternalGLFrame(String clazzName) + { + super("Document #" + (++openFrameCount), + true, //resizable + true, //closable + true, //maximizable + true);//iconifiable + + //...Create the GUI and put it in the window... + master = (JComponent) getContentPane(); + master.setLayout(new BorderLayout()); + switchGLJPanel(clazzName); + + JPanel np = new JPanel(); + master.add("North", np); + glChoice = new JComboBox(data); + glChoice.addItemListener(this); + np.add(glChoice); + glOffScrnSize = new JComboBox(dataSize); + glOffScrnSize.addItemListener(this); + np.add(glOffScrnSize); + + setJMenuBar(createIFMenuBar()); + + //...Then set the window size or call pack... + setSize(300,300); + + //Set the window's location. + setLocation(xOffset*openFrameCount, yOffset*openFrameCount); + + addInternalFrameListener(this); + } + + public void switchGLJPanel(String clazzName) + { + try { + Object obj = + Class.forName(clazzName).newInstance(); + if(obj instanceof GLJPanel) + { + if(canvas!=null) + { + master.remove(canvas); + canvas.cvsDispose(); + } + canvas = (GLJPanel)obj; + canvas.setVisible(true); + master.add("Center", canvas); + master.invalidate(); + master.validate(); + master.repaint(); + glOffScrnSize.setSelectedIndex(0); + } + if(obj instanceof GLAnimJPanel) + { + ((GLAnimJPanel)obj).start(); + } + } catch (Exception ex) { + System.out.println("Exception during loading: "+ + clazzName); + System.out.println(ex); + } + + } + + protected JMenuBar createIFMenuBar() + { + JMenuBar menuBar = new JMenuBar(); + + JMenu menu = new JMenu("Document"); + menu.setMnemonic(KeyEvent.VK_D); + JMenuItem menuItem = new JMenuItem("New"); + menuItem.setMnemonic(KeyEvent.VK_N); + menuItem.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + createIFFrame(); + } + }); + menu.add(menuItem); + menuBar.add(menu); + + return menuBar; + } + + protected void createIFFrame() { + if(activeIF==null) + return; + InternalGLFrame frame = new InternalGLFrame("CrossColorJPanel"); + frame.setVisible(true); //necessary as of kestrel + activeIF.canvas.add(frame); + try { + activeIF.setSelected(true); + } catch (java.beans.PropertyVetoException e) {} + } + + public void itemStateChanged(ItemEvent e) + { + Object source = e.getItemSelectable(); + Object item = e.getItem(); + System.out.println("item changed: "+source); + + if(glChoice!=null && + glChoice.equals(e.getItemSelectable()) && + e.getStateChange()==ItemEvent.SELECTED && + (item instanceof String)==true + ) + { + switchGLJPanel((String)item); + } else + if(glOffScrnSize!=null && canvas!=null && + glOffScrnSize.equals(e.getItemSelectable()) && + e.getStateChange()==ItemEvent.SELECTED && + (item instanceof String)==true + ) + { + int idx = glOffScrnSize.getSelectedIndex(); + canvas.setOffScreenSize(dimSize[idx]); + } + } + + public void internalFrameClosing(InternalFrameEvent e) { + } + + public void internalFrameClosed(InternalFrameEvent e) { + } + + public void internalFrameOpened(InternalFrameEvent e) { + } + + public void internalFrameIconified(InternalFrameEvent e) { + } + + public void internalFrameDeiconified(InternalFrameEvent e) { + } + + public void internalFrameActivated(InternalFrameEvent e) { + activeIF = (InternalGLFrame)e.getSource(); + } + + public void internalFrameDeactivated(InternalFrameEvent e) { + } + } +} diff --git a/demos/SwingDemos/MatrixFuncs.java b/demos/SwingDemos/MatrixFuncs.java new file mode 100644 index 0000000..75493a2 --- /dev/null +++ b/demos/SwingDemos/MatrixFuncs.java @@ -0,0 +1,200 @@ +/**
+ * @(#) MatrixFuncs.java
+ * @(#) author: Ronald B. Cemer
+ * @(#) version: 1.0
+ */
+
+import java.io.*;
+
+public class MatrixFuncs
+{
+ public static final float M_PI = 3.14159265359f;
+
+ // Given the angle in degs, create a 4x4 matrix
+ // in mtx which rotates around the X axis.
+ public void rotateAroundX(float degs, float mtx[])
+ {
+ float rads, rsin, rcos;
+
+ rads = degs*(M_PI/180.0f);
+ rsin = (float)Math.sin(rads);
+ rcos = (float)Math.cos(rads);
+ mtx[0] = 1.0f;
+ mtx[1] = 0.0f;
+ mtx[2] = 0.0f;
+ mtx[3] = 0.0f;
+ mtx[4] = 0.0f;
+ mtx[5] = rcos;
+ mtx[6] = rsin;
+ mtx[7] = 0.0f;
+ mtx[8] = 0.0f;
+ mtx[9] = -rsin;
+ mtx[10] = rcos;
+ mtx[11] = 0.0f;
+ mtx[12] = 0.0f;
+ mtx[13] = 0.0f;
+ mtx[14] = 0.0f;
+ mtx[15] = 1.0f;
+ }
+
+ // Given the angle in degs, create a 4x4 matrix
+ // in mtx which rotates around the Y axis.
+ public void rotateAroundY(float degs, float mtx[])
+ {
+ float rads, rsin, rcos;
+
+ rads = degs*(M_PI/180.0f);
+ rsin = (float)Math.sin(rads);
+ rcos = (float)Math.cos(rads);
+ mtx[0] = rcos;
+ mtx[1] = 0.0f;
+ mtx[2] = -rsin;
+ mtx[3] = 0.0f;
+ mtx[4] = 0.0f;
+ mtx[5] = 1.0f;
+ mtx[6] = 0.0f;
+ mtx[7] = 0.0f;
+ mtx[8] = rsin;
+ mtx[9] = 0.0f;
+ mtx[10] = rcos;
+ mtx[11] = 0.0f;
+ mtx[12] = 0.0f;
+ mtx[13] = 0.0f;
+ mtx[14] = 0.0f;
+ mtx[15] = 1.0f;
+ }
+
+ // Given the angle in degs, create a 4x4 matrix
+ // in mtx which rotates around the Z axis.
+ public void rotateAroundZ(float degs, float mtx[])
+ {
+ float rads, rsin, rcos;
+
+ rads = degs*(M_PI/180.0f);
+ rsin = (float)Math.sin(rads);
+ rcos = (float)Math.cos(rads);
+ mtx[0] = rcos;
+ mtx[1] = rsin;
+ mtx[2] = 0.0f;
+ mtx[3] = 0.0f;
+ mtx[4] = -rsin;
+ mtx[5] = rcos;
+ mtx[6] = 0.0f;
+ mtx[7] = 0.0f;
+ mtx[8] = 0.0f;
+ mtx[9] = 0.0f;
+ mtx[10] = 1.0f;
+ mtx[11] = 0.0f;
+ mtx[12] = 0.0f;
+ mtx[13] = 0.0f;
+ mtx[14] = 0.0f;
+ mtx[15] = 1.0f;
+ }
+
+ // Given two 4x4 matrices in mtx1 and mtx2, multiply
+ // them and put the result in dest.
+ // This routine uses a temporary buffer for the result,
+ // so if dest is the same as mtx1 or mtx2, it will still
+ // work properly.
+ public void multiplyMatrices(float mtx1[], float mtx2[], float dest[])
+ {
+ float nmtx[] = new float[16];
+
+ nmtx[0] =
+ (mtx1[0]*mtx2[0]) +
+ (mtx1[1]*mtx2[4]) +
+ (mtx1[2]*mtx2[8]) +
+ (mtx1[3]*mtx2[12]);
+ nmtx[1] =
+ (mtx1[0]*mtx2[1]) +
+ (mtx1[1]*mtx2[5]) +
+ (mtx1[2]*mtx2[9]) +
+ (mtx1[3]*mtx2[13]);
+ nmtx[2] =
+ (mtx1[0]*mtx2[2]) +
+ (mtx1[1]*mtx2[6]) +
+ (mtx1[2]*mtx2[10]) +
+ (mtx1[3]*mtx2[14]);
+ nmtx[3] =
+ (mtx1[0]*mtx2[3]) +
+ (mtx1[1]*mtx2[7]) +
+ (mtx1[2]*mtx2[11]) +
+ (mtx1[3]*mtx2[15]);
+ nmtx[4] =
+ (mtx1[4]*mtx2[0]) +
+ (mtx1[5]*mtx2[4]) +
+ (mtx1[6]*mtx2[8]) +
+ (mtx1[7]*mtx2[12]);
+ nmtx[5] =
+ (mtx1[4]*mtx2[1]) +
+ (mtx1[5]*mtx2[5]) +
+ (mtx1[6]*mtx2[9]) +
+ (mtx1[7]*mtx2[13]);
+ nmtx[6] =
+ (mtx1[4]*mtx2[2]) +
+ (mtx1[5]*mtx2[6]) +
+ (mtx1[6]*mtx2[10]) +
+ (mtx1[7]*mtx2[14]);
+ nmtx[7] =
+ (mtx1[4]*mtx2[3]) +
+ (mtx1[5]*mtx2[7]) +
+ (mtx1[6]*mtx2[11]) +
+ (mtx1[7]*mtx2[15]);
+ nmtx[8] =
+ (mtx1[8]*mtx2[0]) +
+ (mtx1[9]*mtx2[4]) +
+ (mtx1[10]*mtx2[8]) +
+ (mtx1[11]*mtx2[12]);
+ nmtx[9] =
+ (mtx1[8]*mtx2[1]) +
+ (mtx1[9]*mtx2[5]) +
+ (mtx1[10]*mtx2[9]) +
+ (mtx1[11]*mtx2[13]);
+ nmtx[10] =
+ (mtx1[8]*mtx2[2]) +
+ (mtx1[9]*mtx2[6]) +
+ (mtx1[10]*mtx2[10]) +
+ (mtx1[11]*mtx2[14]);
+ nmtx[11] =
+ (mtx1[8]*mtx2[3]) +
+ (mtx1[9]*mtx2[7]) +
+ (mtx1[10]*mtx2[11]) +
+ (mtx1[11]*mtx2[15]);
+ nmtx[12] =
+ (mtx1[12]*mtx2[0]) +
+ (mtx1[13]*mtx2[4]) +
+ (mtx1[14]*mtx2[8]) +
+ (mtx1[15]*mtx2[12]);
+ nmtx[13] =
+ (mtx1[12]*mtx2[1]) +
+ (mtx1[13]*mtx2[5]) +
+ (mtx1[14]*mtx2[9]) +
+ (mtx1[15]*mtx2[13]);
+ nmtx[14] =
+ (mtx1[12]*mtx2[2]) +
+ (mtx1[13]*mtx2[6]) +
+ (mtx1[14]*mtx2[10]) +
+ (mtx1[15]*mtx2[14]);
+ nmtx[15] =
+ (mtx1[12]*mtx2[3]) +
+ (mtx1[13]*mtx2[7]) +
+ (mtx1[14]*mtx2[11]) +
+ (mtx1[15]*mtx2[15]);
+ dest[0] = nmtx[0];
+ dest[1] = nmtx[1];
+ dest[2] = nmtx[2];
+ dest[3] = nmtx[3];
+ dest[4] = nmtx[4];
+ dest[5] = nmtx[5];
+ dest[6] = nmtx[6];
+ dest[7] = nmtx[7];
+ dest[8] = nmtx[8];
+ dest[9] = nmtx[9];
+ dest[10] = nmtx[10];
+ dest[11] = nmtx[11];
+ dest[12] = nmtx[12];
+ dest[13] = nmtx[13];
+ dest[14] = nmtx[14];
+ dest[15] = nmtx[15];
+ }
+}
diff --git a/demos/SwingDemos/TessJPanel.java b/demos/SwingDemos/TessJPanel.java new file mode 100644 index 0000000..f070823 --- /dev/null +++ b/demos/SwingDemos/TessJPanel.java @@ -0,0 +1,244 @@ +/* + * Copyright (c) 1993-1997, Silicon Graphics, Inc. + * ALL RIGHTS RESERVED + * Permission to use, copy, modify, and distribute this software for + * any purpose and without fee is hereby granted, provided that the above + * copyright notice appear in all copies and that both the copyright notice + * and this permission notice appear in supporting documentation, and that + * the name of Silicon Graphics, Inc. not be used in adverti(float)Math.sing + * or publicity pertaining to distribution of the software without specific, + * written prior permission. + * + * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS" + * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR + * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON + * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, + * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY + * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, + * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF + * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN + * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE + * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE. + * + * US Government Users Restricted Rights + * Use, duplication, or disclosure by the Government is subject to + * restrictions set forth in FAR 52.227f.19(c)(2) or subparagraph + * (c)(1)(ii) of the Rights in Technical Data and Computer Software + * clause at DFARS 252.227f-7013 and/or in similar or successor + * clauses in the FAR or the DOD or NASA FAR Supplement. + * Unpublished-- rights reserved under the copyright laws of the + * United States. Contractor/manufacturer is Silicon Graphics, + * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. + * + * OpenGL(R) is a registered trademark of Silicon Graphics, Inc. + */ + +/* + * tess.c + * This program demonstrates polygon tessellation. + * Two tesselated objects are drawn. The first is a + * rectangle with a triangular hole. The second is a + * smooth shaded, self-intersecting star. + * + * Note the exterior rectangle is drawn with its vertices + * in counter-clockwise order, but its interior clockwise. + * Note the combineCallback is needed for the self-intersecting + * star. Also note that removing the TessProperty for the + * star will make the interior unshaded (WINDING_ODD). + */ + +import gl4java.utils.glut.*; +import gl4java.utils.glut.fonts.*; + +import gl4java.*; +import gl4java.awt.*; +import gl4java.swing.*; +import java.applet.*; +import java.awt.*; +import java.awt.Dimension; +import java.awt.event.*; +import java.lang.*; +import java.util.*; + +public class TessJPanel extends GLJPanel +{ + public static double rect[/*4*/][/*3*/] = + {{50.0, 50.0, 0.0}, + {200.0, 50.0, 0.0}, + {200.0, 200.0f, 0.0}, + {50.0, 200.0, 0.0}}; + public static double tri[/*3*/][/*3*/] = + {{75.0, 75.0, 0.0}, + {125.0, 175.0, 0.0}, + {175.0, 75.0, 0.0}}; + public static double star[/*5*/][/*6*/] = + {{250.0, 50.0, 0.0, 1.0, 0.0, 1.0}, + {325.0, 200.0, 0.0, 1.0, 1.0, 0.0}, + {400.0, 50.0, 0.0, 0.0, 1.0, 1.0}, + {250.0, 150.0, 0.0, 1.0, 0.0, 0.0}, + {400.0, 150.0, 0.0, 0.0, 1.0, 0.0}}; + + protected GLUTFunc glut = null; + + int startList=-1; + boolean exit = false; + + public TessJPanel() { + super(); + } + + public void init() { + int i; + glut = new GLUTFuncLightImplWithFonts(gl, glu); + + int tobj; + + gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); + + startList = gl.glGenLists(2); + + tobj = glu.gluNewTess(); + glu.gluTessCallback ( tobj, GLU_TESS_VERTEX, gl, + "glVertex3dv", "([D)V", + 3, 0, 0, 0, 0); + glu.gluTessCallback ( tobj, GLU_TESS_BEGIN, this, + "beginCallback", "(I)V", + 0, 0, 0, 0, 0); + glu.gluTessCallback ( tobj, GLU_TESS_END, this, + "endCallback", "()V", + 0, 0, 0, 0, 0); + glu.gluTessCallback ( tobj, GLU_TESS_ERROR, this, + "errorCallback", "(I)V", + 0, 0, 0, 0, 0); + + /* rectangle with triangular hole inside */ + gl.glNewList(startList, GL_COMPILE); + gl.glShadeModel(GL_FLAT); + glu.gluTessBeginPolygon(tobj, (double[])null); + glu.gluTessBeginContour(tobj); + glu.gluTessVertex(tobj, rect[0], rect[0]); + glu.gluTessVertex(tobj, rect[1], rect[1]); + glu.gluTessVertex(tobj, rect[2], rect[2]); + glu.gluTessVertex(tobj, rect[3], rect[3]); + glu.gluTessEndContour(tobj); + glu.gluTessBeginContour(tobj); + glu.gluTessVertex(tobj, tri[0], tri[0]); + glu.gluTessVertex(tobj, tri[1], tri[1]); + glu.gluTessVertex(tobj, tri[2], tri[2]); + glu.gluTessEndContour(tobj); + glu.gluTessEndPolygon(tobj); + gl.glEndList(); + + glu.gluTessCallback ( tobj, GLU_TESS_VERTEX, this, + "vertexCallback", "([D)V", + 6, 0, 0, 0, 0); + glu.gluTessCallback ( tobj, GLU_TESS_BEGIN, this, + "beginCallback", "(I)V", + 0, 0, 0, 0, 0); + glu.gluTessCallback ( tobj, GLU_TESS_END, this, + "endCallback", "()V", + 0, 0, 0, 0, 0); + glu.gluTessCallback ( tobj, GLU_TESS_ERROR, this, + "errorCallback", "(I)V", + 0, 0, 0, 0, 0); + glu.gluTessCallback ( tobj, GLU_TESS_COMBINE, this, + "combineCallback", "([D[D[F[D)V", + 3, 4*6, 4, 6, 0); + + /* smooth shaded, self-intersecting star */ + gl.glNewList(startList + 1, GL_COMPILE); + gl.glShadeModel(GL_SMOOTH); + glu.gluTessProperty(tobj, GLU_TESS_WINDING_RULE, + GLU_TESS_WINDING_POSITIVE); + glu.gluTessBeginPolygon(tobj, (double[])null); + glu.gluTessBeginContour(tobj); + glu.gluTessVertex(tobj, star[0], star[0]); + glu.gluTessVertex(tobj, star[1], star[1]); + glu.gluTessVertex(tobj, star[2], star[2]); + glu.gluTessVertex(tobj, star[3], star[3]); + glu.gluTessVertex(tobj, star[4], star[4]); + glu.gluTessEndContour(tobj); + glu.gluTessEndPolygon(tobj); + gl.glEndList(); + + glu.gluDeleteTess(tobj); + + reshape(getSize().width, getSize().height); + + glj.gljCheckGL(); + } + + public void display() + { + if(exit) return; + + gl.glClear(GL_COLOR_BUFFER_BIT); + gl.glColor3f(1.0f, 1.0f, 1.0f); + gl.glCallList(startList); + gl.glCallList(startList + 1); + } + + public void beginCallback(int which) + { + gl.glBegin(which); + } + + public void errorCallback(int errorCode) + { + String str; + + gl.glColor3f( 0.9f, 0.9f, 0.9f ); + gl.glRasterPos2i( 5, 5 ); + + str = glu.gluErrorString( errorCode ); + + glut.glutBitmapString(glut.GLUT_BITMAP_9_BY_15, str); + exit = true; + } + + public void endCallback() + { + gl.glEnd(); + } + + public void vertexCallback(double[/*6*/] vertex) + { + double[] col = new double[3]; + System.arraycopy(vertex, 3, col, 0, 3); + + gl.glColor3dv(col); + gl.glVertex3dv(vertex); + } + + /* combineCallback is used to create a new vertex when edges + * intersect. coordinate location is trivial to calculate, + * but weight[4] may be used to average color, normal, or texture + * coordinate data. In this program, color is weighted. + */ + public void combineCallback(double coords[/*3*/], + double vertex_data[/*4x6*/], + float weight[/*4*/], double[/*6*/] dataOut ) + { + int i; + + dataOut[0] = coords[0]; + dataOut[1] = coords[1]; + dataOut[2] = coords[2]; + for (i = 3; i < 6; i++) + dataOut[i] = weight[0] * vertex_data[0*6+i] + + weight[1] * vertex_data[1*6+i] + + weight[2] * vertex_data[2*6+i] + + weight[3] * vertex_data[3*6+i]; + } + + public void reshape(int w, int h) + { + gl.glViewport( 0, 0, w, h ); + + gl.glMatrixMode( GL_PROJECTION ); + gl.glLoadIdentity(); + glu.gluOrtho2D(0.0f, (double) w, 0.0f, (double) h); + } +} diff --git a/demos/SwingDemos/gears.java b/demos/SwingDemos/gears.java new file mode 100755 index 0000000..db7e97a --- /dev/null +++ b/demos/SwingDemos/gears.java @@ -0,0 +1,370 @@ +/**
+ * @(#) gears.java
+ * @(#) author: Brian Paul (converted to Java by Ron Cemer and Sven Goethel)
+ *
+ * This version is equal to Brian Paul's version 1.2 1999/10/21
+ */
+
+import java.applet.*;
+import java.awt.*;
+import java.awt.event.*;
+import java.lang.*;
+import java.util.*;
+import java.io.*;
+import java.util.*;
+import gl4java.GLContext;
+import gl4java.awt.GLAnimCanvas;
+import gl4java.applet.SimpleGLAnimApplet1;
+
+public class gears extends SimpleGLAnimApplet1
+{
+
+ /* Initialize the applet */
+
+
+ public void init()
+ {
+ super.init();
+ Dimension d = getSize();
+ canvas = new gearsCanvas(d.width, d.height);
+ add("Center", canvas);
+ }
+
+
+ public static void main( String args[] )
+ {
+ Frame mainFrame = new Frame("gears");
+
+ gears applet = new gears();
+
+ applet.setSize(300, 300);
+ applet.init();
+ applet.start();
+
+ mainFrame.add(applet);
+
+ mainFrame.pack();
+ mainFrame.setVisible(true);
+ }
+
+
+ /* Local GLAnimCanvas extension class */
+
+
+ private class gearsCanvas extends GLAnimCanvas implements MouseListener, MouseMotionListener
+ {
+ private static final float M_PI = 3.14159265f;
+
+ private long T0 = 0;
+ private long Frames = 0;
+
+ private float view_rotx = 20.0f, view_roty = 30.0f, view_rotz = 0.0f;
+ private int gear1, gear2, gear3;
+ private float angle = 0.0f;
+
+ private int prevMouseX, prevMouseY;
+ private boolean mouseRButtonDown = false;
+
+ public gearsCanvas(int w, int h)
+ {
+ super(w, h);
+ GLContext.gljNativeDebug = false;
+ GLContext.gljClassDebug = false;
+ setAnimateFps(30.0);
+ }
+
+ public void preInit()
+ {
+ doubleBuffer = true;
+ stereoView = false;
+ }
+
+ public void init()
+ {
+ System.out.println("init(): " + this);
+ reshape(getSize().width, getSize().height);
+
+ float pos[] = { 5.0f, 5.0f, 10.0f, 0.0f };
+ float red[] = { 0.8f, 0.1f, 0.0f, 1.0f };
+ float green[] = { 0.0f, 0.8f, 0.2f, 1.0f };
+ float blue[] = { 0.2f, 0.2f, 1.0f, 1.0f };
+
+ gl.glLightfv(GL_LIGHT0, GL_POSITION, pos);
+ gl.glEnable(GL_CULL_FACE);
+ gl.glEnable(GL_LIGHTING);
+ gl.glEnable(GL_LIGHT0);
+ gl.glEnable(GL_DEPTH_TEST);
+
+ /* make the gears */
+ gear1 = gl.glGenLists(1);
+ gl.glNewList(gear1, GL_COMPILE);
+ gl.glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red);
+ gear(1.0f, 4.0f, 1.0f, 20, 0.7f);
+ gl.glEndList();
+
+ gear2 = gl.glGenLists(1);
+ gl.glNewList(gear2, GL_COMPILE);
+ gl.glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green);
+ gear(0.5f, 2.0f, 2.0f, 10, 0.7f);
+ gl.glEndList();
+
+ gear3 = gl.glGenLists(1);
+ gl.glNewList(gear3, GL_COMPILE);
+ gl.glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue);
+ gear(1.3f, 2.0f, 0.5f, 10, 0.7f);
+ gl.glEndList();
+
+ gl.glEnable(GL_NORMALIZE);
+
+ glj.gljCheckGL();
+
+ addMouseListener(this);
+ addMouseMotionListener(this);
+
+ T0=System.currentTimeMillis();
+ }
+
+ public void doCleanup()
+ {
+ System.out.println("destroy(): " + this);
+ removeMouseListener(this);
+ removeMouseMotionListener(this);
+ }
+
+ public void reshape(int width, int height)
+ {
+ float h = (float)height / (float)width;
+
+ gl.glViewport(0,0,width,height);
+ gl.glMatrixMode(GL_PROJECTION);
+ gl.glLoadIdentity();
+ gl.glFrustum(-1.0f, 1.0f, -h, h, 5.0f, 60.0f);
+ gl.glMatrixMode(GL_MODELVIEW);
+ gl.glLoadIdentity();
+ gl.glTranslatef(0.0f, 0.0f, -40.0f);
+ }
+
+ public void display()
+ {
+ if (glj.gljMakeCurrent() == false) return;
+
+ angle += 2.0f;
+
+ gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+ gl.glPushMatrix();
+ gl.glRotatef(view_rotx, 1.0f, 0.0f, 0.0f);
+ gl.glRotatef(view_roty, 0.0f, 1.0f, 0.0f);
+ gl.glRotatef(view_rotz, 0.0f, 0.0f, 1.0f);
+
+ gl.glPushMatrix();
+ gl.glTranslatef(-3.0f, -2.0f, 0.0f);
+ gl.glRotatef(angle, 0.0f, 0.0f, 1.0f);
+ gl.glCallList(gear1);
+ gl.glPopMatrix();
+
+ gl.glPushMatrix();
+ gl.glTranslatef(3.1f, -2.0f, 0.0f);
+ gl.glRotatef(-2.0f * angle - 9.0f, 0.0f, 0.0f, 1.0f);
+ gl.glCallList(gear2);
+ gl.glPopMatrix();
+
+ gl.glPushMatrix();
+ gl.glTranslatef(-3.1f, 4.2f, 0.0f);
+ gl.glRotatef(-2.0f * angle - 25.0f, 0.0f, 0.0f, 1.0f);
+ gl.glCallList(gear3);
+ gl.glPopMatrix();
+
+ gl.glPopMatrix();
+
+ glj.gljSwap();
+ glj.gljCheckGL();
+ glj.gljFree();
+
+ Frames++;
+
+ long t=System.currentTimeMillis();
+ if(t - T0 >= 5000)
+ {
+ double seconds = (double)(t - T0) / 1000.0;
+ double fps = (double)Frames / seconds;
+ System.out.println(Frames+" frames in "+seconds+" seconds = "+
+ fps+" FPS");
+ T0 = t;
+ Frames = 0;
+ }
+ }
+
+ private void gear
+ (float inner_radius,
+ float outer_radius,
+ float width,
+ int teeth,
+ float tooth_depth)
+ {
+ int i;
+ float r0, r1, r2;
+ float angle, da;
+ float u, v, len;
+
+ r0 = inner_radius;
+ r1 = outer_radius - tooth_depth / 2.0f;
+ r2 = outer_radius + tooth_depth / 2.0f;
+
+ da = 2.0f * M_PI / teeth / 4.0f;
+
+ gl.glShadeModel(GL_FLAT);
+
+ gl.glNormal3f(0.0f, 0.0f, 1.0f);
+
+ /* draw front face */
+ gl.glBegin(GL_QUAD_STRIP);
+ for (i = 0; i <= teeth; i++)
+ {
+ angle = i * 2.0f * M_PI / teeth;
+ gl.glVertex3f(r0 * (float)Math.cos(angle), r0 * (float)Math.sin(angle), width * 0.5f);
+ gl.glVertex3f(r1 * (float)Math.cos(angle), r1 * (float)Math.sin(angle), width * 0.5f);
+ if(i < teeth)
+ {
+ gl.glVertex3f(r0 * (float)Math.cos(angle), r0 * (float)Math.sin(angle), width * 0.5f);
+ gl.glVertex3f(r1 * (float)Math.cos(angle + 3.0f * da), r1 * (float)Math.sin(angle + 3.0f * da), width * 0.5f);
+ }
+ }
+ gl.glEnd();
+
+ /* draw front sides of teeth */
+ gl.glBegin(GL_QUADS);
+ for (i = 0; i < teeth; i++)
+ {
+ angle = i * 2.0f * M_PI / teeth;
+ gl.glVertex3f(r1 * (float)Math.cos(angle), r1 * (float)Math.sin(angle), width * 0.5f);
+ gl.glVertex3f(r2 * (float)Math.cos(angle + da), r2 * (float)Math.sin(angle + da), width * 0.5f);
+ gl.glVertex3f(r2 * (float)Math.cos(angle + 2.0f * da), r2 * (float)Math.sin(angle + 2.0f * da), width * 0.5f);
+ gl.glVertex3f(r1 * (float)Math.cos(angle + 3.0f * da), r1 * (float)Math.sin(angle + 3.0f * da), width * 0.5f);
+ }
+ gl.glEnd();
+
+ /* draw back face */
+ gl.glBegin(GL_QUAD_STRIP);
+ for (i = 0; i <= teeth; i++)
+ {
+ angle = i * 2.0f * M_PI / teeth;
+ gl.glVertex3f(r1 * (float)Math.cos(angle), r1 * (float)Math.sin(angle), -width * 0.5f);
+ gl.glVertex3f(r0 * (float)Math.cos(angle), r0 * (float)Math.sin(angle), -width * 0.5f);
+ gl.glVertex3f(r1 * (float)Math.cos(angle + 3 * da), r1 * (float)Math.sin(angle + 3 * da), -width * 0.5f);
+ gl.glVertex3f(r0 * (float)Math.cos(angle), r0 * (float)Math.sin(angle), -width * 0.5f);
+ }
+ gl.glEnd();
+
+ /* draw back sides of teeth */
+ gl.glBegin(GL_QUADS);
+ for (i = 0; i < teeth; i++)
+ {
+ angle = i * 2.0f * M_PI / teeth;
+ gl.glVertex3f(r1 * (float)Math.cos(angle + 3 * da), r1 * (float)Math.sin(angle + 3 * da), -width * 0.5f);
+ gl.glVertex3f(r2 * (float)Math.cos(angle + 2 * da), r2 * (float)Math.sin(angle + 2 * da), -width * 0.5f);
+ gl.glVertex3f(r2 * (float)Math.cos(angle + da), r2 * (float)Math.sin(angle + da), -width * 0.5f);
+ gl.glVertex3f(r1 * (float)Math.cos(angle), r1 * (float)Math.sin(angle), -width * 0.5f);
+ }
+ gl.glEnd();
+
+ /* draw outward faces of teeth */
+ gl.glBegin(GL_QUAD_STRIP);
+ for (i = 0; i < teeth; i++)
+ {
+ angle = i * 2.0f * M_PI / teeth;
+ gl.glVertex3f(r1 * (float)Math.cos(angle), r1 * (float)Math.sin(angle), width * 0.5f);
+ gl.glVertex3f(r1 * (float)Math.cos(angle), r1 * (float)Math.sin(angle), -width * 0.5f);
+ u = r2 * (float)Math.cos(angle + da) - r1 * (float)Math.cos(angle);
+ v = r2 * (float)Math.sin(angle + da) - r1 * (float)Math.sin(angle);
+ len = (float)Math.sqrt(u * u + v * v);
+ u /= len;
+ v /= len;
+ gl.glNormal3f(v, -u, 0.0f);
+ gl.glVertex3f(r2 * (float)Math.cos(angle + da), r2 * (float)Math.sin(angle + da), width * 0.5f);
+ gl.glVertex3f(r2 * (float)Math.cos(angle + da), r2 * (float)Math.sin(angle + da), -width * 0.5f);
+ gl.glNormal3f((float)Math.cos(angle), (float)Math.sin(angle), 0.0f);
+ gl.glVertex3f(r2 * (float)Math.cos(angle + 2 * da), r2 * (float)Math.sin(angle + 2 * da), width * 0.5f);
+ gl.glVertex3f(r2 * (float)Math.cos(angle + 2 * da), r2 * (float)Math.sin(angle + 2 * da), -width * 0.5f);
+ u = r1 * (float)Math.cos(angle + 3 * da) - r2 * (float)Math.cos(angle + 2 * da);
+ v = r1 * (float)Math.sin(angle + 3 * da) - r2 * (float)Math.sin(angle + 2 * da);
+ gl.glNormal3f(v, -u, 0.0f);
+ gl.glVertex3f(r1 * (float)Math.cos(angle + 3 * da), r1 * (float)Math.sin(angle + 3 * da), width * 0.5f);
+ gl.glVertex3f(r1 * (float)Math.cos(angle + 3 * da), r1 * (float)Math.sin(angle + 3 * da), -width * 0.5f);
+ gl.glNormal3f((float)Math.cos(angle), (float)Math.sin(angle), 0.0f);
+ }
+ gl.glVertex3f(r1 * (float)Math.cos(0), r1 * (float)Math.sin(0), width * 0.5f);
+ gl.glVertex3f(r1 * (float)Math.cos(0), r1 * (float)Math.sin(0), -width * 0.5f);
+ gl.glEnd();
+
+ gl.glShadeModel(GL_SMOOTH);
+
+ /* draw inside radius cylinder */
+ gl.glBegin(GL_QUAD_STRIP);
+ for (i = 0; i <= teeth; i++)
+ {
+ angle = i * 2.0f * M_PI / teeth;
+ gl.glNormal3f(-(float)Math.cos(angle), -(float)Math.sin(angle), 0.0f);
+ gl.glVertex3f(r0 * (float)Math.cos(angle), r0 * (float)Math.sin(angle), -width * 0.5f);
+ gl.glVertex3f(r0 * (float)Math.cos(angle), r0 * (float)Math.sin(angle), width * 0.5f);
+ }
+ gl.glEnd();
+ }
+
+ // Methods required for the implementation of MouseListener
+ public void mouseEntered( MouseEvent evt )
+ {
+ }
+
+ public void mouseExited( MouseEvent evt )
+ {
+ }
+
+ public void mousePressed( MouseEvent evt )
+ {
+ prevMouseX = evt.getX();
+ prevMouseY = evt.getY();
+ if ((evt.getModifiers() & evt.BUTTON3_MASK) != 0)
+ {
+ mouseRButtonDown = true;
+ evt.consume();
+ }
+ }
+
+ public void mouseReleased( MouseEvent evt )
+ {
+ if ((evt.getModifiers() & evt.BUTTON3_MASK) != 0)
+ {
+ mouseRButtonDown = false;
+ evt.consume();
+ }
+ }
+
+ public void mouseClicked( MouseEvent evt )
+ {
+ }
+
+ // Methods required for the implementation of MouseMotionListener
+ public void mouseDragged( MouseEvent evt )
+ {
+ int x = evt.getX();
+ int y = evt.getY();
+ Dimension size = getSize();
+
+ float thetaY = 360.0f * ( (float)(x-prevMouseX)/(float)size.width);
+ float thetaX = 360.0f * ( (float)(prevMouseY-y)/(float)size.height);
+
+ prevMouseX = x;
+ prevMouseY = y;
+
+ view_rotx += thetaX;
+ view_roty += thetaY;
+
+ evt.consume();
+ }
+
+ public void mouseMoved( MouseEvent evt )
+ {
+ }
+ }
+}
diff --git a/demos/SwingDemos/test/GLJPanel/GLJPanel.java b/demos/SwingDemos/test/GLJPanel/GLJPanel.java new file mode 100644 index 0000000..166437b --- /dev/null +++ b/demos/SwingDemos/test/GLJPanel/GLJPanel.java @@ -0,0 +1,694 @@ +//package gl4java.swing; + +import gl4java.*; + +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; + +public class GLJPanel extends JPanel + implements GLEnum, GLUEnum, + ComponentListener, WindowListener, MouseListener +{ + protected GLContext glj = null; + public GLFunc gl = null; + public GLUFunc glu = null; + + protected boolean mustResize = false; + + protected boolean cvsInitialized=false; + + protected boolean needCvsDispose = false; + + /** + * Visual pre-set for doubleBuffer, default: true + * This value is updated after a GLContext is created with the + * original updated value of GLContext ! + * + * @see GLJPanel#preInit + * @see GLJPanel#paint + */ + protected boolean doubleBuffer = true; + + /** + * Visual pre-set for stencil-bit number, default: 0 + * This value is updated after a GLContext is created with the + * original updated value of GLContext ! + * + * @see GLJPanel#preInit + * @see GLJPanel#paint + */ + protected int stencilBits = 0; + + /** + * Visual pre-set for stereoView, default: false + * This value is updated after a GLContext is created with the + * original updated value of GLContext ! + * + * @see GLJPanel#preInit + * @see GLJPanel#paint + */ + protected boolean stereoView = false; + + /** + * Visual pre-set for RGBA usage, default: true - of course ;-) + * This value is updated after a GLContext is created with the + * original updated value of GLContext ! + * + * @see GLJPanel#preInit + * @see GLJPanel#paint + */ + protected boolean rgba = true; + + /** + * Visual pre-set for RGBA usage, default: true - of course ;-) + * This value is updated after a GLContext is created with the + * original updated value of GLContext ! + * + * @see GLJPanel#preInit + * @see GLJPanel#paint + */ + protected boolean createOwnWindow = false; + + /** + * The context with witch display lists and textures will be shared. + * + * @see GLJPanel#preInit + * @see GLJPanel#paint + */ + protected GLContext sharedGLContext; + + static { + if(GLContext.loadNativeLibraries(null, null, null)==false) + System.out.println("GLJPanel could not load def. native libs."); + } + + /** + * + * Constructor + * + * @param gl_Name The name of the GLFunc implementation + * If gl_Name==null, the default class will be used ! + * + * @param glu_Name The name of the GLUFunc implementation + * If gl_LibName==null, the default class will be used ! + * + * @param layout the layout manager + * @param isDoubleBuffered the flag indicates, + * if double buffer should be used + * + */ + public GLJPanel( String gl_Name, + String glu_Name, + LayoutManager layout, boolean isDoubleBuffered + ) + { + super( layout, isDoubleBuffered ); + + if( (gl=GLContext.createGLFunc(gl_Name)) ==null) + { + System.out.println("GLFunc implementation "+gl_Name+" not created"); + } + if( (glu=GLContext.createGLUFunc(glu_Name)) ==null) + { + System.out.println("GLUFunc implementation "+glu_Name+" not created"); + } + + /* to be able for RESIZE event's */ + addComponentListener(this); + + setOpaque(false); + } + + /** + * + * Constructor + * + * @param layout the layout manager + * @param isDoubleBuffered the flag indicates, + * if double buffer should be used + * + */ + public GLJPanel( LayoutManager layout, boolean isDoubleBuffered ) + { + this(null, null, layout, isDoubleBuffered); + } + + /** + * + * Constructor + * + * Uses the default GLFunc and GLUFunc implementation ! + * + * @param isDoubleBuffered the flag indicates, + * if double buffer should be used + */ + public GLJPanel( boolean isDoubleBuffered ) + { + this(null, null, new FlowLayout(), isDoubleBuffered); + } + + /** + * + * Constructor + * + * Uses the default GLFunc and GLUFunc implementation ! + * + * @param layout the layout manager + */ + public GLJPanel(LayoutManager layout) + { + this(null, null, layout, true); + } + + /** + * + * Constructor + * + * Uses the default GLFunc and GLUFunc implementation ! + * + */ + public GLJPanel( ) + { + this(null, null, new FlowLayout(), true); + } + + /** + * Used to return the created GLContext + */ + public final GLContext getGLContext() { return glj; } + + /** + * Safe the toplevel window + */ + protected Window topLevelWindow = null; + + /** + * + * This function returns the found TopLevelWindow, + * which contains this Canvas .. + * + * @return void + * + * @see GLJPanel#paint + */ + public final Window getTopLevelWindow() + { return topLevelWindow; } + + /** + * this function overrides the Canvas paint method ! + * + * For the first paint, + * the user function preInit is called, a GLContext is created + * and the user function init is called ! + * + * Also, if a GL Context exist, GLJPanel's sDisplay-method will be called + * to do OpenGL-rendering. + * + * The sDisplay method itself calls the display-method ! + * sDisplay is needed to be thread-safe, to manage + * the resize functionality and to safe the time per frame. + * + * To define your rendering, you should overwrite the display-method + * in your derivation. + * + * @see gl4java.GLContext#GLContext + * @see GLJPanel#cvsIsInit + * @see GLJPanel#sDisplay + * @see GLJPanel#display + * @see GLJPanel#preInit + * @see GLJPanel#init + */ + public synchronized final void paintComponent(Graphics g) + { + //JAU + if(GLContext.gljClassDebug) + System.out.println("GPanel::paintComponent()"); + //super.paintComponent(g); + setOpaque(false); + if(glj == null ) + { + preInit(); + glj = new GLContext ( this, gl, glu, + createOwnWindow, + doubleBuffer, stereoView, + rgba, stencilBits, + sharedGLContext ); + + if(glj!=null) + { + createOwnWindow = glj.isOwnWindowCreated(); + doubleBuffer = glj.isDoubleBuffer(); + stencilBits = glj.getStencilBitNumber(); + stereoView = glj.isStereoView(); + rgba = glj.isRGBA(); + } + + init(); + + // fetch the top-level window , + // to add us as the windowListener + // + Container _c = getParent(); + Container c = null; + + while(_c!=null) + { + c = _c; + _c = _c.getParent(); + } + + if(c instanceof Window) { + topLevelWindow = (Window)c; + topLevelWindow.addComponentListener(this); + topLevelWindow.addMouseListener(this); + } else { + topLevelWindow = null; + System.out.println("toplevel is not a Window: "+c); + } + + if(topLevelWindow!=null) + { + topLevelWindow.addWindowListener(this); + } else { + System.out.println("no parent found for "+getName()); + System.out.flush(); + } + if(glj!=null && glj.gljIsInit()) + cvsInitialized=true; + } + /* + if( mustResize ) size = getSize(); + g.setClip(0, 0, size.width, size.height ); + */ + sPaint(g); + } + + /** + * + * This is the thread save rendering-method called by paint. + * The actual thread will be set to highes priority befor calling + * 'display'. After 'display' the priority will be reset ! + * + * 'gljFree' will be NOT called after 'display'. + * + * We tested the above to use multi-threading and + * for the demonstration 'glDemos' it works ;-)) ! + * + * BE SURE, if you want to call 'display' by yourself + * (e.g. in the run method for animation) + * YOU HAVE TO CALL sDisplay -- OR YOU MUST KNOW WHAT YOU ARE DOING THEN ! + * + * @return void + * + * @see GLJPanel#paint + * @see GLJPanel#display + */ + public synchronized final void sPaint( Graphics g ) + { + boolean ok = true; + + long _s = System.currentTimeMillis(); + + if(!cvsIsInit()) + return; + + /* + if( glj.gljMakeCurrent() == false ) { + System.out.println("GLJPanel: problem in use() method"); + return; + } + */ + + if( mustResize ) + { + if( (ok = glj.gljMakeCurrent()) == true ) + { + Dimension size = getSize(); + glj.gljResize( size.width, size.height ) ; + reshape(size.width, size.height); + mustResize = false; + } + } + if(ok) + { + display(); + g.setClip(getBounds()); + if(GLContext.gljClassDebug) + glj.gljCheckGL(); + _f_dur_self = System.currentTimeMillis()-_s; + + /* + GLGraphics glg1 = (GLGraphics)glg.create(); + try { + super.paint(glg1); + } finally { + glg1.dispose(); + } + */ + //super.paint(g); + if(GLContext.gljClassDebug) + glj.gljCheckGL(); + _f_dur_total = System.currentTimeMillis()-_s; + } + + } + + /** + * + * This is the rendering-method called by sDisplay + * (and sDisplay is called by paint !). + * The derived-class (Your Subclass) will redefine this, to draw it's own... + * + * BE SURE, if you want to call 'display' by yourself + * (e.g. in the run method for animation) + * YOU HAVE TO CALL sDisplay ! + * + * 'sDisplay' manages a semaphore to avoid reentrance of + * the display function !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + * + * @return void + * + * @see GLJPanel#sDisplay + * @see GLJPanel#paint + */ + public void display() + { + } + + /** + * + * This is your pre-init method. + * preInit is called just BEFORE the GL-Context is created. + * You should override preInit, to initialize your visual-stuff, + * like the protected vars: doubleBuffer and stereoView + * + * @return void + * + * @see GLJPanel#paint + * @see GLJPanel#doubleBuffer + * @see GLJPanel#stereoView + * @see GLJPanel#rgba + * @see GLJPanel#stencilBits + */ + public void preInit() + { + } + + /** + * + * This is your init method. + * init is called right after the GL-Context is initialized. + * You should override init, to initialize your stuff needed + * by OpenGL an Java ! + * + * @return void + * + * @see GLJPanel#paint + */ + public void init() + { + } + + /** + * This method is used to clean up any OpenGL stuff (delete textures + * or whatever) prior to actually deleting the OpenGL context. + * You should override this with your own version, if you need to do + * any cleanup work at this phase. + * This functions is called within cvsDispose + * + * @return void + * + * @see GLJPanel#cvsDispose + */ + public void doCleanup() + { + } + + /** + * This function returns, if everything is init: the GLContext, + * the and the users init function + * This value is set in the paint method! + * + * @return boolean + * + * @see GLJPanel#paint + * @see GLJPanel#init + */ + public boolean cvsIsInit() + { + return cvsInitialized; + } + + protected long _f_dur_self = 0; + protected long _f_dur_total = 0; + + /** + * + * This is the reshape-method called by paint. + * The derived-class (Your Subclass) will redefine this, + * to manage your individual reshape ... + * + * This �reshape� method will be invoked after the first paint command + * after GLJPanel.componentResize is called AND only if �gljUse� was + * succesfull (so a call of gljUse is redundant). + * �reshape� is not an overloading of java.awt.Component.reshape, + * �reshape� is more like �glut�-reshape. + * + * GLJPanel.reshape allready has a simple default implementation, + * which calls �gljResize� and �glViewport� - so you may be can + * left this one as it is (no need to overload). + * The needed call to �gljResize� is done by hte invoker paint ! + * + * @param width the new width + * @param height the new height + * @return void + * + * @see GLJPanel#paint + * @see GLJPanel#sDisplay + */ + public void reshape( int width, int height ) + { + if(GLContext.gljClassDebug) + System.out.println("GLJPanel::reshape bounds("+getBounds()+")"); + gl.glViewport(0,0, width, height); + } + + /* JAU */ + /* + public final void setBounds(int x, int y, int width, int height) { + reshape(x, y, width, height); + } + public final void setBounds(Rectangle r) { + reshape(r.x, r.y, r.width, r.height); + } + + public void reshape(int x, int y, int width, int height) { + super.reshape(x, y, width, height); + if(glj==null || !glj.gljIsInit() || !glj.gljMakeCurrent()) + { + System.out.println("GLJPanel::setBounds(): problem in use() method"); + return; + } + reshape(width-x, height-y); + glj.gljCheckGL(); + glj.gljFree(); + size = new Dimension(width-x, height-y); + } + */ + + + /** + * + * �componentResized� is the componentListeners event handler. + * + * This method sets the variable �mustResize� to true, + * so the upcoming �paint� method-call will invoke �reshape� ! + * + * This little look-alike complicating thing is done, + * to avoid an Exception by using the glContext from more than + * one concurrent thread�s ! + * + * You cannot override this implementation, it is final + * - override �reshape' instead ! + * + * @param e the element, which is resized + * @return void + * + * @see GLJPanel#paint + * @see GLJPanel#reshape + */ + public void componentResized(ComponentEvent e) + { + if(GLContext.gljClassDebug) + System.out.println("GLJPanel::componentResized("+e.getComponent()+")"); + if(glj!=null && glj.gljIsInit() && e.getComponent()==this ) + { + mustResize = true; + //repaint(); + } + } + + public void componentMoved(ComponentEvent e) + { + /* + if(GLContext.gljClassDebug) + System.out.print("GLJPanel::componentMoved("+e.getComponent()+")"); + if(e.getComponent().equals(topLevelWindow)) + { + repaint(); + } + */ + } + + public void componentShown(ComponentEvent e) + { + if(GLContext.gljClassDebug) + System.out.print("GLJPanel::componentShown("+e.getComponent()+")"); + } + + public void componentHidden(ComponentEvent e) + { + if(GLContext.gljClassDebug) + System.out.print("GLJPanel::componentHidden("+e.getComponent()+")"); + } + + public void mouseClicked(MouseEvent e) + { + if(GLContext.gljClassDebug) + System.out.print("."); + } + public void mouseEntered(MouseEvent e) + { + /* + if(GLContext.gljClassDebug) + System.out.print("GLJPanel::mouseEntered("+e.getComponent()+")"); + if(e.getComponent().equals(topLevelWindow)) + { + repaint(); + } + */ + } + public void mouseExited(MouseEvent e) + {} + public void mousePressed(MouseEvent e) + { + if(GLContext.gljClassDebug) + System.out.print("<"); + } + public void mouseReleased(MouseEvent e) + { + if(GLContext.gljClassDebug) + System.out.print(">"); + } + + public void windowOpened(WindowEvent e) + { + } + + /** + * + * �windowClosing� is the windowListeners event handler + * for the topLevelWindow of this Canvas ! + * + * This methods free�s AND destroy�s + * the GL Context with �glj.gljDestroy� ! + * + * @return void + * + */ + public void windowClosing(WindowEvent e) + { + if(e.getComponent().equals(topLevelWindow)) + { + cvsDispose(); + } + } + + /** + * + * �windowClosed� is the windowListeners event handler. + * + * @return void + * + */ + public void windowClosed(WindowEvent e) + { + if (needCvsDispose) cvsDispose(); + } + + public void windowIconified(WindowEvent e) + { + } + + public void windowDeiconified(WindowEvent e) + { + } + + public void windowActivated(WindowEvent e) + { + } + + public void windowDeactivated(WindowEvent e) + { + } + + /** + * You should call this before releasing/dispose this Window ! + * Also you can overwrite this class, + * to dispose your own elements, e.g. a Frame etc. - + * but be shure that you call + * cvsDispose implementation call this one ! + * + * This function calls gljDestroy of GLContext ! + * + * @see gl4java.GLContext#gljDestroy + * @see GLJPanel#doCleanup + */ + public void cvsDispose() + { + cvsInitialized = false; + if (glj != null) + { + if (glj.gljIsInit()) + { + /* Sometimes the Microsoft VM calls the + Applet.stop() method but doesn't have + permissions to do J/Direct calls, so + this whole block of code will throw a + security exception. If this happens, + however, windowClosing() will still + call us again later and we will have + another opportunity to shut down the + context, so it all works out fine. */ + try + { + glj.gljFree(); + doCleanup(); + //locks and free's GLContext + glj.setEnabled(false); + glj.gljDestroy(); + needCvsDispose = false; + } + catch (Exception ex) + { + needCvsDispose = true; + } + } + } + + // Setting glj to null will simply cause paint() to re-initialize. + // We don't want that to happen, so we will leave glj non-null. + } + + /** + * get methods + */ + public final int cvsGetWidth() { + return getSize().width; + } + public final int cvsGetHeight() { + return getSize().height; + } +} + diff --git a/demos/SwingDemos/test/GLJPanel/test1.java b/demos/SwingDemos/test/GLJPanel/test1.java new file mode 100644 index 0000000..3dcb96a --- /dev/null +++ b/demos/SwingDemos/test/GLJPanel/test1.java @@ -0,0 +1,158 @@ +import java.applet.*; +import java.awt.*; +import java.awt.event.*; +import java.awt.Dimension; +import javax.swing.*; +import gl4java.*; +import gl4java.awt.*; +import gl4java.utils.glut.*; +import gl4java.utils.glut.fonts.*; + +public class test1 extends JApplet + implements GLEnum, GLUEnum, ActionListener, ItemListener +{ + static { + if(GLContext.loadNativeLibraries(null, null, null)==false) + System.out.println("GLCanvas could not load def. native libs."); + } + + protected class test1Panel extends GLJPanel + implements ActionListener, ItemListener + { + public test1Panel( LayoutManager layout, boolean isDoubleBuffered) + { + super(layout, isDoubleBuffered); + GLContext.gljNativeDebug = true; + GLContext.gljClassDebug = true; + doubleBuffer = false; + } + + + public void init() { + System.out.println("<i>"); + //glg = new GLGraphics(gl, glu); + reshape(getSize().width, getSize().height); + } + + public void display() + { + if( glj.gljMakeCurrent() == false ) { + System.out.println("problem in use() method"); + return; + } + + System.out.println("<p>"); + + int i; + + gl.glPushMatrix(); + gl.glClear(GL_COLOR_BUFFER_BIT); + + gl.glColor4f(0f, 0f, 1f, 1f); + + int width=getSize().width; + int height=getSize().height; + + gl.glBegin(GLEnum.GL_LINES); + gl.glVertex3i( 0, 0, 0); + gl.glVertex3i( 10, 10, 0); + gl.glVertex3i( 0, 10, 0); + gl.glVertex3i( 10, 0, 0); + gl.glEnd(); + + gl.glPopMatrix(); + + glj.gljSwap(); + glj.gljCheckGL(); + glj.gljFree(); + } + + public void reshape( int width, int height ) + { + Rectangle bounds = getBounds(); + System.out.println("reshape("+width+", "+height+")"); + System.out.println("reshape bounds("+bounds+")"); + //gl.glViewport(0,0, width, height); + gl.glViewport(bounds.x, bounds.y, + bounds.width, bounds.height); + gl.glMatrixMode(GL_PROJECTION); + gl.glLoadIdentity(); + gl.glOrtho(0, 10, 0, 10, -50.0,50.0); + gl.glMatrixMode(GL_MODELVIEW); + } + + public void actionPerformed(ActionEvent e) { + if (e.getActionCommand().equals("east")) { + System.out.println("East pressed"); + } else if (e.getActionCommand().equals("west")) { + System.out.println("West pressed"); + } + } + + public void itemStateChanged(ItemEvent e) { + Object source = e.getItemSelectable(); + System.out.println("item changed: "+source); + } + + } + + test1Panel tst1cvs1; + + public void init() + { + JPanel jp1 = new JPanel (new BorderLayout(), false); + setContentPane(jp1); + tst1cvs1 = new test1Panel(new BorderLayout(), false); + jp1.add("Center", tst1cvs1); + + String[] data = {"one", "two", "three", "four"}; + JList dataList = new JList(data); + jp1.add("North", dataList); + + JButton b1, b2; + jp1.add("East", (b1 = new JButton("E"))); + b1.setActionCommand("east"); + b1.addActionListener(this); + jp1.add("West", (b2 = new JButton("W"))); + b2.setActionCommand("west"); + b2.addActionListener(this); + + JCheckBox c1; + jp1.add("South", (c1 = new JCheckBox("SouthButton", true))); + c1.addItemListener(this); + } + + public static void main(java.lang.String[] args) { + try { + Frame mainFrame = new Frame("test1"); + + test1 applet=new test1(); + + applet.setSize(400, 400); + applet.init(); + applet.start(); + + mainFrame.add(applet); + + mainFrame.pack(); + mainFrame.setVisible(true); + } catch (Throwable exception) { + System.err.println("Exception occurred in main()"); + exception.printStackTrace(System.out); + } + } + + public void actionPerformed(ActionEvent e) { + if (e.getActionCommand().equals("east")) { + System.out.println("East pressed"); + } else if (e.getActionCommand().equals("west")) { + System.out.println("West pressed"); + } + } + + public void itemStateChanged(ItemEvent e) { + Object source = e.getItemSelectable(); + System.out.println("item changed: "+source); + } + +} diff --git a/demos/SwingDemos/test/GLJPanel/test2.java b/demos/SwingDemos/test/GLJPanel/test2.java new file mode 100644 index 0000000..c479133 --- /dev/null +++ b/demos/SwingDemos/test/GLJPanel/test2.java @@ -0,0 +1,115 @@ +import java.applet.*; +import java.awt.*; +import java.awt.event.*; +import java.awt.Dimension; +import javax.swing.*; + +public class test2 extends JApplet + implements ActionListener, ItemListener +{ + protected class test2Panel extends JPanel + implements ActionListener, ItemListener + { + public test2Panel( LayoutManager layout, boolean isDoubleBuffered) + { + super(layout, isDoubleBuffered); + } + + + public void paintComponent(Graphics g) + { + System.out.println("<p>"); + + super.paintComponent(g); + + g.setColor(Color.blue); + + int width=getSize().width; + int height=getSize().height; + + g.drawLine ( 0, height/2, width, height/2 ); + g.drawLine ( width/2, 0, width/2, height ); + + g.setColor(Color.yellow); + + g.drawLine ( 0, 0, width, height); + g.drawString("Left-top", 0, 10); + g.drawString("GLGraphics - CENTER", width/2, height/2); + g.drawString("Right - Bottom (nearly)", width*2/3, height*2/3); + } + + public void actionPerformed(ActionEvent e) { + if (e.getActionCommand().equals("east")) { + System.out.println("East pressed"); + } else if (e.getActionCommand().equals("west")) { + System.out.println("West pressed"); + } + } + + public void itemStateChanged(ItemEvent e) { + Object source = e.getItemSelectable(); + System.out.println("item changed: "+source); + } + + } + + test2Panel tst1cvs1; + + public void init() + { + JPanel jp1 = new JPanel (new BorderLayout(), false); + setContentPane(jp1); + tst1cvs1 = new test2Panel(new BorderLayout(), false); + jp1.add("Center", tst1cvs1); + + String[] data = {"one", "two", "three", "four"}; + JList dataList = new JList(data); + jp1.add("North", dataList); + + JButton b1, b2; + jp1.add("East", (b1 = new JButton("E"))); + b1.setActionCommand("east"); + b1.addActionListener(this); + jp1.add("West", (b2 = new JButton("W"))); + b2.setActionCommand("west"); + b2.addActionListener(this); + + JCheckBox c1; + jp1.add("South", (c1 = new JCheckBox("SouthButton", true))); + c1.addItemListener(this); + } + + public static void main(java.lang.String[] args) { + try { + Frame mainFrame = new Frame("test2"); + + test2 applet=new test2(); + + applet.setSize(400, 400); + applet.init(); + applet.start(); + + mainFrame.add(applet); + + mainFrame.pack(); + mainFrame.setVisible(true); + } catch (Throwable exception) { + System.err.println("Exception occurred in main()"); + exception.printStackTrace(System.out); + } + } + + public void actionPerformed(ActionEvent e) { + if (e.getActionCommand().equals("east")) { + System.out.println("East pressed"); + } else if (e.getActionCommand().equals("west")) { + System.out.println("West pressed"); + } + } + + public void itemStateChanged(ItemEvent e) { + Object source = e.getItemSelectable(); + System.out.println("item changed: "+source); + } + +} diff --git a/demos/SwingDemos/test/GLPanel-AWTGraphics/GLPanel.java b/demos/SwingDemos/test/GLPanel-AWTGraphics/GLPanel.java new file mode 100644 index 0000000..4c7989d --- /dev/null +++ b/demos/SwingDemos/test/GLPanel-AWTGraphics/GLPanel.java @@ -0,0 +1,676 @@ +//package gl4java.awt; + +import gl4java.*; + +import java.awt.*; +import java.awt.event.*; + +public class GLPanel extends Panel + implements GLEnum, GLUEnum, + ComponentListener, WindowListener, MouseListener +{ + protected GLContext glj = null; + public GLFunc gl = null; + public GLUFunc glu = null; + + protected boolean mustResize = false; + + protected boolean cvsInitialized=false; + + protected boolean needCvsDispose = false; + + /** + * Visual pre-set for doubleBuffer, default: true + * This value is updated after a GLContext is created with the + * original updated value of GLContext ! + * + * @see GLPanel#preInit + * @see GLPanel#paint + */ + protected boolean doubleBuffer = true; + + /** + * Visual pre-set for stencil-bit number, default: 0 + * This value is updated after a GLContext is created with the + * original updated value of GLContext ! + * + * @see GLPanel#preInit + * @see GLPanel#paint + */ + protected int stencilBits = 0; + + /** + * Visual pre-set for stereoView, default: false + * This value is updated after a GLContext is created with the + * original updated value of GLContext ! + * + * @see GLPanel#preInit + * @see GLPanel#paint + */ + protected boolean stereoView = false; + + /** + * Visual pre-set for RGBA usage, default: true - of course ;-) + * This value is updated after a GLContext is created with the + * original updated value of GLContext ! + * + * @see GLPanel#preInit + * @see GLPanel#paint + */ + protected boolean rgba = true; + + /** + * Visual pre-set for RGBA usage, default: true - of course ;-) + * This value is updated after a GLContext is created with the + * original updated value of GLContext ! + * + * @see GLPanel#preInit + * @see GLPanel#paint + */ + protected boolean createOwnWindow = false; + + /** + * The context with witch display lists and textures will be shared. + * + * @see GLPanel#preInit + * @see GLPanel#paint + */ + protected GLContext sharedGLContext; + + static { + if(GLContext.loadNativeLibraries(null, null, null)==false) + System.out.println("GLPanel could not load def. native libs."); + } + + /** + * + * Constructor + * + * @param width the canvas initial-prefered width + * @param height the canvas initial-prefered height + * + * @param gl_Name The name of the GLFunc implementation + * If gl_Name==null, the default class will be used ! + * + * @param glu_Name The name of the GLUFunc implementation + * If gl_LibName==null, the default class will be used ! + * + */ + public GLPanel( String gl_Name, + String glu_Name + ) + { + super( new BorderLayout() ); + + if( (gl=GLContext.createGLFunc(gl_Name)) ==null) + { + System.out.println("GLFunc implementation "+gl_Name+" not created"); + } + if( (glu=GLContext.createGLUFunc(glu_Name)) ==null) + { + System.out.println("GLUFunc implementation "+glu_Name+" not created"); + } + + /* to be able for RESIZE event's */ + addComponentListener(this); + } + + /** + * + * Constructor + * + * Uses the default GLFunc and GLUFunc implementation ! + * + * @param width the canvas initial-prefered width + * @param height the canvas initial-prefered height + * + */ + public GLPanel( ) + { + this(null, null); + } + + /** + * Used to return the created GLContext + */ + public final GLContext getGLContext() { return glj; } + + /** + * + * Overridden update + * This one only call's the paint method, without clearing + * the background - thats hopefully done by OpenGL ;-) + * + * @param g the Graphics Context + * @return void + * + * @see GLPanel#paint + */ + public void update(Graphics g) + { + //JAU + if(GLContext.gljClassDebug) + System.out.println("GPanel::update(): isShowing()="+isShowing()); + if(isShowing()) + { + /* let's let OpenGL clear the background ... */ + paint(g); + } + } + + + /** + * Safe the toplevel window + */ + protected Window topLevelWindow = null; + + /** + * + * This function returns the found TopLevelWindow, + * which contains this Canvas .. + * + * @return void + * + * @see GLPanel#paint + */ + public final Window getTopLevelWindow() + { return topLevelWindow; } + + /** + * this function overrides the Canvas paint method ! + * + * For the first paint, + * the user function preInit is called, a GLContext is created + * and the user function init is called ! + * + * Also, if a GL Context exist, GLPanel's sDisplay-method will be called + * to do OpenGL-rendering. + * + * The sDisplay method itself calls the display-method ! + * sDisplay is needed to be thread-safe, to manage + * the resize functionality and to safe the time per frame. + * + * To define your rendering, you should overwrite the display-method + * in your derivation. + * + * @see gl4java.GLContext#GLContext + * @see GLPanel#cvsIsInit + * @see GLPanel#sDisplay + * @see GLPanel#display + * @see GLPanel#preInit + * @see GLPanel#init + */ + public synchronized final void paint( Graphics g ) + { + //JAU + if(GLContext.gljClassDebug) + System.out.println("GPanel::paint()"); + if(glj == null ) + { + preInit(); + glj = new GLContext ( this, gl, glu, + createOwnWindow, + doubleBuffer, stereoView, + rgba, stencilBits, + sharedGLContext ); + + if(glj!=null) + { + createOwnWindow = glj.isOwnWindowCreated(); + doubleBuffer = glj.isDoubleBuffer(); + stencilBits = glj.getStencilBitNumber(); + stereoView = glj.isStereoView(); + rgba = glj.isRGBA(); + } + + init(); + + // fetch the top-level window , + // to add us as the windowListener + // + Container _c = getParent(); + Container c = null; + + while(_c!=null) + { + c = _c; + _c = _c.getParent(); + } + + if(c instanceof Window) { + topLevelWindow = (Window)c; + topLevelWindow.addComponentListener(this); + topLevelWindow.addMouseListener(this); + } else { + topLevelWindow = null; + System.out.println("toplevel is not a Window: "+c); + } + + if(topLevelWindow!=null) + { + topLevelWindow.addWindowListener(this); + } else { + System.out.println("no parent found for "+getName()); + System.out.flush(); + } + if(glj!=null && glj.gljIsInit()) + cvsInitialized=true; + } + /* + if( mustResize ) size = getSize(); + g.setClip(0, 0, size.width, size.height ); + */ + sPaint(g); + } + + /** + * + * This is the thread save rendering-method called by paint. + * The actual thread will be set to highes priority befor calling + * 'display'. After 'display' the priority will be reset ! + * + * 'gljFree' will be NOT called after 'display'. + * + * We tested the above to use multi-threading and + * for the demonstration 'glDemos' it works ;-)) ! + * + * BE SURE, if you want to call 'display' by yourself + * (e.g. in the run method for animation) + * YOU HAVE TO CALL sDisplay -- OR YOU MUST KNOW WHAT YOU ARE DOING THEN ! + * + * @return void + * + * @see GLPanel#paint + * @see GLPanel#display + */ + public synchronized final void sPaint( Graphics g ) + { + boolean ok = true; + + long _s = System.currentTimeMillis(); + + if(!cvsIsInit()) + return; + + /* + if( glj.gljMakeCurrent() == false ) { + System.out.println("GLPanel: problem in use() method"); + return; + } + */ + + if( mustResize ) + { + Dimension size = getSize(); + glj.gljResize( size.width, size.height ) ; + reshape(size.width, size.height); + mustResize = false; + } + if(ok) + { + display(); + if(GLContext.gljClassDebug) + glj.gljCheckGL(); + _f_dur_self = System.currentTimeMillis()-_s; + + /* + GLGraphics glg1 = (GLGraphics)glg.create(); + try { + super.paint(glg1); + } finally { + glg1.dispose(); + } + */ + super.paint(g); + if(GLContext.gljClassDebug) + glj.gljCheckGL(); + _f_dur_total = System.currentTimeMillis()-_s; + + glj.gljSwap(); + glj.gljFree(); + } + + } + + /** + * + * This is the rendering-method called by sDisplay + * (and sDisplay is called by paint !). + * The derived-class (Your Subclass) will redefine this, to draw it's own... + * + * BE SURE, if you want to call 'display' by yourself + * (e.g. in the run method for animation) + * YOU HAVE TO CALL sDisplay ! + * + * 'sDisplay' manages a semaphore to avoid reentrance of + * the display function !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + * + * @return void + * + * @see GLPanel#sDisplay + * @see GLPanel#paint + */ + public void display() + { + } + + /** + * + * This is your pre-init method. + * preInit is called just BEFORE the GL-Context is created. + * You should override preInit, to initialize your visual-stuff, + * like the protected vars: doubleBuffer and stereoView + * + * @return void + * + * @see GLPanel#paint + * @see GLPanel#doubleBuffer + * @see GLPanel#stereoView + * @see GLPanel#rgba + * @see GLPanel#stencilBits + */ + public void preInit() + { + } + + /** + * + * This is your init method. + * init is called right after the GL-Context is initialized. + * You should override init, to initialize your stuff needed + * by OpenGL an Java ! + * + * @return void + * + * @see GLPanel#paint + */ + public void init() + { + } + + /** + * This method is used to clean up any OpenGL stuff (delete textures + * or whatever) prior to actually deleting the OpenGL context. + * You should override this with your own version, if you need to do + * any cleanup work at this phase. + * This functions is called within cvsDispose + * + * @return void + * + * @see GLPanel#cvsDispose + */ + public void doCleanup() + { + } + + /** + * This function returns, if everything is init: the GLContext, + * the and the users init function + * This value is set in the paint method! + * + * @return boolean + * + * @see GLPanel#paint + * @see GLPanel#init + */ + public boolean cvsIsInit() + { + return cvsInitialized; + } + + protected long _f_dur_self = 0; + protected long _f_dur_total = 0; + + /** + * + * This is the reshape-method called by paint. + * The derived-class (Your Subclass) will redefine this, + * to manage your individual reshape ... + * + * This �reshape� method will be invoked after the first paint command + * after GLPanel.componentResize is called AND only if �gljUse� was + * succesfull (so a call of gljUse is redundant). + * �reshape� is not an overloading of java.awt.Component.reshape, + * �reshape� is more like �glut�-reshape. + * + * GLPanel.reshape allready has a simple default implementation, + * which calls �gljResize� and �glViewport� - so you may be can + * left this one as it is (no need to overload). + * The needed call to �gljResize� is done by hte invoker paint ! + * + * @param width the new width + * @param height the new height + * @return void + * + * @see GLPanel#paint + * @see GLPanel#sDisplay + */ + public void reshape( int width, int height ) + { + if(GLContext.gljClassDebug) + System.out.println("GLPanel::reshape bounds("+getBounds()+")"); + gl.glViewport(0,0, width, height); + gl.glMatrixMode(GL_PROJECTION); + gl.glLoadIdentity(); + gl.glOrtho(0, width, height, 0, -50.0,50.0); + gl.glMatrixMode(GL_MODELVIEW); + } + + /* JAU */ + /* + public final void setBounds(int x, int y, int width, int height) { + reshape(x, y, width, height); + } + public final void setBounds(Rectangle r) { + reshape(r.x, r.y, r.width, r.height); + } + + public void reshape(int x, int y, int width, int height) { + super.reshape(x, y, width, height); + if(glj==null || !glj.gljIsInit() || !glj.gljMakeCurrent()) + { + System.out.println("GLPanel::setBounds(): problem in use() method"); + return; + } + reshape(width-x, height-y); + glj.gljCheckGL(); + glj.gljFree(); + size = new Dimension(width-x, height-y); + } + */ + + + /** + * + * �componentResized� is the componentListeners event handler. + * + * This method sets the variable �mustResize� to true, + * so the upcoming �paint� method-call will invoke �reshape� ! + * + * This little look-alike complicating thing is done, + * to avoid an Exception by using the glContext from more than + * one concurrent thread�s ! + * + * You cannot override this implementation, it is final + * - override �reshape' instead ! + * + * @param e the element, which is resized + * @return void + * + * @see GLPanel#paint + * @see GLPanel#reshape + */ + public void componentResized(ComponentEvent e) + { + if(GLContext.gljClassDebug) + System.out.println("GLPanel::componentResized("+e.getComponent()+")"); + if(glj!=null && glj.gljIsInit() && e.getComponent()==this ) + { + mustResize = true; + //repaint(); + } + } + + public void componentMoved(ComponentEvent e) + { + if(GLContext.gljClassDebug) + System.out.print("GLPanel::componentMoved("+e.getComponent()+")"); + /* + if(e.getComponent().equals(topLevelWindow)) + { + repaint(); + } + */ + } + + public void componentShown(ComponentEvent e) + { + if(GLContext.gljClassDebug) + System.out.print("GLPanel::componentShown("+e.getComponent()+")"); + } + + public void componentHidden(ComponentEvent e) + { + if(GLContext.gljClassDebug) + System.out.print("GLPanel::componentHidden("+e.getComponent()+")"); + } + + public void mouseClicked(MouseEvent e) + { + if(GLContext.gljClassDebug) + System.out.print("."); + } + public void mouseEntered(MouseEvent e) + { + if(GLContext.gljClassDebug) + System.out.print("GLPanel::mouseEntered("+e.getComponent()+")"); + /* + if(e.getComponent().equals(topLevelWindow)) + { + repaint(); + } + */ + } + public void mouseExited(MouseEvent e) + {} + public void mousePressed(MouseEvent e) + { + if(GLContext.gljClassDebug) + System.out.print("<"); + } + public void mouseReleased(MouseEvent e) + { + if(GLContext.gljClassDebug) + System.out.print(">"); + } + + public void windowOpened(WindowEvent e) + { + } + + /** + * + * �windowClosing� is the windowListeners event handler + * for the topLevelWindow of this Canvas ! + * + * This methods free�s AND destroy�s + * the GL Context with �glj.gljDestroy� ! + * + * @return void + * + */ + public void windowClosing(WindowEvent e) + { + if(e.getComponent().equals(topLevelWindow)) + { + cvsDispose(); + } + } + + /** + * + * �windowClosed� is the windowListeners event handler. + * + * @return void + * + */ + public void windowClosed(WindowEvent e) + { + if (needCvsDispose) cvsDispose(); + } + + public void windowIconified(WindowEvent e) + { + } + + public void windowDeiconified(WindowEvent e) + { + } + + public void windowActivated(WindowEvent e) + { + } + + public void windowDeactivated(WindowEvent e) + { + } + + /** + * You should call this before releasing/dispose this Window ! + * Also you can overwrite this class, + * to dispose your own elements, e.g. a Frame etc. - + * but be shure that you call + * cvsDispose implementation call this one ! + * + * This function calls gljDestroy of GLContext ! + * + * @see gl4java.GLContext#gljDestroy + * @see GLPanel#doCleanup + */ + public void cvsDispose() + { + cvsInitialized = false; + if (glj != null) + { + if (glj.gljIsInit()) + { + /* Sometimes the Microsoft VM calls the + Applet.stop() method but doesn't have + permissions to do J/Direct calls, so + this whole block of code will throw a + security exception. If this happens, + however, windowClosing() will still + call us again later and we will have + another opportunity to shut down the + context, so it all works out fine. */ + try + { + glj.gljFree(); + doCleanup(); + //locks and free's GLContext + glj.setEnabled(false); + glj.gljDestroy(); + needCvsDispose = false; + } + catch (Exception ex) + { + needCvsDispose = true; + } + } + } + + // Setting glj to null will simply cause paint() to re-initialize. + // We don't want that to happen, so we will leave glj non-null. + } + + /** + * get methods + */ + public final int cvsGetWidth() { + return getSize().width; + } + public final int cvsGetHeight() { + return getSize().height; + } +} + diff --git a/demos/SwingDemos/test/GLPanel-AWTGraphics/test1.java b/demos/SwingDemos/test/GLPanel-AWTGraphics/test1.java new file mode 100644 index 0000000..b9786a0 --- /dev/null +++ b/demos/SwingDemos/test/GLPanel-AWTGraphics/test1.java @@ -0,0 +1,137 @@ +import java.applet.*; +import java.awt.*; +import java.awt.event.*; +import java.awt.Dimension; +import javax.swing.*; +import gl4java.*; +import gl4java.awt.*; +import gl4java.swing.*; +import gl4java.utils.glut.*; +import gl4java.utils.glut.fonts.*; + +public class test1 extends JApplet + implements GLEnum, GLUEnum +{ + static { + if(GLContext.loadNativeLibraries(null, null, null)==false) + System.out.println("GLCanvas could not load def. native libs."); + } + + protected class test1Panel extends GLPanel + implements ActionListener, ItemListener + { + public test1Panel() { + super(); + GLContext.gljNativeDebug = true; + GLContext.gljClassDebug = true; + //String[] data = {"one", "two", "three", "four"}; + //JList dataList = new JList(data); + //add("North", dataList); + JButton b1, b2; + add("East", (b1 = new JButton("E"))); + b1.setActionCommand("east"); + b1.addActionListener(this); + add("West", (b2 = new JButton("W"))); + b2.setActionCommand("west"); + b2.addActionListener(this); + + JCheckBox c1; + add("South", (c1 = new JCheckBox("SouthButton", true))); + c1.addItemListener(this); + } + + + public void init() { + System.out.println("<i>"); + //glg = new GLGraphics(gl, glu); + reshape(getSize().width, getSize().height); + } + + public void display() + { + if( glj.gljMakeCurrent() == false ) { + System.out.println("problem in use() method"); + return; + } + + System.out.println("<p>"); + + int i; + + gl.glPushMatrix(); + gl.glClear(GL_COLOR_BUFFER_BIT); + + gl.glColor4f(0f, 0f, 1f, 1f); + + int width=getSize().width; + int height=getSize().height; + + gl.glBegin(GLEnum.GL_LINES); + gl.glVertex3i( 0, 0, 0); + gl.glVertex3i( 10, 10, 0); + gl.glVertex3i( 0, 10, 0); + gl.glVertex3i( 10, 0, 0); + gl.glEnd(); + + gl.glPopMatrix(); + + glj.gljSwap(); + glj.gljCheckGL(); + glj.gljFree(); + } + + public void reshape( int width, int height ) + { + System.out.println("reshape("+width+", "+height+")"); + System.out.println("reshape bounds("+getBounds()+")"); + gl.glViewport(0,0, width, height); + gl.glMatrixMode(GL_PROJECTION); + gl.glLoadIdentity(); + gl.glOrtho(0, 10, 0, 10, -50.0,50.0); + gl.glMatrixMode(GL_MODELVIEW); + } + + public void actionPerformed(ActionEvent e) { + if (e.getActionCommand().equals("east")) { + System.out.println("East pressed"); + } else if (e.getActionCommand().equals("west")) { + System.out.println("West pressed"); + } + } + + public void itemStateChanged(ItemEvent e) { + Object source = e.getItemSelectable(); + System.out.println("item changed: "+source); + } + + } + + test1Panel tst1cvs1; + + public void init() + { + tst1cvs1 = new test1Panel(); + tst1cvs1.setSize(400,400); + setContentPane(tst1cvs1); + } + + public static void main(java.lang.String[] args) { + try { + Frame mainFrame = new Frame("test1"); + + test1 applet=new test1(); + + applet.setSize(400, 400); + applet.init(); + applet.start(); + + mainFrame.add(applet); + + mainFrame.pack(); + mainFrame.setVisible(true); + } catch (Throwable exception) { + System.err.println("Exception occurred in main()"); + exception.printStackTrace(System.out); + } + } +} diff --git a/demos/SwingDemos/test/GLPanel-GLGraphics/GLGraphics.java b/demos/SwingDemos/test/GLPanel-GLGraphics/GLGraphics.java new file mode 100644 index 0000000..835febf --- /dev/null +++ b/demos/SwingDemos/test/GLPanel-GLGraphics/GLGraphics.java @@ -0,0 +1,513 @@ +/** + * @(#) GLGraphics.java + */ + +//package gl4java.awt; + +import gl4java.*; +import gl4java.utils.glut.*; +import gl4java.utils.glut.fonts.*; + +import java.awt.*; +import java.awt.image.*; +import java.awt.event.*; +import java.awt.image.ImageObserver; +import java.text.*; + +public class GLGraphics + extends java.awt.Graphics + implements Cloneable +{ + +protected final boolean debug = false; + +/** + * this is the original Graphics context + */ +protected Graphics g = null; + +protected GLContext glj = null; +protected GLFunc gl = null; +protected GLUFunc glu = null; +protected GLUTFunc glut = null; +protected int currentGlutFont = GLUTEnum.GLUT_BITMAP_TIMES_ROMAN_10; +protected int x_orig = 0; +protected int y_orig = 0; +protected int z_orig = 0; + +//protected Color clr = Color.black; +//protected Shape clip = null; +//protected Font fnt = null; + +public GLGraphics (Graphics g, GLContext glj, GLFunc gl, GLUFunc glu) { + this.g=g; + this.glj=glj; + this.gl=gl; + this.glu=glu; + glut = new GLUTFuncLightImplWithFonts(gl, glu); +} + +public GLGraphics (Graphics g, GLContext glj, GLFunc gl, GLUFunc glu, GLUTFunc glut) { + this.g=g; + this.glj=glj; + this.gl=gl; + this.glu=glu; + this.glut=glut; +} + +protected GLGraphics (GLContext glj, GLFunc gl, GLUFunc glu, GLUTFunc glut) { + this.glj=glj; + this.gl=gl; + this.glu=glu; + this.glut=glut; +} + +protected Object clone() + throws CloneNotSupportedException +{ + GLGraphics glg = new GLGraphics(g, glj, gl, glu, glut); + //glg.g=g.create(); + glg.x_orig=x_orig; + glg.y_orig=y_orig; + glg.z_orig=z_orig; + glg.currentGlutFont=currentGlutFont; + + //glg.clr = clr; + //glg.clip=clip; + //glg.fnt = fnt; + + return glg; +} + +public Graphics create () { + try { + return ((Graphics)clone()); + } + catch (CloneNotSupportedException _) { + return (null); + } +} + +public Graphics create ( int x, int y, int width, int height ) { + if(debug) + System.out.println("Graphics::create("+x+","+y+","+width+","+height+")"); + // slow, generic version + Graphics g = create(); + + // modify cloned state acording to request + g.translate( x, y); + g.clipRect( 0, 0, width, height); // spec says this should be the intersection + + return g; +} + +public void clearRect ( int x, int y, int width, int height ) +{ + if(debug) + System.out.println("Graphics::clearRect("+x+","+y+","+width+","+height+")"); +} + +public void clipRect ( int x, int y, int width, int height ) +{ g.clipRect(x, y, width, height); +} + +public void copyArea ( int x, int y, int width, int height, int dx, int dy ) +{ + if(debug) + System.out.println("Graphics::copyArea("+x+","+y+","+width+","+height+","+dx+","+dy+")"); +} + +public void dispose () +{ + //g.dispose(); +} + +public void drawArc ( int x, int y, int width, int height, + int startAngle, int arcAngle ) +{ + if(debug) + System.out.println("Graphics::drawArc("+x+","+y+","+width+","+height+","+startAngle+","+arcAngle+")"); +} + +public boolean drawImage (Image img, int x, int y, Color bgcolor, + ImageObserver observer) +{ + if(debug) + System.out.println("Graphics::drawImage("+x+","+y+","+bgcolor+")"); + if( glj.gljMakeCurrent() == false ) { + System.out.println("GLGraphics: problem in use() method"); + return false; + } + return false; +} + +public boolean drawImage ( Image img, int x, int y, ImageObserver observer) +{ + if(debug) + System.out.println("Graphics::drawImage("+x+","+y+")"); + if( glj.gljMakeCurrent() == false ) { + System.out.println("GLGraphics: problem in use() method"); + return false; + } + + glDrawImage(observer, img, x_orig+x, y_orig+y, z_orig); + return false; +} + +public boolean drawImage ( Image img, int x, int y, int width, int height, + Color background, ImageObserver observer ) +{ + if(debug) + System.out.println("Graphics::drawImage("+x+","+y+","+width+","+height+","+background+")"); + if( glj.gljMakeCurrent() == false ) { + System.out.println("GLGraphics: problem in use() method"); + return false; + } + return false; +} + +public boolean drawImage ( Image img, int x, int y, int width, int height, + ImageObserver observer) +{ + if(debug) + System.out.println("Graphics::drawImage("+x+","+y+","+width+","+height+")"); + if( glj.gljMakeCurrent() == false ) { + System.out.println("GLGraphics: problem in use() method"); + return false; + } + return false; +} + +public boolean drawImage ( Image img, + int dx0, int dy0, int dx1, int dy1, + int sx0, int sy0, int sx1, int sy1, + Color bgColor, ImageObserver observer) +{ + if(debug) + System.out.println("Graphics::drawImage(..)"); + if( glj.gljMakeCurrent() == false ) { + System.out.println("GLGraphics: problem in use() method"); + return false; + } + return false; +} + +public boolean drawImage ( Image img, + int dx1, int dy1, int dx2, int dy2, + int sx1, int sy1, int sx2, int sy2, + ImageObserver observer) +{ + if(debug) + System.out.println("Graphics::drawImage(..)"); + return false; +} + +public void drawLine ( int x1, int y1, int x2, int y2 ) +{ + if(debug) + System.out.println("Graphics("+x_orig+","+y_orig+")::drawLine("+x1+","+y1+","+x2+","+y2+")"); + if( glj.gljMakeCurrent() == false ) { + System.out.println("GLGraphics: problem in use() method"); + return; + } + gl.glBegin(GLEnum.GL_LINES); + gl.glVertex3i( x_orig+x1, y_orig+y1, z_orig); + gl.glVertex3i( x_orig+x2, y_orig+y2, z_orig); + gl.glEnd(); +} + +public void drawOval ( int x, int y, int width, int height ) +{ + if(debug) + System.out.println("Graphics::drawOval("+x+","+y+","+width+","+height+")"); +} + +public void drawPolygon ( int xPoints[], int yPoints[], int nPoints ) +{ + if(debug) + System.out.println("Graphics("+x_orig+","+y_orig+")::drawPolygon(...)"); + if( glj.gljMakeCurrent() == false ) { + System.out.println("GLGraphics: problem in use() method"); + return; + } + gl.glPolygonMode(GLEnum.GL_FRONT_AND_BACK, GLEnum.GL_LINE); + gl.glBegin(GLEnum.GL_POLYGON); + for(int i=0; i<nPoints; i++) + gl.glVertex3i( x_orig+xPoints[i], y_orig+yPoints[i], z_orig); + gl.glEnd(); +} + +public void drawPolyline ( int xPoints[], int yPoints[], int nPoints ) +{ + if(debug) + System.out.println("Graphics("+x_orig+","+y_orig+")::drawPolyline(...)"); + if( glj.gljMakeCurrent() == false ) { + System.out.println("GLGraphics: problem in use() method"); + return; + } + gl.glPolygonMode(GLEnum.GL_FRONT_AND_BACK, GLEnum.GL_LINE); + gl.glBegin(GLEnum.GL_POLYGON); + for(int i=0; i<nPoints; i++) + gl.glVertex3i( x_orig+xPoints[i], y_orig+yPoints[i], z_orig); + gl.glEnd(); +} + +public void drawRoundRect ( int x, int y, int width, int height, + int arcWidth, int arcHeight) +{ + if(debug) + System.out.println("Graphics::drawRoundRect("+x+","+y+","+width+","+height+","+arcWidth+","+arcHeight+")"); +} + +public void drawString ( String str, int x, int y ) +{ + if(debug) + System.out.println("Graphics("+x_orig+","+y_orig+")::drawString("+x+","+y+","+str+")"); + if( glj.gljMakeCurrent() == false ) { + System.out.println("GLGraphics: problem in use() method"); + return; + } + gl.glRasterPos3d(x_orig+x, y_orig+y, z_orig); + glut.glutBitmapString(currentGlutFont,str); +} + +public void drawString(java.text.AttributedCharacterIterator aci, int x, int y) +{ + if(debug) + System.out.println("Graphics("+x_orig+","+y_orig+")::drawStringACI("+x+","+y+")"); + StringBuffer sb = new StringBuffer(); + for(char c = aci.first(); c != CharacterIterator.DONE; c = aci.next()) + sb.append(c); + drawString(sb.toString(), x, y); +} + +public void fillArc ( int x, int y, int width, int height, + int startAngle, int arcAngle ) +{ + if(debug) + System.out.println("Graphics::fillArc("+x+","+y+","+width+","+height+","+startAngle+","+arcAngle+")"); +} + +public void fillOval ( int x, int y, int width, int height ) +{ + if(debug) + System.out.println("Graphics::fillOval("+x+","+y+","+width+","+height+")"); +} + +public void fillPolygon ( int xPoints[], int yPoints[], int nPoints ) +{ + if(debug) + System.out.println("Graphics::fillPolygon(..)"); +} + +public void fillRect ( int x, int y, int width, int height ) +{ + if(debug) + System.out.println("Graphics::fillRect("+x+","+y+","+width+","+height+")"); + if( glj.gljMakeCurrent() == false ) { + System.out.println("GLGraphics: problem in use() method"); + return; + } + gl.glPolygonMode(GLEnum.GL_FRONT_AND_BACK, GLEnum.GL_FILL); + gl.glBegin(GLEnum.GL_POLYGON); + gl.glVertex3i( x_orig+x, y_orig+y, z_orig); + gl.glVertex3i( x_orig+x+width, y_orig+y, z_orig); + gl.glVertex3i( x_orig+x+width, y_orig+y+height, z_orig); + gl.glVertex3i( x_orig+x, y_orig+y+height, z_orig); + gl.glVertex3i( x_orig+x, y_orig+y, z_orig); + gl.glEnd(); +} + +public void fillRoundRect ( int x, int y, int width, int height, + int arcWidth, int arcHeight ) +{ + if(debug) + System.out.println("Graphics::fillRoundRect("+x+","+y+","+width+","+height+","+arcWidth+","+arcHeight+")"); +} + +public Shape getClip () +{ return g.getClip(); } + +public Rectangle getClipBounds() +{ return null; } + +public Color getColor() +{ return g.getColor(); } + +public Font getFont() +{ return g.getFont(); } + +public FontMetrics getFontMetrics ( Font fnt ) +{ return g.getFontMetrics(fnt); } + +public void setClip ( Shape clip ) +{ g.setClip(clip); } + +public void setClip ( int x, int y, int width, int height ) +{ g.setClip(x, y, width, height); } + +public void setColor ( Color clr ) +{ + if(debug) + System.out.println("Graphics("+x_orig+","+y_orig+")::setColor("+clr+")"); + g.setColor(clr); + if( glj.gljMakeCurrent() == false ) { + System.out.println("GLGraphics: problem in use() method"); + return; + } + gl.glColor4d(clr.getRed()/255.0, clr.getGreen()/255.0, + clr.getBlue()/255.0, clr.getAlpha()/255.0); +} + +public void setFont ( Font newFnt ) +{ g.setFont(newFnt); + if(debug) + System.out.println("Graphics("+(x_orig)+","+(y_orig)+")::setFont("+newFnt.getName()+" / "+ newFnt.getFamily()+" / "+ newFnt.getSize()+")"); + switch(newFnt.getSize()) + { + case 8: + currentGlutFont = GLUTEnum.GLUT_BITMAP_8_BY_13; + break; + case 9: + currentGlutFont = GLUTEnum.GLUT_BITMAP_9_BY_15; + break; + case 10: + currentGlutFont = GLUTEnum.GLUT_BITMAP_TIMES_ROMAN_10; + break; + case 24: + currentGlutFont = GLUTEnum.GLUT_BITMAP_TIMES_ROMAN_24; + break; + /* + case 10: + currentGlutFont = GLUTEnum.GLUT_BITMAP_HELVETICA_10; + break; + */ + case 12: + currentGlutFont = GLUTEnum.GLUT_BITMAP_HELVETICA_12; + break; + case 18: + currentGlutFont = GLUTEnum.GLUT_BITMAP_HELVETICA_18; + break; + default: + currentGlutFont = GLUTEnum.GLUT_BITMAP_TIMES_ROMAN_10; + } +} + +public void setPaintMode() +{} + +public void setXORMode ( Color newXorClr ) +{} + +public void translate ( int x, int y ) +{ + x_orig+=x; + y_orig+=y; + if(debug) + System.out.println("Graphics("+(x_orig-x)+","+(y_orig-y)+")::translate("+x+","+y+") -> ("+x_orig+","+y_orig+")"); + g.translate(x, y); +} + +protected void glDrawImage(ImageObserver observer, Image image, + int xpos, int ypos, int zpos) +{ + int imageWidth = image.getWidth(observer); + int imageHeight = image.getHeight(observer); + int glFormat=GLEnum.GL_RGB; //def. RGB type + int comps=3; //def. RGB type + + if(debug) + System.out.println("Graphics("+(x_orig)+","+(y_orig)+")::glDrawImage("+xpos+","+ypos+") ("+imageWidth+","+imageHeight+")"); + + /* This is Java2 only code :-( + BufferedImage image = + new BufferedImage(imageWidth, imageHeight, + BufferedImage.TYPE_INT_RGB); + + Graphics g = image.createGraphics(); + g.drawImage(img,0,0,comp); + + imageWidth = image.getWidth(); + imageHeight = image.getHeight(); + */ + + // Read entire PNG image (doesn't throw exceptions) + int[] iPixels = new int[imageWidth * imageHeight]; + + PixelGrabber pp=new PixelGrabber(image, + 0,0, + imageWidth, imageHeight, + iPixels, + 0, + imageWidth); + try + { + pp.grabPixels(); + } + catch (InterruptedException e) + { + System.err.println("interrupted waiting for pixel!"); + return; + } + if ((pp.getStatus() & ImageObserver.ABORT) != 0) + { + System.err.println("image fetch aborted or errored"); + return; + } + + /* This is Java2 only code :-( + int imagetype = image.getType(); + switch(imagetype) + { + case BufferedImage.TYPE_INT_RGB: + glFormat=GLEnum.GL_RGB; + comps=3; + break; + case BufferedImage.TYPE_INT_ARGB: + case BufferedImage.TYPE_INT_ARGB_PRE: + glFormat=GLEnum.GL_RGBA; + comps=4; + break; + default: + System.err.println("unsupported format: "+imagetype); + return; + }; + */ + + byte[] pixel=new byte[imageWidth * imageHeight * comps]; + + byte alpha=0; + byte red=0; + byte green=0; + byte blue=0; + int offset=0; + int aPixel; + int y_desc, y_asc; + for(y_desc=imageHeight-1, y_asc=0; y_desc>=0; y_desc--, y_asc++) + { + for(int x=0;x<imageWidth;x++) + { + aPixel = iPixels[y_desc*imageWidth + x]; + + if(glFormat==GLEnum.GL_RGBA) + alpha =new Integer( (aPixel >> 24) & 0xff ).byteValue(); + red =new Integer( (aPixel >> 16) & 0xff ).byteValue(); + green =new Integer( (aPixel >> 8) & 0xff ).byteValue(); + blue =new Integer( (aPixel ) & 0xff ).byteValue(); + + pixel[offset++]=red; + pixel[offset++]=green; + pixel[offset++]=blue; + if(glFormat==GLEnum.GL_RGBA) + pixel[offset++]=alpha; + } + } + gl.glPixelStorei(GLEnum.GL_UNPACK_ALIGNMENT, 1); + gl.glDrawBuffer(GLEnum.GL_FRONT); + gl.glRasterPos3i(xpos, ypos+imageHeight, zpos); + gl.glDrawPixels(imageWidth, imageHeight, + glFormat, GLEnum.GL_UNSIGNED_BYTE, + pixel); + gl.glDrawBuffer(GLEnum.GL_BACK); +} +} diff --git a/demos/SwingDemos/test/GLPanel-GLGraphics/GLPanel.java b/demos/SwingDemos/test/GLPanel-GLGraphics/GLPanel.java new file mode 100644 index 0000000..266595e --- /dev/null +++ b/demos/SwingDemos/test/GLPanel-GLGraphics/GLPanel.java @@ -0,0 +1,692 @@ +//package gl4java.awt; + +import gl4java.*; + +import java.awt.*; +import java.awt.event.*; + +public class GLPanel extends Panel + implements GLEnum, GLUEnum, + ComponentListener, WindowListener, MouseListener +{ + protected GLContext glj = null; + public GLFunc gl = null; + public GLUFunc glu = null; + public GLGraphics glg = null; + + protected boolean mustResize = false; + + protected boolean cvsInitialized=false; + + protected boolean needCvsDispose = false; + + /** + * Visual pre-set for doubleBuffer, default: true + * This value is updated after a GLContext is created with the + * original updated value of GLContext ! + * + * @see GLPanel#preInit + * @see GLPanel#paint + */ + protected boolean doubleBuffer = true; + + /** + * Visual pre-set for stencil-bit number, default: 0 + * This value is updated after a GLContext is created with the + * original updated value of GLContext ! + * + * @see GLPanel#preInit + * @see GLPanel#paint + */ + protected int stencilBits = 0; + + /** + * Visual pre-set for stereoView, default: false + * This value is updated after a GLContext is created with the + * original updated value of GLContext ! + * + * @see GLPanel#preInit + * @see GLPanel#paint + */ + protected boolean stereoView = false; + + /** + * Visual pre-set for RGBA usage, default: true - of course ;-) + * This value is updated after a GLContext is created with the + * original updated value of GLContext ! + * + * @see GLPanel#preInit + * @see GLPanel#paint + */ + protected boolean rgba = true; + + /** + * Visual pre-set for RGBA usage, default: true - of course ;-) + * This value is updated after a GLContext is created with the + * original updated value of GLContext ! + * + * @see GLPanel#preInit + * @see GLPanel#paint + */ + protected boolean createOwnWindow = false; + + /** + * The context with witch display lists and textures will be shared. + * + * @see GLPanel#preInit + * @see GLPanel#paint + */ + protected GLContext sharedGLContext; + + static { + if(GLContext.loadNativeLibraries(null, null, null)==false) + System.out.println("GLPanel could not load def. native libs."); + } + + /** + * + * Constructor + * + * @param width the canvas initial-prefered width + * @param height the canvas initial-prefered height + * + * @param gl_Name The name of the GLFunc implementation + * If gl_Name==null, the default class will be used ! + * + * @param glu_Name The name of the GLUFunc implementation + * If gl_LibName==null, the default class will be used ! + * + */ + public GLPanel( String gl_Name, + String glu_Name + ) + { + super( new BorderLayout() ); + + if( (gl=GLContext.createGLFunc(gl_Name)) ==null) + { + System.out.println("GLFunc implementation "+gl_Name+" not created"); + } + if( (glu=GLContext.createGLUFunc(glu_Name)) ==null) + { + System.out.println("GLUFunc implementation "+glu_Name+" not created"); + } + + /* to be able for RESIZE event's */ + addComponentListener(this); + } + + /** + * + * Constructor + * + * Uses the default GLFunc and GLUFunc implementation ! + * + * @param width the canvas initial-prefered width + * @param height the canvas initial-prefered height + * + */ + public GLPanel( ) + { + this(null, null); + } + + /** + * Used to return the created GLContext + */ + public final GLContext getGLContext() { return glj; } + + /** + * + * Overridden update + * This one only call's the paint method, without clearing + * the background - thats hopefully done by OpenGL ;-) + * + * @param g the Graphics Context + * @return void + * + * @see GLPanel#paint + */ + public void update(Graphics g) + { + //JAU + if(GLContext.gljClassDebug) + System.out.println("GPanel::update(): isShowing()="+isShowing()); + if(isShowing()) + { + /* let's let OpenGL clear the background ... */ + paint(g); + } + } + + + /** + * Safe the toplevel window + */ + protected Window topLevelWindow = null; + + /** + * + * This function returns the found TopLevelWindow, + * which contains this Canvas .. + * + * @return void + * + * @see GLPanel#paint + */ + public final Window getTopLevelWindow() + { return topLevelWindow; } + + /** + * this function overrides the Canvas paint method ! + * + * For the first paint, + * the user function preInit is called, a GLContext is created + * and the user function init is called ! + * + * Also, if a GL Context exist, GLPanel's sDisplay-method will be called + * to do OpenGL-rendering. + * + * The sDisplay method itself calls the display-method ! + * sDisplay is needed to be thread-safe, to manage + * the resize functionality and to safe the time per frame. + * + * To define your rendering, you should overwrite the display-method + * in your derivation. + * + * @see gl4java.GLContext#GLContext + * @see GLPanel#cvsIsInit + * @see GLPanel#sDisplay + * @see GLPanel#display + * @see GLPanel#preInit + * @see GLPanel#init + */ + public synchronized final void paint( Graphics g ) + { + //JAU + if(GLContext.gljClassDebug) + System.out.println("GPanel::paint()"); + if(glj == null ) + { + preInit(); + glj = new GLContext ( this, gl, glu, + createOwnWindow, + doubleBuffer, stereoView, + rgba, stencilBits, + sharedGLContext ); + + if(glj!=null) + { + createOwnWindow = glj.isOwnWindowCreated(); + doubleBuffer = glj.isDoubleBuffer(); + stencilBits = glj.getStencilBitNumber(); + stereoView = glj.isStereoView(); + rgba = glj.isRGBA(); + } + + init(); + + // fetch the top-level window , + // to add us as the windowListener + // + Container _c = getParent(); + Container c = null; + + while(_c!=null) + { + c = _c; + _c = _c.getParent(); + } + + if(c instanceof Window) { + topLevelWindow = (Window)c; + topLevelWindow.addComponentListener(this); + topLevelWindow.addMouseListener(this); + } else { + topLevelWindow = null; + System.out.println("toplevel is not a Window: "+c); + } + + if(topLevelWindow!=null) + { + topLevelWindow.addWindowListener(this); + } else { + System.out.println("no parent found for "+getName()); + System.out.flush(); + } + if(glj!=null && glj.gljIsInit()) + cvsInitialized=true; + } + if(glg!=null) + glg.dispose(); + glg = new GLGraphics(g, glj, gl, glu); + /* + if( mustResize ) size = getSize(); + g.setClip(0, 0, size.width, size.height ); + */ + sPaint(g); + } + + /** + * + * This is the thread save rendering-method called by paint. + * The actual thread will be set to highes priority befor calling + * 'display'. After 'display' the priority will be reset ! + * + * 'gljFree' will be NOT called after 'display'. + * + * We tested the above to use multi-threading and + * for the demonstration 'glDemos' it works ;-)) ! + * + * BE SURE, if you want to call 'display' by yourself + * (e.g. in the run method for animation) + * YOU HAVE TO CALL sDisplay -- OR YOU MUST KNOW WHAT YOU ARE DOING THEN ! + * + * @return void + * + * @see GLPanel#paint + * @see GLPanel#display + */ + public synchronized final void sPaint( Graphics g ) + { + boolean ok = true; + + long _s = System.currentTimeMillis(); + + if(!cvsIsInit()) + return; + + /* + if( glj.gljMakeCurrent() == false ) { + System.out.println("GLPanel: problem in use() method"); + return; + } + */ + + if( mustResize ) + { + Dimension size = getSize(); + glj.gljResize( size.width, size.height ) ; + reshape(size.width, size.height); + mustResize = false; + } + if(ok) + { + display(); + if(GLContext.gljClassDebug) + glj.gljCheckGL(); + _f_dur_self = System.currentTimeMillis()-_s; + + /* + GLGraphics glg1 = (GLGraphics)glg.create(); + try { + super.paint(glg1); + } finally { + glg1.dispose(); + } + */ + super.paint(glg); + if(GLContext.gljClassDebug) + glj.gljCheckGL(); + _f_dur_total = System.currentTimeMillis()-_s; + + glj.gljSwap(); + glj.gljFree(); + } + + } + + public Graphics getGraphics() + { + if(glg==null) + return super.getGraphics(); + return glg.create(); + } + + public Graphics getNativeGraphics() + { + return super.getGraphics(); + } + + /** + * + * This is the rendering-method called by sDisplay + * (and sDisplay is called by paint !). + * The derived-class (Your Subclass) will redefine this, to draw it's own... + * + * BE SURE, if you want to call 'display' by yourself + * (e.g. in the run method for animation) + * YOU HAVE TO CALL sDisplay ! + * + * 'sDisplay' manages a semaphore to avoid reentrance of + * the display function !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + * + * @return void + * + * @see GLPanel#sDisplay + * @see GLPanel#paint + */ + public void display() + { + } + + /** + * + * This is your pre-init method. + * preInit is called just BEFORE the GL-Context is created. + * You should override preInit, to initialize your visual-stuff, + * like the protected vars: doubleBuffer and stereoView + * + * @return void + * + * @see GLPanel#paint + * @see GLPanel#doubleBuffer + * @see GLPanel#stereoView + * @see GLPanel#rgba + * @see GLPanel#stencilBits + */ + public void preInit() + { + } + + /** + * + * This is your init method. + * init is called right after the GL-Context is initialized. + * You should override init, to initialize your stuff needed + * by OpenGL an Java ! + * + * @return void + * + * @see GLPanel#paint + */ + public void init() + { + } + + /** + * This method is used to clean up any OpenGL stuff (delete textures + * or whatever) prior to actually deleting the OpenGL context. + * You should override this with your own version, if you need to do + * any cleanup work at this phase. + * This functions is called within cvsDispose + * + * @return void + * + * @see GLPanel#cvsDispose + */ + public void doCleanup() + { + } + + /** + * This function returns, if everything is init: the GLContext, + * the and the users init function + * This value is set in the paint method! + * + * @return boolean + * + * @see GLPanel#paint + * @see GLPanel#init + */ + public boolean cvsIsInit() + { + return cvsInitialized; + } + + protected long _f_dur_self = 0; + protected long _f_dur_total = 0; + + /** + * + * This is the reshape-method called by paint. + * The derived-class (Your Subclass) will redefine this, + * to manage your individual reshape ... + * + * This �reshape� method will be invoked after the first paint command + * after GLPanel.componentResize is called AND only if �gljUse� was + * succesfull (so a call of gljUse is redundant). + * �reshape� is not an overloading of java.awt.Component.reshape, + * �reshape� is more like �glut�-reshape. + * + * GLPanel.reshape allready has a simple default implementation, + * which calls �gljResize� and �glViewport� - so you may be can + * left this one as it is (no need to overload). + * The needed call to �gljResize� is done by hte invoker paint ! + * + * @param width the new width + * @param height the new height + * @return void + * + * @see GLPanel#paint + * @see GLPanel#sDisplay + */ + public void reshape( int width, int height ) + { + if(GLContext.gljClassDebug) + System.out.println("GLPanel::reshape bounds("+getBounds()+")"); + gl.glViewport(0,0, width, height); + gl.glMatrixMode(GL_PROJECTION); + gl.glLoadIdentity(); + gl.glOrtho(0, width, height, 0, -50.0,50.0); + gl.glMatrixMode(GL_MODELVIEW); + } + + /* JAU */ + /* + public final void setBounds(int x, int y, int width, int height) { + reshape(x, y, width, height); + } + public final void setBounds(Rectangle r) { + reshape(r.x, r.y, r.width, r.height); + } + + public void reshape(int x, int y, int width, int height) { + super.reshape(x, y, width, height); + if(glj==null || !glj.gljIsInit() || !glj.gljMakeCurrent()) + { + System.out.println("GLPanel::setBounds(): problem in use() method"); + return; + } + reshape(width-x, height-y); + glj.gljCheckGL(); + glj.gljFree(); + size = new Dimension(width-x, height-y); + } + */ + + + /** + * + * �componentResized� is the componentListeners event handler. + * + * This method sets the variable �mustResize� to true, + * so the upcoming �paint� method-call will invoke �reshape� ! + * + * This little look-alike complicating thing is done, + * to avoid an Exception by using the glContext from more than + * one concurrent thread�s ! + * + * You cannot override this implementation, it is final + * - override �reshape' instead ! + * + * @param e the element, which is resized + * @return void + * + * @see GLPanel#paint + * @see GLPanel#reshape + */ + public void componentResized(ComponentEvent e) + { + if(GLContext.gljClassDebug) + System.out.println("GLPanel::componentResized("+e.getComponent()+")"); + if(glj!=null && glj.gljIsInit() && e.getComponent()==this ) + { + mustResize = true; + //repaint(); + } + } + + public void componentMoved(ComponentEvent e) + { + if(GLContext.gljClassDebug) + System.out.print("GLPanel::componentMoved("+e.getComponent()+")"); + /* + if(e.getComponent().equals(topLevelWindow)) + { + repaint(); + } + */ + } + + public void componentShown(ComponentEvent e) + { + if(GLContext.gljClassDebug) + System.out.print("GLPanel::componentShown("+e.getComponent()+")"); + } + + public void componentHidden(ComponentEvent e) + { + if(GLContext.gljClassDebug) + System.out.print("GLPanel::componentHidden("+e.getComponent()+")"); + } + + public void mouseClicked(MouseEvent e) + { + if(GLContext.gljClassDebug) + System.out.print("."); + } + public void mouseEntered(MouseEvent e) + { + if(GLContext.gljClassDebug) + System.out.print("GLPanel::mouseEntered("+e.getComponent()+")"); + /* + if(e.getComponent().equals(topLevelWindow)) + { + repaint(); + } + */ + } + public void mouseExited(MouseEvent e) + {} + public void mousePressed(MouseEvent e) + { + if(GLContext.gljClassDebug) + System.out.print("<"); + } + public void mouseReleased(MouseEvent e) + { + if(GLContext.gljClassDebug) + System.out.print(">"); + } + + public void windowOpened(WindowEvent e) + { + } + + /** + * + * �windowClosing� is the windowListeners event handler + * for the topLevelWindow of this Canvas ! + * + * This methods free�s AND destroy�s + * the GL Context with �glj.gljDestroy� ! + * + * @return void + * + */ + public void windowClosing(WindowEvent e) + { + if(e.getComponent().equals(topLevelWindow)) + { + cvsDispose(); + } + } + + /** + * + * �windowClosed� is the windowListeners event handler. + * + * @return void + * + */ + public void windowClosed(WindowEvent e) + { + if (needCvsDispose) cvsDispose(); + } + + public void windowIconified(WindowEvent e) + { + } + + public void windowDeiconified(WindowEvent e) + { + } + + public void windowActivated(WindowEvent e) + { + } + + public void windowDeactivated(WindowEvent e) + { + } + + /** + * You should call this before releasing/dispose this Window ! + * Also you can overwrite this class, + * to dispose your own elements, e.g. a Frame etc. - + * but be shure that you call + * cvsDispose implementation call this one ! + * + * This function calls gljDestroy of GLContext ! + * + * @see gl4java.GLContext#gljDestroy + * @see GLPanel#doCleanup + */ + public void cvsDispose() + { + cvsInitialized = false; + if (glj != null) + { + if (glj.gljIsInit()) + { + /* Sometimes the Microsoft VM calls the + Applet.stop() method but doesn't have + permissions to do J/Direct calls, so + this whole block of code will throw a + security exception. If this happens, + however, windowClosing() will still + call us again later and we will have + another opportunity to shut down the + context, so it all works out fine. */ + try + { + glj.gljFree(); + doCleanup(); + //locks and free's GLContext + glj.setEnabled(false); + glj.gljDestroy(); + needCvsDispose = false; + } + catch (Exception ex) + { + needCvsDispose = true; + } + } + } + + // Setting glj to null will simply cause paint() to re-initialize. + // We don't want that to happen, so we will leave glj non-null. + } + + /** + * get methods + */ + public final int cvsGetWidth() { + return getSize().width; + } + public final int cvsGetHeight() { + return getSize().height; + } +} + diff --git a/demos/SwingDemos/test/GLPanel-GLGraphics/test1.java b/demos/SwingDemos/test/GLPanel-GLGraphics/test1.java new file mode 100644 index 0000000..1b8bf4b --- /dev/null +++ b/demos/SwingDemos/test/GLPanel-GLGraphics/test1.java @@ -0,0 +1,129 @@ +import java.applet.*; +import java.awt.*; +import java.awt.event.*; +import java.awt.Dimension; +import javax.swing.*; +import gl4java.*; +import gl4java.swing.*; +import gl4java.utils.glut.*; +import gl4java.utils.glut.fonts.*; + +public class test1 extends JApplet + implements GLEnum, GLUEnum +{ + static { + if(GLContext.loadNativeLibraries(null, null, null)==false) + System.out.println("GLCanvas could not load def. native libs."); + } + + protected class test1Panel extends GLPanel + implements ActionListener, ItemListener + { + public test1Panel() { + super(); + GLContext.gljNativeDebug = true; + GLContext.gljClassDebug = true; + //String[] data = {"one", "two", "three", "four"}; + //JList dataList = new JList(data); + //add("North", dataList); + JButton b1, b2; + add("East", (b1 = new JButton("E"))); + b1.setActionCommand("east"); + b1.addActionListener(this); + add("West", (b2 = new JButton("W"))); + b2.setActionCommand("west"); + b2.addActionListener(this); + + JCheckBox c1; + add("South", (c1 = new JCheckBox("SouthButton", true))); + c1.addItemListener(this); + } + + GLGraphics glg = null; + + public void init() { + System.out.println("<i>"); + //glg = new GLGraphics(gl, glu); + reshape(getSize().width, getSize().height); + } + + public void display() + { + System.out.println("<p>"); + + int i; + + glg = (GLGraphics)getGraphics(); + + gl.glPushMatrix(); + gl.glClear(GL_COLOR_BUFFER_BIT); + + glg.setColor(Color.blue); + + int width=getSize().width; + int height=getSize().height; + + glg.drawLine ( 0, height/2, width, height/2 ); + glg.drawLine ( width/2, 0, width/2, height ); + + glg.setColor(Color.yellow); + + glg.drawLine ( 0, 0, width, height); + glg.drawString("Left-top", 0, 10); + glg.drawString("GLGraphics - CENTER", width/2, height/2); + glg.drawString("Right - Bottom (nearly)", width*2/3, height*2/3); + gl.glPopMatrix(); + + glj.gljCheckGL(); + } + + public void reshape(int width, int height) + { + System.out.println("reshape("+width+", "+height+")"); + super.reshape(width, height); + } + + public void actionPerformed(ActionEvent e) { + if (e.getActionCommand().equals("east")) { + System.out.println("East pressed"); + } else if (e.getActionCommand().equals("west")) { + System.out.println("West pressed"); + } + } + + public void itemStateChanged(ItemEvent e) { + Object source = e.getItemSelectable(); + System.out.println("item changed: "+source); + } + + } + + test1Panel tst1cvs1; + + public void init() + { + tst1cvs1 = new test1Panel(); + tst1cvs1.setSize(400,400); + setContentPane(tst1cvs1); + } + + public static void main(java.lang.String[] args) { + try { + Frame mainFrame = new Frame("test1"); + + test1 applet=new test1(); + + applet.setSize(400, 400); + applet.init(); + applet.start(); + + mainFrame.add(applet); + + mainFrame.pack(); + mainFrame.setVisible(true); + } catch (Throwable exception) { + System.err.println("Exception occurred in main()"); + exception.printStackTrace(System.out); + } + } +} diff --git a/demos/change2GL4JavaV2.sh b/demos/change2GL4JavaV2.sh new file mode 100755 index 0000000..7998edb --- /dev/null +++ b/demos/change2GL4JavaV2.sh @@ -0,0 +1,23 @@ +#! /bin/sh + +if [ -z $1 -a -z $2 ] ; then + echo usage: $0 input-file output-file + exit 0 +fi +sed -e 's/gljGetFpsCounter/cvsGetFpsCounter/g' \ + -e 's/gljResetFpsCounter/cvsResetFpsCounter/g' \ + -e 's/gljGetWidth/cvsGetWidth/g' \ + -e 's/gljGetHeight/cvsGetHeight/g' \ + -e 's/gljDispose/cvsDispose/g' \ + -e 's/gljUse()/gljMakeCurrent(true)/g' \ + -e 's/glj/glj.glj/g' \ + -e 's/gl[^a-z]/gl.&\1/g' \ + -e 's/glut/glut.&\1/g' \ + -e 's/glu/glu.&\1/g' \ + -e 's/GLCanvasV2.gl.glClassDebug/GLContext.gljClassDebug/g' \ + -e 's/GLCanvasV2.gl.glNativeDebug/GLContext.gljNativeDebug/g' \ + -e 's/gl.glClassDebug/GLContext.gljClassDebug/g' \ + -e 's/gl.glNativeDebug/GLContext.gljNativeDebug/g' \ + -e 's/import GL4Java/import gl4java.awt/g' \ + -e 's/GL4Java/gl4java/g' \ + $1 > $2 diff --git a/demos/demoCvs.java b/demos/demoCvs.java new file mode 100644 index 0000000..79b5c73 --- /dev/null +++ b/demos/demoCvs.java @@ -0,0 +1,57 @@ +/** + * @(#) demoCvs.java + */ + +import gl4java.GLContext; +import gl4java.awt.GLCanvas; +import java.awt.*; +import java.awt.event.*; +import java.lang.Math; + + +class demoCvs extends GLCanvas +{ +/** + * Instead of using suspend (JAVA2) + * + * @see run + */ + protected boolean threadSuspended = true; + + public demoCvs (int w, int h, + String glClass, String gluClass ) + { + super(w, h, glClass, gluClass ); + } + + public void preInit() + { + doubleBuffer = true; + stereoView = true; + } + + public void init() + { + } + + + public void display() + { + /* Standard GL4Java Init */ + if( glj.gljMakeCurrent() == false ) + { + System.out.println("problem in use() method"); + return; + } + + glj.gljSwap(); + glj.gljCheckGL(); + glj.gljFree(); + } + + public void ReInit() + { + } + +} + diff --git a/demos/demoCvsAnim.java b/demos/demoCvsAnim.java new file mode 100644 index 0000000..3dcc689 --- /dev/null +++ b/demos/demoCvsAnim.java @@ -0,0 +1,57 @@ +/** + * @(#) demoCvsAnim.java + */ + +import gl4java.GLContext; +import gl4java.awt.GLAnimCanvas; +import java.awt.*; +import java.awt.event.*; +import java.lang.Math; + + +class demoCvsAnim extends GLAnimCanvas +{ +/** + * Instead of using suspend (JAVA2) + * + * @see run + */ + protected boolean threadSuspended = true; + + public demoCvsAnim (int w, int h, + String glClass, String gluClass ) + { + super(w, h, glClass, gluClass ); + } + + public void preInit() + { + doubleBuffer = true; + stereoView = true; + } + + public void init() + { + } + + + public void display() + { + /* Standard GL4Java Init */ + if( glj.gljMakeCurrent() == false ) + { + System.out.println("problem in use() method"); + return; + } + + glj.gljSwap(); + glj.gljCheckGL(); + glj.gljFree(); + } + + public void ReInit() + { + } + +} + diff --git a/demos/gl4java.policy b/demos/gl4java.policy new file mode 100644 index 0000000..0db24dc --- /dev/null +++ b/demos/gl4java.policy @@ -0,0 +1,60 @@ +//
+// GL4Java extensions get all permissions !
+//
+// This peace should be added on top of the file:
+//
+// If a Java2 SDK is used:
+// <java2-installation>/jre/lib/security/java.policy
+//
+// If a Java2 JRE is used:
+// <jre-installation>/lib/security/java.policy
+//
+// GL4Java Homepage:
+//
+// http://www.jausoft.com/gl4java/
+//
+
+grant codeBase "http://www.jausoft.com/Files/Java/1.1.X/GL4Java/Installer/*"
+{
+ permission java.security.AllPermission;
+};
+
+grant codeBase "http://www.jausoft.com/Files/Java/1.1.X/GL4Java/demos/*"
+{
+ permission java.security.AllPermission;
+};
+
+grant codeBase "http://www.jausoft.com/Files/Java/1.1.X/GL4Java/demos/MiscDemos/*
+{
+ permission java.security.AllPermission;
+};
+
+grant codeBase "http://www.jausoft.com/Files/Java/1.1.X/GL4Java/demos/RonsDemos/*
+{
+ permission java.security.AllPermission;
+};
+
+grant codeBase "http://www.jausoft.com/Files/Java/1.1.X/GL4Java/demos/SwingDemos/*
+{
+ permission java.security.AllPermission;
+};
+
+grant codeBase "http://www.jausoft.com/Files/Java/1.1.X/GL4Java/demos/GLLandScape/*
+{
+ permission java.security.AllPermission;
+};
+
+grant codeBase "http://www.jausoft.com/Files/Java/1.1.X/GL4Java/demos/HodglimsNeHe/*
+{
+ permission java.security.AllPermission;
+};
+
+
+grant codeBase "file:/home/sven/projects/java/GL4Java/demos/- {
+ permission java.security.AllPermission;
+};
+
+grant codeBase "file:/home/sven/projects/java/GL4Java/demos/RonsDemos/- {
+ permission java.security.AllPermission;
+};
+
diff --git a/demos/glDemosCvs.html b/demos/glDemosCvs.html new file mode 100644 index 0000000..535e9da --- /dev/null +++ b/demos/glDemosCvs.html @@ -0,0 +1,14 @@ +<HTML>
+<HEAD>
+<TITLE>Göthel Hard- und Software Entwicklungen</TITLE>
+</HEAD>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+<hr>
+<applet code="glDemosCvs.class" width=500 height=550>
+<param name=frames value="55">
+</applet>
+<hr>
+</BODY>
+</HTML>
+
+
diff --git a/demos/glDemosCvs.java b/demos/glDemosCvs.java new file mode 100644 index 0000000..6902b95 --- /dev/null +++ b/demos/glDemosCvs.java @@ -0,0 +1,620 @@ + +import gl4java.GLContext; +import gl4java.awt.GLAnimCanvas; +import java.awt.*; +import java.awt.event.*; +import java.applet.*; + +public class glDemosCvs extends Applet + implements MouseListener, WindowListener, ActionListener, ItemListener +{ + /* + * show how independent the + * canvas and the frame are :-) + * + * the canvas size is toggled from: (150,150)->(250,250) + * the frame size is toggled from: (350,350)->(450,450) + * + */ + + Button ButtonFps; + TextField TextFpsOlymp; + TextField TextFpsLogo; + TextField TextFpsWave; + TextField TextFpsStar; + + Button buttonInfo = null; + + Checkbox bUseRepaintW = null; + Checkbox bUseFpsSleepW = null; + Button bReStartW = null; + Checkbox bUseRepaintO = null; + Checkbox bUseFpsSleepO = null; + Button bReStartO = null; + Checkbox bUseRepaintL = null; + Checkbox bUseFpsSleepL = null; + Button bReStartL = null; + Checkbox bUseRepaintS = null; + Checkbox bUseFpsSleepS = null; + Button bReStartS = null; + + String glClass=null; + String gluClass=null; + + olympicCvs cvsOlympic = null; + waveCvs cvsWave = null; + glLogoCvs cvsLogo = null; + starCvs cvsStar = null; + + Frame frame = null; + + public void applicationInit(Frame holder) + { + frame = holder; + + init(); + start(); + } + + public void init() + { + System.out.println("Applet init ..."); + + Panel pTmp = null; + + setLayout(new BorderLayout()); + + // 1. GetFps + ButtonFps=new Button("Get Fps"); + ButtonFps.addMouseListener(this); + add("North", ButtonFps); + + // 4. Info + buttonInfo=new Button("Info"); + buttonInfo.addMouseListener(this); + add("South", buttonInfo); + + // Master-Grid-Panel pAllCvs + // + // 2 rows + // 1. Wave + // 2. Olympic + // 3. Logo + // 4. Star + // + Panel pAllCvs = new Panel(); + pAllCvs.setLayout(new GridLayout(4,1)); + add("Center", pAllCvs); + + // 1. Wave + Panel pWave = new Panel(); + pWave.setLayout(new GridLayout(1,2)); + pAllCvs.add(pWave); + + // 2. Olympic + Panel pOlympic = new Panel(); + pOlympic.setLayout(new GridLayout(1,2)); + pAllCvs.add(pOlympic); + + // 3. Logo + Panel pLogo = new Panel(); + pLogo.setLayout(new GridLayout(1,2)); + pAllCvs.add(pLogo); + + // 3. Star + Panel pStar = new Panel(); + pStar.setLayout(new GridLayout(1,2)); + pAllCvs.add(pStar); + + // Wave-Grid-Panel pWave + // + // 3 coloumns + // + // 1. waveCvs + // 2. options + // + + // 1. waveCvs + cvsWave = new waveCvs(150, 150, glClass, gluClass); + pWave.add(cvsWave); + cvsWave.addMouseListener(this); + + // 2. options + Panel pWaveOpt = new Panel(); + pWaveOpt.setLayout(new GridLayout(4,1)); + pWave.add(pWaveOpt); + bUseRepaintW = new Checkbox("repaint", true); + bUseRepaintW.addItemListener(this); + pWaveOpt.add(bUseRepaintW); + bUseFpsSleepW = new Checkbox("fps-sleep", true); + bUseFpsSleepW.addItemListener(this); + pWaveOpt.add(bUseFpsSleepW); + pTmp = new Panel(); + pTmp.setLayout(new GridLayout(1,2)); + pTmp.add(new Label("fps: ")); + TextFpsWave=new TextField(); + TextFpsWave.addActionListener(this); + pTmp.add(TextFpsWave); + pWaveOpt.add(pTmp); + bReStartW = new Button("restart"); + bReStartW.addMouseListener(this); + pWaveOpt.add(bReStartW); + + // Olympic-Grid-Panel pOlympic + // + // 3 coloumns + // + // 1. olympicCvs + // 2. options + // + + // 1. olympicCvs + cvsOlympic = new olympicCvs(150, 150, glClass, gluClass); + pOlympic.add(cvsOlympic); + cvsOlympic.addMouseListener(this); + + // 2. options + Panel pOlympOpt = new Panel(); + pOlympOpt.setLayout(new GridLayout(4,1)); + pOlympic.add(pOlympOpt); + bUseRepaintO = new Checkbox("repaint", true); + bUseRepaintO.addItemListener(this); + pOlympOpt.add(bUseRepaintO); + bUseFpsSleepO = new Checkbox("fps-sleep", true); + bUseFpsSleepO.addItemListener(this); + pOlympOpt.add(bUseFpsSleepO); + pTmp = new Panel(); + pTmp.setLayout(new GridLayout(1,2)); + pTmp.add(new Label("fps: ")); + TextFpsOlymp=new TextField(); + TextFpsOlymp.addActionListener(this); + pTmp.add(TextFpsOlymp); + pOlympOpt.add(pTmp); + bReStartO = new Button("restart"); + bReStartO.addMouseListener(this); + pOlympOpt.add(bReStartO); + + + // Logo-Grid-Panel pLogo + // + // 3 coloumns + // + // 1. logoCvs + // 2. options + // + + // 1. logoCvs + cvsLogo = new glLogoCvs(150, 150, glClass, gluClass); + pLogo.add(cvsLogo); + cvsLogo.addMouseListener(this); + + // 2. options + Panel pLogoOpt = new Panel(); + pLogoOpt.setLayout(new GridLayout(4,1)); + pLogo.add(pLogoOpt); + bUseRepaintL = new Checkbox("repaint", true); + bUseRepaintL.addItemListener(this); + pLogoOpt.add(bUseRepaintL); + bUseFpsSleepL = new Checkbox("fps-sleep", true); + bUseFpsSleepL.addItemListener(this); + pLogoOpt.add(bUseFpsSleepL); + pTmp = new Panel(); + pTmp.setLayout(new GridLayout(1,2)); + pTmp.add(new Label("fps: ")); + TextFpsLogo=new TextField(); + TextFpsLogo.addActionListener(this); + pTmp.add(TextFpsLogo); + pLogoOpt.add(pTmp); + bReStartL = new Button("ReStart"); + bReStartL.addMouseListener(this); + pLogoOpt.add(bReStartL); + + // Star-Grid-Panel pWave + // + // 3 coloumns + // + // 1. starCvs + // 2. options + // + + // 1. starCvs + cvsStar = new starCvs(150, 150, glClass, gluClass); + pStar.add(cvsStar); + cvsStar.addMouseListener(this); + + // 2. options + Panel pStarOpt = new Panel(); + pStarOpt.setLayout(new GridLayout(4,1)); + pStar.add(pStarOpt); + bUseRepaintS = new Checkbox("repaint", true); + bUseRepaintS.addItemListener(this); + pStarOpt.add(bUseRepaintS); + bUseFpsSleepS = new Checkbox("fps-sleep", true); + bUseFpsSleepS.addItemListener(this); + pStarOpt.add(bUseFpsSleepS); + pTmp = new Panel(); + pTmp.setLayout(new GridLayout(1,2)); + pTmp.add(new Label("fps: ")); + TextFpsStar=new TextField(); + TextFpsStar.addActionListener(this); + pTmp.add(TextFpsStar); + pStarOpt.add(pTmp); + bReStartS = new Button("restart"); + bReStartS.addMouseListener(this); + pStarOpt.add(bReStartS); + + System.out.println("Applet init DONE ! "); + } + + public void start() { + cvsOlympic.start(); + cvsWave.start(); + cvsLogo.start(); + cvsStar.start(); + } + + public void stop() { + cvsOlympic.stop(); + cvsWave.stop(); + cvsLogo.stop(); + cvsStar.stop(); + } + + public void destroy() { + cvsOlympic.stop(); + cvsOlympic.cvsDispose(); + cvsWave.stop(); + cvsWave.cvsDispose(); + cvsLogo.stop(); + cvsLogo.cvsDispose(); + cvsStar.stop(); + cvsStar.cvsDispose(); + } + + public static void main( String args[] ) { + String gljLib=null; + String glLib=null; + String gluLib=null; + + if(args.length>0) + gljLib = args[0]; + if(args.length>1) + glLib = args[1]; + if(args.length>2) + gluLib = args[2]; + + GLContext.gljNativeDebug = true; + GLContext.gljClassDebug = true; + + if(GLContext.loadNativeLibraries(gljLib, glLib, gluLib)==false) + System.out.println("could not load native libs:"+ + gljLib + ", " + glLib + ", " + gluLib); + else + System.out.println("load native libs:"+ + gljLib + ", " + glLib + ", " + gluLib); + + Frame mainFrame = new Frame("glDemosCvs"); + + glDemosCvs applet = new glDemosCvs(); + applet.applicationInit(mainFrame); + + mainFrame.add(applet); + + if(args.length>3) + applet.glClass = args[3]; + if(args.length>4) + applet.gluClass = args[4]; + + mainFrame.pack(); + mainFrame.setVisible(true); + + mainFrame.addWindowListener(applet); + } + + // Methods required for the implementation of MouseListener + public void mouseEntered( MouseEvent evt ) + { + } + + public void mouseExited( MouseEvent evt ) + { + } + + public void mousePressed( MouseEvent evt ) + { + } + + public void mouseReleased( MouseEvent evt ) + { + } + + public void mouseClicked( MouseEvent evt ) + { + Component comp = evt.getComponent(); + + if( comp.equals(ButtonFps) ) + { + double fps = 0; + int a1; + + if(cvsWave!=null && TextFpsWave!=null) + { + cvsWave.stopFpsCounter(); + fps=cvsWave.getFps(); + a1=(int)(fps*100.0); + fps=(double)a1/100.0; + TextFpsWave.setText(String.valueOf(fps)); + } + if(cvsOlympic!=null && TextFpsOlymp!=null) + { + cvsOlympic.stopFpsCounter(); + fps=cvsOlympic.getFps(); + a1=(int)(fps*100.0); + fps=(double)a1/100.0; + TextFpsOlymp.setText(String.valueOf(fps)); + } + if(cvsLogo!=null && TextFpsLogo!=null) + { + cvsLogo.stopFpsCounter(); + fps=cvsLogo.getFps(); + a1=(int)(fps*100.0); + fps=(double)a1/100.0; + TextFpsLogo.setText(String.valueOf(fps)); + } + if(cvsStar!=null && TextFpsStar!=null) + { + cvsStar.stopFpsCounter(); + fps=cvsStar.getFps(); + a1=(int)(fps*100.0); + fps=(double)a1/100.0; + TextFpsStar.setText(String.valueOf(fps)); + } + } + else if( comp.equals(buttonInfo) ) + { + Frame fInfo = null; + if(cvsWave!=null && cvsWave.getGLContext()!=null) + fInfo = cvsWave.getGLContext().gljShowVersions(); + else if(cvsOlympic!=null && cvsOlympic.getGLContext()!=null) + fInfo = cvsOlympic.getGLContext().gljShowVersions(); + else if(cvsLogo!=null && cvsLogo.getGLContext()!=null) + fInfo = cvsLogo.getGLContext().gljShowVersions(); + else if(cvsStar!=null && cvsStar.getGLContext()!=null) + fInfo = cvsStar.getGLContext().gljShowVersions(); + } + else if( comp.equals(cvsWave) ) + { + cvsWave.setSuspended(!cvsWave.isSuspended(), + evt.getClickCount()>1 // -> ReInit + ); + } + else if( comp.equals(cvsOlympic) ) + { + cvsOlympic.setSuspended(!cvsOlympic.isSuspended(), + evt.getClickCount()>1 // -> ReInit + ); + } + else if( comp.equals(cvsLogo) ) + { + cvsLogo.setSuspended(!cvsLogo.isSuspended(), + evt.getClickCount()>1 // -> ReInit + ); + } + else if( comp.equals(cvsStar) ) + { + cvsStar.setSuspended(!cvsStar.isSuspended(), + evt.getClickCount()>1 // -> ReInit + ); + } + if( comp.equals(bReStartL) ) + { + if(cvsLogo!=null) + { + cvsLogo.setSuspended(false, true); + } + } + if( comp.equals(bReStartO) ) + { + if(cvsOlympic!=null) + { + cvsOlympic.setSuspended(false, true); + } + } + if( comp.equals(bReStartW) ) + { + if(cvsWave!=null) + { + cvsWave.setSuspended(false, true); + } + } + if( comp.equals(bReStartS) ) + { + if(cvsStar!=null) + { + cvsStar.setSuspended(false, true); + } + } + } + + public void itemStateChanged( ItemEvent evt ) + { + ItemSelectable comp = evt.getItemSelectable(); + + if( comp.equals(bUseRepaintW ) ) + { + if(cvsWave!=null) + { + cvsWave.setUseRepaint(bUseRepaintW.getState()); + System.out.println("Wave uses repaint: "+ + bUseRepaintW.getState()); + } + } + if( comp.equals(bUseFpsSleepW ) ) + { + if(cvsWave!=null) + { + cvsWave.setUseFpsSleep(bUseFpsSleepW.getState()); + System.out.println("Wave uses fps-sleep: "+ + bUseFpsSleepW.getState()); + } + } + if( comp.equals(bUseRepaintO ) ) + { + if(cvsOlympic!=null) + { + cvsOlympic.setUseRepaint(bUseRepaintO.getState()); + System.out.println("Olympic uses repaint: "+ + bUseRepaintO.getState()); + } + } + if( comp.equals(bUseFpsSleepO ) ) + { + if(cvsOlympic!=null) + { + cvsOlympic.setUseFpsSleep(bUseFpsSleepO.getState()); + System.out.println("Olympic uses fps-sleep: "+ + bUseFpsSleepO.getState()); + } + } + else if( comp.equals(bUseRepaintL ) ) + { + if(cvsLogo!=null) + { + cvsLogo.setUseRepaint(bUseRepaintL.getState()); + System.out.println("Logo uses repaint: "+ + bUseRepaintL.getState()); + } + } + else if( comp.equals(bUseFpsSleepL ) ) + { + if(cvsLogo!=null) + { + cvsLogo.setUseFpsSleep(bUseFpsSleepL.getState()); + System.out.println("Logo uses fps-sleep: "+ + bUseFpsSleepL.getState()); + } + } + else if( comp.equals(bUseRepaintS ) ) + { + if(cvsStar!=null) + { + cvsStar.setUseRepaint(bUseRepaintS.getState()); + System.out.println("Star uses repaint: "+ + bUseRepaintS.getState()); + } + } + else if( comp.equals(bUseFpsSleepS ) ) + { + if(cvsStar!=null) + { + cvsStar.setUseFpsSleep(bUseFpsSleepS.getState()); + System.out.println("Star uses fps-sleep: "+ + bUseFpsSleepS.getState()); + } + } + } + + public void windowOpened(WindowEvent e) + { + } + + public void windowClosing(WindowEvent e) + { + if(frame!=null && e.getComponent().equals(frame)) + { + if(frame!=null) frame.dispose(); + cvsLogo.cvsDispose(); + cvsOlympic.cvsDispose(); + cvsWave.cvsDispose(); + cvsStar.cvsDispose(); + System.exit(0); + } + } + + public void windowClosed(WindowEvent e) + { + } + + public void windowIconified(WindowEvent e) + { + } + + public void windowDeiconified(WindowEvent e) + { + } + + public void windowActivated(WindowEvent e) + { + } + + public void windowDeactivated(WindowEvent e) + { + } + + public void actionPerformed(ActionEvent event) + { + Object source = event.getSource(); + + if ( source == TextFpsWave ) + { + try { + double FramesPerSec= + Double.valueOf(TextFpsWave.getText()).doubleValue(); + if(cvsWave!=null) + { + cvsWave.setAnimateFps(FramesPerSec); + cvsWave.setSuspended(false, true); + } + } catch (NumberFormatException s) { + System.out.println("wrong fps format, use float .."); + } + + } + if ( source == TextFpsOlymp ) + { + try { + double FramesPerSec= + Double.valueOf(TextFpsOlymp.getText()).doubleValue(); + if(cvsOlympic!=null) + { + cvsOlympic.setAnimateFps(FramesPerSec); + cvsOlympic.setSuspended(false, true); + } + } catch (NumberFormatException s) { + System.out.println("wrong fps format, use float .."); + } + + } + if ( source == TextFpsLogo ) + { + try { + double FramesPerSec= + Double.valueOf(TextFpsLogo.getText()).doubleValue(); + if(cvsLogo!=null) + { + cvsLogo.setAnimateFps(FramesPerSec); + cvsLogo.setSuspended(false, true); + } + } catch (NumberFormatException s) { + System.out.println("wrong fps format, use float .."); + } + + } + if ( source == TextFpsStar ) + { + try { + double FramesPerSec= + Double.valueOf(TextFpsStar.getText()).doubleValue(); + if(cvsLogo!=null) + { + cvsStar.setAnimateFps(FramesPerSec); + cvsStar.setSuspended(false, true); + } + } catch (NumberFormatException s) { + System.out.println("wrong fps format, use float .."); + } + + } + } + +} diff --git a/demos/glLogoCvs.java b/demos/glLogoCvs.java new file mode 100644 index 0000000..e287406 --- /dev/null +++ b/demos/glLogoCvs.java @@ -0,0 +1,765 @@ +/** + * @(#) dummyGLCvs.java + */ + +import gl4java.awt.GLAnimCanvas; +import java.awt.*; +import java.awt.event.*; +import java.lang.Math; + +class glLogoCvs extends GLAnimCanvas +{ + + static final int RAND_MAX = 100; + + /* some math.h's don't define M_PI */ + static final float M_PI = 3.14159265359f; + + static final int ACC = 8; + static final int ACC2 = 16; + static final int ACC3 = 48; + static final int ACC4 = 24; + static final float THLD = 0.6f; + static final float THLD2 = 0.8f; + + int angle, rotating; + + float TRANS[][]; + float ROTAXIS[][]; + float ROT[]; + + float char_El[][][]; + float normal_El[][][]; + + float char_O[][][]; + float normal_O[][][]; + + float char_P[][][]; + float normal_P[][][]; + + float char_G[][][]; + float normal_G[][][]; + + float accSIN[], accCOS[]; + + float difmat4[] = { 0.425f, 0.570f, 0.664f, 1.0f }; + float difamb4[] = { 0.425f, 0.570f, 0.664f, 1.0f }; + float matspec4[] = { 0.174f, 0.174f, 0.174f, 1.0f }; + + float lightpos[] = { 1.0f, 1.0f, 1.0f, 0.0f }; + float lightamb[] = { 0.3f, 0.3f, 0.3f, 1.0f }; + float lightdif[] = { 0.8f, 0.8f, 0.8f, 1.0f }; + float speed=0f, progress = 1f; + + public glLogoCvs (int w, int h, + String glClass, String gluClass ) + { + super(w, h, glClass, gluClass ); + } + + public void init() + { + /* here we should add and initialize our JAVA components */ + TRANS = new float[7][3]; + ROTAXIS = new float[7][3]; + ROT = new float[7]; + + char_El=new float[ACC3+1][ACC+1][3]; + normal_El=new float[ACC3+1][ACC+1][3]; + + char_O=new float[ACC4][ACC+1][3]; + normal_O=new float[ACC4][ACC+1][3]; + + char_P=new float[ACC2][ACC+1][3]; + normal_P=new float[ACC2][ACC+1][3]; + + char_G=new float[ACC4][ACC+1][3]; + normal_G=new float[ACC4][ACC+1][3]; + + accSIN=new float[ACC+1]; + accCOS=new float[ACC+1]; + + randomize(); + + gl.glShadeModel (GL_SMOOTH); + gl.glEnable(GL_DEPTH_TEST); + gl.glLightfv(GL_LIGHT0, GL_POSITION, lightpos); + gl.glLightfv(GL_LIGHT0, GL_AMBIENT, lightamb); + gl.glLightfv(GL_LIGHT0, GL_DIFFUSE, lightdif); + gl.glEnable(GL_LIGHTING); + gl.glEnable(GL_LIGHT0); + gl.glColor3f(1.0f, 1.0f, 1.0f); + gl.glClearColor(0.0f, 0.0f, 0.0f, 1.0f); + gl.glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); + gl.glEnable(GL_NORMALIZE); + def_logo(); + gl.glCullFace(GL_BACK); + gl.glEnable(GL_CULL_FACE); + /* . and furthet OpenGL init's - like you want to */ + glj.gljCheckGL(); + } + + public void display() + { + int i; + + /* Standard GL4Java Init */ + if( glj.gljMakeCurrent() == false ) + { + System.out.println("problem in use() method"); + return; + } + + // just render it + gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + SetCamera(); + draw_logo(); + + /* For your animation dutys ;-) */ + glj.gljSwap(); + glj.gljCheckGL(); + glj.gljFree(); + animationCalc(); + } + + public void reshape(int width, int height) + { + gl.glMatrixMode (GL_MODELVIEW); + gl.glViewport (0, 0, width, height); + gl.glLoadIdentity(); + SetCamera(); + } + + + void SetCamera() + { + gl.glMatrixMode (GL_PROJECTION); + gl.glLoadIdentity (); + gl.glFrustum (-0.1333f, 0.1333f, -0.1f, 0.1f, 0.2f, 150.0f); + gl.glMatrixMode(GL_MODELVIEW); + gl.glLoadIdentity(); + glu.gluLookAt(0,1.5f,2, 0,1.5f,0, 0,1,0); + gl.glTranslatef(0.0f, -8.0f, -45.0f); + gl.glRotatef(-progress*720f, 0.0f, 1.0f, 0.0f); + } + + public void animationCalc() + { + // + // computation for an animation sequence ... + // + speed = -0.95f*speed + progress*0.05f; + if (progress > 0.0f && speed < 0.0003f) + speed = 0.0003f; + if (speed > 0.01f) + speed = 0.01f; + progress = progress - speed; + + // may be we just render a sequence, + // so we can set �shallWeRender� to false ... + if (progress <= 0.0005) + { + progress = 0.0f; + speed = 0; + shallWeRender=false; + } + } + + public void ReInit() + { + progress=1f; + randomize(); + } + + int rnd(int i) + { + return ( (int)((float)Math.random()*RAND_MAX) )%i; + } + + void groen_texture() + { + gl.glMaterialfv(GL_FRONT, GL_DIFFUSE, difmat4); + gl.glMaterialfv(GL_FRONT, GL_AMBIENT, difamb4); + gl.glMaterialfv(GL_FRONT, GL_SPECULAR, matspec4); + gl.glMaterialf(GL_FRONT, GL_SHININESS, 35.0f); + } + + void def_O() + { + float a, s, c, ln; + int i,j,k,l,m,n; + float dx, dy; + float dx1, dx2, dy1, dy2, dz1, dz2; + float center_O[][]; + float width_O[]; + + center_O=new float[ACC4+4][3]; + width_O=new float[ACC4+4]; + + for (i=0;i<ACC4;i++) + { + a = 2.0f*((float) i)*M_PI/ACC4; + s = 1+(float)Math.sin(a); + c = (float)Math.cos(a); + center_O[i][0] = c*3.8f; + center_O[i][1] = s*3.8f+(s<-1.01f?-0.8f:(s>1.01f?0.8f:0)) + 0.8f; + center_O[i][2] = 0.0f; + width_O[i] = 0.6f; + } + + /* I should be able to generalise this. oh well */ + for (i=0;i<ACC4;i++) + { + j = (i+1)%ACC4; + k = (i+ACC4-1)%ACC4; + for (a=0;a<ACC;a++) + { + c = (float)Math.cos(a*M_PI*2.0f/ACC); + s = (float)Math.sin(a*M_PI*2.0f/ACC); + dx = center_O[j][0] - center_O[k][0]; + dy = center_O[j][1] - center_O[k][1]; + ln = (float)Math.sqrt(dx*dx+dy*dy); + dx = dx/ln; + dy = dy/ln; + char_O[i][(int) a][0] = center_O[i][0] + width_O[i] * dy * c; + char_O[i][(int) a][1] = center_O[i][1] - width_O[i] * dx * c; + char_O[i][(int) a][2] = (s<-THLD?-THLD:(s>THLD?THLD:s)); + } + } + for (i=0;i<ACC;i++) + { + j = (i+1)%ACC; + k = (i-1+ACC)%ACC; + for (l=0;l<ACC4;l++) + { + m = (l+1)%ACC4; + n = (l+ACC4-1)%ACC4; + dx1 = char_O[m][i][0] - char_O[n][i][0]; + dy1 = char_O[m][i][1] - char_O[n][i][1]; + dz1 = char_O[m][i][2] - char_O[n][i][2]; + dx2 = char_O[l][k][0] - char_O[l][j][0]; + dy2 = char_O[l][k][1] - char_O[l][j][1]; + dz2 = char_O[l][k][2] - char_O[l][j][2]; + normal_O[l][i][0] = dy2*dz1 - dy1*dz2; + normal_O[l][i][1] = dz2*dx1 - dz1*dx2; + normal_O[l][i][2] = dx2*dy1 - dx1*dy2; + } + } + } + + void def_P() + { + float a, s, c, ln; + int i,j,k,l,m,n; + float dx, dy; + float dx1, dx2, dy1, dy2, dz1, dz2; + float center_P[][]; + float width_P[]; + + center_P=new float[ACC2][3]; + width_P=new float[ACC2]; + + + for (i=0;i<ACC2;i++) + { + a = 2.0f*((float) i)*M_PI/ACC2; + s = 1+(float)Math.sin(a); + c = (float)Math.cos(a); + center_P[i][0] = c*2.15f; + center_P[i][1] = s*2.1f + (s<-1.01f?-0.7f:(s>1.01f?0.7f:0)) + 0.7f; + center_P[i][2] = 0.0f; + width_P[i] = 0.5f; + } + + for (i=0;i<ACC2;i++) + { + j = (i+1)%ACC2; + k = (i+ACC2-1)%ACC2; + for (a=0;a<ACC;a++) + { + accCOS[(int) a] = c = (float)Math.cos(a*M_PI*2.0f/ACC); + accSIN[(int) a] = s = (float)Math.sin(a*M_PI*2.0f/ACC); + dx = center_P[j][0] - center_P[k][0]; + dy = center_P[j][1] - center_P[k][1]; + ln = (float)Math.sqrt(dx*dx+dy*dy); + dx = dx/ln; + dy = dy/ln; + char_P[i][(int) a][0] = center_P[i][0] + width_P[i] * dy * c; + char_P[i][(int) a][1] = center_P[i][1] - width_P[i] * dx * c; + char_P[i][(int) a][2] = (s<-THLD?-THLD:(s>THLD?THLD:s)); + } + } + for (i=0;i<ACC;i++) + { + j = (i+1)%ACC; + k = (i-1+ACC)%ACC; + for (l=0;l<ACC2;l++) + { + m = (l+1)%ACC2; + n = (l+ACC2-1)%ACC2; + dx1 = char_P[m][i][0] - char_P[n][i][0]; + dy1 = char_P[m][i][1] - char_P[n][i][1]; + dz1 = char_P[m][i][2] - char_P[n][i][2]; + dx2 = char_P[l][k][0] - char_P[l][j][0]; + dy2 = char_P[l][k][1] - char_P[l][j][1]; + dz2 = char_P[l][k][2] - char_P[l][j][2]; + normal_P[l][i][0] = dy2*dz1 - dy1*dz2; + normal_P[l][i][1] = dz2*dx1 - dz1*dx2; + normal_P[l][i][2] = dx2*dy1 - dx1*dy2; + } + } + } + + void def_El() + { + float a, s, c, ln; + int i,j,k,l,m,n; + float dx, dy; + float dx1, dx2, dy1, dy2, dz1, dz2; + float center_El[][]; + float width_El[]; + + center_El=new float[ACC3+3][3]; + width_El=new float[ACC3+3]; + + for (i=0;i<ACC3+1;i++) + { + /* a = (ACC3/24 + i*11/12)*M_PI*2.0f/ACC3; */ + a = (ACC3/8 + ((float) i)*3/4)*M_PI*2.0f/ACC3; + s = 1+(float)Math.sin(a); + c = (float)Math.cos(a); + center_El[i][0] = c*18.0f; + center_El[i][1] = s*9.3f; + center_El[i][2] = 0.0f; + width_El[i] = (float)Math.pow(3.5, Math.sin(i*M_PI/ACC3))-0.6f; + } + + for (i=0;i<ACC3+1;i++) + { + j = (i+1)%ACC3; + k = (i+ACC3-1)%ACC3; + for (a=0;a<ACC;a++) + { + c = (float)Math.cos(a*M_PI*2.0f/ACC); + s = (float)Math.sin(a*M_PI*2.0f/ACC); + dx = center_El[j][0] - center_El[k][0]; + dy = center_El[j][1] - center_El[k][1]; + ln = (float)Math.sqrt(dx*dx+dy*dy); + dx = dx/ln; + dy = dy/ln; + char_El[i][(int) a][0] = center_El[i][0] + width_El[i] * dy * c; + char_El[i][(int) a][1] = center_El[i][1] - width_El[i] * dx * c; + char_El[i][(int) a][2] = (s<-THLD2?-THLD2:(s>THLD2?THLD2:s)); + } + } + for (i=0;i<ACC+1;i++) + { + j = (i+1)%ACC; + k = (i-1+ACC)%ACC; + for (l=0;l<ACC3;l++) + { + m = (l+1)%ACC3; + n = (l+ACC3-1)%ACC3; + dx1 = char_El[m][i][0] - char_El[n][i][0]; + dy1 = char_El[m][i][1] - char_El[n][i][1]; + dz1 = char_El[m][i][2] - char_El[n][i][2]; + dx2 = char_El[l][k][0] - char_El[l][j][0]; + dy2 = char_El[l][k][1] - char_El[l][j][1]; + dz2 = char_El[l][k][2] - char_El[l][j][2]; + normal_El[l][i][0] = dy2*dz1 - dy1*dz2; + normal_El[l][i][1] = dz2*dx1 - dz1*dx2; + normal_El[l][i][2] = dx2*dy1 - dx1*dy2; + } + } + } + + void def_G() + { + float a, s, c, ln; + int i,j,k,l,m,n; + float dx, dy; + float dx1, dx2, dy1, dy2, dz1, dz2; + float center_G[][]; + float width_G[]; + + center_G=new float[ACC4][3]; + width_G=new float[ACC4]; + + for (i=0;i<ACC4;i++) + { + a = 2.0f*((float) i)*M_PI/ACC4; + s = 1+(float)Math.sin(a); + c = (float)Math.cos(a); + center_G[i][0] = c*3.8f; + center_G[i][1] = s*3.8f+(s<-1.01f?-0.8f:(s>1.01f?0.8f:0)) + 0.8f; + center_G[i][2] = 0.0f; + width_G[i] = 0.9f; + if (i>ACC4*3/4) + width_G[i] = 0.9f - ((i-ACC4*3/4)*0.9f)/ACC; + } + for (i=0;i<ACC4;i++) + { + j = (i+1)%ACC4; + k = (i+ACC4-1)%ACC4; + for (a=0;a<ACC;a++) + { + c = (float)Math.cos(a*M_PI*2.0f/ACC); + s = (float)Math.sin(a*M_PI*2.0f/ACC); + dx = center_G[j][0] - center_G[k][0]; + dy = center_G[j][1] - center_G[k][1]; + ln = (float)Math.sqrt(dx*dx+dy*dy); + dx = dx/ln; + dy = dy/ln; + char_G[i][(int) a][0] = center_G[i][0] + width_G[i] * dy * c; + char_G[i][(int) a][1] = center_G[i][1] - width_G[i] * dx * c; + char_G[i][(int) a][2] = (s<-THLD?-THLD:(s>THLD?THLD:s)); + } + } + for (i=0;i<ACC;i++) + { + j = (i+1)%ACC; + k = (i-1+ACC)%ACC; + for (l=0;l<ACC4;l++) + { + m = (l+1)%ACC4; + n = (l+ACC4-1)%ACC4; + dx1 = char_G[m][i][0] - char_G[n][i][0]; + dy1 = char_G[m][i][1] - char_G[n][i][1]; + dz1 = char_G[m][i][2] - char_G[n][i][2]; + dx2 = char_G[l][k][0] - char_G[l][j][0]; + dy2 = char_G[l][k][1] - char_G[l][j][1]; + dz2 = char_G[l][k][2] - char_G[l][j][2]; + normal_G[l][i][0] = dy2*dz1 - dy1*dz2; + normal_G[l][i][1] = dz2*dx1 - dz1*dx2; + normal_G[l][i][2] = dx2*dy1 - dx1*dy2; + } + } + } + + void randomize() + { + int i; + for (i=0;i<7;i++) + { + TRANS[i][0] = rnd(100)-rnd(100); + TRANS[i][1] = rnd(100)-rnd(100); + TRANS[i][1] = rnd(100)-rnd(100); + ROTAXIS[i][0] = rnd(100)-rnd(100); + ROTAXIS[i][1] = rnd(100)-rnd(100); + ROTAXIS[i][1] = rnd(100)-rnd(100); + ROT[i]=rnd(3600)-rnd(3600); + } + } + + void def_logo() + { + def_O(); + def_P(); + def_El(); + def_G(); + } + + void draw_O() + { + int i,j,k; + for (i=0;i<ACC;i++) + { + k = i+1; + if (k>=ACC) + k = 0; + gl.glBegin(GL_QUAD_STRIP); + for (j=0;j<ACC4;j++) + { + gl.glNormal3f(normal_O[j][k][0], normal_O[j][k][1], normal_O[j][k][2]); + gl.glVertex3f(char_O[j][k][0], char_O[j][k][1], char_O[j][k][2]); + gl.glNormal3f(normal_O[j][i][0], normal_O[j][i][1], normal_O[j][i][2]); + gl.glVertex3f(char_O[j][i][0], char_O[j][i][1], char_O[j][i][2]); + } + gl.glNormal3f(normal_O[0][k][0], normal_O[0][k][1], normal_O[0][k][2]); + gl.glVertex3f(char_O[0][k][0], char_O[0][k][1], char_O[0][k][2]); + gl.glNormal3f(normal_O[0][i][0], normal_O[0][i][1], normal_O[0][i][2]); + gl.glVertex3f(char_O[0][i][0], char_O[0][i][1], char_O[0][i][2]); + gl.glEnd(); + } + } + + void draw_P() + { + int i,j,k; + for (i=0;i<ACC;i++) + { + k = i+1; + if (k>=ACC) + k = 0; + gl.glBegin(GL_QUAD_STRIP); + for (j=0;j<ACC2;j++) + { + gl.glNormal3f(normal_P[j][k][0], normal_P[j][k][1], normal_P[j][k][2]); + gl.glVertex3f(char_P[j][k][0], char_P[j][k][1], char_P[j][k][2]); + gl.glNormal3f(normal_P[j][i][0], normal_P[j][i][1], normal_P[j][i][2]); + gl.glVertex3f(char_P[j][i][0], char_P[j][i][1], char_P[j][i][2]); + } + gl.glNormal3f(normal_P[0][k][0], normal_P[0][k][1], normal_P[0][k][2]); + gl.glVertex3f(char_P[0][k][0], char_P[0][k][1], char_P[0][k][2]); + gl.glNormal3f(normal_P[0][i][0], normal_P[0][i][1], normal_P[0][i][2]); + gl.glVertex3f(char_P[0][i][0], char_P[0][i][1], char_P[0][i][2]); + gl.glEnd(); + } + j = 0; + gl.glBegin(GL_QUAD_STRIP); + for (i=0;i<ACC;i++) + { + gl.glNormal3f(normal_P[0][i][0], normal_P[0][i][1], normal_P[0][i][2]); + gl.glVertex3f(char_P[0][i][0]-4.3f, -1.6f, 1.0f*char_P[0][i][2]); + gl.glVertex3f(char_P[0][i][0]-4.3f, 6.0f, 1.0f*char_P[0][i][2]); + } + gl.glNormal3f(normal_P[0][0][0], normal_P[0][0][1], normal_P[0][0][2]); + gl.glVertex3f(char_P[0][0][0]-4.3f, -1.6f, 1.0f*char_P[0][0][2]); + gl.glVertex3f(char_P[0][0][0]-4.3f, 6.0f, 1.0f*char_P[0][0][2]); + gl.glEnd(); + } + + void draw_E() + { + int i,j,k; + for (i=0;i<ACC;i++) + { + k = i+1; + if (k>=ACC) + k = 0; + gl.glBegin(GL_QUAD_STRIP); + gl.glNormal3f(normal_P[0][k][0], normal_P[0][k][1], normal_P[0][k][2]); + gl.glVertex3f(char_P[0][k][0], char_P[0][k][1]+0.0f, char_P[0][k][2]); + gl.glNormal3f(normal_P[0][i][0], normal_P[0][i][1], normal_P[0][i][2]); + gl.glVertex3f(char_P[0][i][0], char_P[0][i][1]+0.0f, char_P[0][i][2]); + for (j=1;j<ACC2;j++) + { + gl.glNormal3f(normal_P[j][k][0], normal_P[j][k][1], normal_P[j][k][2]); + gl.glVertex3f(char_P[j][k][0], char_P[j][k][1], char_P[j][k][2]); + gl.glNormal3f(normal_P[j][i][0], normal_P[j][i][1], normal_P[j][i][2]); + gl.glVertex3f(char_P[j][i][0], char_P[j][i][1], char_P[j][i][2]); + } + gl.glNormal3f(normal_P[0][k][0], normal_P[0][k][1], normal_P[0][k][2]); + gl.glVertex3f(char_P[0][k][0], char_P[0][k][1]-0.4f, char_P[0][k][2]); + gl.glNormal3f(normal_P[0][i][0], normal_P[0][i][1], normal_P[0][i][2]); + gl.glVertex3f(char_P[0][i][0], char_P[0][i][1]-0.4f, char_P[0][i][2]); + gl.glEnd(); + } + + gl.glBegin(GL_QUAD_STRIP); + j = ACC2*3/4; + for (i=0;i<ACC;i++) + { + gl.glNormal3f(normal_P[j][i][0], normal_P[j][i][1], normal_P[j][i][2]); + gl.glVertex3f(-2.0f, char_P[j][i][1]+2.55f, 1.0f*char_P[j][i][2]); + gl.glVertex3f(2.0f, char_P[j][i][1]+2.55f, 1.0f*char_P[j][i][2]); + } + gl.glNormal3f(normal_P[j][0][0], normal_P[j][0][1], normal_P[j][0][2]); + gl.glVertex3f(-2.0f, char_P[j][0][1]+2.55f, 1.0f*char_P[j][0][2]); + gl.glVertex3f(2.0f, char_P[j][0][1]+2.55f, 1.0f*char_P[j][0][2]); + gl.glEnd(); + } + + void draw_El() + { + int i,j,k; + for (i=0;i<ACC;i++) + { + k = i+1; + if (k>=ACC) + k = 0; + gl.glBegin(GL_QUAD_STRIP); + for (j=0;j<=ACC3;j++) + { + gl.glNormal3f(normal_El[j][k][0], normal_El[j][k][1], normal_El[j][k][2]); + gl.glVertex3f(char_El[j][k][0], char_El[j][k][1], char_El[j][k][2]); + gl.glNormal3f(normal_El[j][i][0], normal_El[j][i][1], normal_El[j][i][2]); + gl.glVertex3f(char_El[j][i][0], char_El[j][i][1], char_El[j][i][2]); + } + gl.glEnd(); + } + } + + void draw_N() + { + int i,j,k; + for (i=0;i<ACC;i++) + { + k = i+1; + if (k>=ACC) + k = 0; + gl.glBegin(GL_QUAD_STRIP); + for (j=0;j<=ACC2/2;j++) + { + gl.glNormal3f(normal_P[j][k][0], normal_P[j][k][1], normal_P[j][k][2]); + gl.glVertex3f(char_P[j][k][0], char_P[j][k][1], char_P[j][k][2]); + gl.glNormal3f(normal_P[j][i][0], normal_P[j][i][1], normal_P[j][i][2]); + gl.glVertex3f(char_P[j][i][0], char_P[j][i][1], char_P[j][i][2]); + } + gl.glEnd(); + } + + j = 0; + gl.glBegin(GL_QUAD_STRIP); + for (i=0;i<ACC;i++) + { + gl.glNormal3f(normal_P[0][i][0], normal_P[0][i][1], normal_P[0][i][2]); + gl.glVertex3f(char_P[0][i][0]-4.3f, 0.2f, 1.0f*char_P[0][i][2]); + gl.glVertex3f(char_P[0][i][0]-4.3f, 6.0f, 1.0f*char_P[0][i][2]); + } + gl.glNormal3f(normal_P[0][0][0], normal_P[0][0][1], normal_P[0][0][2]); + gl.glVertex3f(char_P[0][0][0]-4.3f, 0.2f, 1.0f*char_P[0][0][2]); + gl.glVertex3f(char_P[0][0][0]-4.3f, 6.0f, 1.0f*char_P[0][0][2]); + gl.glEnd(); + j = 0; + + gl.glBegin(GL_QUAD_STRIP); + for (i=0;i<ACC;i++) + { + gl.glNormal3f(normal_P[0][i][0], normal_P[0][i][1], normal_P[0][i][2]); + gl.glVertex3f(char_P[0][i][0], 0.2f, 1.0f*char_P[0][i][2]); + gl.glVertex3f(char_P[0][i][0], 3.4f, 1.0f*char_P[0][i][2]); + } + gl.glNormal3f(normal_P[0][0][0], normal_P[0][0][1], normal_P[0][0][2]); + gl.glVertex3f(char_P[0][0][0], 0.2f, 1.0f*char_P[0][0][2]); + gl.glVertex3f(char_P[0][0][0], 3.4f, 1.0f*char_P[0][0][2]); + gl.glEnd(); + } + + void draw_G() + { + int i,j,k; + for (i=0;i<ACC;i++) + { + k = i+1; + if (k>=ACC) + k = 0; + gl.glBegin(GL_QUAD_STRIP); + gl.glNormal3f(normal_G[0][k][0], normal_G[0][k][1], normal_G[0][k][2]); + gl.glVertex3f(char_G[0][k][0], char_G[0][k][1]+1.2f, char_G[0][k][2]); + gl.glNormal3f(normal_G[0][i][0], normal_G[0][i][1], normal_G[0][i][2]); + gl.glVertex3f(char_G[0][i][0], char_G[0][i][1]+1.2f, char_G[0][i][2]); + for (j=1;j<ACC4;j++) + { + gl.glNormal3f(normal_G[j][k][0], normal_G[j][k][1], normal_G[j][k][2]); + gl.glVertex3f(char_G[j][k][0], char_G[j][k][1], char_G[j][k][2]); + gl.glNormal3f(normal_G[j][i][0], normal_G[j][i][1], normal_G[j][i][2]); + gl.glVertex3f(char_G[j][i][0], char_G[j][i][1], char_G[j][i][2]); + } + gl.glEnd(); + } + + gl.glBegin(GL_QUAD_STRIP); + j = ACC4*3/4; + for (i=0;i<ACC;i++) + { + gl.glNormal3f(accSIN[i], 0.0f, accCOS[i] ); + gl.glVertex3f(4.0f+0.9f*accSIN[i], 4.0f+0.9f*accSIN[i], 0.9f*accCOS[i] ); + gl.glVertex3f(4.0f+0.9f*accSIN[i], 0.0f, 0.9f*accCOS[i]); + } + gl.glNormal3f(accSIN[0], 0.0f, accCOS[0] ); + gl.glVertex3f(4.0f+0.9f*accSIN[0], 4.0f+0.9f*accSIN[0], 0.9f*accCOS[0] ); + gl.glVertex3f(4.0f+0.9f*accSIN[0], 0.0f, 0.9f*accCOS[0]); + gl.glEnd(); + + gl.glBegin(GL_QUAD_STRIP); + j = ACC4*3/4; + for (i=0;i<ACC;i++) + { + gl.glNormal3f(0.0f, accSIN[i], accCOS[i] ); + gl.glVertex3f(4.0f-0.9f*accSIN[i], 4.0f-0.9f*accSIN[i], 0.9f*accCOS[i] ); + gl.glVertex3f(0.0f, 4.0f-0.9f*accSIN[i], 0.9f*accCOS[i]); + } + gl.glNormal3f(0.0f, accSIN[0], accCOS[0] ); + gl.glVertex3f(4.0f-0.9f*accSIN[0], 4.0f-0.9f*accSIN[0], 0.9f*accCOS[0] ); + gl.glVertex3f(0.0f, 4.0f-0.9f*accSIN[0], 0.9f*accCOS[0]); + gl.glEnd(); + + j = ACC4*3/4; + gl.glBegin(GL_TRIANGLE_FAN); + gl.glNormal3f(-1.0f, 0.0f, 0.0f); + gl.glVertex3f(0.0f, 4.0f, 0.0f); + for (i=0;i<ACC;i++) + gl.glVertex3f(0.0f, 4.0f+0.9f*accSIN[i], 0.9f*accCOS[i]); + gl.glVertex3f(0.0f, 4.0f+0.9f*accSIN[0], 0.9f*accCOS[0]); + gl.glEnd(); + } + + void draw_L() + { + int i; + + gl.glBegin(GL_QUAD_STRIP); + for (i=0;i<ACC;i++) + { + gl.glNormal3f(accSIN[i], 0.0f, accCOS[i] ); + gl.glVertex3f(0.9f*accSIN[i], 9.6f, 0.9f*accCOS[i]); + gl.glVertex3f(0.9f*accSIN[i], 0.9f+0.9f*accSIN[i], 0.9f*accCOS[i] ); + } + gl.glNormal3f(accSIN[0], 0.0f, accCOS[0] ); + gl.glVertex3f(0.9f*accSIN[0], 9.6f, 0.9f*accCOS[0]); + gl.glVertex3f(0.9f*accSIN[0], 0.9f+0.9f*accSIN[0], 0.9f*accCOS[0] ); + gl.glEnd(); + + gl.glBegin(GL_QUAD_STRIP); + for (i=0;i<ACC;i++) + { + gl.glNormal3f(0.0f, accSIN[i], accCOS[i] ); + gl.glVertex3f(0.9f*accSIN[i], 0.9f+0.9f*accSIN[i], 0.9f*accCOS[i] ); + gl.glVertex3f(5.6f, 0.9f+0.9f*accSIN[i], 0.9f*accCOS[i]); + } + gl.glNormal3f(0.0f, accSIN[0], accCOS[0] ); + gl.glVertex3f(0.9f*accSIN[0], 0.9f+0.9f*accSIN[0], 0.9f*accCOS[0] ); + gl.glVertex3f(5.6f, 0.9f+0.9f*accSIN[0], 0.9f*accCOS[0]); + gl.glEnd(); + + gl.glBegin(GL_TRIANGLE_FAN); + gl.glNormal3f(1.0f, 0.0f, 0.0f); + gl.glVertex3f(5.6f, 0.9f, 0.0f); + for (i=ACC-1;i>=0;i--) + gl.glVertex3f(5.6f, 0.9f+0.9f*accSIN[i], 0.9f*accCOS[i]); + gl.glVertex3f(5.6f, 0.9f+0.9f*accSIN[ACC-1], 0.9f*accCOS[ACC-1]); + gl.glEnd(); + } + + void draw_part(int i) + { + gl.glPushMatrix(); + gl.glTranslatef(TRANS[i][0]*progress, TRANS[i][1]*progress, TRANS[i][2]*progress); + gl.glRotatef(ROT[i]*progress, ROTAXIS[i][0], ROTAXIS[i][1], ROTAXIS[i][2]); + switch(i) + { + case 0: draw_El(); break; + case 1: draw_O(); break; + case 2: draw_P(); break; + case 3: draw_E(); break; + case 4: draw_N(); break; + case 5: draw_G(); break; + case 6: draw_L(); break; + } + gl.glPopMatrix(); + } + + void draw_logo() + { + groen_texture(); + gl.glEnable(GL_CULL_FACE); + gl.glTranslatef(-2.8f, 0.0f, 0.0f); + + draw_part(0); + gl.glTranslatef(-12.0f, 4.3f, 0.0f); + draw_part(1); + gl.glTranslatef(7.3f, 0.0f, 0.0f); + draw_part(2); + gl.glTranslatef(5.4f, 0.0f, 0.0f); + draw_part(3); + gl.glTranslatef(5.4f, 0.0f, 0.0f); + draw_part(4); + gl.glTranslatef(7.4f, 0.0f, 0.0f); + draw_part(5); + gl.glTranslatef(6.8f, 0.0f, 0.0f); + draw_part(6); + } + +} + diff --git a/demos/glLogoCvsApplet.html b/demos/glLogoCvsApplet.html new file mode 100644 index 0000000..69546d9 --- /dev/null +++ b/demos/glLogoCvsApplet.html @@ -0,0 +1,14 @@ +<HTML>
+<HEAD>
+<TITLE>Göthel Hard- und Software Entwicklungen</TITLE>
+</HEAD>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+<hr>
+<applet code="glLogoCvsApplet.class" width=400 height=220>
+<param name=frames value="55">
+</applet>
+<hr>
+</BODY>
+</HTML>
+
+
diff --git a/demos/glLogoCvsApplet.java b/demos/glLogoCvsApplet.java new file mode 100644 index 0000000..bdd5009 --- /dev/null +++ b/demos/glLogoCvsApplet.java @@ -0,0 +1,71 @@ + +import gl4java.GLContext; + +import java.awt.*; +import java.awt.event.*; +import java.applet.*; + +public class glLogoCvsApplet extends Applet + implements MouseListener +{ + glLogoCvs cvsLogo = null; + + String gljLib=null; + String glLib=null; + String gluLib=null; + + Button bLoadLib = null; + Button bAddGL = null; + + public void init() + { + setLayout(new BorderLayout()); + cvsLogo = new glLogoCvs(150, 150, null, null); + cvsLogo.setAnimateFps(30.0); + add("Center", cvsLogo); + + add("West", new Label("OpenGL")); + add("East", new Label("Java-Applet")); + + cvsLogo.addMouseListener(this); + setBackground(Color.white); + } + + public void start() { + cvsLogo.start(); + } + + public void stop() { + cvsLogo.stop(); + } + + public void destroy() { + cvsLogo.stop(); + cvsLogo.cvsDispose(); + } + + // Methods required for the implementation of MouseListener + public void mouseEntered( MouseEvent evt ) + { + } + + public void mouseExited( MouseEvent evt ) + { + } + + public void mousePressed( MouseEvent evt ) + { + } + + public void mouseReleased( MouseEvent evt ) + { + } + + public void mouseClicked( MouseEvent evt ) + { + Component comp = evt.getComponent(); + + if( comp.equals(cvsLogo) ) + cvsLogo.setSuspended(!cvsLogo.isSuspended(), true); + } +} diff --git a/demos/glLogoCvsAppletDbg.java b/demos/glLogoCvsAppletDbg.java new file mode 100644 index 0000000..8ddfd0a --- /dev/null +++ b/demos/glLogoCvsAppletDbg.java @@ -0,0 +1,125 @@ + +import gl4java.GLContext; + +import java.awt.*; +import java.awt.event.*; +import java.applet.*; + +public class glLogoCvsAppletDbg extends Applet + implements MouseListener +{ + glLogoCvs cvsLogo = null; + + String gljLib=null; + String glLib=null; + String gluLib=null; + + Button bLoadLib = null; + Button bAddGL = null; + + static { + if(GLContext.loadNativeLibraries(null, null, null)==false) + System.out.println("could not load native def. libs"); + else + System.out.println("loaded native def. libs"); + } + + public void init() + { + setLayout(new BorderLayout()); + + bLoadLib = new Button("load lib"); + add("North", bLoadLib); + bAddGL = new Button("add gl"); + add("South", bAddGL); + bAddGL.addMouseListener(this); + /* + if(GLContext.loadNativeLibraries(gljLib, glLib, gluLib)==false) + System.out.println("could not load native libs:"+ + gljLib + ", " + glLib + ", " + gluLib); + else + System.out.println("load native libs:"+ + gljLib + ", " + glLib + ", " + gluLib); + + setLayout(new BorderLayout()); + cvsLogo = new glLogoCvs(150, 150, null, null); + cvsLogo.setAnimateFps(30.0); + add("Center", cvsLogo); + + add("West", new Label("OpenGL")); + add("East", new Label("Java-Applet")); + + cvsLogo.addMouseListener(this); + setBackground(Color.white); + */ + } + + public void start() { + // cvsLogo.start(); + } + + public void stop() { + // cvsLogo.stop(); + } + + public void destroy() { + /* + cvsLogo.stop(); + cvsLogo.cvsDispose(); + */ + } + + // Methods required for the implementation of MouseListener + public void mouseEntered( MouseEvent evt ) + { + } + + public void mouseExited( MouseEvent evt ) + { + } + + public void mousePressed( MouseEvent evt ) + { + } + + public void mouseReleased( MouseEvent evt ) + { + } + + public void mouseClicked( MouseEvent evt ) + { + Component comp = evt.getComponent(); + + if( comp.equals(bLoadLib) ) + loadLib(); + if( comp.equals(bAddGL) ) + addGL(); + else if( comp.equals(cvsLogo) ) + cvsLogo.setSuspended(!cvsLogo.isSuspended(), + evt.getClickCount()>1 // -> ReInit + ); + } + + void loadLib() + { + if(GLContext.loadNativeLibraries(gljLib, glLib, gluLib)==false) + System.out.println("could not load native libs:"+ + gljLib + ", " + glLib + ", " + gluLib); + else + System.out.println("load native libs:"+ + gljLib + ", " + glLib + ", " + gluLib); + } + + void addGL() + { + cvsLogo = new glLogoCvs(150, 150, null, null); + cvsLogo.setAnimateFps(30.0); + add("Center", cvsLogo); + + add("West", new Label("OpenGL")); + add("East", new Label("Java-Applet")); + + cvsLogo.addMouseListener(this); + setBackground(Color.white); + } +} diff --git a/demos/glLogoCvsAppletJ2P.html b/demos/glLogoCvsAppletJ2P.html new file mode 100644 index 0000000..62c9705 --- /dev/null +++ b/demos/glLogoCvsAppletJ2P.html @@ -0,0 +1,45 @@ +<HTML>
+<HEAD>
+<TITLE>Göthel Hard- und Software Entwicklungen</TITLE>
+</HEAD>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+<hr>
+<!--"CONVERTED_APPLET"-->
+<!-- CONVERTER VERSION 1.0 -->
+<SCRIPT LANGUAGE="JavaScript"><!--
+ var _info = navigator.userAgent; var _ns = false;
+ var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0);
+//--></SCRIPT>
+<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!--
+ var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0)));
+//--></SCRIPT></COMMENT>
+
+<SCRIPT LANGUAGE="JavaScript"><!--
+ if (_ie == true) document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = 400 HEIGHT = 220 codebase="http://java.sun.com/products/plugin/1.2/jinstall-12-win32.cab#Version=1,2,0,0"><NOEMBED><XMP>');
+ else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.2" java_CODE = "glLogoCvsApplet.class" WIDTH = 400 HEIGHT = 220 frames = "55" pluginspage="http://java.sun.com/products/plugin/1.2/plugin-install.html"><NOEMBED><XMP>');
+//--></SCRIPT>
+<APPLET CODE = "glLogoCvsApplet.class" WIDTH = 400 HEIGHT = 220 ></XMP>
+<PARAM NAME = CODE VALUE = "glLogoCvsApplet.class" >
+
+<PARAM NAME="type" VALUE="application/x-java-applet;version=1.2">
+<PARAM NAME = frames VALUE ="55">
+
+</APPLET>
+
+</NOEMBED></EMBED></OBJECT>
+
+
+<!--
+<APPLET CODE = "glLogoCvsApplet.class" WIDTH = 400 HEIGHT = 220 >
+<PARAM NAME = frames VALUE ="55">
+
+
+</APPLET>
+-->
+<!--"END_CONVERTED_APPLET"-->
+
+<hr>
+</BODY>
+</HTML>
+
+
diff --git a/demos/glOlympicCvsApplet.html b/demos/glOlympicCvsApplet.html new file mode 100644 index 0000000..97520e7 --- /dev/null +++ b/demos/glOlympicCvsApplet.html @@ -0,0 +1,14 @@ +<HTML>
+<HEAD>
+<TITLE>Göthel Hard- und Software Entwicklungen</TITLE>
+</HEAD>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+<hr>
+<applet code="glOlympicCvsApplet.class" width=400 height=220>
+<param name=frames value="55">
+</applet>
+<hr>
+</BODY>
+</HTML>
+
+
diff --git a/demos/glOlympicCvsApplet.java b/demos/glOlympicCvsApplet.java new file mode 100644 index 0000000..0bc9102 --- /dev/null +++ b/demos/glOlympicCvsApplet.java @@ -0,0 +1,78 @@ + +import gl4java.GLContext; +import gl4java.awt.GLCanvas; +import java.awt.*; +import java.awt.event.*; +import java.applet.*; + +public class glOlympicCvsApplet extends Applet + implements MouseListener +{ + olympicCvs cvsOlympic = null; + + String gljLib=null; + String glLib=null; + String gluLib=null; + + public void init() + { + if(GLContext.loadNativeLibraries(gljLib, glLib, gluLib)==false) + System.out.println("could not load native libs:"+ + gljLib + ", " + glLib + ", " + gluLib); + else + System.out.println("load native libs:"+ + gljLib + ", " + glLib + ", " + gluLib); + + + setLayout(new BorderLayout()); + cvsOlympic = new olympicCvs(150, 150, null, null); + cvsOlympic.setAnimateFps(30.0); + add("Center", cvsOlympic); + + add("West", new Label("OpenGL")); + add("East", new Label("Java-Applet")); + + cvsOlympic.addMouseListener(this); + addMouseListener(this); + + setBackground(Color.white); + } + + public void start() { + cvsOlympic.start(); + } + + public void stop() { + cvsOlympic.stop(); + } + + public void destroy() { + cvsOlympic.stop(); + cvsOlympic.cvsDispose(); + } + + // Methods required for the implementation of MouseListener + public void mouseEntered( MouseEvent evt ) + { + } + + public void mouseExited( MouseEvent evt ) + { + } + + public void mousePressed( MouseEvent evt ) + { + } + + public void mouseReleased( MouseEvent evt ) + { + } + + public void mouseClicked( MouseEvent evt ) + { + Component comp = evt.getComponent(); + + if( comp.equals(cvsOlympic) ) + cvsOlympic.setSuspended(!cvsOlympic.isSuspended(), true); + } +} diff --git a/demos/glOlympicCvsAppletJ2P.html b/demos/glOlympicCvsAppletJ2P.html new file mode 100644 index 0000000..135c58f --- /dev/null +++ b/demos/glOlympicCvsAppletJ2P.html @@ -0,0 +1,45 @@ +<HTML>
+<HEAD>
+<TITLE>Göthel Hard- und Software Entwicklungen</TITLE>
+</HEAD>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+<hr>
+<!--"CONVERTED_APPLET"-->
+<!-- CONVERTER VERSION 1.0 -->
+<SCRIPT LANGUAGE="JavaScript"><!--
+ var _info = navigator.userAgent; var _ns = false;
+ var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0);
+//--></SCRIPT>
+<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!--
+ var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0)));
+//--></SCRIPT></COMMENT>
+
+<SCRIPT LANGUAGE="JavaScript"><!--
+ if (_ie == true) document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = 400 HEIGHT = 220 codebase="http://java.sun.com/products/plugin/1.2/jinstall-12-win32.cab#Version=1,2,0,0"><NOEMBED><XMP>');
+ else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.2" java_CODE = "glOlympicCvsApplet.class" WIDTH = 400 HEIGHT = 220 frames = "55" pluginspage="http://java.sun.com/products/plugin/1.2/plugin-install.html"><NOEMBED><XMP>');
+//--></SCRIPT>
+<APPLET CODE = "glOlympicCvsApplet.class" WIDTH = 400 HEIGHT = 220 ></XMP>
+<PARAM NAME = CODE VALUE = "glOlympicCvsApplet.class" >
+
+<PARAM NAME="type" VALUE="application/x-java-applet;version=1.2">
+<PARAM NAME = frames VALUE ="55">
+
+</APPLET>
+
+</NOEMBED></EMBED></OBJECT>
+
+
+<!--
+<APPLET CODE = "glOlympicCvsApplet.class" WIDTH = 400 HEIGHT = 220 >
+<PARAM NAME = frames VALUE ="55">
+
+
+</APPLET>
+-->
+<!--"END_CONVERTED_APPLET"-->
+
+<hr>
+</BODY>
+</HTML>
+
+
diff --git a/demos/glOlympicSwingApplet.html b/demos/glOlympicSwingApplet.html new file mode 100644 index 0000000..32caef3 --- /dev/null +++ b/demos/glOlympicSwingApplet.html @@ -0,0 +1,14 @@ +<HTML>
+<HEAD>
+<TITLE>Göthel Hard- und Software Entwicklungen</TITLE>
+</HEAD>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+<hr>
+<applet code="glOlympicSwingApplet.class" width=400 height=220>
+<param name=frames value="55">
+</applet>
+<hr>
+</BODY>
+</HTML>
+
+
diff --git a/demos/glOlympicSwingApplet.java b/demos/glOlympicSwingApplet.java new file mode 100644 index 0000000..9e67af2 --- /dev/null +++ b/demos/glOlympicSwingApplet.java @@ -0,0 +1,125 @@ + +import gl4java.GLContext; +import java.awt.*; +import javax.swing.*; +import java.awt.event.*; +import java.applet.*; + +public class glOlympicSwingApplet extends JApplet + implements MouseListener +{ + olympicCvs cvsOlympic = null; + + String gljLib=null; + String glLib=null; + String gluLib=null; + + public void init() + { + if(GLContext.loadNativeLibraries(gljLib, glLib, gluLib)==false) + System.out.println("could not load native libs:"+ + gljLib + ", " + glLib + ", " + gluLib); + else + System.out.println("load native libs:"+ + gljLib + ", " + glLib + ", " + gluLib); + + + cvsOlympic = new olympicCvs(150, 150, null, null); + cvsOlympic.setAnimateFps(30.0); + + JPanel p1 = new JPanel(); + p1.setLayout(new BorderLayout()); + + getContentPane().setLayout(new BorderLayout()); + getContentPane().add("Center", p1); + + p1.add("North", new JLabel("Overlapping Swings do not work")); + p1.add("West", new JLabel("OpenGL")); + p1.add("Center", cvsOlympic); + p1.add("East", new JLabel("Java-JApplet")); + p1.add("South", new JLabel("The Events does not work yet")); + + cvsOlympic.addMouseListener(this); + + setBackground(Color.white); + + JMenuBar jmb1 = new JMenuBar(); + JMenu jm1 = new JMenu("Menu-1"); + jm1.add(new JMenuItem("Menue-1-Item-1")); + jm1.add(new JMenuItem("Menue-1-Item-2")); + jm1.add(new JMenuItem("Menue-1-Item-3")); + JMenu jm2 = new JMenu("Menu-2"); + jm2.add(new JMenuItem("Menue-2-Item-1")); + jm2.add(new JMenuItem("Menue-2-Item-2")); + jm2.add(new JMenuItem("Menue-2-Item-3")); + JMenu jm3 = new JMenu("Menu-3"); + jm3.add(new JMenuItem("Menue-3-Item-1")); + jm3.add(new JMenuItem("Menue-3-Item-2")); + jm3.add(new JMenuItem("Menue-3-Item-3")); + jmb1.add(jm1); + jmb1.add(jm2); + jmb1.add(jm3); + + setJMenuBar(jmb1); + } + + public void start() { + cvsOlympic.start(); + } + + public void stop() { + cvsOlympic.stop(); + } + + public void destroy() { + cvsOlympic.stop(); + cvsOlympic.cvsDispose(); + } + + // Methods required for the implementation of MouseListener + public void mouseEntered( MouseEvent evt ) + { + Component comp = evt.getComponent(); + mouseInfo(evt); + if( comp.equals(cvsOlympic) ) + cvsOlympic.setSuspended(!cvsOlympic.isSuspended(), true); + + } + + public void mouseExited( MouseEvent evt ) + { + mouseInfo(evt); + + } + + public void mousePressed( MouseEvent evt ) + { + mouseInfo(evt); + + } + + public void mouseReleased( MouseEvent evt ) + { + mouseInfo(evt); + + } + + public void mouseClicked( MouseEvent evt ) + { + Component comp = evt.getComponent(); + + mouseInfo(evt); + + if( comp.equals(cvsOlympic) ) + cvsOlympic.setSuspended(!cvsOlympic.isSuspended(), true); + } + + public void mouseInfo(MouseEvent evt) + { + Component comp = evt.getComponent(); + + System.out.println("\n\n----------------------------------"); + System.out.println(comp); + System.out.println(evt); + } +} 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);
+ }
+ }
+}
diff --git a/demos/glc2glj b/demos/glc2glj new file mode 100755 index 0000000..2512144 --- /dev/null +++ b/demos/glc2glj @@ -0,0 +1,32 @@ +#! /bin/sh + +echo "will replace all decimal numbers to java-float constants" +echo "$1 -> $1.new" +sed -e '/[0-9][0-9]*\.[0-9][0-9]*/s//&f/g' \ + -e '/GLbyte/s//byte/g' \ + -e '/GLshort/s//short/g' \ + -e '/GLint/s//int/g' \ + -e '/GLfloat/s//float/g' \ + -e '/GLclampf/s//float/g' \ + -e '/GLdouble/s//double/g' \ + -e '/GLclampd/s//double/g' \ + -e '/GLubyte/s//byte/g' \ + -e '/GLboolean/s//boolean/g' \ + -e '/GLushort/s//short/g' \ + -e '/GLuint/s//int/g' \ + -e '/GLenum/s//int/g' \ + -e '/GLbitfield/s//int/g' \ + -e '/GLUquadricObj *\*/s//long /g' \ + -e '/GLUnurbsObj *\*/s//long /g' \ + -e '/GLUtesselator *\*/s//long /g' \ + -e '/GLUtriangulatorObj *\*/s//long /g' \ + -e '/cos/s//(float)Math.cos/g' \ + -e '/sin/s//(float)Math.sin/g' \ + -e '/sqrt/s//(float)Math.sqrt/g' \ + -e '/pow/s//(float)Math.pow/g' \ + -e '/\#define/s//static final int/g' \ + -e '/glut[A-Z]/s//glut.&/g' \ + -e '/glu[A-Z]/s//glu.&/g' \ + -e '/gl[A-Z]/s//gl.&/g' \ + $1 > $1.new + diff --git a/demos/index.html b/demos/index.html new file mode 100755 index 0000000..1ac862b --- /dev/null +++ b/demos/index.html @@ -0,0 +1,62 @@ +<!doctype html public "-//w3c//dtd html 4.0 transitional//en"> +<html> +<head> + <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> + <meta name="Author" content="Ron Cemer & Sven Goethel"> + <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]"> + <title>Misc Demos</title> +</head> +<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff"> +<p>Here are the demos-I for <B> +<A HREF="http://www.jausoft.com/gl4java/">GL4Java</A> >= 2.4.0.0: </B> <br> +<br> + <LI><P ALIGN=LEFT><I><A HREF="glDemosCvs.html">glDemosCvs</A> + : Many OpenGL Canvas running together</I> + </P> + <LI><P ALIGN=LEFT><I><A HREF="glOlympicCvsApplet.html">glOlympicCvsApplet</A> + : The Olympic Rings alone </I> + </P> + <LI><P ALIGN=LEFT><I><A HREF="glLogoCvsApplet.html">glLogoCvsApplet</A> + : The OpenGL Logo alone</I></P> + <LI><P ALIGN=LEFT><I><A HREF="glOlympicSwingApplet.html">glOlympicSwingApplet</A> + : The Olympic Rings using Swing (needs Swing 1.1 installed + either)</I></P> + <LI><P ALIGN=LEFT><I><A HREF="testTextPPM1.html">testTextPPM1</A> + : A textured Box using Swing (needs Swing 1.1 installed + either)</I></P> + +<BR> + + <LI><P ALIGN=LEFT><I><A HREF="GLLandScape/index.html">GLLandScape World</A> + : The GLLandScape World + </I></P> + <LI><P ALIGN=LEFT><I><A HREF="MiscDemos/index.html">Misc Demos</A> + : Some new ported demos. + </I></P> + <LI><P ALIGN=LEFT><I><A HREF="RonsDemos/index.html">Ron's Demos</A> + : Demo's ported by Ron Cemer + </I></P> + <LI><P ALIGN=LEFT><I><A HREF="HodglimsNeHe/index.html">Hodglim's NeHe Demos</A> + : Here are the NeHe OpenGL Tutorial Demos originally ported by Hodglim + </I></P> +<BR> + +<P ALIGN=CENTER><SPAN STYLE="text-decoration: none"><I>For use with +the Java2-Plug-In: Tested with Win32,Netscape,Java2 <A HREF="Java2.txt">(see +Installation-instructions Java2)</A> ! </I></SPAN> +</P> +<UL> + <LI><P ALIGN=LEFT><I><A HREF="glOlympicCvsAppletJ2P.html">glOlympicCvsAppletJ2P</A> + : Out of the demo directory of GL4Java </I> + </P> + <LI><P ALIGN=LEFT><I><A HREF="glLogoCvsAppletJ2P.html">glLogoCvsAppletJ2P</A> + : Out of the demo directory of GL4Java</I></P> + <LI><P ALIGN=LEFT><I><A HREF="testTextPPM1J2P.html">testTextPPM1J2P</A> + : Out of the demo directory of GL4Java (needs Swing 1.1 installed + either)</I></P> +</UL> +<P ALIGN=CENTER><SPAN STYLE="text-decoration: none"> +<a href="../../Installer/java.policy">The Java2 (sdk, jre, plugin 1.3) policy file example to give GL4Java the necessary permissions (Click here) !</a> +</P> +</BODY> +</HTML> diff --git a/demos/java.policy b/demos/java.policy new file mode 100644 index 0000000..1115932 --- /dev/null +++ b/demos/java.policy @@ -0,0 +1,56 @@ + +// Standard extensions get all permissions by default + +grant codeBase "file:${java.home}/lib/ext/-" { + permission java.security.AllPermission; +}; + +grant codeBase "http://www.jausoft.com/Files/Java/1.1.X/GL4Java/demos/* { + permission java.security.AllPermission; +}; + +grant codeBase "file://f/java-1.1.X/GL4Java/demos/* { + permission java.security.AllPermission; +}; + +// default permissions granted to all domains + +grant { + // Allows any thread to stop itself using the java.lang.Thread.stop() + // method that takes no argument. + // Note that this permission is granted by default only to remain + // backwards compatible. + // It is strongly recommended that you either remove this permission + // from this policy file or further restrict it to code sources + // that you specify, because Thread.stop() is potentially unsafe. + // See "http://java.sun.com/notes" for more information. + permission java.lang.RuntimePermission "stopThread"; + + // allows anyone to listen on un-privileged ports + permission java.net.SocketPermission "localhost:1024-", "listen"; + + // "standard" properies that can be read by anyone + + permission java.util.PropertyPermission "java.version", "read"; + permission java.util.PropertyPermission "java.vendor", "read"; + permission java.util.PropertyPermission "java.vendor.url", "read"; + permission java.util.PropertyPermission "java.class.version", "read"; + permission java.util.PropertyPermission "os.name", "read"; + permission java.util.PropertyPermission "os.version", "read"; + permission java.util.PropertyPermission "os.arch", "read"; + permission java.util.PropertyPermission "file.separator", "read"; + permission java.util.PropertyPermission "path.separator", "read"; + permission java.util.PropertyPermission "line.separator", "read"; + + permission java.util.PropertyPermission "java.specification.version", "read"; + permission java.util.PropertyPermission "java.specification.vendor", "read"; + permission java.util.PropertyPermission "java.specification.name", "read"; + + permission java.util.PropertyPermission "java.vm.specification.version", "read"; + permission java.util.PropertyPermission "java.vm.specification.vendor", "read"; + permission java.util.PropertyPermission "java.vm.specification.name", "read"; + permission java.util.PropertyPermission "java.vm.version", "read"; + permission java.util.PropertyPermission "java.vm.vendor", "read"; + permission java.util.PropertyPermission "java.vm.name", "read"; +}; + diff --git a/demos/lunaL.ppm b/demos/lunaL.ppm Binary files differnew file mode 100644 index 0000000..aaf7c41 --- /dev/null +++ b/demos/lunaL.ppm diff --git a/demos/makefile b/demos/makefile new file mode 100644 index 0000000..56422c8 --- /dev/null +++ b/demos/makefile @@ -0,0 +1,36 @@ +JAVAC = javac + + +JAVA_APPL_FILES = olympicCvs.java \ + starCvs.java \ + waveCvs.java \ + glOlympicCvsApplet.java \ + glOlympicSwingApplet.java \ + glLogoCvs.java \ + glLogoCvsApplet.java \ + glDemosCvs.java \ + testTextPPM1.java + +.SUFFIXES : .java .class + +.java.class: + $(JAVAC) -deprecation $< 2>&1 | tee -a errors + +all: ${JAVA_APPL_FILES:.java=.class} + +showdest: + echo ${JAVA_APPL_FILES:.java=.class} ${C_APPL_FILES:.c=.o} + +clean: + rm -f *.o *~ errors *.dll + +cleanall: clean + rm -f *.class ${C_APPL_FILES:.c=} + rm -f $(find . -name \*.o -o -name \*.exe ) + +windllcpy: + cp /WIN_NT/system32/opengl32.dll . + cp /WIN_NT/system32/opengl.dll . + cp /WIN_NT/system32/gl4java.dll . + cp /WIN_NT/system32/gl4java32.dll . + diff --git a/demos/natives/bc5/cube.c b/demos/natives/bc5/cube.c new file mode 100644 index 0000000..34c2f47 --- /dev/null +++ b/demos/natives/bc5/cube.c @@ -0,0 +1,289 @@ +#include <windows.h>
+#include <GL/gl.h>
+
+char *className = "OpenGL";
+char *windowName = "OpenGL Cube";
+int winX = 0, winY = 0;
+int winWidth = 300, winHeight = 300;
+
+HDC hDC;
+HGLRC hGLRC;
+HPALETTE hPalette;
+
+void
+init(void)
+{
+ /* set viewing projection */
+ glMatrixMode(GL_PROJECTION);
+ glFrustum(-0.5F, 0.5F, -0.5F, 0.5F, 1.0F, 3.0F);
+
+ /* position viewer */
+ glMatrixMode(GL_MODELVIEW);
+ glTranslatef(0.0F, 0.0F, -2.0F);
+
+ /* position object */
+ glRotatef(30.0F, 1.0F, 0.0F, 0.0F);
+ glRotatef(30.0F, 0.0F, 1.0F, 0.0F);
+
+ glEnable(GL_DEPTH_TEST);
+ glEnable(GL_LIGHTING);
+ glEnable(GL_LIGHT0);
+}
+
+void
+redraw(void)
+{
+ /* clear color and depth buffers */
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+ /* draw six faces of a cube */
+ glBegin(GL_QUADS);
+ glNormal3f( 0.0F, 0.0F, 1.0F);
+ glVertex3f( 0.5F, 0.5F, 0.5F); glVertex3f(-0.5F, 0.5F, 0.5F);
+ glVertex3f(-0.5F,-0.5F, 0.5F); glVertex3f( 0.5F,-0.5F, 0.5F);
+
+ glNormal3f( 0.0F, 0.0F,-1.0F);
+ glVertex3f(-0.5F,-0.5F,-0.5F); glVertex3f(-0.5F, 0.5F,-0.5F);
+ glVertex3f( 0.5F, 0.5F,-0.5F); glVertex3f( 0.5F,-0.5F,-0.5F);
+
+ glNormal3f( 0.0F, 1.0F, 0.0F);
+ glVertex3f( 0.5F, 0.5F, 0.5F); glVertex3f( 0.5F, 0.5F,-0.5F);
+ glVertex3f(-0.5F, 0.5F,-0.5F); glVertex3f(-0.5F, 0.5F, 0.5F);
+
+ glNormal3f( 0.0F,-1.0F, 0.0F);
+ glVertex3f(-0.5F,-0.5F,-0.5F); glVertex3f( 0.5F,-0.5F,-0.5F);
+ glVertex3f( 0.5F,-0.5F, 0.5F); glVertex3f(-0.5F,-0.5F, 0.5F);
+
+ glNormal3f( 1.0F, 0.0F, 0.0F);
+ glVertex3f( 0.5F, 0.5F, 0.5F); glVertex3f( 0.5F,-0.5F, 0.5F);
+ glVertex3f( 0.5F,-0.5F,-0.5F); glVertex3f( 0.5F, 0.5F,-0.5F);
+
+ glNormal3f(-1.0F, 0.0F, 0.0F);
+ glVertex3f(-0.5F,-0.5F,-0.5F); glVertex3f(-0.5F,-0.5F, 0.5F);
+ glVertex3f(-0.5F, 0.5F, 0.5F); glVertex3f(-0.5F, 0.5F,-0.5F);
+ glEnd();
+
+ SwapBuffers(hDC);
+}
+
+void
+resize(void)
+{
+ /* set viewport to cover the window */
+ glViewport(0, 0, winWidth, winHeight);
+}
+
+void
+setupPixelFormat(HDC hDC)
+{
+ PIXELFORMATDESCRIPTOR pfd = {
+ sizeof(PIXELFORMATDESCRIPTOR), /* size */
+ 1, /* version */
+ PFD_SUPPORT_OPENGL |
+ PFD_DRAW_TO_WINDOW |
+ PFD_DOUBLEBUFFER, /* support double-buffering */
+ PFD_TYPE_RGBA, /* color type */
+ 16, /* prefered color depth */
+ 0, 0, 0, 0, 0, 0, /* color bits (ignored) */
+ 0, /* no alpha buffer */
+ 0, /* alpha bits (ignored) */
+ 0, /* no accumulation buffer */
+ 0, 0, 0, 0, /* accum bits (ignored) */
+ 16, /* depth buffer */
+ 0, /* no stencil buffer */
+ 0, /* no auxiliary buffers */
+ PFD_MAIN_PLANE, /* main layer */
+ 0, /* reserved */
+ 0, 0, 0, /* no layer, visible, damage masks */
+ };
+ int pixelFormat;
+
+ pixelFormat = ChoosePixelFormat(hDC, &pfd);
+ if (pixelFormat == 0) {
+ MessageBox(WindowFromDC(hDC), "ChoosePixelFormat failed.", "Error",
+ MB_ICONERROR | MB_OK);
+ exit(1);
+ }
+
+ if (SetPixelFormat(hDC, pixelFormat, &pfd) != TRUE) {
+ MessageBox(WindowFromDC(hDC), "SetPixelFormat failed.", "Error",
+ MB_ICONERROR | MB_OK);
+ exit(1);
+ }
+}
+
+void
+setupPalette(HDC hDC)
+{
+ int pixelFormat = GetPixelFormat(hDC);
+ PIXELFORMATDESCRIPTOR pfd;
+ LOGPALETTE* pPal;
+ int paletteSize;
+
+ DescribePixelFormat(hDC, pixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &pfd);
+
+ if (pfd.dwFlags & PFD_NEED_PALETTE) {
+ paletteSize = 1 << pfd.cColorBits;
+ } else {
+ return;
+ }
+
+ pPal = (LOGPALETTE*)
+ malloc(sizeof(LOGPALETTE) + paletteSize * sizeof(PALETTEENTRY));
+ pPal->palVersion = 0x300;
+ pPal->palNumEntries = paletteSize;
+
+ /* build a simple RGB color palette */
+ {
+ int redMask = (1 << pfd.cRedBits) - 1;
+ int greenMask = (1 << pfd.cGreenBits) - 1;
+ int blueMask = (1 << pfd.cBlueBits) - 1;
+ int i;
+
+ for (i=0; i<paletteSize; ++i) {
+ pPal->palPalEntry[i].peRed =
+ (((i >> pfd.cRedShift) & redMask) * 255) / redMask;
+ pPal->palPalEntry[i].peGreen =
+ (((i >> pfd.cGreenShift) & greenMask) * 255) / greenMask;
+ pPal->palPalEntry[i].peBlue =
+ (((i >> pfd.cBlueShift) & blueMask) * 255) / blueMask;
+ pPal->palPalEntry[i].peFlags = 0;
+ }
+ }
+
+ hPalette = CreatePalette(pPal);
+ free(pPal);
+
+ if (hPalette) {
+ SelectPalette(hDC, hPalette, FALSE);
+ RealizePalette(hDC);
+ }
+}
+
+LRESULT APIENTRY
+WndProc(
+ HWND hWnd,
+ UINT message,
+ WPARAM wParam,
+ LPARAM lParam)
+{
+ switch (message) {
+ case WM_CREATE:
+ /* initialize OpenGL rendering */
+ hDC = GetDC(hWnd);
+ setupPixelFormat(hDC);
+ setupPalette(hDC);
+ hGLRC = wglCreateContext(hDC);
+ wglMakeCurrent(hDC, hGLRC);
+ init();
+ return 0;
+ case WM_DESTROY:
+ /* finish OpenGL rendering */
+ if (hGLRC) {
+ wglMakeCurrent(NULL, NULL);
+ wglDeleteContext(hGLRC);
+ }
+ if (hPalette) {
+ DeleteObject(hPalette);
+ }
+ ReleaseDC(hWnd, hDC);
+ PostQuitMessage(0);
+ return 0;
+ case WM_SIZE:
+ /* track window size changes */
+ if (hGLRC) {
+ winWidth = (int) LOWORD(lParam);
+ winHeight = (int) HIWORD(lParam);
+ resize();
+ return 0;
+ }
+ case WM_PALETTECHANGED:
+ /* realize palette if this is *not* the current window */
+ if (hGLRC && hPalette && (HWND) wParam != hWnd) {
+ UnrealizeObject(hPalette);
+ SelectPalette(hDC, hPalette, FALSE);
+ RealizePalette(hDC);
+ redraw();
+ break;
+ }
+ break;
+ case WM_QUERYNEWPALETTE:
+ /* realize palette if this is the current window */
+ if (hGLRC && hPalette) {
+ UnrealizeObject(hPalette);
+ SelectPalette(hDC, hPalette, FALSE);
+ RealizePalette(hDC);
+ redraw();
+ return TRUE;
+ }
+ break;
+ case WM_PAINT:
+ {
+ PAINTSTRUCT ps;
+ BeginPaint(hWnd, &ps);
+ if (hGLRC) {
+ redraw();
+ }
+ EndPaint(hWnd, &ps);
+ return 0;
+ }
+ break;
+ case WM_CHAR:
+ /* handle keyboard input */
+ switch ((int)wParam) {
+ case VK_ESCAPE:
+ DestroyWindow(hWnd);
+ return 0;
+ default:
+ break;
+ }
+ break;
+ default:
+ break;
+ }
+ return DefWindowProc(hWnd, message, wParam, lParam);
+}
+
+int APIENTRY
+WinMain(
+ HINSTANCE hCurrentInst,
+ HINSTANCE hPreviousInst,
+ LPSTR lpszCmdLine,
+ int nCmdShow)
+{
+ WNDCLASS wndClass;
+ HWND hWnd;
+ MSG msg;
+
+ /* register window class */
+ wndClass.style = CS_HREDRAW | CS_VREDRAW;
+ wndClass.lpfnWndProc = WndProc;
+ wndClass.cbClsExtra = 0;
+ wndClass.cbWndExtra = 0;
+ wndClass.hInstance = hCurrentInst;
+ wndClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
+ wndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
+ wndClass.hbrBackground = GetStockObject(BLACK_BRUSH);
+ wndClass.lpszMenuName = NULL;
+ wndClass.lpszClassName = className;
+ RegisterClass(&wndClass);
+
+ /* create window */
+ hWnd = CreateWindow(
+ className, windowName,
+ WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS,
+ winX, winY, winWidth, winHeight,
+ NULL, NULL, hCurrentInst, NULL);
+
+ /* display window */
+ ShowWindow(hWnd, nCmdShow);
+ UpdateWindow(hWnd);
+
+ /* process messages */
+ while (GetMessage(&msg, NULL, 0, 0) == TRUE) {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+ return msg.wParam;
+}
+
\ No newline at end of file diff --git a/demos/natives/bc5/cube.ide b/demos/natives/bc5/cube.ide Binary files differnew file mode 100644 index 0000000..d2fab99 --- /dev/null +++ b/demos/natives/bc5/cube.ide diff --git a/demos/natives/bc5/testGL1.c b/demos/natives/bc5/testGL1.c new file mode 100644 index 0000000..b0094f1 --- /dev/null +++ b/demos/natives/bc5/testGL1.c @@ -0,0 +1,224 @@ +
+
+
+
+ #include <windows.h>
+
+ #include <stdio.h>
+ #include <stdlib.h>
+
+#include <GL/gl.h>
+#include <GL/glut.h>
+
+double width = 250;
+double height = 250;
+double fps = 25.0;
+
+ static float lmodel_twoside[] =
+ {GL_FALSE};
+ static float lmodel_local[] =
+ {GL_FALSE};
+ static float lmodel_ambient[] =
+ {0.0, 0.0, 0.0, 0.0};
+
+void CylinderDraw( )
+{
+ glBegin( GL_TRIANGLE_STRIP );
+ glNormal3f ( 1.0, 0.0, -5.0 );
+ glVertex3f ( 1.0, 0.0, -5.0 );
+ glNormal3f ( 1.0, 0.0, -5.0 );
+ glVertex3f (1.000000, 0.000000, 5.000000);
+ glNormal3f (0.707107, 0.707107, -5.000000);
+ glVertex3f (0.707107, 0.707107, -5.000000);
+ glNormal3f (0.707107, 0.707107, -5.000000);
+ glVertex3f (0.707107, 0.707107, 5.000000);
+ glNormal3f (0.000000, 1.000000, -5.000000);
+ glVertex3f (0.000000, 1.000000, -5.000000);
+ glNormal3f (0.000000, 1.000000, -5.000000);
+ glVertex3f (0.000000, 1.000000, 5.000000);
+ glNormal3f (-0.707107, 0.707107, -5.00000);
+ glVertex3f (-0.707107, 0.707107, -5.00000);
+ glNormal3f (-0.707107, 0.707107, -5.00000);
+ glVertex3f (-0.707107, 0.707107, 5.00000);
+ glNormal3f (-1.000000, 0.000000, -5.000000);
+ glVertex3f (-1.000000, 0.000000, -5.000000);
+ glNormal3f (-1.000000, 0.000000, -5.000000);
+ glVertex3f (-1.000000, 0.000000, 5.00000);
+ glNormal3f (-0.707107, -0.707107, -5.000000);
+ glVertex3f (-0.707107, -0.707107, -5.000000);
+ glNormal3f (-0.707107, -0.707107, -5.000000);
+ glVertex3f (-0.707107, -0.707107, 5.00000);
+ glNormal3f (0.000000, -1.000000, -5.000000);
+ glVertex3f (0.000000, -1.000000, -5.000000);
+ glNormal3f (0.000000, -1.000000, -5.000000);
+ glVertex3f (0.000000, -1.000000, 5.00000);
+ glNormal3f (0.707107, -0.707107, -5.00000);
+ glVertex3f (0.707107, -0.707107, -5.00000);
+ glNormal3f (0.707107, -0.707107, -5.00000);
+ glVertex3f (0.707107, -0.707107, 5.000000);
+ glNormal3f (1.000000, 0.000000, -5.00000);
+ glVertex3f (1.000000, 0.000000, -5.00000);
+ glNormal3f (1.000000, 0.000000, -5.00000);
+ glVertex3f (1.000000, 0.000000, 5.00000);
+ glEnd();
+}
+
+void reshape(int width, int height)
+{
+ double fov = 45.0,
+ aspect = width / height,
+ near_ = 1.0,
+ far_ = 200.0;
+
+ glViewport( 0, 0, width, height );
+
+ glMatrixMode( GL_PROJECTION );
+ glLoadIdentity();
+
+ gluPerspective( fov, aspect, near_, far_ );
+
+ glMatrixMode( GL_MODELVIEW );
+ glLoadIdentity();
+
+}
+
+void display()
+{
+ static int FrameStep = 0;
+
+ glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
+ glPushMatrix();
+ glTranslatef( 0.0, 0.0, -65.0 );
+ glRotatef( 40.0+(2*FrameStep), 0.0, 0.0, 1.0 );
+ glRotatef( 190.0+(2*FrameStep), 0.0, 1.0, 0.0 );
+ glRotatef( 200.0+(FrameStep*2), 1.0, 0.0, 0.0 );
+ glPushMatrix();
+ glScalef( 1.0, 1.0, 10.0 );
+ CylinderDraw( );
+ glPopMatrix();
+ glPushMatrix();
+ glRotatef( 90.0, 0.0, 1.0, 0.0 );
+ glScalef( 1.0, 1.0, 10.0 );
+ CylinderDraw( );
+ glPopMatrix();
+ glPushMatrix();
+ glRotatef( 90.0, 1.0, 0.0, 0.0 );
+ glScalef( 1.0, 1.0, 10.0 );
+ CylinderDraw( );
+ glPopMatrix();
+ glPopMatrix();
+
+ glutSwapBuffers();
+ /* glFlush(); */
+
+ FrameStep++;
+
+ if(FrameStep>100000) FrameStep=0;
+
+}
+
+void init()
+{
+ double fov = 45.0;
+ double aspect = width / height ;
+ double near_ = 1.0;
+ double far_ = 200.0;
+ float lightArr[4];
+ float farr[4];
+
+ /* initialize the widget */
+ glClearColor( 0.8f, 0.8f, 1.0f, 1.0f );
+ glFrontFace( GL_CW );
+ glEnable( GL_DEPTH_TEST );
+
+ glViewport( 0, 0, width, height );
+
+ glMatrixMode( GL_PROJECTION );
+ glLoadIdentity();
+
+ gluPerspective( fov, aspect, near_, far_ );
+
+ /* render three rotated cylinders */
+ glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
+
+ glMatrixMode( GL_MODELVIEW );
+ glLoadIdentity();
+
+ /* enable lighting */
+ lightArr[0] = 1.0f; lightArr[1] = 1.0f;
+ lightArr[2] = 1.0f; lightArr[3] = 1.0f;
+ glLightfv( GL_LIGHT0, GL_DIFFUSE, lightArr );
+ lightArr[0] = 90.0f; lightArr[1] = 90.0f;
+ lightArr[2] = 0.0f; lightArr[3] = 0.0f;
+ glLightfv( GL_LIGHT0, GL_POSITION, lightArr );
+ lightArr[0] = 0.1f; lightArr[1] = 0.1f;
+ lightArr[2] = 0.1f; lightArr[3] = 1.0f;
+ glLightfv( GL_LIGHT0, GL_AMBIENT, lightArr );
+ glEnable( GL_LIGHT0 );
+
+ /*
+ glLightModelfv(GL_LIGHT_MODEL_LOCAL_VIEWER, lmodel_local);
+ glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient);
+ */
+ glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, 1);
+ glEnable( GL_LIGHTING );
+
+ /*
+ glLightModelfv(GL_LIGHT_MODEL_LOCAL_VIEWER, lmodel_local);
+ glLightModelfv(GL_LIGHT_MODEL_TWO_SIDE, lmodel_twoside);
+ glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient);
+ glEnable( GL_LIGHTING );
+ */
+
+
+ glMaterialf( GL_FRONT, GL_SHININESS, 30.0f );
+
+ farr[0] = 0.0f; farr[1] = 0.0f; farr[2] = 0.0f; farr[3] = 1.0f;
+ glMaterialfv( GL_FRONT, GL_SPECULAR, farr );
+
+ farr[0] = 0.0f; farr[1] = 1.0f; farr[2] = 0.0f; farr[3] = 1.0f;
+ glMaterialfv( GL_FRONT, GL_DIFFUSE, farr );
+
+ glMaterialf( GL_BACK, GL_SHININESS, 50.0f );
+
+ farr[0] = 0.0f; farr[1] = 0.0f; farr[2] = 1.0f; farr[3] = 1.0f;
+ glMaterialfv( GL_BACK, GL_SPECULAR, farr );
+
+ farr[0] = 1.0f; farr[1] = 1.0f; farr[2] = 0.0f; farr[3] = 1.0f;
+ glMaterialfv( GL_BACK, GL_DIFFUSE, farr );
+
+}
+
+void idle()
+{
+ glutPostRedisplay();
+}
+
+int main( int argc, char **argv)
+{
+ fprintf(stderr,"1\n");
+ if(argc>2 && strcmp(argv[1], "-fps")==0)
+ {
+ fprintf(stderr,"2\n");
+ fps = atof(argv[2]);
+ argc-=2;
+ argv+=2;
+ }
+ fprintf(stderr, "Frame Per Secounds %d\n ( will be ignored this time )\n", fps);
+
+ glutInit(&argc, argv);
+ glutInitDisplayMode ( GLUT_DOUBLE
+ | GLUT_DEPTH
+ | GLUT_RGBA
+ );
+ glutInitWindowSize(width,height);
+ glutInitWindowPosition(100,100);
+ glutCreateWindow("OpenGL GLUT/NATIVE");
+ init();
+ glutDisplayFunc(display);
+ glutReshapeFunc(reshape);
+ glutIdleFunc(idle);
+ glutMainLoop();
+ return 0;
+}
+
diff --git a/demos/natives/bc5/testGL1.ide b/demos/natives/bc5/testGL1.ide Binary files differnew file mode 100644 index 0000000..d2fab99 --- /dev/null +++ b/demos/natives/bc5/testGL1.ide diff --git a/demos/natives/wgl.c b/demos/natives/wgl.c new file mode 100644 index 0000000..15119e8 --- /dev/null +++ b/demos/natives/wgl.c @@ -0,0 +1,517 @@ +/***************************************************************** + + Xmame OpenGL driver + + Written based on the x11 driver by Mike Oliphant - [email protected] + + http://www.ling.ed.ac.uk/~oliphant/glmame + + This code may be used and distributed under the terms of the + Mame license + +*****************************************************************/ +/* pretend we're x11.c otherwise display and a few other crucial things don't + get declared */ +#define __X11_C_ +#define __XOPENGL_C_ + +#define RRand(range) (random()%range) + +#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#include <windowsx.h>
+#include <assert.h>
+#include <string.h>
+#include <excpt.h>
+#include "common.h"
+#include "usrintrf.h"
+#include "osdepend.h"
+#include "mame.h"
+#include "driver.h"
+#include "MAME32.h"
+#include "Display.h"
+#include "Sound.h"
+#include "Keyboard.h"
+#include "Joystick.h"
+#include "Trak.h"
+#include "resource.h"
+#include "M32Util.h"
+
+#include "wgl.h" +
+/*
+#ifndef NOSEAL
+#include "SealSound.h" /* For sound devices.
+#endif
+*/
+
+struct GameOptions mame_options;
+static void MamePlayGame(); +static int page_index;
+static game_data_type* game_data;
+static int game_count;
+
+static int last_sort = 0;
+
+/* global data--know where to send messages */
+static BOOL in_emulation;
+
+/* quit after game */
+static BOOL quit;
+
+/* idle work at startup */
+static BOOL idle_work;
+static int game_index;
+ +int winwidth=640; +int winheight=480; +float fxgamma=1.0; + +static HDC thisWin;
+static HWND thisHwnd;
+/*
+static wglWnd thisCwnd;
+*/
+static HGLRC cx;
+ +static int fx=0; +static int fxwin=0; +extern int screendirty; +extern int doublebuffer; +extern int dodepth; + +/***************************************************************************
+ Function prototypes
+ ***************************************************************************/
+
+static LRESULT CALLBACK MAME32_MessageProc(HWND, UINT, WPARAM, LPARAM);
+static HWND MAME32_CreateWindow(void);
+static void MAME32_ProcessMessages(void);
+static BOOL MAME32_PumpAndReturnMessage(MSG* pMsg);
+static void MAME32_Quit(void);
+static BOOL OnMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, LRESULT* pResult);
+static void OnActivateApp(HWND hWnd, BOOL fActivate, DWORD dwThreadId);
+static void OnSysCommand(HWND hWnd, UINT cmd, int x, int y);
+static void OnClose(HWND hWnd);
+
+/***************************************************************************
+ External variables
+ ***************************************************************************/
+
+/*
+struct tMAME32App MAME32App =
+{
+ { NULL }, /* m_hwndUI
+ { NULL }, /* m_hWnd
+ { "MAME32" }, /* m_pName
+ { FALSE }, /* m_bIsInitialized
+ { FALSE }, /* m_bIsActive
+ { FALSE }, /* m_bPaused
+ { FALSE }, /* m_bMMXDetected
+ { FALSE }, /* m_bUseAIMouse
+ { NULL }, /* m_pDisplay
+ { NULL }, /* m_pSound
+ { NULL }, /* m_pKeyboard
+ { NULL }, /* m_pJoystick
+ { NULL }, /* m_pTrak
+ { NULL }, /* m_pFMSynth
+
+ { MAME32_CreateWindow }, /* CreateMAMEWindow
+ { MAME32_ProcessMessages }, /* ProcessMessages
+ { MAME32_PumpAndReturnMessage }, /* PumpAndReturnMessage
+ { MAME32_Quit }, /* Quit
+ { NULL } /* detect MMX
+};
+*/
+
+/***************************************************************************
+ Internal structures
+ ***************************************************************************/
+
+/***************************************************************************
+ Internal variables
+ ***************************************************************************/
+
+static BOOL auto_pause;
+
+/***************************************************************************
+ External functions
+ ***************************************************************************/
+
+/*
+void MAME32App_init(options_type *options)
+{
+ MAME32App.m_hWnd = NULL;
+
+ MAME32App.m_bIsInitialized = FALSE;
+ MAME32App.m_bIsActive = FALSE;
+ MAME32App.m_bIsPaused = FALSE;
+
+ MAME32App.m_pDisplay = NULL;
+ MAME32App.m_pSound = NULL;
+ MAME32App.m_pKeyboard = NULL;
+ MAME32App.m_pJoystick = NULL;
+ MAME32App.m_pTrak = NULL;
+ MAME32App.m_pFMSynth = NULL;
+
+ auto_pause = options->auto_pause;
+
+ /*
+ Machine->scrbitmap is not initialized in the mame source
+ until after the call to osd_create_display().
+ This causes a problem if osd_create_display() detects an error,
+ then shows the error message box, which causes focus to change,
+ which causes OnPause() to be called, which uses Machine->scrbitmap.
+ Whew. So it needs to be set to NULL so it doesn't crash in OnPause().
+ /
+ Machine->scrbitmap = NULL;
+}
+*/
+
+
+
+/***************************************************************************
+ Internal OPENGL functions
+ ***************************************************************************/
+
+// Color Palette handle
+HPALETTE hPalette = NULL;
+// Set Pixel Format function - forward declaration
+void SetDCPixelFormat(HDC hDC);
+HPALETTE GetOpenGLPalette(HDC hDC);
+HGLRC tempRC;
+
+static HGLRC get_GC( HDC hDC )
+{
+ if( hDC == 0 )
+ return 0; /* printf( "get_GC: Error, HDC is zero\n"); */
+
+ // Select the pixel format
+ SetDCPixelFormat(hDC);
+
+ // Create palette if needed
+ hPalette = GetOpenGLPalette(hDC);
+
+ tempRC = wglCreateContext( hDC );
+
+ /* check if the context could be created */
+ if( tempRC == NULL ) {
+ /* fprintf(stderr, "getGC context could NOT be created \n"); */
+ return( 0 );
+ }
+
+ /* associated the context with the X window */
+ if( wglMakeCurrent( hDC, tempRC ) == FALSE) {
+ wglDeleteContext( tempRC );
+ return( 0 );
+ }
+
+ return tempRC;
+}
+
+// Select the pixel format for a given device context
+void SetDCPixelFormat(HDC hDC)
+{
+ int nPixelFormat=0;
+
+ static PIXELFORMATDESCRIPTOR pfd = {
+ sizeof(PIXELFORMATDESCRIPTOR), // Size of this structure
+ 1, // Version of this structure
+ PFD_DRAW_TO_WINDOW | // Draw to Window (not to bitmap)
+ PFD_SUPPORT_OPENGL | // Support OpenGL calls in window
+ PFD_DOUBLEBUFFER, // Double buffered
+ PFD_TYPE_RGBA, // RGBA Color mode
+ 24, // Want 24bit color
+ 0,0,0,0,0,0, // Not used to select mode
+ 0,0, // Not used to select mode
+ 0,0,0,0,0, // Not used to select mode
+ 32, // Size of depth buffer
+ 0, // Not used to select mode
+ 0, // Not used to select mode
+ PFD_MAIN_PLANE, // Draw in main plane
+ 0, // Not used to select mode
+ 0,0,0 }; // Not used to select mode
+
+ // Choose a pixel format that best matches that described in pfd
+ nPixelFormat = ChoosePixelFormat(hDC, &pfd);
+
+ // Set the pixel format for the device context
+ if(SetPixelFormat(hDC, nPixelFormat, &pfd)==FALSE)
+ MessageBox(thisHwnd, "could not set PixelFormat", "ERROR",
+ MB_OK|MB_ICONERROR);
+
+}
+
+
+// If necessary, creates a 3-3-2 palette for the device context listed.
+HPALETTE GetOpenGLPalette(HDC hDC)
+{
+ HPALETTE hRetPal = NULL; // Handle to palette to be created
+ PIXELFORMATDESCRIPTOR pfd; // Pixel Format Descriptor
+ LOGPALETTE *pPal; // Pointer to memory for logical palette
+ int nPixelFormat; // Pixel format index
+ int nColors; // Number of entries in palette
+ int i; // Counting variable
+ BYTE RedRange,GreenRange,BlueRange;
+ // Range for each color entry (7,7,and 3)
+
+
+ // Get the pixel format index and retrieve the pixel format description
+ nPixelFormat = GetPixelFormat(hDC);
+ DescribePixelFormat(hDC, nPixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &pfd);
+
+ // Does this pixel format require a palette? If not, do not create a
+ // palette and just return NULL
+ if(!(pfd.dwFlags & PFD_NEED_PALETTE))
+ return NULL;
+
+ // Number of entries in palette. 8 bits yeilds 256 entries
+ nColors = 1 << pfd.cColorBits;
+
+ // Allocate space for a logical palette structure plus all the palette entries
+ pPal = (LOGPALETTE*)malloc(sizeof(LOGPALETTE) + nColors*sizeof(PALETTEENTRY));
+
+ // Fill in palette header
+ pPal->palVersion = 0x300; // Windows 3.0
+ pPal->palNumEntries = nColors; // table size
+
+ // Build mask of all 1's. This creates a number represented by having
+ // the low order x bits set, where x = pfd.cRedBits, pfd.cGreenBits, and
+ // pfd.cBlueBits.
+ RedRange = (1 << pfd.cRedBits) -1;
+ GreenRange = (1 << pfd.cGreenBits) - 1;
+ BlueRange = (1 << pfd.cBlueBits) -1;
+
+ // Loop through all the palette entries
+ for(i = 0; i < nColors; i++)
+ {
+ // Fill in the 8-bit equivalents for each component
+ pPal->palPalEntry[i].peRed = (i >> pfd.cRedShift) & RedRange;
+ pPal->palPalEntry[i].peRed = (unsigned char)(
+ (double) pPal->palPalEntry[i].peRed * 255.0 / RedRange);
+
+ pPal->palPalEntry[i].peGreen = (i >> pfd.cGreenShift) & GreenRange;
+ pPal->palPalEntry[i].peGreen = (unsigned char)(
+ (double)pPal->palPalEntry[i].peGreen * 255.0 / GreenRange);
+
+ pPal->palPalEntry[i].peBlue = (i >> pfd.cBlueShift) & BlueRange;
+ pPal->palPalEntry[i].peBlue = (unsigned char)(
+ (double)pPal->palPalEntry[i].peBlue * 255.0 / BlueRange);
+
+ pPal->palPalEntry[i].peFlags = (unsigned char) NULL;
+ }
+
+
+ // Create the palette
+ hRetPal = CreatePalette(pPal);
+
+ // Go ahead and select and realize the palette for this device context
+ SelectPalette(hDC,hRetPal,FALSE);
+ RealizePalette(hDC);
+
+ // Free the memory used for the logical palette structure
+ free(pPal);
+
+ // Return the handle to the new palette
+ return hRetPal;
+}
+
+
+/***************************************************************************
+ Internal functions
+ ***************************************************************************/
+
+/* Create display */ + +static BOOL Win32UI_init(HINSTANCE hInstance, LPSTR lpCmdLine, int nCmdShow)
+{
+ static BOOL bRegistered = FALSE;
+
+ if (bRegistered == FALSE)
+ {
+ WNDCLASS WndClass;
+
+ WndClass.style = CS_SAVEBITS | CS_BYTEALIGNCLIENT | CS_OWNDC;
+ WndClass.lpfnWndProc = MAME32_MessageProc;
+ WndClass.cbClsExtra = 0;
+ WndClass.cbWndExtra = 0;
+ WndClass.hInstance = hInstance;
+ WndClass.hIcon = LoadIcon(hInstance, MAKEINTATOM(IDI_MAME32_ICON));
+ WndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
+ WndClass.hbrBackground = (HBRUSH)GetStockObject(NULL_BRUSH);
+ WndClass.lpszMenuName = NULL;
+ WndClass.lpszClassName = (LPCSTR)"classMAME32";
+
+ if (RegisterClass(&WndClass) == 0)
+ return FALSE;
+ bRegistered = TRUE;
+ }
+
+ thisHwnd = CreateWindowEx(0,
+ "classMAME32",
+ "WGLMAME" ,
+ WS_OVERLAPPEDWINDOW & ~WS_THICKFRAME | WS_BORDER,
+ CW_USEDEFAULT,
+ CW_USEDEFAULT,
+ 640, 480,
+ NULL,
+ NULL,
+ hInstance,
+ NULL);
+
+ ShowWindow(thisHwnd, nCmdShow);
+
+ /* thisCwnd.attach(thisHwnd); */
+ thisWin = GetDC(thisHwnd);
+
+ wglMakeCurrent(NULL, NULL);
+
+ /* get the graphics context for this widget */
+ if( (cx = get_GC( thisWin )) == 0 )
+ {
+ MessageBox(thisHwnd, "could not create GLContext", "ERROR",
+ MB_OK|MB_ICONERROR);
+
+ } else {
+ MessageBox(thisHwnd, "could create GLContext", "OK", MB_OK);
+ }
+
+ SetFocus(thisHwnd);
+
+ return thisHwnd!=NULL;
+}
+
+static LRESULT CALLBACK MAME32_MessageProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
+{
+ LRESULT Result = 0;
+ HDC hdc = 0;
+
+ switch(Msg)
+ {
+ case WM_DESTROY:
+ PostQuitMessage(0);
+ return 0L;
+
+ case WM_QUIT:
+ OnClose(thisHwnd);
+ return 0;
+
+ case WM_PAINT:
+ hdc = (HDC) wParam;
+ return DefWindowProc(hWnd, Msg, wParam, lParam);
+ }
+ return DefWindowProc(hWnd, Msg, wParam, lParam);
+}
+
+
+static void OnClose(HWND hWnd)
+{
+ /* Don't call DestroyWindow, it will be called by osd_exit. */
+ wglMakeCurrent(NULL, NULL);
+ DestroyWindow(thisHwnd);
+}
+ +
+static BOOL idle_work;
+
+
+int WINAPI WinMain(HINSTANCE hInstance,
+ HINSTANCE hPrevInstance,
+ LPSTR lpCmdLine,
+ int nCmdShow)
+{
+ MSG msg;
+
+ if (!Win32UI_init(hInstance, lpCmdLine, nCmdShow))
+ {
+ MessageBox(thisHwnd, "could not create window ...", "ERROR",
+ MB_OK|MB_ICONERROR);
+ OnClose(thisHwnd);
+ return 1;
+ }
+
+ /* Set the samplerate to 0 if sound is disabled,
+ this should notify mame not to "render" it (speed improvement) */
+ Machine->sample_rate = 0;
+ mame_options.samplerate = 0;
+
+ /*
+ Simplified MFC Run() alg. See mfc/src/thrdcore.cpp.
+ */
+ /* phase2: pump messages while available */
+ while (GetMessage(&msg, NULL, 0, 0))
+ {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+
+ return 0;
+}
+
+
+void MamePlayGame()
+{
+ char buf[1000];
+ int index = 0;
+
+ if (run_game(index ,&mame_options) != 0)
+ {
+ const struct RomModule *romp = drivers[index]->rom;
+
+ /* This needs to be changed to use a window with a scrollbar
+ * because the list can be too large to fit on the screen.
+ */
+ sprintf(buf, "Unable to initialize machine emulation.\r\n\r\n"
+ "Most likely you have a corrupt ROM file.\r\n"
+ "The following files must exist in the specified\r\n"
+ "directory or .zip file for %s to run.\r\n\r\n",
+ drivers[index]->description);
+
+ sprintf(buf + strlen(buf), "Directory:\r\n");
+ GetCurrentDirectory(sizeof(buf) - strlen(buf), buf + strlen(buf));
+ sprintf(buf + strlen(buf), "\\%s\r\n\r\n", drivers[index]->name);
+ sprintf(buf + strlen(buf), "or .zip file:\r\n");
+ GetCurrentDirectory(sizeof(buf) - strlen(buf), buf + strlen(buf));
+ sprintf(buf + strlen(buf), "\\roms\\%s.zip\r\n\r\n", drivers[index]->name);
+
+ sprintf(buf + strlen(buf), "Files:\r\n");
+ while (romp->name || romp->offset || romp->length)
+ {
+ romp++; /* skip memory region definition */
+
+ while (romp->length)
+ {
+ char name[100];
+ int length;
+
+ sprintf(name, romp->name, drivers[index]->name);
+
+ length = 0;
+
+ do
+ {
+ /* ROM_RELOAD */
+ if (romp->name == (char *)-1)
+ length = 0; /* restart */
+
+ length += romp->length & ~0x80000000;
+
+ romp++;
+ } while (romp->length && (romp->name == 0 || romp->name == (char *)-1));
+
+ sprintf(buf + strlen(buf), "%-12s\t%u bytes\n", name, length);
+ }
+ }
+
+ MessageBox(thisHwnd, buf, "MAME32 Error", MB_OK | MB_ICONERROR);
+ }
+
+ in_emulation = FALSE;
+
+ if (quit)
+ {
+ PostMessage(thisHwnd, WM_CLOSE, 0, 0);
+ return;
+ }
+
+}
diff --git a/demos/natives/wgl.h b/demos/natives/wgl.h new file mode 100644 index 0000000..5ebe096 --- /dev/null +++ b/demos/natives/wgl.h @@ -0,0 +1,81 @@ +/***************************************************************************
+
+ M.A.M.E.32 - Multiple Arcade Machine Emulator for Win32
+ Win32 Portions Copyright (C) 1997-98 Michael Soderstrom and Chris Kirmse
+
+ This file is part of MAME32, and may only be used, modified and
+ distributed under the terms of the MAME license, in "readme.txt".
+ By continuing to use, modify or distribute this file you indicate
+ that you have read the license and understand and accept it fully.
+
+ ***************************************************************************/
+
+#ifndef __MAME32_H__
+#define __MAME32_H__
+
+#include <math.h>
+/*JAU #include <X11/cursorfont.h> */
+#include <windows.h>
+#include <GL/gl.h>
+#include <GL/glu.h>
+#include <wingdi.h>
+
+
+#define HANDLE_MESSAGE(hwnd, message, fn) \
+ case (message): \
+ { \
+ *pResult = HANDLE_##message((hwnd), (wParam), (lParam), (fn)); \
+ return TRUE; \
+ }
+
+#define PEEK_MESSAGE(hwnd, message, fn) \
+ case (message): \
+ { \
+ *pResult = HANDLE_##message((hwnd), (wParam), (lParam), (fn)); \
+ return FALSE; \
+ }
+
+/*
+struct tMAME32App
+{
+ HWND m_hwndUI;
+ HWND m_hWnd;
+ const char* m_Name;
+
+ BOOL m_bIsInitialized;
+ BOOL m_bIsActive;
+ BOOL m_bIsPaused;
+
+ BOOL m_bMMXDetected;
+
+ TRUE if using m_pTrak for standard analog inputs,
+ FALSE if using m_pJoystick for standard analog inputs.
+ BOOL m_bUseAIMouse;
+
+ struct OSDDisplay* m_pDisplay;
+ struct OSDSound* m_pSound;
+ struct OSDKeyboard* m_pKeyboard;
+ struct OSDJoystick* m_pJoystick;
+ struct OSDTrak* m_pTrak;
+
+ struct OSDFMSynth* m_pFMSynth;
+
+ HWND (*CreateMAMEWindow)(void);
+ void (*ProcessMessages)(void);
+ BOOL (*PumpAndReturnMessage)(MSG* pMsg);
+ void (*Quit)(void);
+ BOOL (*DetectMMX)(void);
+};
+
+extern struct tMAME32App MAME32App;
+
+*/
+
+/*
+class wglWnd : CWnd
+{
+}
+*/
+
+
+#endif
diff --git a/demos/natives/x11/cube.c b/demos/natives/x11/cube.c new file mode 100644 index 0000000..6f2fd57 --- /dev/null +++ b/demos/natives/x11/cube.c @@ -0,0 +1,95 @@ +
+/* Copyright (c) Mark J. Kilgard, 1997. */
+
+/* This program is freely distributable without licensing fees
+ and is provided without guarantee or warrantee expressed or
+ implied. This program is -not- in the public domain. */
+
+/* This program was requested by Patrick Earl; hopefully someone else
+ will write the equivalent Direct3D immediate mode program. */
+
+#include <GL/glut.h>
+
+GLfloat light_diffuse[] = {1.0, 0.0, 0.0, 1.0}; /* Red diffuse light. */
+GLfloat light_position[] = {1.0, 1.0, 1.0, 0.0}; /* Infinite light location. */
+GLfloat n[6][3] = { /* Normals for the 6 faces of a cube. */
+ {-1.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, {1.0, 0.0, 0.0},
+ {0.0, -1.0, 0.0}, {0.0, 0.0, 1.0}, {0.0, 0.0, -1.0} };
+GLint faces[6][4] = { /* Vertex indices for the 6 faces of a cube. */
+ {0, 1, 2, 3}, {3, 2, 6, 7}, {7, 6, 5, 4},
+ {4, 5, 1, 0}, {5, 6, 2, 1}, {7, 4, 0, 3} };
+GLfloat v[8][3]; /* Will be filled in with X,Y,Z vertexes. */
+
+void
+drawBox(void)
+{
+ int i;
+
+ for (i = 0; i < 6; i++) {
+ glBegin(GL_QUADS);
+ glNormal3fv(&n[i][0]);
+ glVertex3fv(&v[faces[i][0]][0]);
+ glVertex3fv(&v[faces[i][1]][0]);
+ glVertex3fv(&v[faces[i][2]][0]);
+ glVertex3fv(&v[faces[i][3]][0]);
+ glEnd();
+ }
+}
+
+void
+display(void)
+{
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ drawBox();
+ glutSwapBuffers();
+}
+
+void
+init(void)
+{
+ /* Setup cube vertex data. */
+ v[0][0] = v[1][0] = v[2][0] = v[3][0] = -1;
+ v[4][0] = v[5][0] = v[6][0] = v[7][0] = 1;
+ v[0][1] = v[1][1] = v[4][1] = v[5][1] = -1;
+ v[2][1] = v[3][1] = v[6][1] = v[7][1] = 1;
+ v[0][2] = v[3][2] = v[4][2] = v[7][2] = 1;
+ v[1][2] = v[2][2] = v[5][2] = v[6][2] = -1;
+
+ /* Enable a single OpenGL light. */
+ glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse);
+ glLightfv(GL_LIGHT0, GL_POSITION, light_position);
+ glEnable(GL_LIGHT0);
+ glEnable(GL_LIGHTING);
+
+ glClearColor( 0.3f, 0.3f, 5.0f, 1.0f );
+
+ /* Use depth buffering for hidden surface elimination. */
+ glEnable(GL_DEPTH_TEST);
+
+ /* Setup the view of the cube. */
+ glMatrixMode(GL_PROJECTION);
+ gluPerspective( /* field of view in degree */ 40.0,
+ /* aspect ratio */ 1.0,
+ /* Z near */ 1.0, /* Z far */ 10.0);
+ glMatrixMode(GL_MODELVIEW);
+ gluLookAt(0.0, 0.0, 5.0, /* eye is at (0,0,5) */
+ 0.0, 0.0, 0.0, /* center is at (0,0,0) */
+ 0.0, 1.0, 0.); /* up is in positive Y direction */
+
+ /* Adjust cube position to be asthetic angle. */
+ glTranslatef(0.0, 0.0, -1.0);
+ glRotatef(60, 1.0, 0.0, 0.0);
+ glRotatef(-20, 0.0, 0.0, 1.0);
+}
+
+int
+main(int argc, char **argv)
+{
+ glutInit(&argc, argv);
+ glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
+ glutCreateWindow("red 3D lighted cube");
+ glutDisplayFunc(display);
+ init();
+ glutMainLoop();
+ return 0; /* ANSI C requires main to return int. */
+}
diff --git a/demos/natives/x11/gears.c b/demos/natives/x11/gears.c new file mode 100644 index 0000000..f1812ae --- /dev/null +++ b/demos/natives/x11/gears.c @@ -0,0 +1,374 @@ +/* $Id$ */ + +/* + * 3-D gear wheels. This program is in the public domain. + * + * Command line options: + * -info print GL implementation information + * + * + * Brian Paul + */ + +/* Conversion to GLUT by Mark J. Kilgard */ + +/* + * $Log$ + * Revision 1.1 2000/11/18 06:54:01 sven + * Initial revision + * + * Revision 1.2 1999/10/21 16:39:06 brianp + * added -info command line option + * + * Revision 1.1.1.1 1999/08/19 00:55:40 jtg + * Imported sources + * + * Revision 3.2 1999/06/03 17:07:36 brianp + * an extra quad was being drawn in front and back faces + * + * Revision 3.1 1998/11/03 02:49:10 brianp + * added fps output + * + * Revision 3.0 1998/02/14 18:42:29 brianp + * initial rev + * + */ + + +#include <math.h> +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <GL/glut.h> + +#ifndef M_PI +#define M_PI 3.14159265 +#endif + +static GLint T0 = 0; +static GLint Frames = 0; + + +/** + + Draw a gear wheel. You'll probably want to call this function when + building a display list since we do a lot of trig here. + + Input: inner_radius - radius of hole at center + outer_radius - radius at center of teeth + width - width of gear + teeth - number of teeth + tooth_depth - depth of tooth + + **/ + +static void +gear(GLfloat inner_radius, GLfloat outer_radius, GLfloat width, + GLint teeth, GLfloat tooth_depth) +{ + GLint i; + GLfloat r0, r1, r2; + GLfloat angle, da; + GLfloat u, v, len; + + r0 = inner_radius; + r1 = outer_radius - tooth_depth / 2.0; + r2 = outer_radius + tooth_depth / 2.0; + + da = 2.0 * M_PI / teeth / 4.0; + + glShadeModel(GL_FLAT); + + glNormal3f(0.0, 0.0, 1.0); + + /* draw front face */ + glBegin(GL_QUAD_STRIP); + for (i = 0; i <= teeth; i++) { + angle = i * 2.0 * M_PI / teeth; + glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5); + glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5); + if (i < teeth) { + glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5); + glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), width * 0.5); + } + } + glEnd(); + + /* draw front sides of teeth */ + glBegin(GL_QUADS); + da = 2.0 * M_PI / teeth / 4.0; + for (i = 0; i < teeth; i++) { + angle = i * 2.0 * M_PI / teeth; + + glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5); + glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), width * 0.5); + glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), width * 0.5); + glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), width * 0.5); + } + glEnd(); + + glNormal3f(0.0, 0.0, -1.0); + + /* draw back face */ + glBegin(GL_QUAD_STRIP); + for (i = 0; i <= teeth; i++) { + angle = i * 2.0 * M_PI / teeth; + glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5); + glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5); + if (i < teeth) { + glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), -width * 0.5); + glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5); + } + } + glEnd(); + + /* draw back sides of teeth */ + glBegin(GL_QUADS); + da = 2.0 * M_PI / teeth / 4.0; + for (i = 0; i < teeth; i++) { + angle = i * 2.0 * M_PI / teeth; + + glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), -width * 0.5); + glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), -width * 0.5); + glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), -width * 0.5); + glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5); + } + glEnd(); + + /* draw outward faces of teeth */ + glBegin(GL_QUAD_STRIP); + for (i = 0; i < teeth; i++) { + angle = i * 2.0 * M_PI / teeth; + + glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5); + glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5); + u = r2 * cos(angle + da) - r1 * cos(angle); + v = r2 * sin(angle + da) - r1 * sin(angle); + len = sqrt(u * u + v * v); + u /= len; + v /= len; + glNormal3f(v, -u, 0.0); + glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), width * 0.5); + glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), -width * 0.5); + glNormal3f(cos(angle), sin(angle), 0.0); + glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), width * 0.5); + glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), -width * 0.5); + u = r1 * cos(angle + 3 * da) - r2 * cos(angle + 2 * da); + v = r1 * sin(angle + 3 * da) - r2 * sin(angle + 2 * da); + glNormal3f(v, -u, 0.0); + glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), width * 0.5); + glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), -width * 0.5); + glNormal3f(cos(angle), sin(angle), 0.0); + } + + glVertex3f(r1 * cos(0), r1 * sin(0), width * 0.5); + glVertex3f(r1 * cos(0), r1 * sin(0), -width * 0.5); + + glEnd(); + + glShadeModel(GL_SMOOTH); + + /* draw inside radius cylinder */ + glBegin(GL_QUAD_STRIP); + for (i = 0; i <= teeth; i++) { + angle = i * 2.0 * M_PI / teeth; + glNormal3f(-cos(angle), -sin(angle), 0.0); + glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5); + glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5); + } + glEnd(); + +} + +static GLfloat view_rotx = 20.0, view_roty = 30.0, view_rotz = 0.0; +static GLint gear1, gear2, gear3; +static GLfloat angle = 0.0; + +static void +draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + glPushMatrix(); + glRotatef(view_rotx, 1.0, 0.0, 0.0); + glRotatef(view_roty, 0.0, 1.0, 0.0); + glRotatef(view_rotz, 0.0, 0.0, 1.0); + + glPushMatrix(); + glTranslatef(-3.0, -2.0, 0.0); + glRotatef(angle, 0.0, 0.0, 1.0); + glCallList(gear1); + glPopMatrix(); + + glPushMatrix(); + glTranslatef(3.1, -2.0, 0.0); + glRotatef(-2.0 * angle - 9.0, 0.0, 0.0, 1.0); + glCallList(gear2); + glPopMatrix(); + + glPushMatrix(); + glTranslatef(-3.1, 4.2, 0.0); + glRotatef(-2.0 * angle - 25.0, 0.0, 0.0, 1.0); + glCallList(gear3); + glPopMatrix(); + + glPopMatrix(); + + glutSwapBuffers(); + + Frames++; + { + GLint t = glutGet(GLUT_ELAPSED_TIME); + if (t - T0 >= 5000) { + GLfloat seconds = (t - T0) / 1000.0; + GLfloat fps = Frames / seconds; + printf("%d frames in %g seconds = %g FPS\n", Frames, seconds, fps); + T0 = t; + Frames = 0; + } + } +} + + +static void +idle(void) +{ + angle += 2.0; + glutPostRedisplay(); +} + +/* change view angle, exit upon ESC */ +/* ARGSUSED1 */ +static void +key(unsigned char k, int x, int y) +{ + switch (k) { + case 'z': + view_rotz += 5.0; + break; + case 'Z': + view_rotz -= 5.0; + break; + case 27: /* Escape */ + exit(0); + break; + default: + return; + } + glutPostRedisplay(); +} + +/* change view angle */ +/* ARGSUSED1 */ +static void +special(int k, int x, int y) +{ + switch (k) { + case GLUT_KEY_UP: + view_rotx += 5.0; + break; + case GLUT_KEY_DOWN: + view_rotx -= 5.0; + break; + case GLUT_KEY_LEFT: + view_roty += 5.0; + break; + case GLUT_KEY_RIGHT: + view_roty -= 5.0; + break; + default: + return; + } + glutPostRedisplay(); +} + +/* new window size or exposure */ +static void +reshape(int width, int height) +{ + GLfloat h = (GLfloat) height / (GLfloat) width; + + glViewport(0, 0, (GLint) width, (GLint) height); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glFrustum(-1.0, 1.0, -h, h, 5.0, 60.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef(0.0, 0.0, -40.0); +} + +static void +init(int argc, char *argv[]) +{ + static GLfloat pos[4] = + {5.0, 5.0, 10.0, 0.0}; + static GLfloat red[4] = + {0.8, 0.1, 0.0, 1.0}; + static GLfloat green[4] = + {0.0, 0.8, 0.2, 1.0}; + static GLfloat blue[4] = + {0.2, 0.2, 1.0, 1.0}; + + glLightfv(GL_LIGHT0, GL_POSITION, pos); + glEnable(GL_CULL_FACE); + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + glEnable(GL_DEPTH_TEST); + + /* make the gears */ + gear1 = glGenLists(1); + glNewList(gear1, GL_COMPILE); + glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red); + gear(1.0, 4.0, 1.0, 20, 0.7); + glEndList(); + + gear2 = glGenLists(1); + glNewList(gear2, GL_COMPILE); + glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green); + gear(0.5, 2.0, 2.0, 10, 0.7); + glEndList(); + + gear3 = glGenLists(1); + glNewList(gear3, GL_COMPILE); + glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue); + gear(1.3, 2.0, 0.5, 10, 0.7); + glEndList(); + + glEnable(GL_NORMALIZE); + + if (argc > 1 && strcmp(argv[1], "-info")==0) { + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION)); + printf("GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR)); + printf("GL_EXTENSIONS = %s\n", (char *) glGetString(GL_EXTENSIONS)); + } +} + +void +visible(int vis) +{ + if (vis == GLUT_VISIBLE) + glutIdleFunc(idle); + else + glutIdleFunc(NULL); +} + +int main(int argc, char *argv[]) +{ + glutInit(&argc, argv); + glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE); + + glutInitWindowPosition(0, 0); + glutInitWindowSize(300, 300); + glutCreateWindow("Gears"); + init(argc, argv); + + glutDisplayFunc(draw); + glutReshapeFunc(reshape); + glutKeyboardFunc(key); + glutSpecialFunc(special); + glutVisibilityFunc(visible); + + glutMainLoop(); + return 0; /* ANSI C requires main to return int. */ +} diff --git a/demos/natives/x11/makeGears.sh b/demos/natives/x11/makeGears.sh new file mode 100755 index 0000000..f7c6f27 --- /dev/null +++ b/demos/natives/x11/makeGears.sh @@ -0,0 +1,3 @@ +#! /bin/sh +gcc -ogears -I/usr/X11R6/include/ gears.c \ + -lGL -lGLU -lglut -L/usr/X11R6/lib -lm diff --git a/demos/natives/x11/makefile b/demos/natives/x11/makefile new file mode 100644 index 0000000..d4e03bb --- /dev/null +++ b/demos/natives/x11/makefile @@ -0,0 +1,30 @@ +# +# Uses: Linux2.0X-glibc-pthreads-mesa3.0pthreads +# + +CC = cc + +CCINCL = -I/usr/local/include -I/usr/X11/include -I/usr/X11R6/include +CCLIBS = -L/usr/X11R6/lib -L/usr/local/lib -L/usr/X11/lib \ + -lGL -lGLU -lglut \ + -lXmu -lXt -lSM -lICE -lXext -lX11 -lXi -lXext -lX11 -lm -lpthread + + +C_APPL_FILES = cube.c olympic.c testGL1.c testGL2.c wave.c + + +.SUFFIXES : .c .o + +.c.o: + $(CC) -c -o $@ $< $(CCINCL) 2>&1 | tee -a errors + $(CC) -o ${@:.o=} $@ $(CCINCL) $(CCLIBS) 2>&1 | tee -a errors + +all: ${C_APPL_FILES:.c=.o} + + +clean: + rm -f *.o *~ errors + +cleanall: clean + rm -f ${C_APPL_FILES:.c=} + diff --git a/demos/natives/x11/makefile.mesa b/demos/natives/x11/makefile.mesa new file mode 100644 index 0000000..9068e08 --- /dev/null +++ b/demos/natives/x11/makefile.mesa @@ -0,0 +1,30 @@ +# +# Uses: Linux2.0X-glibc-pthreads-mesa3.0pthreads +# + +CC = cc + +CCINCL = -I/usr/local/include -I/usr/local/mesa/include -I/usr/X11R6/include +CCLIBS = -L/usr/X11R6/lib -L/usr/local/lib -L/usr/local/mesa/lib \ + -lGL -lGLU -lglut \ + -lXmu -lXt -lSM -lICE -lXext -lX11 -lXi -lXext -lX11 -lm -lpthread + + +C_APPL_FILES = cube.c olympic.c testGL1.c testGL2.c wave.c + + +.SUFFIXES : .c .o + +.c.o: + $(CC) -c -o $@ $< $(CCINCL) 2>&1 | tee -a errors + $(CC) -o ${@:.o=} $@ $(CCINCL) $(CCLIBS) 2>&1 | tee -a errors + +all: ${C_APPL_FILES:.c=.o} + + +clean: + rm -f *.o *~ errors + +cleanall: clean + rm -f ${C_APPL_FILES:.c=} + diff --git a/demos/natives/x11/makefile.x11 b/demos/natives/x11/makefile.x11 new file mode 100644 index 0000000..d4e03bb --- /dev/null +++ b/demos/natives/x11/makefile.x11 @@ -0,0 +1,30 @@ +# +# Uses: Linux2.0X-glibc-pthreads-mesa3.0pthreads +# + +CC = cc + +CCINCL = -I/usr/local/include -I/usr/X11/include -I/usr/X11R6/include +CCLIBS = -L/usr/X11R6/lib -L/usr/local/lib -L/usr/X11/lib \ + -lGL -lGLU -lglut \ + -lXmu -lXt -lSM -lICE -lXext -lX11 -lXi -lXext -lX11 -lm -lpthread + + +C_APPL_FILES = cube.c olympic.c testGL1.c testGL2.c wave.c + + +.SUFFIXES : .c .o + +.c.o: + $(CC) -c -o $@ $< $(CCINCL) 2>&1 | tee -a errors + $(CC) -o ${@:.o=} $@ $(CCINCL) $(CCLIBS) 2>&1 | tee -a errors + +all: ${C_APPL_FILES:.c=.o} + + +clean: + rm -f *.o *~ errors + +cleanall: clean + rm -f ${C_APPL_FILES:.c=} + diff --git a/demos/natives/x11/olympic.c b/demos/natives/x11/olympic.c new file mode 100644 index 0000000..0527d58 --- /dev/null +++ b/demos/natives/x11/olympic.c @@ -0,0 +1,409 @@ +
+/* Copyright (c) Mark J. Kilgard, 1994. */
+
+/**
+ * (c) Copyright 1993, 1994, Silicon Graphics, Inc.
+ * ALL RIGHTS RESERVED
+ * Permission to use, copy, modify, and distribute this software for
+ * any purpose and without fee is hereby granted, provided that the above
+ * copyright notice appear in all copies and that both the copyright notice
+ * and this permission notice appear in supporting documentation, and that
+ * the name of Silicon Graphics, Inc. not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission.
+ *
+ * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
+ * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
+ * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
+ * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
+ * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
+ * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
+ * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
+ * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
+ * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * US Government Users Restricted Rights
+ * Use, duplication, or disclosure by the Government is subject to
+ * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
+ * (c)(1)(ii) of the Rights in Technical Data and Computer Software
+ * clause at DFARS 252.227-7013 and/or in similar or successor
+ * clauses in the FAR or the DOD or NASA FAR Supplement.
+ * Unpublished-- rights reserved under the copyright laws of the
+ * United States. Contractor/manufacturer is Silicon Graphics,
+ * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
+ *
+ * OpenGL(TM) is a trademark of Silicon Graphics, Inc.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+#include <sys/types.h>
+#include <sys/time.h>
+#include <GL/glut.h>
+
+/* Some <math.h> files do not define M_PI... */
+#ifndef M_PI
+#define M_PI 3.141592654
+#endif
+
+extern double drand48(void);
+extern void srand48(long seedval);
+
+#define XSIZE 100
+#define YSIZE 75
+
+#define RINGS 5
+#define BLUERING 0
+#define BLACKRING 1
+#define REDRING 2
+#define YELLOWRING 3
+#define GREENRING 4
+
+#define BACKGROUND 8
+
+enum {
+ BLACK = 0,
+ RED,
+ GREEN,
+ YELLOW,
+ BLUE,
+ MAGENTA,
+ CYAN,
+ WHITE
+};
+
+typedef short Point[2];
+
+GLenum rgb, doubleBuffer, directRender;
+
+unsigned char rgb_colors[RINGS][3];
+int mapped_colors[RINGS];
+float dests[RINGS][3];
+float offsets[RINGS][3];
+float angs[RINGS];
+float rotAxis[RINGS][3];
+int iters[RINGS];
+GLuint theTorus;
+
+void
+FillTorus(float rc, int numc, float rt, int numt)
+{
+ int i, j, k;
+ double s, t;
+ double x, y, z;
+ double pi, twopi;
+
+ pi = M_PI;
+ twopi = 2 * pi;
+
+ for (i = 0; i < numc; i++) {
+ glBegin(GL_QUAD_STRIP);
+ for (j = 0; j <= numt; j++) {
+ for (k = 1; k >= 0; k--) {
+ s = (i + k) % numc + 0.5;
+ t = j % numt;
+
+ x = cos(t * twopi / numt) * cos(s * twopi / numc);
+ y = sin(t * twopi / numt) * cos(s * twopi / numc);
+ z = sin(s * twopi / numc);
+ glNormal3f(x, y, z);
+
+ x = (rt + rc * cos(s * twopi / numc)) * cos(t * twopi / numt);
+ y = (rt + rc * cos(s * twopi / numc)) * sin(t * twopi / numt);
+ z = rc * sin(s * twopi / numc);
+ glVertex3f(x, y, z);
+ }
+ }
+ glEnd();
+ }
+}
+
+float
+Clamp(int iters_left, float t)
+{
+
+ if (iters_left < 3) {
+ return 0.0;
+ }
+ return (iters_left - 2) * t / iters_left;
+}
+
+void
+Idle(void)
+{
+ int i, j;
+ int more = GL_FALSE;
+
+ for (i = 0; i < RINGS; i++) {
+ if (iters[i]) {
+ for (j = 0; j < 3; j++) {
+ offsets[i][j] = Clamp(iters[i], offsets[i][j]);
+ }
+ angs[i] = Clamp(iters[i], angs[i]);
+ iters[i]--;
+ more = GL_TRUE;
+ }
+ }
+ if (more) {
+ glutPostRedisplay();
+ } else {
+ glutIdleFunc(NULL);
+ }
+}
+
+void
+DrawScene(void)
+{
+ int i;
+
+ glPushMatrix();
+
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ gluLookAt(0, 0, 10, 0, 0, 0, 0, 1, 0);
+
+ for (i = 0; i < RINGS; i++) {
+ if (rgb) {
+ glColor3ubv(rgb_colors[i]);
+ } else {
+ glIndexi(mapped_colors[i]);
+ }
+ glPushMatrix();
+ glTranslatef(dests[i][0] + offsets[i][0], dests[i][1] + offsets[i][1],
+ dests[i][2] + offsets[i][2]);
+ glRotatef(angs[i], rotAxis[i][0], rotAxis[i][1], rotAxis[i][2]);
+ glCallList(theTorus);
+ glPopMatrix();
+ }
+
+ glPopMatrix();
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ } else {
+ glFlush();
+ }
+}
+
+float
+MyRand(void)
+{
+ return 10.0 * (drand48() - 0.5);
+}
+
+void
+ReInit(void)
+{
+ int i;
+ float deviation;
+
+ deviation = MyRand() / 2;
+ deviation = deviation * deviation;
+ for (i = 0; i < RINGS; i++) {
+ offsets[i][0] = MyRand();
+ offsets[i][1] = MyRand();
+ offsets[i][2] = MyRand();
+ angs[i] = 260.0 * MyRand();
+ rotAxis[i][0] = MyRand();
+ rotAxis[i][1] = MyRand();
+ rotAxis[i][2] = MyRand();
+ iters[i] = (deviation * MyRand() + 60.0);
+ }
+}
+
+void
+Init(void)
+{
+ int i;
+ float top_y = 1.0;
+ float bottom_y = 0.0;
+ float top_z = 0.15;
+ float bottom_z = 0.69;
+ float spacing = 2.5;
+ static float lmodel_ambient[] =
+ {0.0, 0.0, 0.0, 0.0};
+ static float lmodel_twoside[] =
+ {GL_FALSE};
+ static float lmodel_local[] =
+ {GL_FALSE};
+ static float light0_ambient[] =
+ {0.1, 0.1, 0.1, 1.0};
+ static float light0_diffuse[] =
+ {1.0, 1.0, 1.0, 0.0};
+ static float light0_position[] =
+ {0.8660254, 0.5, 1, 0};
+ static float light0_specular[] =
+ {1.0, 1.0, 1.0, 0.0};
+ static float bevel_mat_ambient[] =
+ {0.0, 0.0, 0.0, 1.0};
+ static float bevel_mat_shininess[] =
+ {40.0};
+ static float bevel_mat_specular[] =
+ {1.0, 1.0, 1.0, 0.0};
+ static float bevel_mat_diffuse[] =
+ {1.0, 0.0, 0.0, 0.0};
+
+ srand48(0x102342);
+ ReInit();
+ for (i = 0; i < RINGS; i++) {
+ rgb_colors[i][0] = rgb_colors[i][1] = rgb_colors[i][2] = 0;
+ }
+ rgb_colors[BLUERING][2] = 255;
+ rgb_colors[REDRING][0] = 255;
+ rgb_colors[GREENRING][1] = 255;
+ rgb_colors[YELLOWRING][0] = 255;
+ rgb_colors[YELLOWRING][1] = 255;
+ mapped_colors[BLUERING] = BLUE;
+ mapped_colors[REDRING] = RED;
+ mapped_colors[GREENRING] = GREEN;
+ mapped_colors[YELLOWRING] = YELLOW;
+ mapped_colors[BLACKRING] = BLACK;
+
+ dests[BLUERING][0] = -spacing;
+ dests[BLUERING][1] = top_y;
+ dests[BLUERING][2] = top_z;
+
+ dests[BLACKRING][0] = 0.0;
+ dests[BLACKRING][1] = top_y;
+ dests[BLACKRING][2] = top_z;
+
+ dests[REDRING][0] = spacing;
+ dests[REDRING][1] = top_y;
+ dests[REDRING][2] = top_z;
+
+ dests[YELLOWRING][0] = -spacing / 2.0;
+ dests[YELLOWRING][1] = bottom_y;
+ dests[YELLOWRING][2] = bottom_z;
+
+ dests[GREENRING][0] = spacing / 2.0;
+ dests[GREENRING][1] = bottom_y;
+ dests[GREENRING][2] = bottom_z;
+
+ theTorus = glGenLists(1);
+ glNewList(theTorus, GL_COMPILE);
+ FillTorus(0.1, 8, 1.0, 25);
+ glEndList();
+
+ glEnable(GL_CULL_FACE);
+ glCullFace(GL_BACK);
+ glEnable(GL_DEPTH_TEST);
+ glClearDepth(1.0);
+
+ if (rgb) {
+ glClearColor(0.5, 0.5, 0.5, 0.0);
+ glLightfv(GL_LIGHT0, GL_AMBIENT, light0_ambient);
+ glLightfv(GL_LIGHT0, GL_DIFFUSE, light0_diffuse);
+ glLightfv(GL_LIGHT0, GL_SPECULAR, light0_specular);
+ glLightfv(GL_LIGHT0, GL_POSITION, light0_position);
+ glEnable(GL_LIGHT0);
+
+ glLightModelfv(GL_LIGHT_MODEL_LOCAL_VIEWER, lmodel_local);
+ glLightModelfv(GL_LIGHT_MODEL_TWO_SIDE, lmodel_twoside);
+ glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient);
+ glEnable(GL_LIGHTING);
+
+ glMaterialfv(GL_FRONT, GL_AMBIENT, bevel_mat_ambient);
+ glMaterialfv(GL_FRONT, GL_SHININESS, bevel_mat_shininess);
+ glMaterialfv(GL_FRONT, GL_SPECULAR, bevel_mat_specular);
+ glMaterialfv(GL_FRONT, GL_DIFFUSE, bevel_mat_diffuse);
+
+ glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
+ glEnable(GL_COLOR_MATERIAL);
+ glShadeModel(GL_SMOOTH);
+ } else {
+ glClearIndex(BACKGROUND);
+ glShadeModel(GL_FLAT);
+ }
+
+ glMatrixMode(GL_PROJECTION);
+ gluPerspective(45, 1.33, 0.1, 100.0);
+ glMatrixMode(GL_MODELVIEW);
+}
+
+void
+Reshape(int width, int height)
+{
+ glViewport(0, 0, width, height);
+}
+
+/* ARGSUSED1 */
+void
+Key(unsigned char key, int x, int y)
+{
+
+ switch (key) {
+ case 27:
+ exit(0);
+ break;
+ case ' ':
+ ReInit();
+ glutIdleFunc(Idle);
+ break;
+ }
+}
+
+GLenum
+Args(int argc, char **argv)
+{
+ GLint i;
+
+ rgb = GL_TRUE;
+ doubleBuffer = GL_TRUE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-ci") == 0) {
+ rgb = GL_FALSE;
+ } else if (strcmp(argv[i], "-rgb") == 0) {
+ rgb = GL_TRUE;
+ } else if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ printf("%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+void
+visible(int vis)
+{
+ if (vis == GLUT_VISIBLE) {
+ glutIdleFunc(Idle);
+ } else {
+ glutIdleFunc(NULL);
+ }
+}
+
+int
+main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInitWindowSize(400, 300);
+ glutInit(&argc, argv);
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+ type = (rgb) ? GLUT_RGB : GLUT_INDEX;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
+ glutInitDisplayMode(type);
+
+ glutCreateWindow("Olympic");
+
+ Init();
+
+ glutReshapeFunc(Reshape);
+ glutKeyboardFunc(Key);
+ glutDisplayFunc(DrawScene);
+
+ glutVisibilityFunc(visible);
+
+ glutMainLoop();
+ return 0; /* ANSI C requires main to return int. */
+}
diff --git a/demos/natives/x11/testGL1.c b/demos/natives/x11/testGL1.c new file mode 100644 index 0000000..71f9ab2 --- /dev/null +++ b/demos/natives/x11/testGL1.c @@ -0,0 +1,222 @@ +
+
+
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <GL/gl.h>
+#include <GL/glut.h>
+
+double width = 250;
+double height = 250;
+double fps = 25.0;
+
+ static float lmodel_twoside[] =
+ {GL_FALSE};
+ static float lmodel_local[] =
+ {GL_FALSE};
+ static float lmodel_ambient[] =
+ {0.0, 0.0, 0.0, 0.0};
+
+void CylinderDraw( )
+{
+ glBegin( GL_TRIANGLE_STRIP );
+ glNormal3f ( 1.0, 0.0, -5.0 );
+ glVertex3f ( 1.0, 0.0, -5.0 );
+ glNormal3f ( 1.0, 0.0, -5.0 );
+ glVertex3f (1.000000, 0.000000, 5.000000);
+ glNormal3f (0.707107, 0.707107, -5.000000);
+ glVertex3f (0.707107, 0.707107, -5.000000);
+ glNormal3f (0.707107, 0.707107, -5.000000);
+ glVertex3f (0.707107, 0.707107, 5.000000);
+ glNormal3f (0.000000, 1.000000, -5.000000);
+ glVertex3f (0.000000, 1.000000, -5.000000);
+ glNormal3f (0.000000, 1.000000, -5.000000);
+ glVertex3f (0.000000, 1.000000, 5.000000);
+ glNormal3f (-0.707107, 0.707107, -5.00000);
+ glVertex3f (-0.707107, 0.707107, -5.00000);
+ glNormal3f (-0.707107, 0.707107, -5.00000);
+ glVertex3f (-0.707107, 0.707107, 5.00000);
+ glNormal3f (-1.000000, 0.000000, -5.000000);
+ glVertex3f (-1.000000, 0.000000, -5.000000);
+ glNormal3f (-1.000000, 0.000000, -5.000000);
+ glVertex3f (-1.000000, 0.000000, 5.00000);
+ glNormal3f (-0.707107, -0.707107, -5.000000);
+ glVertex3f (-0.707107, -0.707107, -5.000000);
+ glNormal3f (-0.707107, -0.707107, -5.000000);
+ glVertex3f (-0.707107, -0.707107, 5.00000);
+ glNormal3f (0.000000, -1.000000, -5.000000);
+ glVertex3f (0.000000, -1.000000, -5.000000);
+ glNormal3f (0.000000, -1.000000, -5.000000);
+ glVertex3f (0.000000, -1.000000, 5.00000);
+ glNormal3f (0.707107, -0.707107, -5.00000);
+ glVertex3f (0.707107, -0.707107, -5.00000);
+ glNormal3f (0.707107, -0.707107, -5.00000);
+ glVertex3f (0.707107, -0.707107, 5.000000);
+ glNormal3f (1.000000, 0.000000, -5.00000);
+ glVertex3f (1.000000, 0.000000, -5.00000);
+ glNormal3f (1.000000, 0.000000, -5.00000);
+ glVertex3f (1.000000, 0.000000, 5.00000);
+ glEnd();
+}
+
+void reshape(int width, int height)
+{
+ double fov = 45.0,
+ aspect = width / height,
+ near_ = 1.0,
+ far_ = 200.0;
+
+ glViewport( 0, 0, width, height );
+
+ glMatrixMode( GL_PROJECTION );
+ glLoadIdentity();
+
+ gluPerspective( fov, aspect, near_, far_ );
+
+ glMatrixMode( GL_MODELVIEW );
+ glLoadIdentity();
+
+}
+
+void display()
+{
+ static int FrameStep = 0;
+
+ glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
+ glPushMatrix();
+ glTranslatef( 0.0, 0.0, -65.0 );
+ glRotatef( 40.0+(2*FrameStep), 0.0, 0.0, 1.0 );
+ glRotatef( 190.0+(2*FrameStep), 0.0, 1.0, 0.0 );
+ glRotatef( 200.0+(FrameStep*2), 1.0, 0.0, 0.0 );
+ glPushMatrix();
+ glScalef( 1.0, 1.0, 10.0 );
+ CylinderDraw( );
+ glPopMatrix();
+ glPushMatrix();
+ glRotatef( 90.0, 0.0, 1.0, 0.0 );
+ glScalef( 1.0, 1.0, 10.0 );
+ CylinderDraw( );
+ glPopMatrix();
+ glPushMatrix();
+ glRotatef( 90.0, 1.0, 0.0, 0.0 );
+ glScalef( 1.0, 1.0, 10.0 );
+ CylinderDraw( );
+ glPopMatrix();
+ glPopMatrix();
+
+ glutSwapBuffers();
+ /* glFlush(); */
+
+ FrameStep++;
+
+ if(FrameStep>100000) FrameStep=0;
+
+}
+
+void init()
+{
+ double fov = 45.0;
+ double aspect = width / height ;
+ double near_ = 1.0;
+ double far_ = 200.0;
+ float lightArr[4];
+ float farr[4];
+
+ /* initialize the widget */
+ glClearColor( 0.8f, 0.8f, 1.0f, 1.0f );
+ glFrontFace( GL_CW );
+ glEnable( GL_DEPTH_TEST );
+
+ glViewport( 0, 0, width, height );
+
+ glMatrixMode( GL_PROJECTION );
+ glLoadIdentity();
+
+ gluPerspective( fov, aspect, near_, far_ );
+
+ /* render three rotated cylinders */
+ glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
+
+ glMatrixMode( GL_MODELVIEW );
+ glLoadIdentity();
+
+ /* enable lighting */
+ lightArr[0] = 1.0f; lightArr[1] = 1.0f;
+ lightArr[2] = 1.0f; lightArr[3] = 1.0f;
+ glLightfv( GL_LIGHT0, GL_DIFFUSE, lightArr );
+ lightArr[0] = 90.0f; lightArr[1] = 90.0f;
+ lightArr[2] = 0.0f; lightArr[3] = 0.0f;
+ glLightfv( GL_LIGHT0, GL_POSITION, lightArr );
+ lightArr[0] = 0.1f; lightArr[1] = 0.1f;
+ lightArr[2] = 0.1f; lightArr[3] = 1.0f;
+ glLightfv( GL_LIGHT0, GL_AMBIENT, lightArr );
+ glEnable( GL_LIGHT0 );
+
+ /*
+ glLightModelfv(GL_LIGHT_MODEL_LOCAL_VIEWER, lmodel_local);
+ glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient);
+ */
+ glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, 1);
+ glEnable( GL_LIGHTING );
+
+ /*
+ glLightModelfv(GL_LIGHT_MODEL_LOCAL_VIEWER, lmodel_local);
+ glLightModelfv(GL_LIGHT_MODEL_TWO_SIDE, lmodel_twoside);
+ glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient);
+ glEnable( GL_LIGHTING );
+ */
+
+
+ glMaterialf( GL_FRONT, GL_SHININESS, 30.0f );
+
+ farr[0] = 0.0f; farr[1] = 0.0f; farr[2] = 0.0f; farr[3] = 1.0f;
+ glMaterialfv( GL_FRONT, GL_SPECULAR, farr );
+
+ farr[0] = 0.0f; farr[1] = 1.0f; farr[2] = 0.0f; farr[3] = 1.0f;
+ glMaterialfv( GL_FRONT, GL_DIFFUSE, farr );
+
+ glMaterialf( GL_BACK, GL_SHININESS, 50.0f );
+
+ farr[0] = 0.0f; farr[1] = 0.0f; farr[2] = 1.0f; farr[3] = 1.0f;
+ glMaterialfv( GL_BACK, GL_SPECULAR, farr );
+
+ farr[0] = 1.0f; farr[1] = 1.0f; farr[2] = 0.0f; farr[3] = 1.0f;
+ glMaterialfv( GL_BACK, GL_DIFFUSE, farr );
+
+}
+
+void idle()
+{
+ glutPostRedisplay();
+}
+
+int main( int argc, char **argv)
+{
+ fprintf(stderr,"1\n");
+ if(argc>2 && strcmp(argv[1], "-fps")==0)
+ {
+ fprintf(stderr,"2\n");
+ fps = atof(argv[2]);
+ argc-=2;
+ argv+=2;
+ }
+ fprintf(stderr, "Frame Per Secounds %d\n ( will be ignored this time )\n", fps);
+
+ glutInit(&argc, argv);
+ glutInitDisplayMode ( GLUT_DOUBLE
+ | GLUT_DEPTH
+ | GLUT_RGBA
+ );
+ glutInitWindowSize(width,height);
+ glutInitWindowPosition(100,100);
+ glutCreateWindow("OpenGL GLUT/NATIVE");
+ init();
+ glutDisplayFunc(display);
+ glutReshapeFunc(reshape);
+ glutIdleFunc(idle);
+ glutMainLoop();
+ return 0;
+}
+
diff --git a/demos/natives/x11/testGL2.c b/demos/natives/x11/testGL2.c new file mode 100644 index 0000000..335acc9 --- /dev/null +++ b/demos/natives/x11/testGL2.c @@ -0,0 +1,517 @@ +#include <stdio.h>
+#include <stdlib.h>
+#include <GL/gl.h>
+#include <GL/glx.h>
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+
+Display *dpy; /* X display connection */
+Window xid; /* X window id */
+GLXContext glid; /* GL window id */
+
+double width = 250;
+double height = 250;
+double fps = 25.0;
+
+ static float lmodel_twoside[] =
+ {GL_FALSE};
+ static float lmodel_local[] =
+ {GL_FALSE};
+ static float lmodel_ambient[] =
+ {0.0, 0.0, 0.0, 0.0};
+
+void CylinderDraw( )
+{
+ glBegin( GL_TRIANGLE_STRIP );
+ glNormal3f ( 1.0, 0.0, -5.0 );
+ glVertex3f ( 1.0, 0.0, -5.0 );
+ glNormal3f ( 1.0, 0.0, -5.0 );
+ glVertex3f (1.000000, 0.000000, 5.000000);
+ glNormal3f (0.707107, 0.707107, -5.000000);
+ glVertex3f (0.707107, 0.707107, -5.000000);
+ glNormal3f (0.707107, 0.707107, -5.000000);
+ glVertex3f (0.707107, 0.707107, 5.000000);
+ glNormal3f (0.000000, 1.000000, -5.000000);
+ glVertex3f (0.000000, 1.000000, -5.000000);
+ glNormal3f (0.000000, 1.000000, -5.000000);
+ glVertex3f (0.000000, 1.000000, 5.000000);
+ glNormal3f (-0.707107, 0.707107, -5.00000);
+ glVertex3f (-0.707107, 0.707107, -5.00000);
+ glNormal3f (-0.707107, 0.707107, -5.00000);
+ glVertex3f (-0.707107, 0.707107, 5.00000);
+ glNormal3f (-1.000000, 0.000000, -5.000000);
+ glVertex3f (-1.000000, 0.000000, -5.000000);
+ glNormal3f (-1.000000, 0.000000, -5.000000);
+ glVertex3f (-1.000000, 0.000000, 5.00000);
+ glNormal3f (-0.707107, -0.707107, -5.000000);
+ glVertex3f (-0.707107, -0.707107, -5.000000);
+ glNormal3f (-0.707107, -0.707107, -5.000000);
+ glVertex3f (-0.707107, -0.707107, 5.00000);
+ glNormal3f (0.000000, -1.000000, -5.000000);
+ glVertex3f (0.000000, -1.000000, -5.000000);
+ glNormal3f (0.000000, -1.000000, -5.000000);
+ glVertex3f (0.000000, -1.000000, 5.00000);
+ glNormal3f (0.707107, -0.707107, -5.00000);
+ glVertex3f (0.707107, -0.707107, -5.00000);
+ glNormal3f (0.707107, -0.707107, -5.00000);
+ glVertex3f (0.707107, -0.707107, 5.000000);
+ glNormal3f (1.000000, 0.000000, -5.00000);
+ glVertex3f (1.000000, 0.000000, -5.00000);
+ glNormal3f (1.000000, 0.000000, -5.00000);
+ glVertex3f (1.000000, 0.000000, 5.00000);
+ glEnd();
+}
+
+void reshape(int width, int height)
+{
+ double fov = 45.0,
+ aspect = width / height,
+ near = 1.0,
+ far = 200.0;
+
+ glViewport( 0, 0, width, height );
+
+ glMatrixMode( GL_PROJECTION );
+ glLoadIdentity();
+
+ gluPerspective( fov, aspect, near, far );
+
+ glMatrixMode( GL_MODELVIEW );
+ glLoadIdentity();
+
+}
+
+void display()
+{
+ static int FrameStep = 0;
+
+ glXWaitGL();
+ glXWaitX();
+ /* associated the context with the X window */
+ if( glXMakeCurrent( dpy, xid, glid ) == False) {
+ glXDestroyContext( display, glid );
+ fprintf(stderr,"(NO GC ASSOC)\n");
+ fflush(stderr);
+ return 1;
+ }
+
+ glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
+ glPushMatrix();
+ glTranslatef( 0.0, 0.0, -65.0 );
+ glRotatef( 40.0+(2*FrameStep), 0.0, 0.0, 1.0 );
+ glRotatef( 190.0+(2*FrameStep), 0.0, 1.0, 0.0 );
+ glRotatef( 200.0+(FrameStep*2), 1.0, 0.0, 0.0 );
+ glPushMatrix();
+ glScalef( 1.0, 1.0, 10.0 );
+ CylinderDraw( );
+ glPopMatrix();
+ glPushMatrix();
+ glRotatef( 90.0, 0.0, 1.0, 0.0 );
+ glScalef( 1.0, 1.0, 10.0 );
+ CylinderDraw( );
+ glPopMatrix();
+ glPushMatrix();
+ glRotatef( 90.0, 1.0, 0.0, 0.0 );
+ glScalef( 1.0, 1.0, 10.0 );
+ CylinderDraw( );
+ glPopMatrix();
+ glPopMatrix();
+
+ glXWaitGL();
+ glXWaitX();
+ glXSwapBuffers(dpy, xid);
+
+ glXWaitGL();
+ glXWaitX();
+ /* associated the context with the X window */
+ if( glXMakeCurrent( dpy, None, NULL ) == False) {
+ glXDestroyContext( display, glid );
+ fprintf(stderr,"(free GC failed)\n");
+ fflush(stderr);
+ return 1;
+ }
+
+ FrameStep++;
+
+ if(FrameStep>100000) FrameStep=0;
+
+}
+
+void init()
+{
+ double fov = 45.0;
+ double aspect = width / height ;
+ double near = 1.0;
+ double far = 200.0;
+ float lightArr[4];
+ float farr[4];
+
+ /* initialize the widget */
+ glClearColor( 0.8f, 0.8f, 1.0f, 1.0f );
+ glFrontFace( GL_CW );
+ glEnable( GL_DEPTH_TEST );
+
+ glViewport( 0, 0, width, height );
+
+ glMatrixMode( GL_PROJECTION );
+ glLoadIdentity();
+
+ gluPerspective( fov, aspect, near, far );
+
+ /* render three rotated cylinders */
+ glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
+
+ glMatrixMode( GL_MODELVIEW );
+ glLoadIdentity();
+
+ /* enable lighting */
+ lightArr[0] = 1.0f; lightArr[1] = 1.0f;
+ lightArr[2] = 1.0f; lightArr[3] = 1.0f;
+ glLightfv( GL_LIGHT0, GL_DIFFUSE, lightArr );
+ lightArr[0] = 90.0f; lightArr[1] = 90.0f;
+ lightArr[2] = 0.0f; lightArr[3] = 0.0f;
+ glLightfv( GL_LIGHT0, GL_POSITION, lightArr );
+ lightArr[0] = 0.1f; lightArr[1] = 0.1f;
+ lightArr[2] = 0.1f; lightArr[3] = 1.0f;
+ glLightfv( GL_LIGHT0, GL_AMBIENT, lightArr );
+ glEnable( GL_LIGHT0 );
+
+ /*
+ glLightModelfv(GL_LIGHT_MODEL_LOCAL_VIEWER, lmodel_local);
+ glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient);
+ */
+ glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, 1);
+ glEnable( GL_LIGHTING );
+
+ /*
+ glLightModelfv(GL_LIGHT_MODEL_LOCAL_VIEWER, lmodel_local);
+ glLightModelfv(GL_LIGHT_MODEL_TWO_SIDE, lmodel_twoside);
+ glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient);
+ glEnable( GL_LIGHTING );
+ */
+
+
+ glMaterialf( GL_FRONT, GL_SHININESS, 30.0f );
+
+ farr[0] = 0.0f; farr[1] = 0.0f; farr[2] = 0.0f; farr[3] = 1.0f;
+ glMaterialfv( GL_FRONT, GL_SPECULAR, farr );
+
+ farr[0] = 0.0f; farr[1] = 1.0f; farr[2] = 0.0f; farr[3] = 1.0f;
+ glMaterialfv( GL_FRONT, GL_DIFFUSE, farr );
+
+ glMaterialf( GL_BACK, GL_SHININESS, 50.0f );
+
+ farr[0] = 0.0f; farr[1] = 0.0f; farr[2] = 1.0f; farr[3] = 1.0f;
+ glMaterialfv( GL_BACK, GL_SPECULAR, farr );
+
+ farr[0] = 1.0f; farr[1] = 1.0f; farr[2] = 0.0f; farr[3] = 1.0f;
+ glMaterialfv( GL_BACK, GL_DIFFUSE, farr );
+
+}
+
+
+static void GetLargeVisual(Display *dpy, XVisualInfo *bigVisualInfo);
+static XVisualInfo *findVisualGlX( Display *display);
+Window findAWindow( const char *frameName, Display *display, Window window);
+int verbose=1;
+
+main()
+{
+ XWMHints *p_xwmh=NULL;
+ Window xid2;
+ XEvent event;
+ XVisualInfo bigVisualInfo; /* largest pseudo color visual type */
+ XSetWindowAttributes attribs; /* X window attributes structure */
+ Colormap bigColormap; /* 12-bit color map */
+ unsigned long vmask; /* value mask for attributes */
+ int i;
+
+
+ /* Get the X display connection. We'll assume that the DISPLAY
+ * environment variable is "unix:0" since GL windows only run on
+ * on the local display. */
+ if(!(dpy = XOpenDisplay(""))) {
+ printf("\n can't open display connection \n");
+ exit(0);
+ }
+
+ /* GetLargeVisual(dpy, &bigVisualInfo); */
+ bigVisualInfo = * findVisualGlX(dpy);
+ printf("\n address of XVisualInfo structure = 0x%x \n", bigVisualInfo);
+ printf("\n address of Visual structure = 0x%x ", bigVisualInfo.visual);
+ printf("\n visualID = 0x%x ", bigVisualInfo.visualid);
+ printf("\n depth of visual = %d", bigVisualInfo.depth);
+ printf("\n class of visual = %d", bigVisualInfo.class);
+ printf("\n bits_per_rgb of visual = %d", bigVisualInfo.bits_per_rgb);
+ printf("\n colormap_size of visual = %d \n", bigVisualInfo.colormap_size);
+
+ attribs.event_mask =
+ ExposureMask;
+ attribs.border_pixel =
+ BlackPixel(dpy, bigVisualInfo.screen);
+ attribs.colormap =
+ XCreateColormap( dpy,
+ RootWindow( dpy, bigVisualInfo.screen ),
+ bigVisualInfo.visual,
+ AllocNone ) ;
+
+
+ attribs.background_pixel = 0xFFFFFFFF;
+
+ attribs.background_pixel =
+ BlackPixel(dpy, bigVisualInfo.screen);
+
+ attribs.border_pixmap = None;
+ attribs.background_pixmap = None;
+
+ vmask = CWColormap | CWBorderPixmap | CWBackPixmap;
+ vmask = CWEventMask | CWColormap | CWBorderPixel | CWBackPixel;
+
+ xid =
+ XCreateWindow(dpy,
+ RootWindow( dpy, bigVisualInfo.screen ),
+ 0,0, 400, 400,
+ 0,
+ bigVisualInfo.depth,
+ InputOutput, bigVisualInfo.visual,
+ vmask,
+ &attribs);
+
+ /* Name the window, map it, and flush the X buffer. */
+ XStoreName(dpy, xid, "GLWindow");
+ XMapWindow(dpy, xid);
+ XFlush(dpy);
+
+ glid = glXCreateContext( dpy, &bigVisualInfo, None, True );
+
+ /* check if the context could be created */
+ if( glid == NULL ) {
+ fprintf(stderr,"(NO GC)\n");
+ fflush(stderr);
+ return 1;
+ }
+ /* associated the context with the X window */
+ if( glXMakeCurrent( dpy, xid, glid ) == False) {
+ glXDestroyContext( display, glid );
+ fprintf(stderr,"(NO GC ASSOC)\n");
+ fflush(stderr);
+ return 1;
+ }
+
+ XFlush(dpy);
+ XRaiseWindow (dpy, xid);
+
+ xid2 = findAWindow("GLWindow", dpy, RootWindow( dpy, bigVisualInfo.screen ));
+
+ if(xid==xid2)
+ fprintf(stderr,"found win equals created win\n");
+ else
+ fprintf(stderr,"found win ** NOT ** equals created win\n");
+ fflush(stderr);
+
+ if((p_xwmh = XAllocWMHints()) == NULL)
+ {
+ fprintf(stderr,"No Mem for WMHints\n");
+ fflush(stderr);
+ exit(1);
+ }
+ p_xwmh->flags = (InputHint|StateHint);
+ p_xwmh->input = True;
+ p_xwmh->initial_state=NormalState;
+
+ XSetWMHints(dpy, xid, p_xwmh);
+
+ init();
+
+ for(;;)
+ display();
+
+ /* exit */
+ XDestroyWindow(dpy, xid);
+ XCloseDisplay(dpy);
+}
+
+/* ============================================================== */
+/* The following routine draws a constant pitch spiral,
+ * with initial radius r0, pitch p,
+ * nsteps line segments per revolution,
+ * and nrev revolutions */
+
+/* ============================================================== */
+
+void GetLargeVisual(Display *dpy, XVisualInfo *bigVisualInfo)
+{
+ XVisualInfo *visual_info; /* Info. about visual classes */
+ /*
+ * Get all visuals based on these masks
+ */
+ long vinfo_mask = VisualClassMask | VisualScreenMask;
+ XVisualInfo vtemp ; /* template for visuals to look for */
+ int i; /* counter */
+ int nitem ; /* number of visuals returned */
+
+ /*
+ * Get All PseudoColor Visuals
+ */
+ vtemp.class = PseudoColor ; /* Set PseudoColor class */
+ vtemp.screen = DefaultScreen(dpy) ; /* Set screen */
+ /*
+ * Get all visuals of the correct class on the correct screen
+ */
+ visual_info = XGetVisualInfo(dpy, vinfo_mask, &vtemp, &nitem) ;
+ /*
+ * Search for largest visual from all visual classes
+ */
+ *(bigVisualInfo) = *(visual_info);
+
+
+ /* NOTE: on GXT1000 and GXT500 family, winX does not support
+ * overlay window, so careful not to pick up overlay visual
+ * here!
+ */
+
+ for (i=0; i<nitem; i++, visual_info++) {
+ if (visual_info->colormap_size >= bigVisualInfo->colormap_size) {
+ *(bigVisualInfo) = *(visual_info);
+ }
+ }
+ /*
+ * return largest visual
+ */
+ return;
+}
+
+static XVisualInfo *findVisualGlX( Display *display )
+{
+ int visualAttribList[11];
+ XVisualInfo *visual;
+
+ /* Ask GLX for a visual that matches the attributes we want: Single
+ buffered and RGB with at least 4 bits for each component
+ */
+ visualAttribList[0] = GLX_RGBA;
+ visualAttribList[1] = GLX_RED_SIZE;
+ visualAttribList[2] = 1;
+ visualAttribList[3] = GLX_GREEN_SIZE;
+ visualAttribList[4] = 1;
+ visualAttribList[5] = GLX_BLUE_SIZE;
+ visualAttribList[6] = 1;
+ visualAttribList[7] = GLX_DOUBLEBUFFER;
+ visualAttribList[8] = GLX_DEPTH_SIZE;
+ visualAttribList[9] = 1;
+ visualAttribList[10] = None;
+
+ visual = glXChooseVisual( display,
+ DefaultScreen( display ),
+ visualAttribList );
+ fprintf(stderr, "\nused vi(ID:%d): \n screen %d, depth %d, class %d,\n clrmapsz %d, bitsPerRGB %d\n",
+ visual->visualid,
+ visual->screen,
+ visual->depth,
+ visual->class,
+ visual->colormap_size,
+ visual->bits_per_rgb );
+ fflush(stderr);
+
+ return( visual );
+}
+
+Window findAWindow( const char *frameName, Display *display, Window window)
+{
+ /* Variables used to find the correct java Window to render into */
+ Window root, parent, *children;
+ unsigned int numOfChildren;
+ char *buff;
+ int i, status;
+ Window retWindow, lastWindow;
+
+ /* debug helpers */
+ int i1, i2, i3;
+
+ XFlush(display);
+
+ status = XFetchName( display, window, &buff );
+
+ if( status )
+ {
+ if( !strcmp( frameName, buff ) )
+ {
+ /* Ok, we've found it,
+ so return the last child under this heirarchy
+ */
+ lastWindow = window;
+
+ XFlush(display);
+
+ status = XQueryTree( display, window,
+ &root, &parent, &children, &numOfChildren );
+
+ if(verbose)
+ {
+ fprintf(stderr,"\nfjw 4 (got :0x%x with %d childs)\n",
+ window, numOfChildren);
+ fflush(stderr);
+ }
+
+ i1=0;
+
+ while( status )
+ {
+ if( children == NULL )
+ {
+ XFlush(display);
+
+ if(verbose)
+ {
+ fprintf(stderr,"\nfjw 4 (FOUND LAST WINDOW 0x%x)\n",
+ lastWindow);
+ fflush(stderr);
+ }
+ return lastWindow;
+ }
+ lastWindow = children[numOfChildren-1];
+
+ status = XQueryTree( display, lastWindow,
+ &root, &parent, &children, &numOfChildren );
+
+ if(verbose)
+ {
+ fprintf(stderr,"fjw 4 (got :0x%x with %d childs)\n",
+ lastWindow, numOfChildren);
+ fflush(stderr);
+ }
+
+ XFlush(display);
+
+ }
+
+ return (Window)0;
+ }
+ }
+
+ /* If Window has no name, or if it's not equal to the java Frame window name
+ carry on searching recursivly
+ */
+ status = XQueryTree( display, window,
+ &root, &parent, &children, &numOfChildren );
+
+ XFlush(display);
+
+ if( status )
+ {
+ for( i=0; i < numOfChildren; i++ )
+ {
+ retWindow = findAWindow( frameName, display, children[ i ]);
+ if( retWindow )
+ {
+ /* Free up the child list */
+ /* XFree( children ); */
+ return retWindow;
+ }
+ }
+ }
+
+ /* Free up the child list */
+ /* if(children!=0) XFree( children ); */
+ return (Window)0;
+}
diff --git a/demos/natives/x11/wave.c b/demos/natives/x11/wave.c new file mode 100644 index 0000000..36d518d --- /dev/null +++ b/demos/natives/x11/wave.c @@ -0,0 +1,500 @@ +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#include <math.h> +#include "GL/glut.h" + + +#ifndef PI +#define PI 3.14159265358979323846 +#endif + +#define GETCOORD(frame, x, y) (&(theMesh.coords[frame*theMesh.numCoords+(x)+(y)*(theMesh.widthX+1)])) +#define GETFACET(frame, x, y) (&(theMesh.facets[frame*theMesh.numFacets+(x)+(y)*theMesh.widthX])) + + +GLenum rgb, doubleBuffer, directRender; + +GLint colorIndexes1[3]; +GLint colorIndexes2[3]; +GLenum clearMask = GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT; + +GLenum smooth = GL_FALSE; +GLenum lighting = GL_TRUE; +GLenum depth = GL_TRUE; +GLenum stepMode = GL_FALSE; +GLenum spinMode = GL_FALSE; +GLint contouring = 0; + +GLint widthX, widthY; +GLint checkerSize; +float height; + +GLint frames, curFrame = 0, nextFrame = 0; + +struct facet { + float color[3]; + float normal[3]; +}; +struct coord { + float vertex[3]; + float normal[3]; +}; +struct mesh { + GLint widthX, widthY; + GLint numFacets; + GLint numCoords; + GLint frames; + struct coord *coords; + struct facet *facets; +} theMesh; + +GLubyte contourTexture1[] = { + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 127, 127, 127, 127, +}; +GLubyte contourTexture2[] = { + 255, 255, 255, 255, + 255, 127, 127, 127, + 255, 127, 127, 127, + 255, 127, 127, 127, +}; + + +static void display(void) +{ + struct coord *coord; + struct facet *facet; + float *lastColor; + float *thisColor; + GLint i, j; + + glClear(clearMask); + + if (nextFrame || !stepMode) { + curFrame++; + } + if (curFrame >= theMesh.frames) { + curFrame = 0; + } + + if ((nextFrame || !stepMode) && spinMode) { + glRotatef(5.0, 0.0, 0.0, 1.0); + } + nextFrame = 0; + + for (i = 0; i < theMesh.widthX; i++) { + glBegin(GL_QUAD_STRIP); + lastColor = NULL; + for (j = 0; j < theMesh.widthY; j++) { + facet = GETFACET(curFrame, i, j); + if (!smooth && lighting) { + glNormal3fv(facet->normal); + } + if (lighting) { + thisColor = facet->color; + glColor3fv(facet->color); + } else { + thisColor = facet->color; + glColor3fv(facet->color); + } + + if (!lastColor || (thisColor[0] != lastColor[0] && smooth)) { + if (lastColor) { + glEnd(); + glBegin(GL_QUAD_STRIP); + } + coord = GETCOORD(curFrame, i, j); + if (smooth && lighting) { + glNormal3fv(coord->normal); + } + glVertex3fv(coord->vertex); + + coord = GETCOORD(curFrame, i+1, j); + if (smooth && lighting) { + glNormal3fv(coord->normal); + } + glVertex3fv(coord->vertex); + } + + coord = GETCOORD(curFrame, i, j+1); + if (smooth && lighting) { + glNormal3fv(coord->normal); + } + glVertex3fv(coord->vertex); + + coord = GETCOORD(curFrame, i+1, j+1); + if (smooth && lighting) { + glNormal3fv(coord->normal); + } + glVertex3fv(coord->vertex); + + lastColor = thisColor; + } + glEnd(); + } + + glFlush(); + if (doubleBuffer) { + glutSwapBuffers(); + } +} + + +static void InitMesh(void) +{ + struct coord *coord; + struct facet *facet; + float dp1[3], dp2[3]; + float *pt1, *pt2, *pt3; + float angle, d, x, y; + GLint numFacets, numCoords, frameNum, i, j; + + theMesh.widthX = widthX; + theMesh.widthY = widthY; + theMesh.frames = frames; + + numFacets = widthX * widthY; + numCoords = (widthX + 1) * (widthY + 1); + + theMesh.numCoords = numCoords; + theMesh.numFacets = numFacets; + + theMesh.coords = (struct coord *)malloc(frames*numCoords* + sizeof(struct coord)); + theMesh.facets = (struct facet *)malloc(frames*numFacets* + sizeof(struct facet)); + if (theMesh.coords == NULL || theMesh.facets == NULL) { + printf("Out of memory.\n"); + exit(0); + } + + for (frameNum = 0; frameNum < frames; frameNum++) { + for (i = 0; i <= widthX; i++) { + x = i / (float)widthX; + for (j = 0; j <= widthY; j++) { + y = j / (float)widthY; + + d = sqrt(x*x+y*y); + if (d == 0.0) { + d = 0.0001; + } + angle = 2 * PI * d + (2 * PI / frames * frameNum); + + coord = GETCOORD(frameNum, i, j); + + coord->vertex[0] = x - 0.5; + coord->vertex[1] = y - 0.5; + coord->vertex[2] = (height - height * d) * cos(angle); + + coord->normal[0] = -(height / d) * x * ((1 - d) * 2 * PI * + sin(angle) + cos(angle)); + coord->normal[1] = -(height / d) * y * ((1 - d) * 2 * PI * + sin(angle) + cos(angle)); + coord->normal[2] = -1; + + d = 1.0 / sqrt(coord->normal[0]*coord->normal[0]+ + coord->normal[1]*coord->normal[1]+1); + coord->normal[0] *= d; + coord->normal[1] *= d; + coord->normal[2] *= d; + } + } + for (i = 0; i < widthX; i++) { + for (j = 0; j < widthY; j++) { + facet = GETFACET(frameNum, i, j); + if (((i/checkerSize)%2)^(j/checkerSize)%2) { + facet->color[0] = 1.0; + facet->color[1] = 0.2; + facet->color[2] = 0.2; + } else { + facet->color[0] = 0.2; + facet->color[1] = 1.0; + facet->color[2] = 0.2; + } + pt1 = GETCOORD(frameNum, i, j)->vertex; + pt2 = GETCOORD(frameNum, i, j+1)->vertex; + pt3 = GETCOORD(frameNum, i+1, j+1)->vertex; + + dp1[0] = pt2[0] - pt1[0]; + dp1[1] = pt2[1] - pt1[1]; + dp1[2] = pt2[2] - pt1[2]; + + dp2[0] = pt3[0] - pt2[0]; + dp2[1] = pt3[1] - pt2[1]; + dp2[2] = pt3[2] - pt2[2]; + + facet->normal[0] = dp1[1] * dp2[2] - dp1[2] * dp2[1]; + facet->normal[1] = dp1[2] * dp2[0] - dp1[0] * dp2[2]; + facet->normal[2] = dp1[0] * dp2[1] - dp1[1] * dp2[0]; + + d = 1.0 / sqrt(facet->normal[0]*facet->normal[0]+ + facet->normal[1]*facet->normal[1]+ + facet->normal[2]*facet->normal[2]); + + facet->normal[0] *= d; + facet->normal[1] *= d; + facet->normal[2] *= d; + } + } + } +} + +static void InitMaterials(void) +{ + static float ambient[] = {0.1, 0.1, 0.1, 1.0}; + static float diffuse[] = {0.5, 1.0, 1.0, 1.0}; + static float position[] = {90.0, 90.0, 150.0, 0.0}; + static float front_mat_shininess[] = {60.0}; + static float front_mat_specular[] = {0.2, 0.2, 0.2, 1.0}; + static float front_mat_diffuse[] = {0.5, 0.28, 0.38, 1.0}; + static float back_mat_shininess[] = {60.0}; + static float back_mat_specular[] = {0.5, 0.5, 0.2, 1.0}; + static float back_mat_diffuse[] = {1.0, 1.0, 0.2, 1.0}; + static float lmodel_ambient[] = {1.0, 1.0, 1.0, 1.0}; + static float lmodel_twoside[] = {GL_TRUE}; + + glMatrixMode(GL_PROJECTION); + gluPerspective(450, 1.0, 0.5, 10.0); + + glLightfv(GL_LIGHT0, GL_AMBIENT, ambient); + glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse); + glLightfv(GL_LIGHT0, GL_POSITION, position); + glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient); + glLightModelfv(GL_LIGHT_MODEL_TWO_SIDE, lmodel_twoside); + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + + glMaterialfv(GL_FRONT, GL_SHININESS, front_mat_shininess); + glMaterialfv(GL_FRONT, GL_SPECULAR, front_mat_specular); + glMaterialfv(GL_FRONT, GL_DIFFUSE, front_mat_diffuse); + glMaterialfv(GL_BACK, GL_SHININESS, back_mat_shininess); + glMaterialfv(GL_BACK, GL_SPECULAR, back_mat_specular); + glMaterialfv(GL_BACK, GL_DIFFUSE, back_mat_diffuse); + glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE); + + glEnable(GL_COLOR_MATERIAL); +} + +static void InitTexture(void) +{ + + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); +} + +void +Idle(void) +{ + glutPostRedisplay(); +} + +static void Init(void) +{ + + glClearColor(0.0, 0.0, 0.0, 0.0); + + glShadeModel(GL_FLAT); + + glFrontFace(GL_CW); + + glEnable(GL_DEPTH_TEST); + + InitMaterials(); + InitTexture(); + InitMesh(); + + glMatrixMode(GL_MODELVIEW); + glTranslatef(0.0, 0.4, -1.8); + glScalef(2.0, 2.0, 2.0); + glRotatef(-35.0, 1.0, 0.0, 0.0); + glRotatef(35.0, 0.0, 0.0, 1.0); +} + +static void Reshape(int width, int height) +{ + + glViewport(0, 0, (GLint)width, (GLint)height); +} + +void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(0); break; + case 'c': + contouring++; + if (contouring == 1) { + static GLfloat map[4] = {0, 0, 20, 0}; + + glTexImage2D(GL_TEXTURE_2D, 0, 3, 4, 4, 0, GL_LUMINANCE, + GL_UNSIGNED_BYTE, (GLvoid *)contourTexture1); + glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); + glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); + glTexGenfv(GL_S, GL_OBJECT_PLANE, map); + glTexGenfv(GL_T, GL_OBJECT_PLANE, map); + glEnable(GL_TEXTURE_2D); + glEnable(GL_TEXTURE_GEN_S); + glEnable(GL_TEXTURE_GEN_T); + } else if (contouring == 2) { + static GLfloat map[4] = {0, 0, 20, 0}; + + glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR); + glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR); + glPushMatrix(); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTexGenfv(GL_S, GL_EYE_PLANE, map); + glTexGenfv(GL_T, GL_EYE_PLANE, map); + glPopMatrix(); + } else { + contouring = 0; + glDisable(GL_TEXTURE_GEN_S); + glDisable(GL_TEXTURE_GEN_T); + glDisable(GL_TEXTURE_2D); + } + break; + case 's': + smooth = !smooth; + if (smooth) { + glShadeModel(GL_SMOOTH); + } else { + glShadeModel(GL_FLAT); + } + break; + case 'l': + lighting = !lighting; + if (lighting) { + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + glEnable(GL_COLOR_MATERIAL); + } else { + glDisable(GL_LIGHTING); + glDisable(GL_LIGHT0); + glDisable(GL_COLOR_MATERIAL); + } + break; + case 'd': + depth = !depth; + if (depth) { + glEnable(GL_DEPTH_TEST); + clearMask |= GL_DEPTH_BUFFER_BIT; + } else { + glDisable(GL_DEPTH_TEST); + clearMask &= ~GL_DEPTH_BUFFER_BIT; + } + break; + case ' ': + stepMode = !stepMode; + if (stepMode) { + glutIdleFunc(0); + } else { + glutIdleFunc(Idle); + } + break; + case 'n': + if (stepMode) { + nextFrame = 1; + } + break; + case 'a': + spinMode = !spinMode; + break; + default: + return ; + } + return ; +} + +static GLenum Args(int argc, char **argv) +{ + GLint i; + + doubleBuffer = GL_TRUE; + directRender = GL_TRUE; + rgb = GL_TRUE; + frames = 10; + widthX = 10; + widthY = 10; + checkerSize = 2; + height = 0.2; + + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "-sb") == 0) { + doubleBuffer = GL_FALSE; + } else if (strcmp(argv[i], "-db") == 0) { + doubleBuffer = GL_TRUE; + } else if (strcmp(argv[i], "-dr") == 0) { + directRender = GL_TRUE; + } else if (strcmp(argv[i], "-ir") == 0) { + directRender = GL_FALSE; + } else if (strcmp(argv[i], "-grid") == 0) { + if (i+2 >= argc || argv[i+1][0] == '-' || argv[i+2][0] == '-') { + printf("-grid (No numbers).\n"); + return GL_FALSE; + } else { + widthX = atoi(argv[++i]); + widthY = atoi(argv[++i]); + } + } else if (strcmp(argv[i], "-size") == 0) { + if (i+1 >= argc || argv[i+1][0] == '-') { + printf("-checker (No number).\n"); + return GL_FALSE; + } else { + checkerSize = atoi(argv[++i]); + } + } else if (strcmp(argv[i], "-wave") == 0) { + if (i+1 >= argc || argv[i+1][0] == '-') { + printf("-wave (No number).\n"); + return GL_FALSE; + } else { + height = atof(argv[++i]); + } + } else if (strcmp(argv[i], "-frames") == 0) { + if (i+1 >= argc || argv[i+1][0] == '-') { + printf("-frames (No number).\n"); + return GL_FALSE; + } else { + frames = atoi(argv[++i]); + } + } else { + printf("%s (Bad option).\n", argv[i]); + return GL_FALSE; + } + } + return GL_TRUE; +} + +int +main(int argc, char **argv) +{ + GLenum type; + + glutInitWindowSize(300, 300); + glutInit(&argc, argv); + if (Args(argc, argv) == GL_FALSE) { + exit(1); + } + type = (rgb) ? GLUT_RGB : GLUT_INDEX; + type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; + glutInitDisplayMode(type); + + glutCreateWindow("wave"); + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutIdleFunc(Idle); + glutDisplayFunc(display); + + glutMainLoop(); + return 0; /* ANSI C requires main to return int. */ +} + diff --git a/demos/olympicCvs.java b/demos/olympicCvs.java new file mode 100644 index 0000000..189e52d --- /dev/null +++ b/demos/olympicCvs.java @@ -0,0 +1,282 @@ +/** + * @(#) olympicCvs.java + */ + +import gl4java.GLContext; +import gl4java.awt.GLAnimCanvas; +import java.awt.*; +import java.awt.event.*; +import java.lang.Math; + + +class olympicCvs extends GLAnimCanvas +{ +/** + * Instead of using suspend (JAVA2) + * + * @see run + */ + protected boolean threadSuspended = true; + + static final double M_PI= 3.141592654; + static final double M_2PI= 2*3.141592654; + + static final int + XSIZE= 100, + YSIZE= 75, + RINGS= 5, + BLUERING= 0, + BLACKRING= 1, + REDRING= 2, + YELLOWRING =3, + GREENRING =4, + BACKGROUND =8, + BLACK = 0, + RED=1, + GREEN=2, + YELLOW=3, + BLUE=4, + MAGENTA=5, + CYAN=6, + WHITE=7; + + byte rgb_colors[][]; + int mapped_colors[]; + float dests[][]; + float offsets[][]; + float angs[]; + float rotAxis[][]; + int iters[]; + int theTorus; + + float lmodel_ambient[] = {0.0f, 0.0f, 0.0f, 0.0f}; + float lmodel_twoside[] = {0.0f, 0.0f, 0.0f, 0.0f}; + float lmodel_local[] = {0.0f, 0.0f, 0.0f, 0.0f}; + float light0_ambient[] = {0.1f, 0.1f, 0.1f, 1.0f}; + float light0_diffuse[] = {1.0f, 1.0f, 1.0f, 0.0f}; + float light0_position[] = {0.8660254f, 0.5f, 1f, 0f}; + float light0_specular[] = {1.0f, 1.0f, 1.0f, 0.0f}; + float bevel_mat_ambient[] = {0.0f, 0.0f, 0.0f, 1.0f}; + float bevel_mat_shininess[] = {40.0f, 0f, 0f, 0f}; + float bevel_mat_specular[] = {1.0f, 1.0f, 1.0f, 0.0f}; + float bevel_mat_diffuse[] = {1.0f, 0.0f, 0.0f, 0.0f}; + + public olympicCvs (int w, int h, + String glClass, String gluClass ) + { + super(w, h, glClass, gluClass ); + } + + public void preInit() + { + doubleBuffer = true; + stereoView = true; + } + + public void init() + { + rgb_colors=new byte[RINGS][3]; + mapped_colors=new int [RINGS]; + dests=new float [RINGS][3]; + offsets=new float[RINGS][3]; + angs=new float[RINGS]; + rotAxis=new float[RINGS][3]; + iters=new int[RINGS]; + + int i; + float top_y = 1.0f; + float bottom_y = 0.0f; + float top_z = 0.15f; + float bottom_z = 0.69f; + float spacing = 2.5f; + + ReInit(); + for (i = 0; i < RINGS; i++) { + rgb_colors[i][0] = rgb_colors[i][1] = rgb_colors[i][2] = (byte)0; + } + rgb_colors[BLUERING][2] = (byte)255; + rgb_colors[REDRING][0] = (byte)255; + rgb_colors[GREENRING][1] = (byte)255; + rgb_colors[YELLOWRING][0] = (byte)255; + rgb_colors[YELLOWRING][1] = (byte)255; + mapped_colors[BLUERING] = BLUE; + mapped_colors[REDRING] = RED; + mapped_colors[GREENRING] = GREEN; + mapped_colors[YELLOWRING] = YELLOW; + mapped_colors[BLACKRING] = BLACK; + + dests[BLUERING][0] = -spacing; + dests[BLUERING][1] = top_y; + dests[BLUERING][2] = top_z; + + dests[BLACKRING][0] = 0.0f; + dests[BLACKRING][1] = top_y; + dests[BLACKRING][2] = top_z; + + dests[REDRING][0] = spacing; + dests[REDRING][1] = top_y; + dests[REDRING][2] = top_z; + + dests[YELLOWRING][0] = -spacing / 2.0f; + dests[YELLOWRING][1] = bottom_y; + dests[YELLOWRING][2] = bottom_z; + + dests[GREENRING][0] = spacing / 2.0f; + dests[GREENRING][1] = bottom_y; + dests[GREENRING][2] = bottom_z; + + theTorus = gl.glGenLists(1); + gl.glNewList(theTorus, GL_COMPILE); + FillTorus(0.1f, 8, 1.0f, 25); + gl.glEndList(); + + gl.glEnable(GL_CULL_FACE); + gl.glCullFace(GL_BACK); + gl.glEnable(GL_DEPTH_TEST); + gl.glClearDepth(1.0); + + gl.glLightfv(GL_LIGHT0, GL_AMBIENT, light0_ambient); + gl.glLightfv(GL_LIGHT0, GL_DIFFUSE, light0_diffuse); + gl.glLightfv(GL_LIGHT0, GL_SPECULAR, light0_specular); + gl.glLightfv(GL_LIGHT0, GL_POSITION, light0_position); + gl.glEnable(GL_LIGHT0); + + gl.glLightModelfv(GL_LIGHT_MODEL_LOCAL_VIEWER, lmodel_local); + gl.glLightModelfv(GL_LIGHT_MODEL_TWO_SIDE, lmodel_twoside); + gl.glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient); + gl.glEnable(GL_LIGHTING); + + gl.glClearColor(0.5f, 0.5f, 0.5f, 0.0f); + + gl.glMaterialfv(GL_FRONT, GL_AMBIENT, bevel_mat_ambient); + gl.glMaterialfv(GL_FRONT, GL_SHININESS, bevel_mat_shininess); + gl.glMaterialfv(GL_FRONT, GL_SPECULAR, bevel_mat_specular); + gl.glMaterialfv(GL_FRONT, GL_DIFFUSE, bevel_mat_diffuse); + + gl.glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE); + gl.glEnable(GL_COLOR_MATERIAL); + gl.glShadeModel(GL_SMOOTH); + + gl.glMatrixMode(GL_PROJECTION); + glu.gluPerspective(45f, 1.33f, 0.1f, 100.0f); + gl.glMatrixMode(GL_MODELVIEW); + glj.gljCheckGL(); + } + + + public void display() + { + int i; + + /* Standard GL4Java Init */ + if( glj.gljMakeCurrent() == false ) + { + System.out.println("problem in use() method"); + return; + } + + gl.glPushMatrix(); + + gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glu.gluLookAt(0, 0, 10, 0, 0, 0, 0, 1, 0); + + for (i = 0; i < RINGS; i++) { + gl.glColor3ubv(rgb_colors[i]); + gl.glPushMatrix(); + gl.glTranslatef(dests[i][0] + offsets[i][0], dests[i][1] + offsets[i][1], + dests[i][2] + offsets[i][2]); + gl.glRotatef(angs[i], rotAxis[i][0], rotAxis[i][1], rotAxis[i][2]); + gl.glCallList(theTorus); + gl.glPopMatrix(); + } + + gl.glPopMatrix(); + glj.gljSwap(); + glj.gljCheckGL(); + glj.gljFree(); + animationCalc(); + } + + public void animationCalc() + { + int i, j; + + for (i = 0; i < RINGS; i++) { + if (iters[i]!=0) { + for (j = 0; j < 3; j++) { + offsets[i][j] = Clamp(iters[i], offsets[i][j]); + } + angs[i] = Clamp(iters[i], angs[i]); + iters[i]--; + } + } + if (iters[0]==0) + { + shallWeRender=false; + } + } + + public void ReInit() + { + int i; + float deviation; + + deviation = MyRand() / 2; + deviation = deviation * deviation; + for (i = 0; i < RINGS; i++) { + offsets[i][0] = MyRand(); + offsets[i][1] = MyRand(); + offsets[i][2] = MyRand(); + angs[i] = (float) (260.0 * MyRand()); + rotAxis[i][0] = MyRand(); + rotAxis[i][1] = MyRand(); + rotAxis[i][2] = MyRand(); + iters[i] = ( int ) (deviation * MyRand() + 60.0); + } + } + + public void FillTorus(float rc, int numc, float rt, int numt) + { + int i, j, k; + double s, t; + float x, y, z; + + for (i = 0; i < numc; i++) { + gl.glBegin(GL_QUAD_STRIP); + for (j = 0; j <= numt; j++) { + for (k = 1; k >= 0; k--) { + s = (i + k) % numc + 0.5; + t = j % numt; + + x = (float) Math.cos(t * M_2PI / numt) * (float) Math.cos(s * M_2PI / numc); + y = (float) Math.sin(t * M_2PI / numt) * (float) Math.cos(s * M_2PI / numc); + z = (float) Math.sin(s * M_2PI / numc); + gl.glNormal3f(x, y, z); + + x = (rt + rc * (float) Math.cos(s * M_2PI / numc)) * (float) Math.cos(t * M_2PI / numt); + y = (rt + rc * (float) Math.cos(s * M_2PI / numc)) * (float) Math.sin(t * M_2PI / numt); + z = rc * (float) Math.sin(s * M_2PI / numc); + gl.glVertex3f(x, y, z); + } + } + gl.glEnd(); + } + } + + public float Clamp(int iters_left, float t) + { + + if (iters_left < 3) { + return 0.0f; + } + return (iters_left - 2) * t / iters_left; + } + + public float MyRand() + { + // return 10.0 * (drand48() - 0.5); + return (float) ( 10.0 * (Math.random() - 0.5) ); + } + +} + diff --git a/demos/sappletviewer.bat b/demos/sappletviewer.bat new file mode 100755 index 0000000..90f7666 --- /dev/null +++ b/demos/sappletviewer.bat @@ -0,0 +1 @@ +appletviewer.exe -J-Djava.security.policy=gl4java.policy %*
diff --git a/demos/sappletviewer.sh b/demos/sappletviewer.sh new file mode 100755 index 0000000..21c2e07 --- /dev/null +++ b/demos/sappletviewer.sh @@ -0,0 +1,4 @@ +#! /bin/sh
+
+echo aa
+appletviewer -J-Djava.security.policy=gl4java.policy $*
diff --git a/demos/starCvs.java b/demos/starCvs.java new file mode 100644 index 0000000..b7c942c --- /dev/null +++ b/demos/starCvs.java @@ -0,0 +1,205 @@ +/*
+ * Leo Chan
+ *
+ * October 1995
+ *
+ * -----------
+ *
+ * Sven Goethel
+ * September 1997
+ *
+ * @version 1.0, 23. JUNI 1998
+ */
+
+
+import gl4java.awt.*;
+import java.awt.*;
+import java.awt.event.*;
+
+
+class starCvs extends GLAnimCanvas
+{
+ protected int FrameStep =0;
+
+ float lmodel_twoside[] = null;
+ float lmodel_local[] = null;
+ float lmodel_ambient[] = null;
+
+ public starCvs(int w, int h, String glClass, String gluClass)
+ {
+ super( w, h, glClass, gluClass);
+ }
+
+ public void init()
+ {
+ lmodel_twoside= new float[4];
+ lmodel_twoside[0]=0f;
+ lmodel_twoside[1]=0f;
+ lmodel_twoside[2]=0f;
+ lmodel_twoside[3]=0f;
+ lmodel_local= new float[4];
+ lmodel_local[0]=0f;
+ lmodel_local[1]=0f;
+ lmodel_local[2]=0f;
+ lmodel_local[3]=0f;
+ lmodel_ambient= new float[4];
+ lmodel_ambient[0]=0f;
+ lmodel_ambient[1]=0f;
+ lmodel_ambient[2]=0f;
+ lmodel_ambient[3]=0f;
+
+ /* initialize the widget */
+ gl.glClearColor( 0.8f, 0.8f, 1.0f, 1.0f );
+ gl.glFrontFace( GL_CW );
+ gl.glEnable( GL_DEPTH_TEST );
+
+ int width = cvsGetWidth();
+ int height = cvsGetHeight();
+
+ gl.glViewport( 0, 0, width, height );
+
+ gl.glMatrixMode( GL_PROJECTION );
+ gl.glLoadIdentity();
+
+ double fov = 45.0,
+ aspect = width / height,
+ near = 1.0,
+ far = 200.0;
+ glu.gluPerspective( fov, aspect, near, far );
+
+ gl.glMatrixMode( GL_MODELVIEW );
+ gl.glLoadIdentity();
+
+ /* render three rotated cylinders */
+ gl.glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
+
+
+ float lightArr[] = new float[4];
+ float farr[] = new float[4];
+
+ /* enable lighting */
+
+ lightArr[0] = 1.0f; lightArr[1] = 1.0f;
+ lightArr[2] = 1.0f; lightArr[3] = 1.0f;
+ gl.glLightfv( GL_LIGHT0, GL_DIFFUSE, lightArr );
+ lightArr[0] = 90.0f; lightArr[1] = 90.0f;
+ lightArr[2] = 0.0f; lightArr[3] = 0.0f;
+ gl.glLightfv( GL_LIGHT0, GL_POSITION, lightArr );
+ lightArr[0] = 0.1f; lightArr[1] = 0.1f;
+ lightArr[2] = 0.1f; lightArr[3] = 1.0f;
+ gl.glLightfv( GL_LIGHT0, GL_AMBIENT, lightArr );
+ gl.glLightModeli( GL_LIGHT_MODEL_TWO_SIDE,
+ 1 );
+ gl.glEnable( GL_LIGHT0 );
+
+ /*
+ gl.glLightModelfv(GL_LIGHT_MODEL_LOCAL_VIEWER, lmodel_local);
+ gl.glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient);
+ */
+ gl.glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, 1);
+ gl.glEnable( GL_LIGHTING );
+
+
+ gl.glMaterialf( GL_FRONT, GL_SHININESS, 30.0f );
+
+ farr[0] = 0.0f; farr[1] = 0.0f; farr[2] = 0.0f; farr[3] = 1.0f;
+ gl.glMaterialfv( GL_FRONT, GL_SPECULAR, farr );
+
+ farr[0] = 0.0f; farr[1] = 1.0f; farr[2] = 0.0f; farr[3] = 1.0f;
+ gl.glMaterialfv( GL_FRONT, GL_DIFFUSE, farr );
+
+ gl.glMaterialf( GL_BACK, GL_SHININESS, 50.0f );
+
+ farr[0] = 0.0f; farr[1] = 0.0f; farr[2] = 1.0f; farr[3] = 1.0f;
+ gl.glMaterialfv( GL_BACK, GL_SPECULAR, farr );
+
+ farr[0] = 1.0f; farr[1] = 1.0f; farr[2] = 0.0f; farr[3] = 1.0f;
+ gl.glMaterialfv( GL_BACK, GL_DIFFUSE, farr );
+ }
+
+ public void animationCalc()
+ {
+ FrameStep+=1;
+ if(FrameStep>100000) FrameStep=0;
+ }
+
+ public void display()
+ {
+ /* Standard gl4java Init */
+ if( glj.gljMakeCurrent() == false )
+ {
+ System.out.println("problem in use() method");
+ return;
+ }
+
+ gl.glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
+ gl.glPushMatrix();
+ gl.glTranslatef( 0.0f, 0.0f, -65.0f );
+ gl.glRotatef( 40.0f+(2f*FrameStep), 0.0f, 0.0f, 1.0f );
+ gl.glRotatef( 190.0f+(2f*FrameStep), 0.0f, 1.0f, 0.0f );
+ gl.glRotatef( 200.0f+(FrameStep*2f), 1.0f, 0.0f, 0.0f );
+ gl.glPushMatrix();
+ gl.glScalef( 1.0f, 1.0f, 10.0f );
+ drawCylinder();
+ gl.glPopMatrix();
+ gl.glPushMatrix();
+ gl.glRotatef( 90.0f, 0.0f, 1.0f, 0.0f );
+ gl.glScalef( 1.0f, 1.0f, 10.0f );
+ drawCylinder();
+ gl.glPopMatrix();
+ gl.glPushMatrix();
+ gl.glRotatef( 90.0f, 1.0f, 0.0f, 0.0f );
+ gl.glScalef( 1.0f, 1.0f, 10.0f );
+ drawCylinder();
+ gl.glPopMatrix();
+ gl.glPopMatrix();
+
+ glj.gljSwap();
+ glj.gljCheckGL();
+ glj.gljFree();
+ animationCalc() ;
+ }
+
+ public void drawCylinder()
+ {
+ gl.glBegin( GL_TRIANGLE_STRIP );
+ gl.glNormal3f ( 1.0f, 0.0f, -5.0f);
+ gl.glVertex3f ( 1.0f, 0.0f, -5.0f);
+ gl.glNormal3f ( 1.0f, 0.0f, -5.0f);
+ gl.glVertex3f (1.000000f, 0.000000f, 5.000000f);
+ gl.glNormal3f (0.707107f, 0.707107f, -5.000000f);
+ gl.glVertex3f (0.707107f, 0.707107f, -5.000000f);
+ gl.glNormal3f (0.707107f, 0.707107f, -5.000000f);
+ gl.glVertex3f (0.707107f, 0.707107f, 5.000000f);
+ gl.glNormal3f (0.000000f, 1.000000f, -5.000000f);
+ gl.glVertex3f (0.000000f, 1.000000f, -5.000000f);
+ gl.glNormal3f (0.000000f, 1.000000f, -5.000000f);
+ gl.glVertex3f (0.000000f, 1.000000f, 5.000000f);
+ gl.glNormal3f (-0.707107f, 0.707107f, -5.00000f);
+ gl.glVertex3f (-0.707107f, 0.707107f, -5.00000f);
+ gl.glNormal3f (-0.707107f, 0.707107f, -5.00000f);
+ gl.glVertex3f (-0.707107f, 0.707107f, 5.00000f);
+ gl.glNormal3f (-1.000000f, 0.000000f, -5.000000f);
+ gl.glVertex3f (-1.000000f, 0.000000f, -5.000000f);
+ gl.glNormal3f (-1.000000f, 0.000000f, -5.000000f);
+ gl.glVertex3f (-1.000000f, 0.000000f, 5.00000f);
+ gl.glNormal3f (-0.707107f, -0.707107f, -5.000000f);
+ gl.glVertex3f (-0.707107f, -0.707107f, -5.000000f);
+ gl.glNormal3f (-0.707107f, -0.707107f, -5.000000f);
+ gl.glVertex3f (-0.707107f, -0.707107f, 5.00000f);
+ gl.glNormal3f (0.000000f, -1.000000f, -5.000000f);
+ gl.glVertex3f (0.000000f, -1.000000f, -5.000000f);
+ gl.glNormal3f (0.000000f, -1.000000f, -5.000000f);
+ gl.glVertex3f (0.000000f, -1.000000f, 5.00000f);
+ gl.glNormal3f (0.707107f, -0.707107f, -5.00000f);
+ gl.glVertex3f (0.707107f, -0.707107f, -5.00000f);
+ gl.glNormal3f (0.707107f, -0.707107f, -5.00000f);
+ gl.glVertex3f (0.707107f, -0.707107f, 5.000000f);
+ gl.glNormal3f (1.000000f, 0.000000f, -5.00000f);
+ gl.glVertex3f (1.000000f, 0.000000f, -5.00000f);
+ gl.glNormal3f (1.000000f, 0.000000f, -5.00000f);
+ gl.glVertex3f (1.000000f, 0.000000f, 5.00000f);
+ gl.glEnd();
+ }
+}
+
diff --git a/demos/starCvs.java-orig b/demos/starCvs.java-orig new file mode 100644 index 0000000..9a45e68 --- /dev/null +++ b/demos/starCvs.java-orig @@ -0,0 +1,444 @@ +/* + * Leo Chan + * + * October 1995 + * + * ----------- + * + * Sven Goethel + * September 1997 + * + * @version 1.0, 23. JUNI 1998 + */ + + +import GL4Java.*; +import java.awt.*; +import java.awt.event.*; + + +class testGL1 extends GLFrame + implements ActionListener, ComponentListener, MouseListener, Runnable +{ + + protected double FramesPerSec=20; + protected long fps_count=0; + protected long fps_start=0; + + protected Thread killme = null; + protected int FrameStep =0; + + protected boolean inAnApplet = true; + + float lmodel_twoside[] = null; + float lmodel_local[] = null; + float lmodel_ambient[] = null; + + InfoWin iw=null; + + public static void main( String args[] ) + { + GLFrame.glNativeDebug = false; + GLFrame.glClassDebug = false; + testGL1 tt = new testGL1(); + tt.inAnApplet=false; + } + + public testGL1() + { + super( "Star GL4Java", 300, 250 ); + setVisible(true); + } + + Frame ctrl = null; + + Button ButtonFps; TextField TextFps; + + public void init() + { + ctrl = new Frame ("Features"); + + ctrl.setLayout(new GridLayout(1,2)); + ctrl.add ( ButtonFps=new Button("Frames per secound") ); + ctrl.add ( TextFps=new TextField() ); + + ctrl.pack(); + ctrl.setVisible( true ); + + ButtonFps.addMouseListener(this); + TextFps.addActionListener(this); + + ctrl.addWindowListener(this); + + iw = new InfoWin(this); + iw.pack(); + iw.show(); + + iw.addWindowListener(this); + + lmodel_twoside= new float[4]; + lmodel_twoside[0]=0f; + lmodel_twoside[1]=0f; + lmodel_twoside[2]=0f; + lmodel_twoside[3]=0f; + lmodel_local= new float[4]; + lmodel_local[0]=0f; + lmodel_local[1]=0f; + lmodel_local[2]=0f; + lmodel_local[3]=0f; + lmodel_ambient= new float[4]; + lmodel_ambient[0]=0f; + lmodel_ambient[1]=0f; + lmodel_ambient[2]=0f; + lmodel_ambient[3]=0f; + + /* Standard GL4Java Init */ + if( gljUse() == false ) + { + System.out.println("problem in use() method"); + return; + } + + /* initialize the widget */ + glClearColor( 0.8f, 0.8f, 1.0f, 1.0f ); + glFrontFace( GL_CW ); + glEnable( GL_DEPTH_TEST ); + + int width = gljGetWidth(); + int height = gljGetHeight(); + + glViewport( 0, 0, width, height ); + + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); + + double fov = 45.0, + aspect = width / height, + near = 1.0, + far = 200.0; + gluPerspective( fov, aspect, near, far ); + + glMatrixMode( GL_MODELVIEW ); + glLoadIdentity(); + + /* render three rotated cylinders */ + glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); + + + float lightArr[] = new float[4]; + float farr[] = new float[4]; + + /* enable lighting */ + + lightArr[0] = 1.0f; lightArr[1] = 1.0f; + lightArr[2] = 1.0f; lightArr[3] = 1.0f; + glLightfv( GL_LIGHT0, GL_DIFFUSE, lightArr ); + lightArr[0] = 90.0f; lightArr[1] = 90.0f; + lightArr[2] = 0.0f; lightArr[3] = 0.0f; + glLightfv( GL_LIGHT0, GL_POSITION, lightArr ); + lightArr[0] = 0.1f; lightArr[1] = 0.1f; + lightArr[2] = 0.1f; lightArr[3] = 1.0f; + glLightfv( GL_LIGHT0, GL_AMBIENT, lightArr ); + glLightModeli( GL_LIGHT_MODEL_TWO_SIDE, + 1 ); + glEnable( GL_LIGHT0 ); + + /* + glLightModelfv(GL_LIGHT_MODEL_LOCAL_VIEWER, lmodel_local); + glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient); + */ + glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, 1); + glEnable( GL_LIGHTING ); + + + glMaterialf( GL_FRONT, GL_SHININESS, 30.0f ); + + farr[0] = 0.0f; farr[1] = 0.0f; farr[2] = 0.0f; farr[3] = 1.0f; + glMaterialfv( GL_FRONT, GL_SPECULAR, farr ); + + farr[0] = 0.0f; farr[1] = 1.0f; farr[2] = 0.0f; farr[3] = 1.0f; + glMaterialfv( GL_FRONT, GL_DIFFUSE, farr ); + + glMaterialf( GL_BACK, GL_SHININESS, 50.0f ); + + farr[0] = 0.0f; farr[1] = 0.0f; farr[2] = 1.0f; farr[3] = 1.0f; + glMaterialfv( GL_BACK, GL_SPECULAR, farr ); + + farr[0] = 1.0f; farr[1] = 1.0f; farr[2] = 0.0f; farr[3] = 1.0f; + glMaterialfv( GL_BACK, GL_DIFFUSE, farr ); + + start(); + } + + public void start() + { + if(killme == null) + { + killme = new Thread(this,"star"); + killme.start(); + + fps_count=0; + fps_start=System.currentTimeMillis(); + } + } + public void stop() + { + killme.stop(); + killme = null; + } + + public void run() + { + + while (killme!=null) + { + + /* DRAW THE TINGS .. */ + repaint(); + try {Thread.sleep((int)((1.0/FramesPerSec)*1000.0));} catch (InterruptedException e){} + + //sDisplay(); + + FrameStep+=1; + if(FrameStep>100000) FrameStep=0; + + //Thread.yield(); + } + + } + + public void display() + { + /* Standard GL4Java Init */ + if( gljUse() == false ) + { + System.out.println("problem in use() method"); + return; + } + + glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); + glPushMatrix(); + glTranslatef( 0.0f, 0.0f, -65.0f ); + glRotatef( 40.0f+(2f*FrameStep), 0.0f, 0.0f, 1.0f ); + glRotatef( 190.0f+(2f*FrameStep), 0.0f, 1.0f, 0.0f ); + glRotatef( 200.0f+(FrameStep*2f), 1.0f, 0.0f, 0.0f ); + glPushMatrix(); + glScalef( 1.0f, 1.0f, 10.0f ); + drawCylinder(); + glPopMatrix(); + glPushMatrix(); + glRotatef( 90.0f, 0.0f, 1.0f, 0.0f ); + glScalef( 1.0f, 1.0f, 10.0f ); + drawCylinder(); + glPopMatrix(); + glPushMatrix(); + glRotatef( 90.0f, 1.0f, 0.0f, 0.0f ); + glScalef( 1.0f, 1.0f, 10.0f ); + drawCylinder(); + glPopMatrix(); + glPopMatrix(); + + gljSwap(); + gljCheckGL(); + + fps_count++; + } + + public void drawCylinder() + { + glBegin( GL_TRIANGLE_STRIP ); + glNormal3f ( 1.0f, 0.0f, -5.0f); + glVertex3f ( 1.0f, 0.0f, -5.0f); + glNormal3f ( 1.0f, 0.0f, -5.0f); + glVertex3f (1.000000f, 0.000000f, 5.000000f); + glNormal3f (0.707107f, 0.707107f, -5.000000f); + glVertex3f (0.707107f, 0.707107f, -5.000000f); + glNormal3f (0.707107f, 0.707107f, -5.000000f); + glVertex3f (0.707107f, 0.707107f, 5.000000f); + glNormal3f (0.000000f, 1.000000f, -5.000000f); + glVertex3f (0.000000f, 1.000000f, -5.000000f); + glNormal3f (0.000000f, 1.000000f, -5.000000f); + glVertex3f (0.000000f, 1.000000f, 5.000000f); + glNormal3f (-0.707107f, 0.707107f, -5.00000f); + glVertex3f (-0.707107f, 0.707107f, -5.00000f); + glNormal3f (-0.707107f, 0.707107f, -5.00000f); + glVertex3f (-0.707107f, 0.707107f, 5.00000f); + glNormal3f (-1.000000f, 0.000000f, -5.000000f); + glVertex3f (-1.000000f, 0.000000f, -5.000000f); + glNormal3f (-1.000000f, 0.000000f, -5.000000f); + glVertex3f (-1.000000f, 0.000000f, 5.00000f); + glNormal3f (-0.707107f, -0.707107f, -5.000000f); + glVertex3f (-0.707107f, -0.707107f, -5.000000f); + glNormal3f (-0.707107f, -0.707107f, -5.000000f); + glVertex3f (-0.707107f, -0.707107f, 5.00000f); + glNormal3f (0.000000f, -1.000000f, -5.000000f); + glVertex3f (0.000000f, -1.000000f, -5.000000f); + glNormal3f (0.000000f, -1.000000f, -5.000000f); + glVertex3f (0.000000f, -1.000000f, 5.00000f); + glNormal3f (0.707107f, -0.707107f, -5.00000f); + glVertex3f (0.707107f, -0.707107f, -5.00000f); + glNormal3f (0.707107f, -0.707107f, -5.00000f); + glVertex3f (0.707107f, -0.707107f, 5.000000f); + glNormal3f (1.000000f, 0.000000f, -5.00000f); + glVertex3f (1.000000f, 0.000000f, -5.00000f); + glNormal3f (1.000000f, 0.000000f, -5.00000f); + glVertex3f (1.000000f, 0.000000f, 5.00000f); + glEnd(); + } + + // Methods required for the implementation of MouseListener + public void mouseClicked( MouseEvent evt ) + { + Component comp = evt.getComponent(); + + if( gljUse() == false ) + { + System.out.println("CtrlWin: problem in use() method"); + return; + } + + glFinish(); + + if(comp.equals(ButtonFps)) + { + long fps_end=System.currentTimeMillis(); + long timed= (fps_end-fps_start)/1000; + if(timed==0) timed=1; + TextFps.setText(String.valueOf(fps_count/timed)); + System.out.println("calculated fps: "+TextFps.getText()); + + fps_count=0; + fps_start=System.currentTimeMillis(); + } + + glFinish(); + gljFree(); + + if ( killme==null || ! Thread.currentThread().equals(killme) ) + repaint(); + } + + public void mouseEntered( MouseEvent evt ) + { + } + + public void mouseExited( MouseEvent evt ) + { + } + + public void mousePressed( MouseEvent evt ) + { + } + + public void mouseReleased( MouseEvent evt ) + { + } + + public void windowClosing(WindowEvent e) + { + Component comp = e.getComponent(); + + if(ctrl!=null && ( comp.equals(ctrl) || comp.equals(this) ) ) + { + ctrl.dispose(); + } + + if(iw!=null && ( comp.equals(iw) || comp.equals(this) ) ) + { + iw.dispose(); + } + + + if(killme!=null && comp.equals(this) ) + { + ctrl.dispose(); + iw.dispose(); + super.windowClosing(e); + killme.stop(); + } + } + + public void actionPerformed(ActionEvent event) + { + Object source = event.getSource(); + + if ( source == TextFps) + { + try { + FramesPerSec=Double.valueOf(TextFps.getText()).doubleValue(); + System.out.println("trying "+FramesPerSec+" fps."); + } catch (NumberFormatException s) { + System.out.println("wrong fps format, use float .."); + } + + fps_count=0; + fps_start=System.currentTimeMillis(); + } + } + + public class InfoWin extends Frame + implements ActionListener + { + GLFrame glFrame = null; + + TextArea output = null; + + MenuItem miGLInfo = null; + + public InfoWin(GLFrame glf) + { + glFrame=glf; + + setTitle("Info Window"); + + output = new TextArea(5, 30); + output.setEditable(false); + setLayout(new BorderLayout()); //give max space to the output + add("Center", output); + + + MenuBar mb = new MenuBar(); + setMenuBar( mb ); + + Menu info = new Menu( "Info"); + info.add( (miGLInfo=new MenuItem( "about GL/GLU"))); + mb.add( info ); + + miGLInfo.addActionListener(this); + + } + + public void actionPerformed(ActionEvent event) + { + String str = new String(); + + if (event.getSource().equals(miGLInfo)) { + if( gljUse() == false ) + { + str=str+"problem in use() method\n"; + } else { + String glVen = glGetString(GL_VENDOR); + String glRen = glGetString(GL_RENDERER); + String glVer = glGetString(GL_VERSION); + String glExt = glGetString(GL_EXTENSIONS); + String gluVer = gluGetString(GLU_VERSION); + String gluExt = gluGetString(GLU_EXTENSIONS); + + str=str+"GL VENDOR: "+glVen+"\n"; + str=str+"GL RENDERER: "+glRen+"\n"; + str=str+"GL VERSION: "+glVer+"\n"; + str=str+"GL EXTENSIONS: "+glExt+"\n"; + str=str+"GLU VERSION: "+gluVer+"\n"; + str=str+"GLU EXTENSIONS: "+gluExt+"\n"; + gljFree(); + } + + } + str += "\n\n"; + output.append(str); + } + + } + +} + diff --git a/demos/test-jni12tst.sh b/demos/test-jni12tst.sh new file mode 100755 index 0000000..d5f0d45 --- /dev/null +++ b/demos/test-jni12tst.sh @@ -0,0 +1,3 @@ +#! /bin/sh + +java gl4java.utils.Test -gljlib GL4JavaJauGljJNI12 -gllib GL4JavaJauGLJNI12tst -glulib GL4JavaJauGLUJNI12tst -testclass $1 diff --git a/demos/test-jnitst.sh b/demos/test-jnitst.sh new file mode 100755 index 0000000..b078d5e --- /dev/null +++ b/demos/test-jnitst.sh @@ -0,0 +1,3 @@ +#! /bin/sh + +java gl4java.utils.Test -gljlib GL4JavaJauGljJNI -gllib GL4JavaJauGLJNItst -glulib GL4JavaJauGLUJNItst -testclass $1 diff --git a/demos/test.sh b/demos/test.sh new file mode 100755 index 0000000..3b1eb58 --- /dev/null +++ b/demos/test.sh @@ -0,0 +1,3 @@ +#! /bin/sh + +java gl4java.utils.Test -testclass $1 diff --git a/demos/test1Cvs.java b/demos/test1Cvs.java new file mode 100644 index 0000000..85e03bb --- /dev/null +++ b/demos/test1Cvs.java @@ -0,0 +1,100 @@ +/** + * @(#) test1Cvs.java + */ + +import gl4java.GLContext; +import gl4java.awt.GLCanvas; +import java.awt.*; +import java.awt.event.*; +import java.lang.Math; + + +class test1Cvs extends GLCanvas +{ +/** + * Instead of using suspend (JAVA2) + * + * @see run + */ + protected boolean threadSuspended = true; + + protected int[] textures = null; + + public test1Cvs (int w, int h, + String glClass, String gluClass ) + { + super(w, h, glClass, gluClass ); + } + + public void preInit() + { + doubleBuffer = true; + stereoView = true; + } + + public void init() + { + textures = new int[10]; + gl.glGenTextures(10, textures); + for (int i=0; i<10; i++) + System.out.println("Texture "+ i +" maps to GL tex "+ textures[i]); + } + + + public void display() + { + /* Standard GL4Java Init */ + if( glj.gljMakeCurrent() == false ) + { + System.out.println("problem in use() method"); + return; + } + + glj.gljSwap(); + glj.gljCheckGL(); + glj.gljFree(); + } + + public void ReInit() + { + } + + public static void main( String args[] ) { + String gljLib=null; + String glLib=null; + String gluLib=null; + String glClass=null; + String gluClass=null; + + if(args.length>0) + gljLib = args[0]; + if(args.length>1) + glLib = args[1]; + if(args.length>2) + gluLib = args[2]; + + if(GLContext.loadNativeLibraries(gljLib, glLib, gluLib)==false) + System.out.println("could not load native libs:"+ + gljLib + ", " + glLib + ", " + gluLib); + else + System.out.println("load native libs:"+ + gljLib + ", " + glLib + ", " + gluLib); + + + Frame mainFrame = new Frame("glDemosCvs"); + + if(args.length>3) + glClass = args[3]; + if(args.length>4) + gluClass = args[4]; + + test1Cvs cvs1 = new test1Cvs(100, 100, glClass, gluClass); + + mainFrame.add(cvs1); + + mainFrame.pack(); + mainFrame.setVisible(true); + } + +} + diff --git a/demos/testTextPPM1.html b/demos/testTextPPM1.html new file mode 100644 index 0000000..abc9237 --- /dev/null +++ b/demos/testTextPPM1.html @@ -0,0 +1,13 @@ +
+<HTML>
+<HEAD>
+<TITLE>test</TITLE>
+</HEAD>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+<hr>
+<applet code="testTextPPM1.class" width=550 height=550 >
+</applet>
+<hr>
+</BODY>
+</HTML>
+
diff --git a/demos/testTextPPM1.java b/demos/testTextPPM1.java new file mode 100755 index 0000000..e7d876c --- /dev/null +++ b/demos/testTextPPM1.java @@ -0,0 +1,496 @@ +//-? IMPORTS +import gl4java.awt.GLCanvas; +import gl4java.GLContext; +import gl4java.utils.textures.*;
+ +import javax.swing.*; +import javax.swing.event.*; +import javax.swing.border.*; + +import java.awt.*; +import java.awt.Color.*; +import java.awt.event.*; +import java.applet.*; +import java.io.*; +import java.net.*; + +//// TEST +// UniversalFileAccess -> netscape +///////////////////////////////////////////////////////////////// +public class testTextPPM1 extends JApplet +{ + +//-? VARIABLES GLOBALS APPLET + JPanel panelControl,panelDibuix; + JButton botoShading,botoTexture; + dibuix dib; +// ActionsListener Actions; +// SliderListener Sliders; + + //-? VARIABLES de CONTROL + double obsX=0 , obsY=0 , obsZ=1.0; //-? POSICIO OBSERVADOR + JSlider sl_alfaUsu,sl_betaUsu; + + //-? VARIABLES GL + int tipusPolMode; + + boolean isAnApplet = true; + +//--------------------------------------------------------------- + +public void init() { + + +// Actions = new ActionsListener(); + + panelDibuix = iniDibuix(); + panelControl = iniControl(); + + + getContentPane().setLayout(new BoxLayout(getContentPane(),BoxLayout.Y_AXIS)); + getContentPane().add(panelControl); + getContentPane().add(panelDibuix); + + getContentPane().repaint(); +} + public static void main( String args[] ) { + testTextPPM1 applet = + new testTextPPM1(); + + Frame f = new Frame("testTextPPM1"); + + f.addWindowListener( new WindowAdapter() + { + public void windowClosed(WindowEvent e) + { + System.exit(0); + } + public void windowClosing(WindowEvent e) + { + windowClosed(e); + } + } + ); + + f.setLayout(new BorderLayout()); + f.add("Center", applet); + applet.setSize(500,300); + applet.isAnApplet = false; + applet.init(); + applet.start(); + Dimension ps = applet.getPreferredSize(); + f.setBounds(-100,-100,99,99); + f.setVisible(true); + f.setVisible(false); + Insets i = f.getInsets(); + f.setBounds(0,0, + ps.width+i.left+i.right, + ps.height+i.top+i.bottom); + f.setVisible(true); + } + +//--------------------------------------------------------------- +public void paint(Graphics g) { + getContentPane().repaint(); + dib.display(); +} + +//--------------------------------------------------------------- +public JPanel iniControl() { + + panelControl = new JPanel(); + + sl_alfaUsu = new JSlider(JSlider.HORIZONTAL,-180,180,0); + sl_alfaUsu.setMajorTickSpacing(45); + sl_alfaUsu.setMinorTickSpacing(15); + sl_alfaUsu.setPaintTicks(true); + sl_alfaUsu.setPaintLabels(true); + sl_alfaUsu.setPreferredSize(new Dimension(350,50)); + sl_alfaUsu.setMaximumSize(new Dimension(350,50)); + sl_alfaUsu.setMinimumSize(new Dimension(350,50)); + + sl_betaUsu = new JSlider(JSlider.HORIZONTAL,-90,90,0); + sl_betaUsu.setMajorTickSpacing(30); + sl_betaUsu.setMinorTickSpacing(10); + sl_betaUsu.setPaintTicks(true); + sl_betaUsu.setPaintLabels(true); + sl_betaUsu.setPreferredSize(new Dimension(350,50)); + sl_betaUsu.setMaximumSize(new Dimension(350,50)); + sl_betaUsu.setMinimumSize(new Dimension(350,50)); + + sl_alfaUsu.addChangeListener(dib); + sl_betaUsu.addChangeListener(dib); + + //-? PANEL DE BOTONS + JPanel panelBotons = new JPanel(); + panelBotons.setLayout(new BoxLayout(panelBotons,BoxLayout.X_AXIS)); + + botoShading = new JButton("Shading Model"); + botoShading.addActionListener(dib); + botoShading.setActionCommand("bS"); + + botoTexture = new JButton("Textures"); + botoTexture.addActionListener(dib); + botoTexture.setActionCommand("bT"); + + panelBotons.add(botoShading); + panelBotons.add(botoTexture); + + //-? PANEL GLOBAL DE CONTROLS + panelControl.setLayout(new BoxLayout(panelControl,BoxLayout.Y_AXIS)); + panelControl.add(sl_alfaUsu); + panelControl.add(sl_betaUsu); + panelControl.add(panelBotons); + + return panelControl; +} + +//--------------------------------------------------------------- +public JPanel iniDibuix() { + + dib = new dibuix(550,550); + + panelDibuix = new JPanel(); + panelDibuix.setLayout(new BoxLayout(panelDibuix,BoxLayout.X_AXIS)); + panelDibuix.setBorder(new SoftBevelBorder(BevelBorder.LOWERED)); + panelDibuix.add(dib); + + return panelDibuix; +} + +///////////////////////////////////////////////////////////////// +//// DIBUIX +///////////////////////////////////////////////////////////////// +class dibuix extends GLCanvas + implements ActionListener,ChangeListener,MouseMotionListener,MouseListener +{ + //-? VARIABLES GLOBALS DE LA CLASSE + + float n[][] = null; //-? NORMALS + int f[][] = null; //-? FACES + float v[][] = null; //-? VERTEXS + + //-? POSICIO OBSERVADOR + //L'HEM POSADA GLOBAL double obsX=0 , obsY=0 , obsZ=5.0; + + float llum_d[]; //-? LLUM DIFOSA + float llum_d_pos[]; //-? POSICIO LLUM DIFOSA + float llum_d2[]; //-? LLUM DIFOSA + float llum_d2_pos[]; //-? POSICIO LLUM DIFOSA + + int texName[]={0}; + boolean textures=false; + + int anclaX,anclaY,anclaAlfa,anclaBeta; +//--------------------------------------------------------------- +public dibuix(int x, int y){ + + //-? PASSEM A CLASSE SUPERIOR ELS 2 PARAMS. DE CONSTRUCTOR + super(x,y); +} +//--------------------------------------------------------------- + +public void init(){ + + System.out.println("-- INIT"); + + addMouseMotionListener(this); + addMouseListener(this); + + //-? INICIALITZEM NORMALS, VERTEXS , CARES i LLUMS + n = new float[6][3]; + n[0][0]=-1f; + n[0][1]=0f; + n[0][2]=0f; + n[1][0]=0f; + n[1][1]=1f; + n[1][2]=0f; + n[2][0]=1f; + n[2][1]=0f; + n[2][2]=0f; + n[3][0]=0f; + n[3][1]=-1f; + n[3][2]=0f; + n[4][0]=0f; + n[4][1]=0f; + n[4][2]=1f; + n[5][0]=0f; + n[5][1]=0f; + n[5][2]=-1f; + + f = new int[6][4]; + f[0][0]=0; + f[0][1]=1; + f[0][2]=2; + f[0][3]=3; + f[1][0]=3; + f[1][1]=2; + f[1][2]=6; + f[1][3]=7; + f[2][0]=7; + f[2][1]=6; + f[2][2]=5; + f[2][3]=4; + f[3][0]=4; + f[3][1]=5; + f[3][2]=1; + f[3][3]=0; + f[4][0]=5; + f[4][1]=6; + f[4][2]=2; + f[4][3]=1; + f[5][0]=7; + f[5][1]=4; + f[5][2]=0; + f[5][3]=3; + + v = new float[8][3]; + v[0][0] = v[1][0] = v[2][0] = v[3][0] = -1; + v[4][0] = v[5][0] = v[6][0] = v[7][0] = 1; + v[0][1] = v[1][1] = v[4][1] = v[5][1] = -1; + v[2][1] = v[3][1] = v[6][1] = v[7][1] = 1; + v[0][2] = v[3][2] = v[4][2] = v[7][2] = 1; + v[1][2] = v[2][2] = v[5][2] = v[6][2] = -1; + + //-? DEFINICIO DE LLUMS + //-? LLUM DIFOSA 1 + llum_d = new float[4]; + llum_d[0] = 1.0f; + llum_d[1] = 0.0f; + llum_d[2] = 0.0f; + llum_d[3] = 1.0f; + + llum_d_pos = new float[4]; + llum_d_pos[0] = -3.0f; + llum_d_pos[1] = -3.0f; + llum_d_pos[2] = -4.0f; + llum_d_pos[3] = 0.0f; + + //-? LLUM DIFOSA 2 + llum_d2 = new float[4]; + llum_d2[0] = 1.0f; + llum_d2[1] = 1.0f; + llum_d2[2] = 0.0f; + llum_d2[3] = 1.0f; + + llum_d2_pos = new float[4]; + llum_d2_pos[0] = 3.0f; + llum_d2_pos[1] = 3.0f; + llum_d2_pos[2] = 4.0f; + llum_d2_pos[3] = 0.0f; + + //-? INICIALITZACIO GL -> NOPE + + gl.glClearColor( 0.4f, 0.4f, 5.0f, 1.0f ); + gl.glShadeModel(GL_SMOOTH); + gl.glEnable(GL_DEPTH_TEST); + + //-? CREEM LA TEXTURA + TextureLoader txtLoader1 = new PPMAsciiTextureLoader(gl, glu);
+ if(isAnApplet)
+ txtLoader1.readTexture(getCodeBase(), "lunaL.ppm");
+ else {
+ txtLoader1.readTexture("lunaL.ppm");
+ }
+
+ gl.glPixelStorei(GL_UNPACK_ALIGNMENT,1); + gl.glGenTextures(1,texName);
+ gl.glBindTexture(GL_TEXTURE_2D,texName[0]); + + gl.glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); + gl.glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); + gl.glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + gl.glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + + txtLoader1.texImage2DNonScaled(true); + // The Scaled Way + // txtLoader1.texImage2DScaled2Pow2(); + + //-? ILUMINACIO + gl.glLightfv(GL_LIGHT0, GL_DIFFUSE, llum_d); + gl.glLightfv(GL_LIGHT0, GL_POSITION, llum_d_pos); + gl.glLightfv(GL_LIGHT1, GL_DIFFUSE, llum_d2); + gl.glLightfv(GL_LIGHT1, GL_POSITION, llum_d2_pos); + gl.glEnable(GL_LIGHTING); + gl.glEnable(GL_LIGHT0); + gl.glEnable(GL_LIGHT1); + + puntVista(); +} +//--------------------------------------------------------------- +public void display() +{ + int i; + + if (cvsIsInit()==false || glj.gljMakeCurrent() == false) + { + System.out.println("-- Tenim algun problema glj.gljUse -2-"); + return; + } + puntVista(); + + gl.glLineWidth(1.4f); + gl.glPolygonMode(GL_FRONT_AND_BACK,tipusPolMode); + gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + if (textures) + { + gl.glEnable(GL_TEXTURE_2D); + gl.glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + gl.glBindTexture(GL_TEXTURE_2D,texName[0]); + } + + for(i=0;i<6;i++) + { + gl.glBegin(GL_QUADS); + gl.glNormal3fv(n[i]); + gl.glTexCoord2f(0.0f,0.0f);gl.glVertex3fv(v[f[i][0]]); + gl.glTexCoord2f(0.0f,1.0f);gl.glVertex3fv(v[f[i][1]]); + gl.glTexCoord2f(1.0f,1.0f);gl.glVertex3fv(v[f[i][2]]); + gl.glTexCoord2f(1.0f,0.0f);gl.glVertex3fv(v[f[i][3]]); + + gl.glEnd(); + gl.glFlush(); + } + if (textures) gl.glDisable(GL_TEXTURE_2D); + glj.gljSwap(); + glj.gljFree(); +} +//--------------------------------------------------------------- + +public void puntVista() +{ + + if (cvsIsInit()==false || glj.gljMakeCurrent() == false) + { + System.out.println("-- Tenim algun problema glj.gljUse -3-"); + return; + } + //-? Actualitzem PUNT OBS + + Integer IaU = new Integer(sl_alfaUsu.getValue()); + Integer IbU = new Integer(sl_betaUsu.getValue()); + + double daU =-(((double)IaU.doubleValue())*((double)2.0*java.lang.Math.PI))/ (double)360.0; + double dbU = (((double)IbU.doubleValue())*((double)2.0*java.lang.Math.PI))/ (double)360.0; + + obsX = 5.0 * java.lang.Math.sin(-daU) * java.lang.Math.cos(dbU); + obsY = 5.0 * java.lang.Math.sin(dbU); + obsZ = 5.0 * java.lang.Math.cos(-daU) * java.lang.Math.cos(dbU); + + //-? PUNT DE VISTA + gl.glMatrixMode(GL_PROJECTION); + gl.glLoadIdentity(); + glu.gluPerspective( /* field of view in degree */ 90.0, + /* aspect ratio */ 1.0, + /* Z near */ 1.0, + /* Z far */ 100.0); + gl.glMatrixMode(GL_MODELVIEW); + gl.glLoadIdentity(); + glu.gluLookAt(obsX, obsY, obsZ, /* eye is at (0,0,5) */ + 0.0, 0.0, 0.0, /* center is at (0,0,0) */ + 0.0, 1.0, 0.); /* up is in positive Y direction */ + + + + //gl.glTranslatef(0.0f, 0.0f, -1.0f); + //gl.glRotatef(-60f, 1.0f, 0.0f, 0.0f); + //gl.glRotatef(-20f, 0.0f, 0.0f, 1.0f); + +} +//--------------------------------------------------------------- + public void actionPerformed(java.awt.event.ActionEvent e) + { + + if (e.getActionCommand().equals("bS")) + { + if (tipusPolMode == GL_LINE) + { + tipusPolMode=GL_FILL; + } + else + { + tipusPolMode=GL_LINE; + } + display(); + } + if (e.getActionCommand().equals("bT")) + { + if (textures) + textures = false; + else + textures = true; + display(); + } + + } + +//--------------------------------------------------------------- +public void mouseClicked(MouseEvent e) +{ + +} +//--------------------------------------------------------------- +public void mouseEntered(MouseEvent e) +{ + +} +//--------------------------------------------------------------- +public void mouseExited(MouseEvent e) +{ + +} +//--------------------------------------------------------------- +public void mousePressed(MouseEvent e) +{ + anclaX=e.getX(); + anclaY=e.getY(); + + anclaAlfa=sl_alfaUsu.getValue(); + anclaBeta=sl_betaUsu.getValue(); +} +//--------------------------------------------------------------- +public void mouseReleased(MouseEvent e) +{ +} +//--------------------------------------------------------------- +public void mouseDragged(MouseEvent e) +{ + int difX=anclaX-e.getX(); + int difY=e.getY()-anclaY; + + sl_alfaUsu.setValue(anclaAlfa+difX); + sl_betaUsu.setValue(anclaBeta+difY); + + // puntVista(); JAU + // display(); JAU ... -> sDisplay() or repaint ... + repaint(); +} +//--------------------------------------------------------------- +public void mouseMoved(MouseEvent e) +{ + +} +//--------------------------------------------------------------- +public void stateChanged(ChangeEvent e) +{ + JSlider source = (JSlider) e.getSource(); + + dib.repaint(); + + if (source.equals(sl_alfaUsu)) + { + + } + + if (source.equals(sl_betaUsu)) + { + + } +} +//--------------------------------------------------------------- +} //-? Fi CLASSE Dibuix + +//--------------------------------------------------------------- +}// Fi Applet testTextPPM1 + diff --git a/demos/testTextPPM1J2P.html b/demos/testTextPPM1J2P.html new file mode 100644 index 0000000..4d76baf --- /dev/null +++ b/demos/testTextPPM1J2P.html @@ -0,0 +1,43 @@ +
+<HTML>
+<HEAD>
+<TITLE>test</TITLE>
+</HEAD>
+<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
+<hr>
+<!--"CONVERTED_APPLET"-->
+<!-- CONVERTER VERSION 1.0 -->
+<SCRIPT LANGUAGE="JavaScript"><!--
+ var _info = navigator.userAgent; var _ns = false;
+ var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0);
+//--></SCRIPT>
+<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!--
+ var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0)));
+//--></SCRIPT></COMMENT>
+
+<SCRIPT LANGUAGE="JavaScript"><!--
+ if (_ie == true) document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = 550 HEIGHT = 550 codebase="http://java.sun.com/products/plugin/1.2/jinstall-12-win32.cab#Version=1,2,0,0"><NOEMBED><XMP>');
+ else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.2" java_CODE = "testTextPPM1.class" WIDTH = 550 HEIGHT = 550 pluginspage="http://java.sun.com/products/plugin/1.2/plugin-install.html"><NOEMBED><XMP>');
+//--></SCRIPT>
+<APPLET CODE = "testTextPPM1.class" WIDTH = 550 HEIGHT = 550 ></XMP>
+<PARAM NAME = CODE VALUE = "testTextPPM1.class" >
+
+<PARAM NAME="type" VALUE="application/x-java-applet;version=1.2">
+
+</APPLET>
+
+</NOEMBED></EMBED></OBJECT>
+
+
+<!--
+<APPLET CODE = "testTextPPM1.class" WIDTH = 550 HEIGHT = 550 >
+
+
+</APPLET>
+-->
+<!--"END_CONVERTED_APPLET"-->
+
+<hr>
+</BODY>
+</HTML>
+
diff --git a/demos/waveCvs.java b/demos/waveCvs.java new file mode 100644 index 0000000..bd7afbe --- /dev/null +++ b/demos/waveCvs.java @@ -0,0 +1,634 @@ +
+/*
+ * @version 1.0, 23. JUNI 1998
+ */
+
+import gl4java.GLContext;
+import gl4java.awt.GLAnimCanvas;
+import java.awt.*;
+import java.awt.event.*;
+
+
+class waveCvs extends GLAnimCanvas
+ implements MouseListener
+{
+
+ class facet {
+ public float color[];
+ public float normal[];
+
+ public facet()
+ { color = new float[3];
+ normal = new float[3];
+ }
+ }
+
+ class coord {
+ public float vertex[];
+ public float normal[];
+
+ public coord()
+ { vertex = new float[3];
+ normal = new float[3];
+ }
+ }
+
+ class mesh {
+ public int widthX, widthY;
+ public int numFacets;
+ public int numCoords;
+ public int frames;
+ coord coords[];
+ facet facets[];
+ }
+
+/**
+ * The thread for referencing Thread (Animation)
+ *
+ * @see sbin
+ */
+ boolean rgb;
+
+ int colorIndexes1[];
+ int colorIndexes2[];
+ int clearMask = GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT;
+
+ boolean smooth = GL_TRUE;
+ boolean lighting = GL_TRUE;
+ boolean depth = GL_TRUE;
+ boolean stepMode = GL_FALSE;
+ boolean spinMode = GL_FALSE;
+ int contouring = 0;
+ int widthX, widthY;
+
+ int checkerSize;
+ float height;
+
+ int frames, curFrame = 0, nextFrame = 0;
+
+ mesh theMesh;
+
+ static final float PI = 3.14159265358979323846f;
+
+
+ byte contourTexture1[] = {
+ (byte) 255, (byte)255, (byte) 255, (byte) 255,
+ (byte) 255, (byte)255, (byte) 255, (byte) 255,
+ (byte) 255, (byte)255, (byte) 255, (byte) 255,
+ (byte) 127, (byte)127, (byte) 127, (byte) 127
+ };
+ byte contourTexture2[] = {
+ (byte) 255, (byte) 255, (byte) 255, (byte) 255,
+ (byte) 255, (byte) 127, (byte) 127, (byte) 127,
+ (byte) 255, (byte) 127, (byte) 127, (byte) 127,
+ (byte) 255, (byte) 127, (byte) 127, (byte) 127
+ };
+
+
+ public waveCvs(int w, int h, String glClass, String gluClass)
+ {
+ super( w, h, glClass, gluClass);
+ }
+
+ Frame ctrl = null;
+
+ Button ButtonCont; TextField TextCont;
+ Button ButtonShade; TextField TextShade;
+ Button ButtonLight; TextField TextLight;
+ Button ButtonDepth; TextField TextDepth;
+ Button ButtonStepMode; TextField TextStepMode;
+ Button ButtonStep; TextField TextStep;
+ Button ButtonSpinMode; TextField TextSpinMode;
+
+ public void init()
+ {
+ ctrl = new Frame ("Wave-Features");
+
+ ctrl.setLayout(new GridLayout(7,2));
+ ctrl.add ( ButtonCont=new Button("Contour") );
+ ctrl.add ( TextCont=new TextField() );
+ ctrl.add ( ButtonShade=new Button("Shade") );
+ ctrl.add ( TextShade=new TextField() );
+ ctrl.add ( ButtonLight=new Button("Light") );
+ ctrl.add ( TextLight=new TextField() );
+ ctrl.add ( ButtonDepth=new Button("Depth") );
+ ctrl.add ( TextDepth=new TextField() );
+ ctrl.add ( ButtonStepMode=new Button("StepMod") );
+ ctrl.add ( TextStepMode=new TextField() );
+ ctrl.add ( ButtonStep=new Button("Step") );
+ ctrl.add ( TextStep=new TextField() );
+ ctrl.add ( ButtonSpinMode=new Button("SpinMod") );
+ ctrl.add ( TextSpinMode=new TextField() );
+
+ TextCont.setEditable(false);
+ TextShade.setEditable(false);
+ TextLight.setEditable(false);
+ TextDepth.setEditable(false);
+ TextStepMode.setEditable(false);
+ TextStep.setEditable(false);
+ TextSpinMode.setEditable(false);
+
+ updateTextFields();
+
+ ctrl.pack();
+ ctrl.setVisible( true );
+
+ ButtonCont.addMouseListener(this);
+ ButtonShade.addMouseListener(this);
+ ButtonLight.addMouseListener(this);
+ ButtonDepth.addMouseListener(this);
+ ButtonStepMode.addMouseListener(this);
+ ButtonStep.addMouseListener(this);
+ ButtonSpinMode.addMouseListener(this);
+
+ rgb = GL_TRUE;
+ frames = 10;
+ widthX = 10;
+ widthY = 10;
+ checkerSize = 2;
+ height = 0.2f;
+
+ /* here we should add and initialize our JAVA components */
+ colorIndexes1=new int [3];
+ colorIndexes2=new int [3];
+
+ /* Standard gl4java Init */
+ if(rgb==GL_TRUE)
+ System.out.println("using rgb...");
+ else
+ System.out.println("using color index...");
+
+ gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
+
+ gl.glShadeModel(GL_SMOOTH);
+
+ gl.glFrontFace(GL_CW);
+
+ gl.glEnable(GL_DEPTH_TEST);
+
+ InitMaterials();
+ InitTexture();
+ InitMesh();
+
+ gl.glMatrixMode(GL_MODELVIEW);
+ gl.glTranslatef(0.0f, 0.4f, -1.8f);
+ gl.glScalef(2.0f, 2.0f, 2.0f);
+ gl.glRotatef(-35.0f, 1.0f, 0.0f, 0.0f);
+ gl.glRotatef(35.0f, 0.0f, 0.0f, 1.0f);
+ /* ... and furthet OpenGL init's - like you want to */
+ glj.gljCheckGL();
+ }
+
+ public coord GETCOORD(int frame, int x, int y)
+ {
+ return
+ theMesh.coords[frame*theMesh.numCoords+(x)+(y)*(theMesh.widthX+1)];
+ }
+ public facet GETFACET(int frame, int x, int y)
+ {
+ return
+ theMesh.facets[frame*theMesh.numFacets+(x)+(y)*(theMesh.widthX)];
+ }
+
+ public void display()
+ {
+ coord coord_;
+ facet facet_;
+ float lastColor[] = null;
+ float thisColor[] = null;
+ int i, j;
+
+ /* Standard gl4java Init */
+ if( glj.gljMakeCurrent() == false )
+ {
+ System.out.println("wave-display: problem in use() method");
+ return;
+ }
+
+ gl.glClear(clearMask);
+
+ if (nextFrame>0 || stepMode==GL_FALSE) {
+ curFrame++;
+ }
+ if (curFrame >= theMesh.frames) {
+ curFrame = 0;
+ }
+
+ if ((nextFrame>0 || stepMode==GL_FALSE) && spinMode==GL_TRUE)
+ {
+ gl.glRotatef(5.0f, 0.0f, 0.0f, 1.0f);
+ }
+ nextFrame = 0;
+
+ for (i = 0; i < theMesh.widthX; i++) {
+ gl.glBegin(GL_QUAD_STRIP);
+ lastColor = null;
+ for (j = 0; j < theMesh.widthY; j++) {
+ facet_ = GETFACET(curFrame, i, j);
+ if (smooth==GL_FALSE && lighting==GL_TRUE)
+ {
+ gl.glNormal3fv(facet_.normal);
+ }
+ if (lighting==GL_TRUE) {
+ if (rgb==GL_TRUE) {
+ thisColor = facet_.color;
+ gl.glColor3fv(facet_.color);
+ } else {
+ thisColor = facet_.color;
+ gl.glMaterialfv(GL_FRONT_AND_BACK, GL_COLOR_INDEXES,
+ facet_.color);
+ }
+ } else {
+ if (rgb==GL_TRUE) {
+ thisColor = facet_.color;
+ gl.glColor3fv(facet_.color);
+ } else {
+ thisColor = facet_.color;
+ gl.glIndexf(facet_.color[1]);
+ }
+ }
+
+ if (lastColor==null ||
+ (thisColor[0] != lastColor[0] && smooth==GL_TRUE)
+ )
+ {
+ if (lastColor!=null) {
+ gl.glEnd();
+ gl.glBegin(GL_QUAD_STRIP);
+ }
+ coord_ = GETCOORD(curFrame, i, j);
+ if (smooth==GL_TRUE && lighting==GL_TRUE)
+ {
+ gl.glNormal3fv(coord_.normal);
+ }
+ gl.glVertex3fv(coord_.vertex);
+
+ coord_ = GETCOORD(curFrame, i+1, j);
+ if (smooth==GL_TRUE && lighting==GL_TRUE)
+ {
+ gl.glNormal3fv(coord_.normal);
+ }
+ gl.glVertex3fv(coord_.vertex);
+ }
+
+ coord_ = GETCOORD(curFrame, i, j+1);
+ if (smooth==GL_TRUE && lighting==GL_TRUE) {
+ gl.glNormal3fv(coord_.normal);
+ }
+ gl.glVertex3fv(coord_.vertex);
+
+ coord_ = GETCOORD(curFrame, i+1, j+1);
+ if (smooth==GL_TRUE && lighting==GL_TRUE) {
+ gl.glNormal3fv(coord_.normal);
+ }
+ gl.glVertex3fv(coord_.vertex);
+
+ lastColor = thisColor;
+ }
+ gl.glEnd();
+ }
+
+ glj.gljSwap();
+ glj.gljCheckGL();
+ glj.gljFree();
+ }
+
+ public void InitMesh()
+ {
+ coord coord_;
+ facet facet_;
+ float dp1[], dp2[];
+ float pt1[], pt2[], pt3[];
+ float angle, d, x, y;
+ int numFacets, numCoords, frameNum, i, j;
+
+ dp1=new float[3];
+ dp2=new float[3];
+
+ theMesh = new mesh();
+ theMesh.widthX = widthX;
+ theMesh.widthY = widthY;
+ theMesh.frames = frames;
+
+ numFacets = widthX * widthY;
+ numCoords = (widthX + 1) * (widthY + 1);
+
+ theMesh.numCoords = numCoords;
+ theMesh.numFacets = numFacets;
+
+ theMesh.coords = new coord[frames*numCoords];
+ for(i=0; i<frames*numCoords; i++)
+ theMesh.coords[i]=new coord();
+
+ theMesh.facets = new facet[frames*numFacets];
+ for(i=0; i<frames*numFacets; i++)
+ theMesh.facets[i]=new facet();
+
+ for (frameNum = 0; frameNum < frames; frameNum++) {
+ for (i = 0; i <= widthX; i++) {
+ x = i / (float)widthX;
+ for (j = 0; j <= widthY; j++) {
+ y = j / (float)widthY;
+
+ d = (float) Math.sqrt(x*x+y*y);
+ if (d == 0.0) {
+ d = 0.0001f;
+ }
+ angle = 2 * (float)PI * d +
+ (2 * (float)PI / frames * frameNum);
+
+ coord_ = GETCOORD(frameNum, i, j);
+
+ coord_.vertex[0] = x - 0.5f;
+ coord_.vertex[1] = y - 0.5f;
+ coord_.vertex[2] = (height - height * d) *
+ (float)Math.cos(angle);
+
+ coord_.normal[0] = -(height / d) * x * ((1 - d) * 2 *
+ PI * (float)Math.sin(angle) +
+ (float)Math.cos(angle));
+ coord_.normal[1] = -(height / d) * y * ((1 - d) * 2 *
+ PI * (float)Math.sin(angle) +
+ (float)Math.cos(angle));
+ coord_.normal[2] = -1;
+
+ d = 1.0f /
+ (float)Math.sqrt(coord_.normal[0]*coord_.normal[0]+
+ coord_.normal[1]*coord_.normal[1]+1);
+ coord_.normal[0] *= d;
+ coord_.normal[1] *= d;
+ coord_.normal[2] *= d;
+ }
+ }
+ for (i = 0; i < widthX; i++) {
+ for (j = 0; j < widthY; j++) {
+ facet_ = GETFACET(frameNum, i, j);
+ if ( ( ( (i/checkerSize)%2 ) ^ (j/checkerSize) %2 )
+ >0
+ )
+ {
+ if (rgb==GL_TRUE) {
+ facet_.color[0] = 1.0f;
+ facet_.color[1] = 0.2f;
+ facet_.color[2] = 0.2f;
+ } else {
+ facet_.color[0] = colorIndexes1[0];
+ facet_.color[1] = colorIndexes1[1];
+ facet_.color[2] = colorIndexes1[2];
+ }
+ } else {
+ if (rgb==GL_TRUE) {
+ facet_.color[0] = 0.2f;
+ facet_.color[1] = 1.0f;
+ facet_.color[2] = 0.2f;
+ } else {
+ facet_.color[0] = colorIndexes2[0];
+ facet_.color[1] = colorIndexes2[1];
+ facet_.color[2] = colorIndexes2[2];
+ }
+ }
+ pt1 = GETCOORD(frameNum, i, j).vertex;
+ pt2 = GETCOORD(frameNum, i, j+1).vertex;
+ pt3 = GETCOORD(frameNum, i+1, j+1).vertex;
+
+ dp1[0] = pt2[0] - pt1[0];
+ dp1[1] = pt2[1] - pt1[1];
+ dp1[2] = pt2[2] - pt1[2];
+
+ dp2[0] = pt3[0] - pt2[0];
+ dp2[1] = pt3[1] - pt2[1];
+ dp2[2] = pt3[2] - pt2[2];
+
+ facet_.normal[0] = dp1[1] * dp2[2] - dp1[2] * dp2[1];
+ facet_.normal[1] = dp1[2] * dp2[0] - dp1[0] * dp2[2];
+ facet_.normal[2] = dp1[0] * dp2[1] - dp1[1] * dp2[0];
+
+ d = 1.0f / (float)Math.sqrt(facet_.normal[0]*facet_.normal[0]+
+ facet_.normal[1]*facet_.normal[1]+
+ facet_.normal[2]*facet_.normal[2]);
+
+ facet_.normal[0] *= d;
+ facet_.normal[1] *= d;
+ facet_.normal[2] *= d;
+ }
+ }
+ }
+ }
+
+ static float ambient[] = {0.1f, 0.1f, 0.1f, 1.0f};
+ static float diffuse[] = {0.5f, 1.0f, 1.0f, 1.0f};
+ static float position[] = {90.0f, 90.0f, 150.0f, 0.0f};
+ static float front_mat_shininess[] = {60.0f, 0f, 0f, 0f};
+ static float front_mat_specular[] = {0.2f, 0.2f, 0.2f, 1.0f};
+ static float front_mat_diffuse[] = {0.5f, 0.28f, 0.38f, 1.0f};
+ static float back_mat_shininess[] = {60.0f, 0f, 0f, 0f};
+ static float back_mat_specular[] = {0.5f, 0.5f, 0.2f, 1.0f};
+ static float back_mat_diffuse[] = {1.0f, 1.0f, 0.2f, 1.0f};
+ static float lmodel_ambient[] = {1.0f, 1.0f, 1.0f, 1.0f};
+ static float lmodel_twoside[] = {1f, 0f, 0f, 0f};
+
+ public void InitMaterials()
+ {
+ gl.glMatrixMode(GL_PROJECTION);
+ glu.gluPerspective(450, 1.0, 0.5, 10.0);
+
+ gl.glLightfv(GL_LIGHT0, GL_AMBIENT, ambient);
+ gl.glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse);
+ gl.glLightfv(GL_LIGHT0, GL_POSITION, position);
+ gl.glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient);
+ gl.glLightModelfv(GL_LIGHT_MODEL_TWO_SIDE, lmodel_twoside);
+ gl.glEnable(GL_LIGHTING);
+ gl.glEnable(GL_LIGHT0);
+
+ gl.glMaterialfv(GL_FRONT, GL_SHININESS, front_mat_shininess);
+ gl.glMaterialfv(GL_FRONT, GL_SPECULAR, front_mat_specular);
+ gl.glMaterialfv(GL_FRONT, GL_DIFFUSE, front_mat_diffuse);
+ gl.glMaterialfv(GL_BACK, GL_SHININESS, back_mat_shininess);
+ gl.glMaterialfv(GL_BACK, GL_SPECULAR, back_mat_specular);
+ gl.glMaterialfv(GL_BACK, GL_DIFFUSE, back_mat_diffuse);
+ if (rgb==GL_TRUE) {
+ gl.glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
+ }
+
+ if (rgb==GL_TRUE) {
+ gl.glEnable(GL_COLOR_MATERIAL);
+ } /* else {
+ SetColorMap();
+ } */
+ }
+
+ public void InitTexture()
+ {
+
+ gl.glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
+ gl.glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
+ gl.glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ gl.glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ gl.glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+ }
+
+ // Methods required for the implementation of MouseListener
+ public void mouseClicked( MouseEvent evt )
+ {
+ Component comp = evt.getComponent();
+
+ if( cvsIsInit()==false ) return ;
+
+ if( glj.gljMakeCurrent() == false )
+ {
+ System.out.println("CtrlWin: problem in use() method");
+ return;
+ } else {
+ gl.glFinish();
+ }
+
+ if(comp.equals(ButtonCont))
+ {
+ contouring++;
+ if (contouring == 1) {
+ float map[];
+ map=new float[4];
+ map[0]=0f;
+ map[1]=0f;
+ map[2]=20f;
+ map[3]=0f;
+
+ gl.glTexImage2D(GL_TEXTURE_2D, 0, 3, 4, 4, 0, GL_LUMINANCE,
+ GL_UNSIGNED_BYTE, contourTexture1);
+ gl.glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
+ gl.glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
+ gl.glTexGenfv(GL_S, GL_OBJECT_PLANE, map);
+ gl.glTexGenfv(GL_T, GL_OBJECT_PLANE, map);
+ gl.glEnable(GL_TEXTURE_2D);
+ gl.glEnable(GL_TEXTURE_GEN_S);
+ gl.glEnable(GL_TEXTURE_GEN_T);
+ } else if (contouring == 2) {
+ float map[];
+ map=new float[4];
+ map[0]=0f;
+ map[1]=0f;
+ map[2]=20f;
+ map[3]=0f;
+
+ gl.glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
+ gl.glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
+ gl.glPushMatrix();
+ gl.glMatrixMode(GL_MODELVIEW);
+ gl.glLoadIdentity();
+ gl.glTexGenfv(GL_S, GL_EYE_PLANE, map);
+ gl.glTexGenfv(GL_T, GL_EYE_PLANE, map);
+ gl.glPopMatrix();
+ } else {
+ contouring = 0;
+ gl.glDisable(GL_TEXTURE_GEN_S);
+ gl.glDisable(GL_TEXTURE_GEN_T);
+ gl.glDisable(GL_TEXTURE_2D);
+ }
+ }
+ else if(comp.equals(ButtonShade))
+ {
+ smooth = (smooth==GL_TRUE)?GL_FALSE:GL_TRUE;
+ if (smooth==GL_TRUE) {
+ gl.glShadeModel(GL_SMOOTH);
+ } else {
+ gl.glShadeModel(GL_FLAT);
+ }
+ }
+ else if(comp.equals(ButtonLight))
+ {
+ lighting = (lighting==GL_TRUE)?GL_FALSE:GL_TRUE;
+ if (lighting==GL_TRUE) {
+ gl.glEnable(GL_LIGHTING);
+ gl.glEnable(GL_LIGHT0);
+ if (rgb==GL_TRUE) {
+ gl.glEnable(GL_COLOR_MATERIAL);
+ }
+ } else {
+ gl.glDisable(GL_LIGHTING);
+ gl.glDisable(GL_LIGHT0);
+ if (rgb==GL_TRUE) {
+ gl.glDisable(GL_COLOR_MATERIAL);
+ }
+ }
+ }
+ else if(comp.equals(ButtonDepth))
+ {
+ depth = (depth==GL_TRUE)?GL_FALSE:GL_TRUE;
+ if (depth==GL_TRUE) {
+ gl.glEnable(GL_DEPTH_TEST);
+ clearMask |= GL_DEPTH_BUFFER_BIT;
+ } else {
+ gl.glDisable(GL_DEPTH_TEST);
+ clearMask &= ~GL_DEPTH_BUFFER_BIT;
+ }
+ }
+ else if(comp.equals(ButtonStepMode))
+ {
+ stepMode = (stepMode==GL_TRUE)?GL_FALSE:GL_TRUE;
+ if (stepMode==GL_TRUE) {
+ stop();
+ } else {
+ start();
+ }
+ }
+ else if(comp.equals(ButtonStep))
+ {
+ if (stepMode==GL_TRUE) {
+ nextFrame = 1;
+ }
+ }
+ else if(comp.equals(ButtonSpinMode))
+ {
+ spinMode = (spinMode==GL_TRUE)?GL_FALSE:GL_TRUE;
+ }
+
+ updateTextFields();
+
+ gl.glFinish();
+ glj.gljFree();
+
+ repaint();
+ }
+
+ public void updateTextFields()
+ {
+ TextCont.setText(String.valueOf(contouring));
+
+ TextShade.setText((smooth==GL_TRUE)?"ON":"OFF");
+
+ TextLight.setText((lighting==GL_TRUE)?"ON":"OFF");
+
+ TextDepth.setText((depth==GL_TRUE)?"ON":"OFF");
+
+ TextStepMode.setText((stepMode==GL_TRUE)?"ON":"OFF");
+
+ TextStep.setText((stepMode==GL_TRUE)?"ON":"OFF");
+
+ TextSpinMode.setText((spinMode==GL_TRUE)?"ON":"OFF");
+ }
+
+ public void mouseEntered( MouseEvent evt )
+ {
+ }
+
+ public void mouseExited( MouseEvent evt )
+ {
+ }
+
+ public void mousePressed( MouseEvent evt )
+ {
+ }
+
+ public void mouseReleased( MouseEvent evt )
+ {
+ }
+
+ public void cvsDispose()
+ {
+ if(ctrl!=null)
+ {
+ ctrl.dispose();
+ }
+ super.cvsDispose();
+ }
+}
|