Hello to everyone,
I have problems running fullscreen jogl applications on macs.
I tried both my code and jogl sample gears-fullscreen demo and
the screen is completely black. These programs run correctly
in windowed mode. They also run correctly on windows xp machines
in fullscreen mode.
I also noticed that the first frame of gears demo is rendered
correctly. Perhaps this is done before the frame becomes fullscreen.
I tried a non-jogl fullscreen java application work well on these macs.
macs are:
emac with java 1.4.2,
powerbook g4 with java 1.5
win machines are:
java 1.6 and 1.4.2
with radeon x1600 video card
the code is compiled for java version 1.1
Has anyone successful experience with macs in fullscreen mode?
What is wrong with this code:
package test;
import javax.media.opengl.*;
import java.awt.*;
import java.awt.event.*;
public class Test implements GLEventListener {
private GLCanvas canvas;
private int sizex, sizey;
public static void main(String[] args) {
new Test();
}
Test() {
create_window();
while(true) {
canvas.display();
Thread.yield();
}
}
private void create_window() {
GraphicsDevice dev = GraphicsEnvironment.
getLocalGraphicsEnvironment().
getDefaultScreenDevice();
if (!dev.isFullScreenSupported())
die("!dev.isFullScreenSupported()");
int initWidth = 400, initHeight = 300;
DisplayMode mode = null;
DisplayMode[] modes = dev.getDisplayModes();
// find any 32 bit mode:
for(int i = 0 ; i < modes.length; i++)
{
if (modes[i].getBitDepth() == 32 && modes[i].getWidth() >= 640)
{
mode = modes[i];
break;
}
}
initWidth = mode.getWidth();
initHeight = mode.getHeight();
canvas = new GLCanvas();
canvas.addGLEventListener(this);
canvas.addGLEventListener(new FullscreenWorkaround(initWidth, initHeight));
Frame frame = new Frame("test");
frame.setUndecorated(true);
frame.setLayout(new BorderLayout());
canvas.setSize(initWidth, initHeight);
frame.add(canvas, BorderLayout.CENTER);
frame.pack();
canvas.setFocusable(true);
canvas.requestFocus();
frame.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
dev.setFullScreenWindow(frame);
if (!dev.isDisplayChangeSupported())
die("!dev.isDisplayChangeSupported()");
dev.setDisplayMode(mode);
frame.setVisible(true);
}
public void init(GLAutoDrawable drawable){ }
public void reshape(GLAutoDrawable drawable, int x1, int y1, int x2, int y2) {
sizex = x2-x1;
sizey = y2-y1;
}
public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged){}
public void display(GLAutoDrawable drawable)
{
GL gl = drawable.getGL();
gl.glViewport(0, 0, sizex, sizey);
gl.glMatrixMode(GL.GL_PROJECTION);
gl.glLoadIdentity();
gl.glOrtho(0, sizex, 0, sizey, -1, 1);
gl.glMatrixMode(GL.GL_MODELVIEW);
gl.glLoadIdentity();
gl.glColor3f(1,1,1);
gl.glRectf(100, 100, 500, 400);
}
private static void die(String message) {
javax.swing.JOptionPane.showMessageDialog(
null, message, "message",
javax.swing.JOptionPane.PLAIN_MESSAGE, null);
}
}