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 19874 times)
Fullscreen mode with openGL
Oct 29th, 2005, 11:46pm
 
Hello to you all.
I've searched through the board for an answer to this question but I couldn't find any so I fire off.

I'm currently working on a project that will convert satelite data into both graphic and sound.
What I really would like is to be able to run the program in fullscreen mode. Using openGL for this task is therefor the (only?) choice.

I'm not very familiar with the openGL framework wich leaves me muttering over this issue.

It would be very helpful if anyone could post a little code snipped on how to turn the processing window into an openGL-fullscreen.
Re: Fullscreen mode with openGL
Reply #1 - Oct 30th, 2005, 12:01am
 
There's a simple way, set the size(..) to be your screen resolution, then go to the top menu->sketch->Present and that'll run it full screen.

Hitting escape will exit back to processing.
Re: Fullscreen mode with openGL
Reply #2 - Oct 30th, 2005, 1:04am
 
Oh, such a sweet little feature.

What I'm wondering is if it's possible to utilize the openGL renderer to render the scene (sketch window) in fullscreen.

Say that my sketch window is 800x600, can this be rendered into a fullscreen with 800x600 resolution?
Re: Fullscreen mode with openGL
Reply #3 - Oct 30th, 2005, 2:07am
 
Not as far as I know -- you can make it go fullscreen with your size() set to any pixel size, but it'll just draw an x by y image in the middle of the screen with a blank border, in that case.

Making Processing change the graphics mode would be sweet, and is probably do-able, but I don't believe that it does that now.
Re: Fullscreen mode with openGL
Reply #4 - Oct 31st, 2005, 11:42pm
 
Alterscape wrote on Oct 30th, 2005, 2:07am:
Making Processing change the graphics mode would be sweet, and is probably do-able, but I don't believe that it does that now.

nah, it doesn't.. we didn't want to get into that. if you'd like to see it in a future release, the best way to see it happen is get it logged as an "enhancement" in the bugs db, and/or write some code that'll handle it that i can add to PApplet.main().
Re: Fullscreen mode with openGL
Reply #5 - Nov 2nd, 2005, 11:20am
 
just a hack, not tested and all that bla bla. but you can just throw the 'PApplet' into a 'Frame' and make that fullscreen.

Code:

import processing.opengl.*;

void setup() {
size(640, 480, OPENGL);
startFullscreen();
background(255);
}

void draw() {
background(255);
stroke(0, 64);
line(mouseX, mouseY, random(width), random(height));

if (mousePressed) {
stopFullscreen();
background(255);
}
}

void startFullscreen() {
/* todo. dispose old frame */
frame = new Frame();
frame.setUndecorated(true);
frame.add(this);

GraphicsDevice myGraphicsDevice = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
myGraphicsDevice.setFullScreenWindow(frame);
if (myGraphicsDevice.isDisplayChangeSupported()) {
DisplayMode myDisplayMode = new DisplayMode(
width,
height,
32,
DisplayMode.REFRESH_RATE_UNKNOWN);
myGraphicsDevice.setDisplayMode(myDisplayMode);
}
}

void stopFullscreen() {
GraphicsDevice myGraphicsDevice = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
myGraphicsDevice.setFullScreenWindow(null);
}


Re: Fullscreen mode with openGL
Reply #6 - Nov 25th, 2005, 1:56pm
 
Hi. I tried to run your code by putting the two methods into a subclass of PApplet and called startFullscreen() in setup() and stopFullscreen().

It is changing the Displaymode properly, but then i get the following GL_ERRORS ..

Code:

GL_ERROR at top endFrame(): 0502 GL_INVALID_OPERATION
GL_ERROR at bot endFrame(): 0502 GL_INVALID_OPERATION


.. and this Java exceptions ..

Code:

java.lang.RuntimeException: net.java.games.jogl.GLException: Error freeing OpenGL context: 0

at processing.opengl.PGraphicsGL.requestDisplay(PGraphicsGL.java:214)

