import gl4java.*; import gl4java.drawable.*; import gl4java.awt.GLAnimCanvas; import gl4java.applet.SimpleGLAnimApplet1; import gl4java.utils.textures.*; import gl4java.utils.glf.*; import java.awt.*; import java.awt.event.*; import java.applet.*; import java.net.*; public class glf3dtext extends SimpleGLAnimApplet1 { public void init() { super.init(); GLContext.gljNativeDebug = false; GLContext.gljClassDebug = false; Dimension d = getSize(); GLCapabilities caps = new GLCapabilities(); canvas = GLDrawableFactory.getFactory().createGLAnimCanvas(caps, d.width, d.height); glf3dtextRenderer renderer = new glf3dtextRenderer(); canvas.addGLEventListener(renderer); add("Center", canvas); addMouseListener(this); } public static void main( String args[] ) { Frame mainFrame = new Frame("font test 2"); glf3dtext applet = new glf3dtext(); applet.setSize(400, 400); applet.init(); applet.start(); mainFrame.add(applet); mainFrame.pack(); mainFrame.setVisible(true); } class glf3dtextRenderer implements GLEventListener, MouseListener,MouseMotionListener { float []mPosObjTrans; float []mPosObjRot; Point mousePoint; Point oldMousePoint; boolean mouseMoveFlag; private GLFunc gl; private GLUFunc glu; private GLContext glj; protected GLF glf = null; int fArial1 = 0; int fArialBMF = 0; int fTechno1 = 0; int fTechnoBMF = 0; int fTimesNew1 = 0; int fTimesNewBMF = 0; public glf3dtextRenderer () { super(); } public void init(GLDrawable drawable) { gl = drawable.getGL(); glu = drawable.getGLU(); glj = drawable.getGLContext(); glf = new GLF(); fArial1 = glf.glfLoadFont("arial1.glf"); fArialBMF = glf.glfLoadBFont("arial.bmf"); fTechno1 = glf.glfLoadFont("techno1.glf"); fTechnoBMF = glf.glfLoadBFont("techno.bmf"); fTimesNew1 = glf.glfLoadFont("times_new1.glf"); fTimesNewBMF = glf.glfLoadBFont("times_new.bmf"); // cameraMatrix init mPosObjTrans=new float[16]; for(int i=0;i<16;i++) mPosObjTrans[i]=0f; mPosObjTrans[0]=mPosObjTrans[5]=mPosObjTrans[10]=mPosObjTrans[15]=1f; mPosObjRot=new float[16]; for(int i=0;i<16;i++) mPosObjRot[i]=0f; mPosObjRot[0]=mPosObjRot[5]=mPosObjRot[10]=mPosObjRot[15]=1f; TranlateObj(0f,0f,-10f); gl.glShadeModel (GL_SMOOTH); gl.glEnable(GL_DEPTH_TEST); gl.glClearColor(0.2f, 0.2f, 0.2f, 1.0f); gl.glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glj.gljCheckGL(); canvas.addMouseListener(this); canvas.addMouseMotionListener(this); mouseMoveFlag=false; } public void cleanup(GLDrawable drawable) { System.out.println("destroy(): " + this); removeMouseListener(this); removeMouseMotionListener(this); } public void display(GLDrawable drawable) { int i; // just render it gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); SetCamera(); DrawScene(); glj.gljCheckGL(); } public void preDisplay(GLDrawable drawable) { } public void postDisplay(GLDrawable drawable) { } public void reshape(gl4java.drawable.GLDrawable gld,int width,int height) { gl.glMatrixMode (GL_MODELVIEW); gl.glViewport (0, 0, width, height); gl.glLoadIdentity(); SetCamera(); } public void drawGrid(float x0, float y0, float width, float height, float step) { float i,j; /* draw grid */ gl.glBegin(GL_LINES); for(i=x0;i