We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOpenGL and 3D Libraries › Gift #2: Fast 2D openGL Font
Pages: 1 2 
Gift #2: Fast 2D openGL Font (Read 8659 times)
Re: Gift #2: Fast 2D openGL Font
Reply #15 - Mar 6th, 2009, 10:36pm
 
for 3d you will need to call processing beginGL/endGL

example:
 ((PGraphicsOpenGL)g).beginGL();
 textRender.print( "your text here", 0, 0, 0, 1/10.0 );
 ((PGraphicsOpenGL)g).endGL();
Re: Gift #2: Fast 2D openGL Font
Reply #16 - Mar 6th, 2009, 10:42pm
 
Ahh, great. Smiley
Any way to keep the text rightside up as the camera moves around (I'm using PeasyCam)?  I'd like the text to move around the screen as you move through the 3d space, but I don't want to to flip around or go to an edge.  I want it to stay readable.  Thoughts?
Re: Gift #2: Fast 2D openGL Font
Reply #17 - Mar 6th, 2009, 10:57pm
 
rightside up ? what do you mean ?

to move it around just pass the x,y,z coordinates
Re: Gift #2: Fast 2D openGL Font
Reply #18 - Mar 6th, 2009, 11:12pm
 
The text should stay readable (not upsidedown or backwards).  When moving the camera around, the text flips around like all the objects in the scene.  

I'm trying to apply a label to a sphere that I want to move around in 3d.

Code:

import peasy.*;
import processing.opengl.*;

PeasyCam cam;
VTextRenderer textRender;

void setup()
{
size( 800, 600, OPENGL );
cam = new PeasyCam(this, 100);
textRender = new VTextRenderer( "Arial", 32 );
}

void draw()
{
background(255 );
fill(171, 67, 234, 40);
pushMatrix();
translate(0,0,0);
sphere(5);
popMatrix();
pushMatrix();
translate(25,0,0);
sphere(5);
popMatrix();

textRender.setColor( 0.3, 0.3, 0.3, 1 );
((PGraphicsOpenGL)g).beginGL();
textRender.print( "sphere1", 32, 0, 0, 1/10.0 );
((PGraphicsOpenGL)g).endGL();
}
Re: Gift #2: Fast 2D openGL Font
Reply #19 - Mar 6th, 2009, 11:27pm
 
to flip on the y: scale( 1, -1, 1 );

as for the camera backwards the camera might be looking from behind the text.
Re: Gift #2: Fast 2D openGL Font
Reply #20 - Apr 6th, 2009, 11:58am
 
Ness, pretty cool text render.  I found it to be faster than the VTextRender, however, I had issues when zooming out and such.  The text starts to pull apart.  Instead of rendering each letter as image, perhaps you could rewrite it to render the text as a single image.  Any thoughts on using a shader or something, so the text can easily billboard?

Also, I had to add "import java.nio.*;" in the sketch to get it to work.  In another sketch when testing, I had to prefix ByteBuffer tempBuf; to be "java.nio.ByteBuffer tempBuf;" and Buffer data to be "java.nio.Buffer data".
Re: Gift #2: Fast 2D openGL Font
Reply #21 - Oct 14th, 2009, 11:42am
 
V wrote on Feb 9th, 2009, 10:47am:
here's another textwriter in opengl for 2d/3d mode.


Where is the "Font" class being used here

Thanks!
Joe
Pages: 1 2