--- FogTab.java	Fri Aug  7 13:56:47 2009
+++ GradientTab.java	Fri Aug  7 13:56:58 2009
@@ -16,15 +16,25 @@
 import org.eclipse.swt.layout.*;
 import org.eclipse.swt.widgets.*;
 
-class FogTab extends OpenGLTab {
+class GradientTab extends OpenGLTab {
+	private float xPos = 0.0f, yPos = 0.0f, zPos = -7.0f;
+	private float xRot = 180.0f, yRot = 180.0f, zRot = 180.0f;
+	private int currentSelection = 1;
+	private final static float[] BEZIER_COLORS = {
+		0.0f, 1.0f, 0.0f, 0.0f, 0.3f, 0.6f, 0.1f, 0.0f,
+		0.8f, 0.2f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f,
+		0.0f, 0.0f, 1.0f, 0.0f, 0.8f, 0.8f, 0.8f, 0.0f
+	};
+	private final static float[] BEZIER_POINTS = {
+		-1.5f, -1.5f, 4.0f, -0.5f, -1.5f, 2.0f, 0.5f, -1.5f,
+		-1.0f, 1.5f, -1.5f, 2.0f, -1.5f, -0.5f, 1.0f, -0.5f,
+		-0.5f, 3.0f, 0.5f, -0.5f, 0.0f, 1.5f, -0.5f, -1.0f,
+		-1.5f, 0.5f, 4.0f, -0.5f, 0.5f, 0.0f, 0.5f, 0.5f,
+		3.0f, 1.5f, 0.5f, 4.0f, -1.5f, 1.5f, -2.0f, -0.5f,
+		1.5f, -2.0f, 0.5f, 1.5f, 0.0f, 1.5f, 1.5f, -1.0f,
+	};
+	private final static String[] OBJECT_NAMES = { "Bezier", "Square" };
 
-	private float rotY = 0.0f;
-	private float yPos = 0.0f, xPos = 0.0f, zPos = -15.0f;
-	private int cubeListIndexBase;
-	private final static int[] FOG_TYPES = { GL.GL_LINEAR, GL.GL_EXP, GL.GL_EXP2 };
-	private final static String[] FOG_NAMES = { "LINEAR", "GL_EXP", "GL_EXP2" };
-	private final static int SLEEP_LENGTH = 0;
-
 	/**
 	 * @see OpenGLTab#createControls(Composite)
 	 */
@@ -64,191 +74,160 @@
 		new Label(movementGroup, SWT.NONE).setText("Z:");
 		final Slider zMove = new Slider(movementGroup, SWT.NONE);
 		zMove.setIncrement(1);
-		zMove.setMaximum(24);
+		zMove.setMaximum(12);
 		zMove.setMinimum(0);
-		zMove.setThumb(4);
+		zMove.setThumb(2);
 		zMove.setPageIncrement(2);
-		zMove.setSelection(10);
+		zMove.setSelection(5);
 		zMove.addListener(SWT.Selection, new Listener() {
 			public void handleEvent(Event e) {
-				zPos = zMove.getSelection() - 25;
+				zPos = zMove.getSelection() - 12;
 			}
 		});
 
-		Composite fogTypesGroup = new Composite(composite,SWT.NONE);
+		Group rotationGroup = new Group(composite, SWT.NONE);
+		rotationGroup.setText("Rotation");
+		rotationGroup.setLayout(new GridLayout(2, false));
+
+		new Label(rotationGroup, SWT.NONE).setText("X:");
+		final Slider xRotation = new Slider(rotationGroup, SWT.NONE);
+		xRotation.setIncrement(10);
+		xRotation.setMaximum(362);
+		xRotation.setMinimum(0);
+		xRotation.setThumb(2);
+		xRotation.setPageIncrement(20);
+		xRotation.setSelection(180);
+		xRotation.addListener(SWT.Selection, new Listener() {
+			public void handleEvent(Event e) {
+				xRot = xRotation.getSelection();
+			}
+		});
+
+		new Label(rotationGroup, SWT.NONE).setText("Y:");
+		final Slider yRotation = new Slider(rotationGroup, SWT.NONE);
+		yRotation.setIncrement(10);
+		yRotation.setMaximum(362);
+		yRotation.setMinimum(0);
+		yRotation.setThumb(2);
+		yRotation.setPageIncrement(20);
+		yRotation.setSelection(180);
+		yRotation.addListener(SWT.Selection, new Listener() {
+			public void handleEvent(Event e) {
+				yRot = yRotation.getSelection();
+			}
+		});
+
+		new Label(rotationGroup, SWT.NONE).setText("Z:");
+		final Slider zRotation = new Slider(rotationGroup, SWT.NONE);
+		zRotation.setIncrement(10);
+		zRotation.setMaximum(362);
+		zRotation.setMinimum(0);
+		zRotation.setThumb(2);
+		zRotation.setPageIncrement(20);
+		zRotation.setSelection(180);
+		zRotation.addListener(SWT.Selection, new Listener() {
+			public void handleEvent(Event e) {
+				zRot = zRotation.getSelection();
+			}
+		});
+		
+		Composite objectGroup = new Composite(composite,SWT.NONE);
 		GridLayout layout = new GridLayout(2,false);
 		layout.marginHeight = 0;
 		layout.marginWidth = 0;
-		fogTypesGroup.setLayout(layout);
-		fogTypesGroup.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
+		objectGroup.setLayout(layout);
+		objectGroup.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
 
-		new Label(fogTypesGroup, SWT.NONE).setText("Fog Types:");
-		final Combo fogTypeCombo = new Combo(fogTypesGroup, SWT.READ_ONLY);
+		new Label(objectGroup, SWT.NONE).setText("Object:");
+		final Combo objectCombo = new Combo(objectGroup, SWT.READ_ONLY);
 		GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
 		data.grabExcessHorizontalSpace = true;
-		fogTypeCombo.setLayoutData(data);
-		fogTypeCombo.setItems(FOG_NAMES);
-		fogTypeCombo.select(0);
-
-		new Label(composite, SWT.NONE).setText("Fog Density:");
-		final Slider fogDensitySlider = new Slider(composite, SWT.NONE);
-		fogDensitySlider.setIncrement(1);
-		fogDensitySlider.setMaximum(32);
-		fogDensitySlider.setMinimum(0);
-		fogDensitySlider.setThumb(2);
-		fogDensitySlider.setPageIncrement(5);
-		fogDensitySlider.setSelection(0);
-		fogDensitySlider.setEnabled(false);
-		fogDensitySlider.addListener(SWT.Selection, new Listener() {
+		objectCombo.setLayoutData(data);
+		objectCombo.setItems(OBJECT_NAMES);
+		objectCombo.select(0);
+		objectCombo.addListener(SWT.Selection, new Listener() {
 			public void handleEvent(Event e) {
-				float fogDensity = ((float)fogDensitySlider.getSelection()) / 100;
-				GL.glFogf(GL.GL_FOG_DENSITY, fogDensity);
+				currentSelection = objectCombo.getSelectionIndex() + 1;
 			}
 		});
-		fogTypeCombo.addListener(SWT.Selection, new Listener() {
-			public void handleEvent(Event e) {
-				int currentSelection = fogTypeCombo.getSelectionIndex();
-				// fog type GL.GL_LINEAR does not utilize fogDensity, but the other fog types do
-				fogDensitySlider.setEnabled(currentSelection != 0);
-				GL.glFogf(GL.GL_FOG_MODE, FOG_TYPES[currentSelection]);
-			}
-		});
 	}
-
+	
 	/**
-	 * Creates a cube at 0,0 in the viewport.
-	 */
- 	void createCube() {
-		GL.glNewList(cubeListIndexBase, GL.GL_COMPILE);
-		GL.glBegin(GL.GL_QUADS);
-		// front
-		GL.glColor3f(0.0f, 1.0f, 0.0f);
-		GL.glVertex3f(-0.5f, -0.5f, 0.5f);	// bottom left 
-		GL.glColor3f(0.0f, 0.0f, 1.0f);
-		GL.glVertex3f(0.5f, -0.5f, 0.5f);	// bottom right
-		GL.glColor3f(1.0f, 1.0f, 0.0f);
-		GL.glVertex3f(0.5f, 0.5f, 0.5f);	// top right
-		GL.glColor3f(1.0f, 0.0f, 0.0f);
-		GL.glVertex3f(-0.5f, 0.5f, 0.5f);	// top left
-		// back
-		GL.glColor3f(0.0f, 0.0f, 1.0f);
-		GL.glVertex3f(-0.5f, -0.5f, -0.5f);	// bottom left 
-		GL.glColor3f(0.0f, 1.0f, 0.0f);
-		GL.glVertex3f(0.5f, -0.5f, -0.5f);	// bottom right
-		GL.glColor3f(1.0f, 0.0f, 0.0f);
-		GL.glVertex3f(0.5f, 0.5f, -0.5f);	// top right
-		GL.glColor3f(1.0f, 1.0f, 0.0f);
-		GL.glVertex3f(-0.5f, 0.5f, -0.5f);	// top left
-		// left
-		GL.glColor3f(0.0f, 0.0f, 1.0f);
-		GL.glVertex3f(-0.5f, -0.5f, -0.5f);	// bottom left
-		GL.glColor3f(0.0f, 1.0f, 0.0f);
-		GL.glVertex3f(-0.5f, -0.5f, 0.5f);	// bottom right
-		GL.glColor3f(1.0f, 0.0f, 0.0f);
-		GL.glVertex3f(-0.5f, 0.5f, 0.5f);	// top right
-		GL.glColor3f(1.0f, 1.0f, 0.0f);
-		GL.glVertex3f(-0.5f, 0.5f, -0.5f);	// top left	
-		// right
-		GL.glColor3f(0.0f, 0.0f, 1.0f);
-		GL.glVertex3f(0.5f, -0.5f, 0.5f);	// bottom left
-		GL.glColor3f(0.0f, 1.0f, 0.0f);
-		GL.glVertex3f(0.5f, -0.5f, -0.5f);	// bottom right
-		GL.glColor3f(1.0f, 0.0f, 0.0f);
-		GL.glVertex3f(0.5f, 0.5f, -0.5f);	// top right
-		GL.glColor3f(1.0f, 1.0f, 0.0f);
-		GL.glVertex3f(0.5f, 0.5f, 0.5f);	// top left
-		// top
-		GL.glColor3f(1.0f, 0.0f, 0.0f);
-		GL.glVertex3f(0.5f, 0.5f, -0.5f);
-		GL.glColor3f(1.0f, 1.0f, 0.0f);
-		GL.glVertex3f(-0.5f, 0.5f, -0.5f);
-		GL.glColor3f(1.0f, 0.0f, 0.0f);
-		GL.glVertex3f(-0.5f, 0.5f, 0.5f);
-		GL.glColor3f(1.0f, 1.0f, 0.0f);
-		GL.glVertex3f(0.5f, 0.5f, 0.5f);
-		// bottom
-		GL.glColor3f(0.0f, 0.0f, 1.0f);
-		GL.glVertex3f(0.5f, -0.5f, 0.5f);
-		GL.glColor3f(0.0f, 1.0f, 0.0f);
-		GL.glVertex3f(-0.5f, -0.5f, 0.5f);
-		GL.glColor3f(0.0f, 0.0f, 1.0f);
-		GL.glVertex3f(-0.5f, -0.5f, -0.5f);
-		GL.glColor3f(0.0f, 1.0f, 0.0f);
-		GL.glVertex3f(0.5f, -0.5f, -0.5f);
-		GL.glEnd();
-		GL.glEndList();
-	}
-
-	/**
 	 * @see OpenGLTab#dispose()
 	 */
 	void dispose() {
 		super.dispose();
-		GL.glDeleteLists(cubeListIndexBase, 1);
+		GL.glDeleteLists(1, 2);
 	}
-
+	
 	/**
-	 * @see OpenGLTab#getSleepLength()
-	 */
-	int getSleepLength() {
-		return SLEEP_LENGTH;	
-	}
-	/**
 	 * @see OpenGLTab#getTabText()
 	 */
 	String getTabText() {
-		return "Fog";
+		return "Gradients";
 	}
-
+	
 	/**
 	 * @see OpenGLTab#init()
 	 */
 	void init() {
 		GL.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
-		// fog color should be the same as the clear color
-		// to look appropriate
-		float[] fogColor = { 1.0f, 1.0f, 1.0f, 1.0f };
-		GL.glFogfv(GL.GL_FOG_COLOR, fogColor);
-		GL.glHint(GL.GL_FOG_HINT, GL.GL_DONT_CARE);
-		GL.glFogf(GL.GL_FOG_START, 0);
-		GL.glFogf(GL.GL_FOG_DENSITY, 0.0f);
-		// set the end of the start distance; anything > 15
-		// units from the camera will be covered in fog
-		GL.glFogf(GL.GL_FOG_END, 15);
-		GL.glFogf(GL.GL_FOG_MODE, FOG_TYPES[0]);
-		GL.glEnable(GL.GL_FOG);
+		GL.glHint(GL.GL_LINE_SMOOTH_HINT, GL.GL_NICEST);
+		GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
+		GL.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_FILL);
+		GL.glMap2f(GL.GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4, BEZIER_POINTS);
+		GL.glMap2f(GL.GL_MAP2_COLOR_4, 0, 1, 4, 1, 0, 1, 4, 6, BEZIER_COLORS);
+		GL.glMapGrid2f(20, 0.0f, 1.0f, 20, 0.0f, 1.0f);
+		GL.glShadeModel(GL.GL_SMOOTH);
+		GL.glEnable(GL.GL_LINE_SMOOTH);
+		GL.glEnable(GL.GL_LINE_STIPPLE);
+		GL.glEnable(GL.GL_BLEND);
+		GL.glEnable(GL.GL_MAP2_COLOR_4);
+		GL.glEnable(GL.GL_MAP2_VERTEX_3);
 		GL.glEnable(GL.GL_DEPTH_TEST);
 
-		cubeListIndexBase = GL.glGenLists(1);
-		createCube();
+		// create display lists
+		GL.glNewList(1, GL.GL_COMPILE);
+		GL.glEvalMesh2(GL.GL_FILL, 0, 20, 0, 20);
+		GL.glEndList();
+		GL.glNewList(2, GL.GL_COMPILE);
+		GL.glBegin(GL.GL_TRIANGLE_FAN);
+		GL.glColor3f(0.0f, 1.0f, 0.0f);
+		GL.glVertex3f(0.0f, 0.0f, 0.0f);
+		GL.glColor3f(1.0f, 0.0f, 0.0f);
+		GL.glVertex3f(0.0f, 2.0f, 0.0f);
+		GL.glColor3f(0.0f, 1.0f, 0.0f);
+		GL.glVertex3f(-2.0f, 2.0f, 0.0f);
+		GL.glColor3f(0.0f, 0.0f, 1.0f);
+		GL.glVertex3f(-2.0f, 0.0f, 0.0f);
+		GL.glColor3f(0.0f, 1.0f, 0.0f);
+		GL.glVertex3f(-2.0f, -2.0f, 0.0f);
+		GL.glColor3f(1.0f, 0.0f, 0.0f);
+		GL.glVertex3f(0.0f, -2.0f, 0.0f);
+		GL.glColor3f(0.0f, 1.0f, 0.0f);
+		GL.glVertex3f(2.0f, -2.0f, 0.0f);
+		GL.glColor3f(0.0f, 0.0f, 1.0f);
+		GL.glVertex3f(2.0f, 0.0f, 0.0f);
+		GL.glColor3f(0.0f, 1.0f, 0.0f);
+		GL.glVertex3f(2.0f, 2.0f, 0.0f);
+		GL.glColor3f(1.0f, 0.0f, 0.0f);
+		GL.glVertex3f(0.0f, 2.0f, 0.0f);
+		GL.glEnd();
+		GL.glEndList();
 	}
-
+	
 	/**
 	 * @see OpenGLTab#renderScene()
 	 */
 	void renderScene() {
-		GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
+		GL.glClear(GL.GL_COLOR_BUFFER_BIT);
 		GL.glLoadIdentity();
+		GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
 		GL.glTranslatef(xPos, yPos, zPos);
-		GL.glRotatef(rotY, 0.0f, 1.0f, 0.0f);
-
-		GL.glCallList(cubeListIndexBase);
-
-		GL.glPushMatrix();
-		GL.glTranslatef(3, 0, -3);
-		GL.glCallList(cubeListIndexBase);
-		GL.glPopMatrix();
-
-		GL.glPushMatrix();
-		GL.glTranslatef(-3, 0, -3);
-		GL.glCallList(cubeListIndexBase);
-		GL.glPopMatrix();
-
-		GL.glPushMatrix();
-		GL.glTranslatef(0, 0, 4);
-		GL.glCallList(cubeListIndexBase);
-		GL.glPopMatrix();
-
-		rotY += 0.6f;
+		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.glColor3f(1.0f, 0.0f, 0.0f);
+		GL.glCallList(currentSelection);
 	}
 }
