Closed SimonH89 closed 10 years ago
I managed to get full-screen mode to work by myself. There are some issues I needed to take care of:
GLG2DCanvas
. After using the default layout manager the paintComponent
method was called properly. But still the screen remained black.-Dsun.java2d.noddraw=true
has to be set.Here is my finally working code:
import org.jogamp.glg2d.GLG2DCanvas;
import javax.swing.*;
import java.awt.*;
public class Fullscreen {
private static GraphicsDevice device;
private static JFrame frame;
private static Dimension resolution = new Dimension(1920, 1080);
public static void main(String[] args) {
System.setProperty("sun.java2d.noddraw", "true");
GraphicsEnvironment gsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment();
device = gsEnvironment.getDefaultScreenDevice();
frame = new JFrame();
frame.setUndecorated(true);
frame.setIgnoreRepaint(true);
frame.setResizable(false);
JComponent canvas = new GLG2DCanvas(new MyRenderPane());
canvas.setPreferredSize(resolution);
frame.setContentPane(canvas);
frame.pack();
device.setFullScreenWindow(frame);
device.setDisplayMode(new DisplayMode(resolution.width, resolution.height, 32, DisplayMode.REFRESH_RATE_UNKNOWN));
frame.repaint();
}
private static class MyRenderPane extends JComponent {
@Override
public void paintComponent(Graphics g) {
System.out.println("Drawing...");
g.setColor(Color.BLUE);
g.fillRect(0, 0, 200, 200);
}
}
}
Hello, I have an issue using the glg2d wrapper with the java full-screen exclusive mode API. Independet of which display mode I set I'm always getting a black screen. When I don't use the wrapper everything works properly. Here is my test source code:
What I noticed is that the
paintComponent
method of myJComponent
isn't called even though I callrepaint
on myJFrame
. There is no output ("Drawing...") toSystem.out
.Sorry if i missed somthing, but I couldn't find any information on how glg2d behaves with that API. Is there anything special I need to take care of or is the API not supported yet?