Author: paperwing
Date: 2012-02-27 16:00:32 -0800 (Mon, 27 Feb 2012)
New Revision: 28380

Modified:
   
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderNodeLabelsProcedure.java
Log:
Attempt to use GPU-based TextRenderer 
(com.jogamp.graph.curve.opengl.TextRenderer)

Modified: 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderNodeLabelsProcedure.java
===================================================================
--- 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderNodeLabelsProcedure.java
      2012-02-27 23:23:29 UTC (rev 28379)
+++ 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderNodeLabelsProcedure.java
      2012-02-28 00:00:32 UTC (rev 28380)
@@ -14,16 +14,18 @@
 import org.cytoscape.view.presentation.property.BasicVisualLexicon;
 import org.cytoscape.view.presentation.property.BasicVisualLexicon;
 
-import com.jogamp.opengl.util.awt.TextRenderer;
+// import com.jogamp.opengl.util.awt.TextRenderer;
 
 // Below will be used for JOGL 2.0-b45-20111219
-/*
+
 import com.jogamp.graph.curve.opengl.RenderState;
 import com.jogamp.graph.curve.opengl.TextRenderer;
 import com.jogamp.graph.curve.opengl.GLRegion;
 import com.jogamp.graph.font.FontFactory;
-*/
+import com.jogamp.graph.geom.opengl.SVertex;
+import com.jogamp.opengl.util.glsl.ShaderState;
 
+
 public class RenderNodeLabelsProcedure implements ReadOnlyGraphicsProcedure {
 
        private static final int TEXT_FONT_SIZE = 9;
@@ -45,14 +47,15 @@
                // textRenderer.setSmoothing(false);
                
                // Temporarily removed -- pausing JOGL update to 
2.0-b45-20111219
-//             textRenderer = 
TextRenderer.create(RenderState.getRenderState(gl), 
GLRegion.TWO_PASS_DEFAULT_TEXTURE_UNIT);
+               RenderState renderState = RenderState.createRenderState(new 
ShaderState(), SVertex.factory());
+               textRenderer = 
TextRenderer.create(RenderState.getRenderState(gl), 0);
        }
 
        @Override
        public void execute(GraphicsData graphicsData) {
                GL2 gl = graphicsData.getGlContext();
                
-               textRenderer = new TextRenderer(TEXT_DEFAULT_FONT);
+               // textRenderer = new TextRenderer(TEXT_DEFAULT_FONT);
                
                CyNetworkView networkView = graphicsData.getNetworkView();
                float distanceScale = graphicsData.getDistanceScale();
@@ -71,7 +74,7 @@
                Color textColor;
                
                gl.glPushMatrix();
-               textRenderer.beginRendering(graphicsData.getScreenWidth(), 
graphicsData.getScreenHeight(), true);
+               // textRenderer.beginRendering(graphicsData.getScreenWidth(), 
graphicsData.getScreenHeight(), true);
                // textRenderer.drawString3D(arg0, arg1, arg2, arg3, arg4, arg5)
                
                // textRenderer.beginRendering(graphicsData.getScreenWidth(), 
graphicsData.getScreenHeight(), true);
@@ -109,24 +112,25 @@
                                                }
                        
                                                // Below to be used for JOGL 
2.0-b45-20111219's new TextRenderer
-//                                             gl.glColor3f((float) 
textColor.getRed() / 255, 
-//                                                             (float) 
textColor.getGreen() / 255, 
-//                                                             (float) 
textColor.getBlue() / 255);
+                                               gl.glColor3f((float) 
textColor.getRed() / 255, 
+                                                               (float) 
textColor.getGreen() / 255, 
+                                                               (float) 
textColor.getBlue() / 255);
                                                
                                                
-//                                             textRenderer.drawString3D(gl, 
FontFactory.getDefault().getDefault(), 
-//                                                             text, new 
float[]{1.0f, 1.0f, 2.0f}, TEXT_FONT_SIZE, 1024);
+                                               textRenderer.drawString3D(gl, 
FontFactory.get(FontFactory.JAVA).getDefault(), 
+                                                               text, new 
float[]{1.0f, 1.0f, 2.0f}, TEXT_FONT_SIZE, 128);
                                                                
-                                               
textRenderer.setColor(textColor);
-                                               textRenderer.draw(text, (int) 
screenCoordinates.x() - findTextScreenWidth(text) / 2, (int) 
screenCoordinates.y());              
+//                                             
textRenderer.setColor(textColor);
+//                                             textRenderer.draw(text, (int) 
screenCoordinates.x() - findTextScreenWidth(text) / 2, (int) 
screenCoordinates.y());              
+//                                             textRenderer.flush();
                                        }
                                }
                        }
                }
                
-               textRenderer.flush();
-               textRenderer.endRendering();
                
+//             textRenderer.endRendering();
+               
                gl.glPopMatrix();
                
        }
@@ -135,7 +139,7 @@
                int width = 0;
                
                for (int i = 0; i < text.length(); i++) {
-                       width += textRenderer.getCharWidth(text.charAt(i));
+//                     width += textRenderer.getCharWidth(text.charAt(i));
                }
                
                return width;

-- 
You received this message because you are subscribed to the Google Groups 
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/cytoscape-cvs?hl=en.

Reply via email to