Hello,
Thank you for sharing the code!
I tried implementing it and I got the error; The type RRectangle is not visible with a highlight on this line:
float charOffset=character.getBounds().points[3].x-character.getBounds().points[1].x;
But even if I comment it out no text gets displayed.
I put everything inside draw() and drawText() after it in the main tab.
Can anyone help me?
Thank you!
-edit-
I still have the RRectangle problem, but other than that it finally works.
Thanks again!!
Code:import peasy.org.apache.commons.math.*;
import peasy.*;
import peasy.org.apache.commons.math.geometry.*;
import geomerative.*;
import org.apache.batik.svggen.font.table.*;
import org.apache.batik.svggen.font.*;
import java.nio.ByteBuffer;
import com.sun.opengl.util.BufferUtil;
import processing.opengl.PGraphicsOpenGL;
import processing.core.*;
import javax.media.opengl.GL;
import javax.media.opengl.glu.GLU;
import java.util.*;
import java.nio.*;
int fontList;
ByteBuffer stringBuffer;
color c;
PGraphicsOpenGL pgl;
GL gl;
PeasyCam cam;
String fontString;
RFont font;
float charSpace;
void setup(){
size(300,300,OPENGL);
RG.init(this);
fill(255);
stroke(255);
stringBuffer = BufferUtil.newByteBuffer(256);
cam = new PeasyCam(this, 100);
cam.setMinimumDistance(50);
cam.setMaximumDistance(500);
/////BUILD FONT GEOMETRY
fontString = "################0123456789#######ABCDEFGHIJKLMNOPQRSTUVWXYZ######abcdefghijklmnopqrstuvwxyz";
//###'s are placeholders until I get all the right chars in place
font = new RFont("AMIENNE_.TTF", 72, RFont.CENTER);
charSpace = 30.0; //SPACING OFFSET
pgl = (PGraphicsOpenGL)g;
gl = pgl.gl;
fontList = gl.glGenLists(fontString.length());
for(int i = 0; i < fontString.length(); i++){
gl.glNewList(fontList + i, GL.GL_COMPILE);
if(i != 0){//////SPACE CHARACTER
RMesh character = font.toPolygon(fontString.charAt(i)).toMesh();
RStrip[] triangleStrips = character.strips;
for(int j = 0; j < triangleStrips.length; j++){
gl.glBegin(GL.GL_TRIANGLE_STRIP);
RPoint[] pts = triangleStrips[j].getPoints();
for(int k = 0; k < pts.length; k++){
gl.glVertex2f(pts[k].x, pts[k].y);
}
gl.glEnd();
}
//float charOffset = character.getBounds().points[3].x - character.getBounds().points[1].x;////GET CHAR BOUNDS TO ADJUST SPACE
//println(charOffset);
gl.glTranslatef(charSpace+(10), 0, 0);
gl.glEndList();
}
else{ //////SPACE CHARACTER
gl.glTranslatef(charSpace+10.0, 0, 0);
gl.glEndList();
}
}
// pgl.endGL();
c = #FFCC00;
}
void draw(){
background(125);
drawText("abcdefg",4,c,0);
}
/////////////////////////DRAW METHOD
void drawText(String string, float _scale, color _color, float _alpha) {
gl.glPushAttrib(GL.GL_LIST_BIT);
gl.glPushMatrix();
//gl.glRotatef(180, 1,0,0);
//gl.glScalef(_scale,-_scale,_scale);
//gl.glScalef(.02, .02, .02);
//gl.glColor4f( red(_color), green(_color), blue(_color), _alpha );
gl.glListBase(fontList-32);
if(stringBuffer.capacity() < string.length()) {
stringBuffer = BufferUtil.newByteBuffer(string.length());
}
stringBuffer.clear();
stringBuffer.put(string.getBytes());
stringBuffer.flip();
pgl = (PGraphicsOpenGL)g;
pgl.beginGL();
// Write The Text To The Screen
gl.glCallLists(string.length(), GL.GL_BYTE, stringBuffer);
gl.glPopMatrix();
gl.glPopAttrib();
gl.glEnd();
pgl.endGL();
}