GLGraphics 0.9.3   15 comments

After a long pause, I’m back to the blog. This time, to mention a new package of the GLGraphics library, 0.9.3, that I uploaded to sourceforge just a few days ago. Download link here.
This version includes:

  • minor bugfixes and improvements to the GLModel and GLTexture classes.
  • improved integration between openGL and Processing camera and projection matrices.
  • OpenGL lights in both the GLGraphics and GLGraphicsOffScreen renderer.
  • GLFont class that uses openGL textures to store the characters.

The GLFont class is used in the same way as the core PFont, however a GLFont object must be created with the loadGLFont() method of the GLGraphics renderer. After creation, the usual fonts methods, text(), textFont(), etc. can be used with the GLFont objects. Update: After some testing I realised that the performance of GLFont is comparable to that of PFont. Some more work in GLGraphics is required in order to have increased performance with GLFonts.

import codeanticode.glgraphics.*;
import processing.opengl.*;

GLFont font;

void setup() {
size(400, 400, GLConstants.GLGRAPHICS);

// The GLGraphics renderer is needed to access the loadGLFont() method.
GLGraphics renderer = (GLGraphics)g;
// The font must be located in the sketch’s
// "data" directory to load successfully
font = renderer.loadGLFont("FreeSerif-32.vlw");
textFont(font, 32);
}

void draw() {
background(0);

fill(250, 10, 10);
text("GLFont demo", width/2 - textWidth("GLFont demo")/2, height/2, -100);

fill(255, 150);
text("[" + mouseX + ", " + mouseY + "]", mouseX, mouseY);
}

Advertisements

Posted February 4, 2010 by ac in Programming

Tagged with , , ,

15 responses to “GLGraphics 0.9.3

Subscribe to comments with RSS.

  1. Could you link the FastFonts example in this post? Thanks

    • Ok, I updated the post with the code sample.

      • When I run this code, I get an error on this line.
        “font = renderer.loadGLFont(“Arial-Black-32.vlw”);”

        processing.app.debug.RunnerException: unexpected char: ‘\’

      • does it happen with other fonts? or only with this one?

      • I just picked that one at random. Created and tried “Tahoma-32” and had the same issue.

      • Here is the full output:

        processing.app.debug.RunnerException: unexpected char: ‘\’
        at processing.app.Sketch.preprocess(Sketch.java:1395)
        at processing.app.Sketch.preprocess(Sketch.java:1194)
        at processing.app.Sketch.build(Sketch.java:1480)
        at processing.app.Sketch.compile(Sketch.java:1174)
        at processing.app.Editor.handleRun(Editor.java:1644)
        at processing.app.EditorToolbar.mousePressed(EditorToolbar.java:318)
        at java.awt.Component.processMouseEvent(Component.java:6345)
        at javax.swing.JComponent.processMouseEvent(JComponent.java:3255)
        at java.awt.Component.processEvent(Component.java:6113)
        at java.awt.Container.processEvent(Container.java:2085)
        at java.awt.Component.dispatchEventImpl(Component.java:4714)
        at java.awt.Container.dispatchEventImpl(Container.java:2143)
        at java.awt.Component.dispatchEvent(Component.java:4544)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4618)
        at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4279)
        at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4212)
        at java.awt.Container.dispatchEventImpl(Container.java:2129)
        at java.awt.Window.dispatchEventImpl(Window.java:2475)
        at java.awt.Component.dispatchEvent(Component.java:4544)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:635)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
        processing.app.debug.RunnerException: unexpected char: ‘\’
        at processing.app.Sketch.preprocess(Sketch.java:1395)
        at processing.app.Sketch.preprocess(Sketch.java:1194)
        at processing.app.Sketch.build(Sketch.java:1480)
        at processing.app.Sketch.compile(Sketch.java:1174)
        at processing.app.Editor.handleRun(Editor.java:1644)
        at processing.app.EditorToolbar.mousePressed(EditorToolbar.java:318)
        at java.awt.Component.processMouseEvent(Component.java:6345)
        at javax.swing.JComponent.processMouseEvent(JComponent.java:3255)
        at java.awt.Component.processEvent(Component.java:6113)
        at java.awt.Container.processEvent(Container.java:2085)
        at java.awt.Component.dispatchEventImpl(Component.java:4714)
        at java.awt.Container.dispatchEventImpl(Container.java:2143)
        at java.awt.Component.dispatchEvent(Component.java:4544)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4618)
        at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4279)
        at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4212)
        at java.awt.Container.dispatchEventImpl(Container.java:2129)
        at java.awt.Window.dispatchEventImpl(Window.java:2475)
        at java.awt.Component.dispatchEvent(Component.java:4544)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:635)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

      • ok, i’ll see what is going on… bugs like this are common in new releases ;-)

        thanks for reporting!

  2. Will GLFont make use (if possible) of “hint(ENABLE_NATIVE_FONTS);”? I’d love to get the best performance out of my fonts (since I have a lot of text), so this is a great addition.

    • From what understand, the ENABLE_NATIVE_FONTS hint would make sense only when using the JAVA2D renderer. GLFont copies the glyph data into openGL textures, so it should be the fastest method, even when compared with java native fonts.

      However, i haven’t made exhaustive benchmarking yet…

      • actually… i just did some simple benchmarking… and it turns out that GLFont is not noticeably faster than PFont :-(

        I guess it was too optimistic about GLFont…. What I realized just now is that PFont with the OPENGL renderer already used OpenGL textures to store each individual character glyph.

  3. Figured it out… it was the copy from your site. It uses “smart quotes” and a dash instead of a subtract.

  4. I ended up replying to myself in the middle.. but I did figure it out. The copy of the code from the site contain some unknown syntax (smart quotes, etc). After fixing this, it worked fine.

  5. does your lib support passing a uniform vec4 into a glsl shader from processing? (And if so what do i pass) I found some old processing post with the glg naming conventions but it only mentioned mat2 and floats.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: