i tried to run a simple example that definetly worked some month ago (radeon 8500)
now (fx5900xt), i get only a white frame, and nothing happens. the display-code gets called - but it doesn’t do anything.
here’s the code
public class GLEngine extends Frame implements GLEventListener
{
private GLExecutable gleRenderer;
private Cursor invisibleCursor;
private Cursor standardCursor;
private Toolkit tk = Toolkit.getDefaultToolkit();
private GLCanvas canvas;
private Thread loop;
private Robot r;
private static HashMap hmExtensions;
private boolean running = true;
public GLEngine(int w, int h, GLExecutable gleRenderer) throws AWTException
{
//init openGL-renderframe
super();
r = new Robot();
setTitle("GLEngine");
setLayout(new BorderLayout());
setSize(w, h);
this.gleRenderer = gleRenderer;
GLCapabilities capabilities = new GLCapabilities();
capabilities.setHardwareAccelerated(true);
capabilities.setDoubleBuffered(true);
canvas = GLDrawableFactory.getFactory()
.createGLCanvas(capabilities);
canvas.addGLEventListener(this);
//actionlistener aktivieren
KeyListener kl = new KeyAdapter()
{
public void keyReleased(KeyEvent k)
{
if (k.getKeyCode() == KeyEvent.VK_ESCAPE)
{
shutdown();
}
}
};
canvas.addKeyListener(kl);
canvas.addFocusListener(
new FocusAdapter()
{
public void focusLost(FocusEvent e)
{
canvas.requestFocus();
}
}
);
add(canvas, BorderLayout.CENTER);
//setCursor(invisibleCursor);
addWindowListener(
new WindowAdapter()
{
public void windowCLosing(WindowEvent e)
{
shutdown();
}
public void windowClosed(WindowEvent e)
{
shutdown();
}
}
);
}
public void setUser(HumanControl user)
{
canvas.addKeyListener(user);
canvas.requestFocus();
}
public void init(GLDrawable gd)
{
GL gl = gd.getGL();
reshape(gd, 0, 0, (int) getSize()
.getWidth(), (int) getSize()
.getHeight());
if (gleRenderer != null)
{
gleRenderer.init(gd);
} else
{
//test init
gl.glShadeModel(GL.GL_SMOOTH); //Enables Smooth Color Shading
gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); //This Will Clear The Background Color To Black
gl.glClearDepth(1.0); //Enables Clearing Of The Depth Buffer
gl.glEnable(GL.GL_DEPTH_TEST); //Enables Depth Testing
gl.glDepthFunc(GL.GL_LEQUAL); //The Type Of Depth Test To Do
}
//run in fixed rate loop
Timer timer = new Timer();
timer.scheduleAtFixedRate(new TimerTask()
{
public void run()
{
do
{
canvas.display();
} while (running);
}
}, 500,100);
}
public void shutdown()
{
running = false;
setVisible(false);
}
public static boolean isExtensionSupported(String extension, GL gl)
{
if (hmExtensions == null)
{
hmExtensions = new HashMap();
StringTokenizer tok = new StringTokenizer(gl.glGetString(GL.GL_EXTENSIONS));
while (tok.hasMoreElements())
{
hmExtensions.put(tok.nextToken(), null);
}
}
return hmExtensions.containsKey(extension);
}
public void display(GLDrawable glDrawable)
{
glDrawable.getGL()
.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
if (gleRenderer != null)
{
gleRenderer.drawScene(glDrawable.getGL());
} else
{ //test
GL gl = glDrawable.getGL();
//gl.glLoadIdentity(); //Reset The View
gl.glTranslatef(-0f, 0.0f, -18.0f); // Move Left 1.5 Units And Into The Screen 8(not 6.0 like VC.. not sure why)
gl.glBegin(GL.GL_TRIANGLES);
// Drawing Using Triangles
gl.glColor3f(1.0f,0f,0.45f);
gl.glVertex3f(0.0f, 1.0f, 0.0f); // Top
gl.glColor3f(1.0f, 0.2f, 0.15f);
gl.glVertex3f(-1.0f, -1.0f, 0.0f); // Bottom Left
gl.glColor3f(0.2f, 0f, 0.85f);
gl.glVertex3f(1.0f, -1.0f, 0.0f); // Bottom Right
gl.glEnd(); // Finished Drawing The Triangle
}
}
public void reshape(GLDrawable glDrawable, int i, int i1, int width, int height)
{
if (height == 0)
{
height = 1;
}
//Reset The Current Viewport And Perspective Transformation
GL gl = glDrawable.getGL();
gl.glViewport(0, 0, width, height);
gl.glMatrixMode(GL.GL_PROJECTION);
gl.glLoadIdentity();
glDrawable.getGLU()
.gluPerspective(45f, (float) width / (float) height, 1f, 1500f);
gl.glMatrixMode(GL.GL_MODELVIEW);
}
public void displayChanged(GLDrawable glDrawable, boolean b, boolean b1)
{
//To change body of implemented methods use File | Settings | File Templates.
}
public static void main(String[] args) throws AWTException
{
GLEngine gl = new GLEngine(500, 500, null);
gl.setVisible(true);
}
}
did i miss some api changes ?