at processing.core.PApplet.run(PApplet.java:1009)

at java.lang.Thread.run(Unknown Source)
Caused by: net.java.games.jogl.GLException: Error freeing OpenGL context: 0

at net.java.games.jogl.impl.windows.WindowsGLContext.free(WindowsGLContext.java:189)

at net.java.games.jogl.impl.windows.WindowsOnscreenGLContext.free(WindowsOnscreenGLContext.java:147)

at net.java.games.jogl.impl.GLContext.invokeGL(GLContext.java:324)

at net.java.games.jogl.impl.windows.WindowsOnscreenGLContext.invokeGL(WindowsOnscreenGLContext.java:76)

at net.java.games.jogl.GLCanvas$DisplayOnEventDispatchThreadAction.run(GLCanvas.java:266)

at java.awt.event.InvocationEvent.dispatch(Unknown Source)

at java.awt.EventQueue.dispatchEvent(Unknown Source)

at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)

at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)

at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

at java.awt.EventDispatchThread.run(Unknown Source)


At least after the uncought exceptions Processing properly restores the Displaymode.

Maybe I need to free the old rendercontext before initializing the new one? Any hint would be appriciated.

PS: I am running two monitors with different resolutions on Windows XP SP2, ATI 9600 mobile. Could this be a prob?


Re: Fullscreen mode with openGL
Reply #7 - Feb 7th, 2006, 3:45pm
 
I have the same problem. Has anyone figured out a clever way to do this? I noticed there were some arguents you can pass into PApplet, one of which is --present (which should go fullscreen), but I can't seem to get these working from Eclipse (perhaps they're only for the Processing IDE?)
Re: Fullscreen mode with openGL
Reply #8 - Feb 7th, 2006, 6:14pm
 
yes, very strange again. i have no solution to the problem on windows machines right now, except for using 'P3D' which is probably not much of a solution.

the code works fine on OS X machines though.

i updated the snippet to properly use the existing frame as i just found out how to remove decoration from a living frame.

Code:

import processing.opengl.*;

void setup() {
size(640, 480, OPENGL);
startFullscreen(); /* call this early in setup */
}

void draw() {
background(255);
stroke(0, 127);
line(mouseX, mouseY, random(width), random(height));

if (mousePressed && mouseButton == RIGHT) {
stopFullscreen();
}
}

void startFullscreen() {
frame.dispose();
frame.setUndecorated(true);

GraphicsDevice myGraphicsDevice = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice ();
myGraphicsDevice.setFullScreenWindow(frame);
if (myGraphicsDevice.isDisplayChangeSupported()) {
DisplayMode myDisplayMode = new DisplayMode(
width,
height,
32,
DisplayMode.REFRESH_RATE_UNKNOWN);
myGraphicsDevice.setDisplayMode(myDisplayMode);
}
}

void stopFullscreen() {
GraphicsDevice myGraphicsDevice = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice ();
myGraphicsDevice.setFullScreenWindow(null);
}
Re: Fullscreen mode with openGL
Reply #9 - Feb 8th, 2006, 11:50am
 
