From 34d7e1f13a107e63bd234e4b31782cfb46feb4c0 Mon Sep 17 00:00:00 2001
From: Sven Gothel <sgothel@jausoft.com>
Date: Wed, 10 Oct 2012 16:36:46 +0200
Subject: ImmModeSink: Fix bugs (use glBufferUsage, vboUsage, GL_POLYGON,
 GL_QUADS) and add API docs. (API Change)

- Changed create*(..) factory methods (API Change)
  - Drop passing GL instance, not needed
    - allows creation of ImmModeSink as final field w/o GL context
  - Use 'glBufferUsage' to determine whether to use VBO or not ( 0 == glBufferUsage )

- Use glBufferUsage in glBufferData(..) call (oops)

- Toggle vboUsage per object ( 0 == glBufferUsage ? nonVBO : VBO )
  remove static VBO usage flag

- Fix render mode
  - GL_POLYGON -> GL_TRIANGLE_FAN (not GL_LINES)
  - GL_QUADS -> Looped GL_TRIANGLE_FAN (is !GL2) in draw(..) w/ and w/o indices

- Buffer usage

  - documented

  - allow creating sink w/ all components (vertices, color, normal and texCoords)
    bit render and grow only used parts.
    This allows proper usage of sink where it is not known
    which types are being used.

- Added test case

- Manually tested w/ Jake2 ES1
  Jake2 uses the FFP immediate mode rendering, where we utilize this sink
  w/o rendering artifacts.
---
 .../classes/jogamp/opengl/glu/GLUquadricImpl.java  | 42 +++++++++++-----------
 1 file changed, 22 insertions(+), 20 deletions(-)

(limited to 'src/jogl/classes/jogamp/opengl/glu/GLUquadricImpl.java')

diff --git a/src/jogl/classes/jogamp/opengl/glu/GLUquadricImpl.java b/src/jogl/classes/jogamp/opengl/glu/GLUquadricImpl.java
index 3f8a76535..62ff3aa09 100644
--- a/src/jogl/classes/jogamp/opengl/glu/GLUquadricImpl.java
+++ b/src/jogl/classes/jogamp/opengl/glu/GLUquadricImpl.java
@@ -115,10 +115,11 @@
 
 package jogamp.opengl.glu;
 
-import javax.media.opengl.*;
-import javax.media.opengl.glu.*;
+import javax.media.opengl.GL;
+import javax.media.opengl.glu.GLU;
+import javax.media.opengl.glu.GLUquadric;
+
 import com.jogamp.opengl.util.ImmModeSink;
-import java.nio.*;
 
 /**
  * GLUquadricImpl.java
@@ -190,17 +191,19 @@ public class GLUquadricImpl implements GLUquadric {
 
     ImmModeSink res = immModeSink;
     if(useGLSL) {
-        immModeSink = ImmModeSink.createGLSL (gl, GL.GL_STATIC_DRAW, 32, 
-                                              3, GL.GL_FLOAT,  // vertex
-                                              0, GL.GL_FLOAT,  // color
-                                              USE_NORM?3:0, normalType,// normal
-                                              USE_TEXT?2:0, GL.GL_FLOAT); // texture
+        immModeSink = ImmModeSink.createGLSL (32, 
+                                              3, GL.GL_FLOAT,             // vertex 
+                                              0, GL.GL_FLOAT,             // color
+                                              USE_NORM?3:0, normalType,   // normal
+                                              USE_TEXT?2:0, GL.GL_FLOAT,  // texCoords
+                                              GL.GL_STATIC_DRAW);
     } else {
-        immModeSink = ImmModeSink.createFixed(gl, GL.GL_STATIC_DRAW, 32, 
-                                              3, GL.GL_FLOAT,  // vertex
-                                              0, GL.GL_FLOAT,  // color
-                                              USE_NORM?3:0, normalType,// normal
-                                              USE_TEXT?2:0, GL.GL_FLOAT); // texture
+        immModeSink = ImmModeSink.createFixed(32,
+                                              3, GL.GL_FLOAT,             // vertex
+                                              0, GL.GL_FLOAT,             // color
+                                              USE_NORM?3:0, normalType,   // normal
+                                              USE_TEXT?2:0, GL.GL_FLOAT,  // texCoords
+                                              GL.GL_STATIC_DRAW);
     }
     return res;
   }
@@ -430,7 +433,7 @@ public class GLUquadricImpl implements GLUquadric {
       r = baseRadius;
       for (j = 0; j < stacks; j++) {
         float s = 0.0f;
-        glBegin(gl, immModeSink.GL_QUAD_STRIP);
+        glBegin(gl, ImmModeSink.GL_QUAD_STRIP);
         for (i = 0; i <= slices; i++) {
           if (i == slices) {
             x = sin(0.0f);
@@ -514,7 +517,7 @@ public class GLUquadricImpl implements GLUquadric {
           float r2 = r1 + dr;
           if (orientation == GLU.GLU_OUTSIDE) {
             int s;
-            glBegin(gl, immModeSink.GL_QUAD_STRIP);
+            glBegin(gl, ImmModeSink.GL_QUAD_STRIP);
             for (s = 0; s <= slices; s++) {
               float a;
               if (s == slices)
@@ -532,7 +535,7 @@ public class GLUquadricImpl implements GLUquadric {
           }
           else {
             int s;
-            glBegin(gl, immModeSink.GL_QUAD_STRIP);
+            glBegin(gl, ImmModeSink.GL_QUAD_STRIP);
             for (s = slices; s >= 0; s--) {
               float a;
               if (s == slices)
@@ -655,11 +658,10 @@ public class GLUquadricImpl implements GLUquadric {
                               int loops,
                               float startAngle,
                               float sweepAngle) {
-    int i, j, max;
+    int i, j;
     float[] sinCache = new float[CACHE_SIZE];
     float[] cosCache = new float[CACHE_SIZE];
     float angle;
-    float x, y;
     float sintemp, costemp;
     float deltaRadius;
     float radiusLow, radiusHigh;
@@ -770,7 +772,7 @@ public class GLUquadricImpl implements GLUquadric {
           texHigh = radiusHigh / outerRadius / 2;
         }
 
-        glBegin(gl, immModeSink.GL_QUAD_STRIP);
+        glBegin(gl, ImmModeSink.GL_QUAD_STRIP);
         for (i = 0; i <= slices; i++) {
           if (orientation == GLU.GLU_OUTSIDE) {
             if (textureFlag) {
@@ -984,7 +986,7 @@ public class GLUquadricImpl implements GLUquadric {
       // draw intermediate stacks as quad strips
       for (i = imin; i < imax; i++) {
         rho = i * drho;
-        glBegin(gl, immModeSink.GL_QUAD_STRIP);
+        glBegin(gl, ImmModeSink.GL_QUAD_STRIP);
         s = 0.0f;
         for (j = 0; j <= slices; j++) {
           theta = (j == slices) ? 0.0f : j * dtheta;
-- 
cgit v1.2.3