Hi everyone, I recently installed jogl and am trying to get the “Getting started with jogl” tutorial going. However, i noticed when compiling the code some of the items were deprecated and some completely missing. This tutorial was written in 2003, so it is fairly old. Anyhow, (I’ll post the code below) when I run the Test.java file, all I get is a blank window with no triangle. I’ve been beating my head over this one and cannot quite pinpoint where the problem is and was hoping someone might spot something wrong… thanks for any and all help!!
~Bolt
this is part 1
package tester;
import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.media.opengl.GLCanvas;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLDrawableFactory;
import javax.media.opengl.GLEventListener;
import com.sun.opengl.util.Animator;
public class Test
{
public static void main( String[] args )
{
try
{
Frame testFrame = new Frame("TestFrame");
testFrame.setSize( 512, 384 );
GLCapabilities glCaps = new GLCapabilities();
glCaps.setRedBits(8);
glCaps.setBlueBits(8);
glCaps.setGreenBits(8);
glCaps.setAlphaBits(8);
GLCanvas canvas = new GLCanvas();
testFrame.add( canvas );
canvas.addGLEventListener((GLEventListener) new TestRenderer());
final Animator animator = new Animator( canvas);
testFrame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
animator.stop();
System.exit(0);
}
});
testFrame.setVisible(true);
animator.start();
}
catch( Exception e )
{
e.printStackTrace();
}
}
}
this is part 2
package tester;
import javax.media.opengl.DebugGL;
import javax.media.opengl.GL;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLDrawable;
import javax.media.opengl.GLEventListener;
public class TestRenderer implements GLEventListener
{
private GL gl;
private GLDrawable glDrawable;
public void init(GLDrawable drawable)
{
this.gl = ((GLAutoDrawable) drawable).getGL();
this.glDrawable = drawable;
((GLAutoDrawable) drawable).setGL( new DebugGL(((GLAutoDrawable) drawable).getGL() ));
System.out.println("Init GL is " + gl.getClass().getName());
}
public void display(GLDrawable drawable)
{
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT );
gl.glLoadIdentity();
gl.glColor3f(1.0f, 0.0f, 0.0f );
System.out.println("Init GL is " + gl.getClass().getName());
gl.glBegin( GL.GL_TRIANGLES );
gl.glVertex3f( 0.0f, 0.0f, 0.0f );
gl.glVertex3f( 1.0f, 0.0f, 0.0f );
gl.glVertex3f( 1.0f, 1.0f, 0.0f );
gl.glEnd();
}
public void reshape(GLDrawable drawable, int x, int y, int width, int height)
{
}
public void displayChanged(GLDrawable drawable, boolean modeChanged, boolean deviceChanged)
{
}
@Override
public void display(GLAutoDrawable arg0) {
// TODO Auto-generated method stub
}
@Override
public void displayChanged(GLAutoDrawable arg0, boolean arg1, boolean arg2) {
// TODO Auto-generated method stub
}
@Override
public void init(GLAutoDrawable arg0) {
// TODO Auto-generated method stub
}
@Override
public void reshape(GLAutoDrawable arg0, int arg1, int arg2, int arg3,
int arg4) {
// TODO Auto-generated method stub
}
}