:-( Nope.. nothing (well, except from a lot of error output). What I don't understand is that the Processing IDE can run OpenGL sketches in fullscreen (using 'Present' mode).. I've been trying to get it to go fullscreen by passing '--present' as an argument but with no luck. Here is a snippet from the PApplet source:

* The simplest way to turn and applet into an application is to
  * add the following code to your program:
  * <PRE>static public void main(String args[]) {
  *   PApplet.main(new String[] { "YourSketchName" };
  * }</PRE>
  * This will properly launch your applet from a double-clickable
  * .jar or from the command line.
  * <PRE>
  * Parameters useful for launching or also used by the PDE:
  *
  * --location=x,y        upper-lefthand corner of where the applet
  *                       should appear on screen. if not used,
  *                       the default is to center on the main screen.
  *
  * --present             put the applet into full screen presentation
  *                       mode. requires java 1.4 or later.
  *
  * --bgcolor=#xxxxxx     background color of the window.

etc..
It seems that all the attempts at this sort of thing (BappletFS, LauncherApp) have consisted of a Java Application, which sets up a Frame and then sticks the Applet in it. I've tried to get these to work (not from command line, but just inside Eclipse) with mixed results.. but nothing works well with OpenGL so far. I'm guessing 'present' is some variation on full screen exclusive mode in java.awt..
Re: Fullscreen mode with openGL
Reply #10 - Feb 8th, 2006, 12:20pm
 
i've been successfully using the code below to show an OpenGL applet fullscreen by resizing the applet to the current screen dimensions (not resizing the screen to the applet)...
Code:
import processing.opengl.*;

public class hairdynamicsGL extends PApplet {

static public void main(String args[]) {
PApplet.main(new String[] {
"--present",
"--bgcolor=#000000",
"--present-stop-color=#000000",
"hairdynamicsGL"
});
}

void setup(){
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
size(screen.width,screen.height,OPENGL);
}
...
}
Re: Fullscreen mode with openGL
Reply #11 - Feb 8th, 2006, 12:25pm
 
Well on closer inspection it looks like the answer is already on this thread:
http://processing.org/discourse/yabb_beta/YaBB.cgi?board=Syntax;action=display;num=1133541482;start=0#0

Got this working ok (with OpenGL).. thanks Toxi. (I was almost there.. but I had my arguments in the wrong order.. doh!)

For anyone else making similar mistakes, if you want to pass arguments through the main method (as discussed in the thread i linked to, to go fullscreen (present mode).. the code in the method seems to need the '--present' argument before the applet name..

PApplet.main(new String[] { "YourApplet", "--display=1", "--present" });
WILL NOT GO FULLSCREEN

PApplet.main(new String[] { "--display=1", "--present", "BrightColourApplet" });
WILL

Don't forget to run it as an application (not applet)
Re: Fullscreen mode with openGL
Reply #12 - Apr 1st, 2006, 8:22am
 
I've been looking through the fullscreen discussions in the hopes of creating a fullscreen processing application to be run as a windows screen saver. All screen saver nonsense aside... I have created this code:

Code:
import processing.opengl.*;

public class screensaver2 extends PApplet{
float roty = 0.0;
float rotx = 0.0;
float rotyspeed = random(0,0.5);
float rotxspeed = random(0,0.5);

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

void setup(){
Dimension scr = Toolkit.getDefaultToolkit().getScreenSize();
size(scr.width,scr.height,OPENGL);
stroke(255);
noFill();
}

void draw(){
background(0);
translate(width/2, height/2);
rotateY(radians(roty));
rotateX(radians(rotx));
roty += rotyspeed;
rotx += rotxspeed;
box(height/2);
}

void keyPressed(){
exit();
}
}


...which basically gets the dimensions of the screen and changes the width and height of the stage to those of the screen.

After being exported to an EXE, it does open fullscreen, but doesn't seem to run the draw() loop. And after I attempt to run it, every other attempt to run an opengl application afterward (processing, python, second life) results in failure until I restart the computer.

I'm so close to success, I can taste it. I'm running windows xp with processing 1.11.
Re: Fullscreen mode with openGL
Reply #13 - Apr 1st, 2006, 8:00pm
 
couple things:

- try with an earlier release to see if this is a bug with the new jogl
- screen.width and screen.height contain the size, no need to do the Toolkit stuff

and finally, it's *not* processing 1.11, it's 0111. as in, the 111th release of a thing that's still in beta. we're not yet at 1.0.
Re: Fullscreen mode with openGL
Reply #14 - Apr 5th, 2006, 11:06am
 
I changed the setup to the following:

Code:
  void setup(){
size(screen.width,screen.height,OPENGL);
stroke(255);
noFill();
}

and tried exporting twice, with a copy of 0109 and 0099 with the same results.
Pages: 1 2