We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOpenGL and 3D Libraries › Fullscreen mode with openGL
Pages: 1 2 
Fullscreen mode with openGL (Read 19875 times)
Re: Fullscreen mode with openGL
Reply #15 - May 30th, 2006, 5:19pm
 
here is another hack that enables your sketch to not only run as fullscreen but also switch the resolution.

Code:

import java.awt.Component;
import java.awt.DisplayMode;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;

import processing.core.PApplet;


public class TestFullscreen
extends PApplet {

public void setup() {
size(640, 480, OPENGL);
rectMode(CENTER);
switchResolution();
}


public void draw() {
background(127, 255, 0);

fill(255, 255);
stroke(0, 255);
strokeWeight(20);
rect(mouseX, mouseY, 200, 200);
}


private void switchResolution() {
try {
GraphicsDevice myGraphicsDevice = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
if (myGraphicsDevice.isDisplayChangeSupported()) {
DisplayMode myDisplayMode = new DisplayMode(
width,
height,
32,
DisplayMode.REFRESH_RATE_UNKNOWN);
myGraphicsDevice.setDisplayMode(myDisplayMode);
}

Component[] myComponents = frame.getComponents();
for (int i = 0; i < myComponents.length; i++) {
if (myComponents[i] instanceof PApplet) {
myComponents[i].setLocation(0, 0);
}
}
}
catch (Exception e) {
}
}


public static void main(String[] args) {
PApplet.main(new String[] {"--present", "TestFullscreen"});
}
}


the sketch needs to run in presentation mode ( shift + play ) and you need to define meaningful screen dimensions that are supported by your output device.

enjoy.
Re: Fullscreen mode with openGL
Reply #16 - Jan 6th, 2007, 2:15am
 
I've another question about that. Any one knows how to make an static full screen in OPENGL? It means, I want to have two aplications running at the same time, one of them in full screen always in the display 2, but interacting at the same time with the other in the display 1. My problem is, when I interact with  another window the full screen window is minimized. May be the rigth solution would be something like "frame.setUndecorated(true)" but that don't run in OPENGL.
Re: Fullscreen mode with openGL
Reply #17 - Jan 10th, 2007, 6:15pm
 
If I've understood it correctly, full-screen mode is a special mode where an application has full control of the screen and hence potentially better performance. It's more than just a big window with the frame turned off, which is why you get a problem when trying to interact with another window. When you do that, your sketch loses "control" and reverts back to being a regular window.

Generally, a window that is the same size as the screen resolution and has no frames will work well for "full screen". I use that even for dual-screen projections, with a single window with sizes up 2560x1024. Just set up a double-size window, turn off the frame and place it at the top left corner. You might have problems with the positioning though, but it can be done through the switches built into main().
Re: Fullscreen mode with openGL
Reply #18 - Jan 10th, 2007, 7:53pm
 
Thank you for your answer Marius. My question now is how can I trun off the frame? If I make something like this:

import processing.opengl.*;

void setup(){

 size(400,400,OPENGL);
 frame.setUndecorated(true);
 background(0);
}

void draw(){
 stroke(255);
 line(0,0,200,200);
}

I recive an error:  java.awt.IllegalComponentStateException: The frame is displayable.
Re: Fullscreen mode with openGL
Reply #19 - Jan 10th, 2007, 10:50pm
 
Sorry, not sure I can help since it seems to be buried deep in the main() / setup() / size() logic that controls how Processing sets up and runs a sketch. So from inside Processing you might not be able to. But.... there's always Java.

If you look at the source code for PApplet.java you can get a drift of the execution order. Most of the fullscreen etc. stuff happens in main(), but that is only called when running as an application. Inside the Processing environment your sketch is still executed as an applet, so init() is called instead of main().

So... digging around a little I tried a little hack by overriding init(), and guess what It works for turning off window decorations, but not setting the location of the window. So it's not a complete solution, but maybe someone else has the final key to the puzzle.

Code:
import processing.opengl.*;

void setup(){
size(400,400,OPENGL);
background(0);
}

void draw(){
stroke(255);
line(0,0,200,200);
}

public void init() {
frame.setUndecorated(true); // works.
frame.setLocation(0,0); // doesn't. why not?

// call PApplet.init() to take care of business
super.init();
}
Re: Fullscreen mode with openGL
Reply #20 - Jan 11th, 2007, 11:01am
 
That's the solution, good! The complete solution it's a little bit chaotic, but if you move the setLocation() from the init() to the setup() it works.

import processing.opengl.*;

void setup(){
 size(300,300,OPENGL);
 frame.setLocation(0,0); //works
 background(0);
}

void draw(){
 stroke(255);
 line(0,0,200,200);
}  

public void init() {
 frame.setUndecorated(true); // works.
 // call PApplet.init() to take care of business
 super.init();  
}
Re: Fullscreen mode with openGL
Reply #21 - Jul 18th, 2007, 9:16am
 
FYI everyone who is using multiple displays on a mac and wants specific control over which display your sketch uses and full screen without taking over the other screen--

setLocation(0,0) means the upper left corner of the MAIN display - which is the display with the menubar (you can drag the mini menubar between displays in the displays sys pref to switch).

You can use negative values in setLocation if your sketch display is configured for the left of the main display. For example if your main display is 1440x900 and your 2nd display is to the left and 800x600, you can use:

frame.setLocation(-800,0);

It works the other way too, if your 2nd display is instead to the right of the main display, you can then use:

frame.setLocation(1440, 0);

and it'll pop it over to the 2nd display full screen without disrupting the other display.
Re: Fullscreen mode with openGL
Reply #22 - Oct 30th, 2007, 12:21pm
 
Anyone had problems with present mode, opengl and vista ?

I've got a project that uses opengl, and works fine on my XP laptop, but wont go into present mode on my vista PC.

It's a pity, I was presenting tomorrow on my vista PC, would have liked to use present mode, only just realised it too! haha. Ah well!
Re: Fullscreen mode with openGL
Reply #23 - Nov 14th, 2008, 1:40am
 
tomgupper wrote on Oct 30th, 2007, 12:21pm:
Anyone had problems with present mode, opengl and vista

I've got a project that uses opengl, and works fine on my XP laptop, but wont go into present mode on my vista PC.

It's a pity, I was presenting tomorrow on my vista PC, would have liked to use present mode, only just realised it too! haha. Ah well!


I seem to be having the same issue not just openGL, P3D and P2D also. It looks like it launches but dosen't display anything. The sketch shows up in the task bar and everything. I tried it on multiple vista machines no luck.
Re: Fullscreen mode with openGL
Reply #24 - Nov 14th, 2008, 7:00pm
 
Use release 0156, which fixes problems with Present (full screen) mode for all renderers.

However, Present + OpenGL still has problems on Vista, which you might be able to get around by disabling Aero.
Pages: 1 2