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/HodglimsNeHe |
Initial revision
Diffstat (limited to 'demos/HodglimsNeHe')
47 files changed, 6732 insertions, 0 deletions
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> |