aboutsummaryrefslogtreecommitdiffstats
path: root/demos/GLFDemos
diff options
context:
space:
mode:
Diffstat (limited to 'demos/GLFDemos')
-rw-r--r--demos/GLFDemos/glf3dtext2.java-not-finished378
-rw-r--r--demos/GLFDemos/index.html4
-rw-r--r--demos/GLFDemos/index_plugin13.html4
3 files changed, 380 insertions, 6 deletions
diff --git a/demos/GLFDemos/glf3dtext2.java-not-finished b/demos/GLFDemos/glf3dtext2.java-not-finished
new file mode 100644
index 0000000..9efb0bf
--- /dev/null
+++ b/demos/GLFDemos/glf3dtext2.java-not-finished
@@ -0,0 +1,378 @@
+
+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 glf3dtext2 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");
+
+ glf3dtext2 applet = new glf3dtext2();
+
+ 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;
+
+ float angle=0f;
+
+ public glf3dtextRenderer ()
+ {
+ super();
+ }
+
+ public void init(GLDrawable drawable)
+ {
+ gl = drawable.getGL();
+ glu = drawable.getGLU();
+ glj = drawable.getGLContext();
+
+ glf = new GLF();
+
+ glf.glfInit();
+
+ fArial1 = glf.glfLoadFont("arial1.glf");
+ fArialBMF = glf.glfLoadBMFFont("arial.bmf");
+
+ fTechno1 = glf.glfLoadFont("techno1.glf");
+ fTechnoBMF = glf.glfLoadBMFFont("techno.bmf");
+
+ fTimesNew1 = glf.glfLoadFont("times_new1.glf");
+ fTimesNewBMF = glf.glfLoadBMFFont("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);
+ glf.glfClose();
+ }
+
+ 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<width;i+=step)
+ for(j=y0;j<height;j+=step)
+ {
+ if(i==0f && j==0f)
+ gl.glColor3f (1f,0f,0f);
+ else
+ gl.glColor3f (0.6f,0.5f,0.5f);
+ gl.glVertex2f(0f,j);
+ gl.glVertex2f(width,j);
+ gl.glVertex2f(i,height);
+ gl.glVertex2f(i,0f);
+ }
+ gl.glEnd();
+ }
+
+ void DrawScene()
+ {
+ gl.glMatrixMode (GL_MODELVIEW);
+ gl.glLoadIdentity ();
+
+ // kamera setzen
+ gl.glLoadMatrixf(mPosObjTrans);
+ gl.glMultMatrixf(mPosObjRot);
+
+ gl.glPushMatrix();
+ drawGrid(0f, 0f, 10f, 10f, 0.5f);
+ gl.glPopMatrix();
+
+ // obj zeichnen
+ gl.glPushMatrix();
+ gl.glColor3d(0.3,0,0);
+
+ gl.glBegin(GL_POLYGON);
+ gl.glVertex2d(0,-0.5);
+ gl.glVertex2d(0.5,0.5);
+ gl.glVertex2d(-0.5,0.5);
+ gl.glEnd();
+
+ gl.glColor3d(1,1,1);
+ gl.glPopMatrix();
+
+ gl.glPushMatrix();
+ gl.glRotatef(angle, 1, 1, 1);
+ angle += 3f;
+ if (angle > 359f) angle = angle - 360f;
+
+ gl.glScalef(0.5f, 0.5f, 0.5f);
+ gl.glTranslatef(-2.2f,-4f,0.5f);
+
+ gl.glTranslatef(0f,2f,0f);
+ glf.glfDraw3DWiredStringF(fArial1, "Arial - GLF 3D Text");
+
+ gl.glTranslatef(0f,2f,0f);
+ glf.glfDraw3DSolidStringF(fArial1, "Arial - GLF 3D Text");
+
+ gl.glTranslatef(0f,2f,0f);
+ glf.glfDraw3DWiredStringF(fTechno1, "Techno - GLF 3D Text");
+
+ gl.glTranslatef(0f,2f,0f);
+ glf.glfDraw3DSolidStringF(fTechno1, "Techno - GLF 3D Text");
+
+ gl.glTranslatef(0f,2f,0f);
+ glf.glfDraw3DWiredStringF(fTimesNew1, "TimesNew - GLF 3D Text");
+
+ gl.glTranslatef(0f,2f,0f);
+ glf.glfDraw3DSolidStringF(fTimesNew1, "TimesNew - GLF 3D Text");
+
+ gl.glTranslatef(0f,2f,0f);
+ glf.glfSetCurrentBMFFont(fArialBMF);
+ glf.glfStartBitmapDrawing();
+ glf.glfDrawBString("Arial BMF - GLF 3D Text");
+ glf.glfStopBitmapDrawing();
+
+ gl.glTranslatef(0f, 2f, 0f);
+ glf.glfSetCurrentBMFFont(fTechnoBMF);
+ glf.glfStartBitmapDrawing();
+ glf.glfDrawBString("Techno BMF - GLF 3D Text");
+ glf.glfStopBitmapDrawing();
+
+ gl.glTranslatef(0f, 2f, 0f);
+ glf.glfSetCurrentBMFFont(fTimesNewBMF);
+ glf.glfStartBitmapDrawing();
+ glf.glfDrawBString("TimesNew BMF - GLF 3D Text");
+ glf.glfStopBitmapDrawing();
+
+ gl.glPopMatrix();
+ }
+
+ void SetCamera()
+ {
+ Dimension dim=getSize();
+ float aspect=(float)dim.width/(float)dim.height;
+
+ gl.glMatrixMode (GL_PROJECTION);
+ gl.glLoadIdentity ();
+ glu.gluPerspective(60f,aspect,.01,100);
+ }
+
+ void RotateObj(float degree,
+ float axisX,
+ float axisY,
+ float axisZ)
+ {
+ gl.glMatrixMode (GL_MODELVIEW);
+ gl.glLoadIdentity ();
+
+ // kamera setzen
+ gl.glRotatef(degree,axisX,axisY,axisZ);
+ gl.glMultMatrixf(mPosObjRot);
+ gl.glGetFloatv(GL_MODELVIEW_MATRIX,mPosObjRot);
+ }
+
+ void TranlateObj(float x,float y,float z)
+ {
+ gl.glMatrixMode (GL_MODELVIEW);
+ gl.glLoadIdentity ();
+
+ // kamera setzen
+ gl.glLoadMatrixf(mPosObjTrans);
+ gl.glTranslatef(x,y,z);
+ gl.glGetFloatv(GL_MODELVIEW_MATRIX,mPosObjTrans);
+ }
+
+ // entfernt rotationen aus aktueller matrix
+ double Billboard()
+ {
+ float[] mat=new float[16];
+
+ gl.glGetFloatv(GL_MODELVIEW_MATRIX,mat);
+ mat[0] = mat[5] = mat[10] = 1;
+ mat[1] = mat[2] = mat[4] = mat[6] = mat[8] = mat[9] = 0;
+ gl.glLoadMatrixf(mat);
+
+ return mat[14];
+ }
+
+ // Methods required for the implementation of MouseListener
+ public void mouseEntered( MouseEvent evt )
+ {
+ }
+
+ public void mouseExited( MouseEvent evt )
+ {
+ }
+
+ public void mousePressed( MouseEvent evt )
+ {
+ if(mouseMoveFlag==false)
+ { // start drag
+ mouseMoveFlag=true;
+ mousePoint=evt.getPoint();
+ }
+ }
+
+ public void mouseReleased( MouseEvent evt )
+ {
+ mouseMoveFlag=false;
+ }
+
+ public void mouseClicked( MouseEvent evt )
+ {
+ Component comp = evt.getComponent();
+ }
+
+ public void mouseDragged(MouseEvent e)
+ {
+ if(mouseMoveFlag==true)
+ {
+ oldMousePoint=new Point(mousePoint);
+ mousePoint=e.getPoint();
+
+ Point dif=new Point(mousePoint.x-oldMousePoint.x,
+ mousePoint.y-oldMousePoint.y);
+
+ if( glj.gljMakeCurrent() == false )
+ {
+ System.out.println("problem in use() method");
+ return;
+ }
+
+ if(e.isShiftDown()==true)
+ TranlateObj((float)dif.x/6.0f,(float)dif.y/-6.0f,0f);
+ else if(e.isAltDown()==true)
+ {
+ TranlateObj(0f,0f,(float)dif.y/6.0f);
+ RotateObj(dif.x,0f,0f,1f);
+ }
+ else
+ {
+ RotateObj(dif.x,0f,1f,0f);
+ RotateObj(dif.y,1f,0f,0f);
+ }
+
+ glj.gljFree();
+
+ repaint();
+
+ }
+ }
+ public void mouseMoved(MouseEvent e)
+ {
+ }
+
+
+ }
+}
diff --git a/demos/GLFDemos/index.html b/demos/GLFDemos/index.html
index 3b014e2..c2c93c4 100644
--- a/demos/GLFDemos/index.html
+++ b/demos/GLFDemos/index.html
@@ -7,7 +7,7 @@
<title>Misc Demos</title>
</head>
<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
-<p>Here are the GLF-Demos for <B> GL4Java >= 2.7.2.0: </B> <br>
+<p>Here are the GLF-Demos for <B> GL4Java >= 2.8.1.0: </B> <br>
<br>
<p><a href="index_plugin13.html">To use the Java2 Plug-In (Java2, JRE, Plug-In 1.3), click here !</a><br>
<br>
@@ -15,8 +15,6 @@
<br>
<p>&nbsp;<a href="glf3dtext.html">GLF Font Demo 1</a>
: GLF Font Demo 1 (GLF DEMO)
-<p>&nbsp;<a href="glf3dtext2.html">GLF Font Demo 2</a>
-: GLF Font Demo 2 with rotation (GLF DEMO)
<br>&nbsp;
<br>
<br>
diff --git a/demos/GLFDemos/index_plugin13.html b/demos/GLFDemos/index_plugin13.html
index deb60a6..460859f 100644
--- a/demos/GLFDemos/index_plugin13.html
+++ b/demos/GLFDemos/index_plugin13.html
@@ -7,7 +7,7 @@
<title>Misc Demos</title>
</head>
<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#e6e6ff">
-<p>Here are the GLF Demos for <B> GL4Java >= 2.7.2.0: & Java2 Plug-In 1.3</B>
+<p>Here are the GLF Demos for <B> GL4Java >= 2.8.1.0: & Java2 Plug-In 1.3</B>
<hr
<br>&nbsp;
<a href="../../Installer/java.policy">The Java2 (sdk, jre, plugin 1.3) policy file example to give GL4Java the necessary permissions (Click here) !</a>
@@ -17,8 +17,6 @@
<br>
<p>&nbsp;<a href="glf3dtext_plugin13.html">GLF Font Demo 1</a>
: GLF Font Demo 1 (GLF DEMO)
-<p>&nbsp;<a href="glf3dtext2_plugin13.html">GLF Font Demo 2</a>
-: GLF Font Demo 2 with rotation (GLF DEMO)
<br>&nbsp;
<br>
<br>