Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

* Loads of bugfixes

* Removed no-cursor example (as it didn't work)
* Preparing for version 0.96
* Still todo: general cleanup, adding comments

git-svn-id: http://svn.gna.org/svn/fullscreen-p5/trunk@18 2047cd6a-46a1-4efc-9f20-c343b47ea501
  • Loading branch information...
commit 30345324f3020307267b87bbf32643b33819e14a 1 parent 4bd131f
kritzikratzi authored
View
4 build.xml
@@ -23,7 +23,7 @@
<!-- path to the processing installation -->
<property name="sketch.path" value="${user.home}/Documents/Processing"/>
- <property name="version" value="0.95"/>
+ <property name="version" value="0.96"/>
<fileset id="cp" includes="dependencies/*.jar"/>
<path id="cp">
<fileset dir="." includes="dependencies/*.jar"/>
@@ -37,7 +37,7 @@
<!-- compile the sources, place the class files in the bin folder -->
<target name="compile">
<mkdir dir="bin"/>
- <javac srcdir="src" destdir="bin" classpathref="cp" target="1.4" />
+ <javac srcdir="src" destdir="bin" classpathref="cp" target="1.5" />
</target>
<!-- create the files for the website -->
View
BIN  dependencies/jogl.jar
Binary file not shown
View
BIN  dependencies/processing-core.jar
Binary file not shown
View
BIN  dependencies/processing-opengl.jar
Binary file not shown
View
42 examples/e_hide_cursor/e_hide_cursor.pde
@@ -1,42 +0,0 @@
-// processing will show/hide the cursor whenever you
-// go to fullscreen mode / leave fullscreen mode.
-// here's an example how you can supress this behaviour
-import fullscreen.*;
-
-FullScreen fs;
-
-void setup(){
- // set size to 640x480
- size(640, 480);
-
- // 5 fps
- frameRate(5);
-
- // Create the fullscreen object
- fs = new FullScreen(this);
-
- noCursor();
-}
-
-
-void draw(){
- background(0);
- fill(255, 0, 0);
-
- for(int i = 0; i < 10; i++){
- fill(
- random(255),
- random(255),
- random(255)
- );
- rect(
- i*10, i*10,
- width - i*20, height - i*20
- );
- }
-}
-
-// every time the display mode changes hide the cursor!
-void displayChanged(){
- noCursor();
-}
View
98 src/fullscreen/FullScreen.java
@@ -20,12 +20,18 @@
*/
package fullscreen;
+
+import java.awt.Color;
import java.awt.Dimension;
import java.awt.DisplayMode;
+import java.awt.Frame;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
+import processing.core.GLTextureUpdateHelper;
import processing.core.PApplet;
+import processing.opengl.GLDrawableHelper;
+import processing.opengl.PGraphicsOpenGL;
/**
* FullScreen support for processing.
@@ -72,17 +78,21 @@
boolean fsIsInitialized;
// Daddy...
- PApplet dad;
+ private PApplet dad;
// Refresh rate
private int refreshRate;
+ // A frame for going fullscreen
+ private Frame fsFrame;
+
/**
* Create a new fullscreen object
*/
public FullScreen( final PApplet dad, int screenNr ){
super( dad );
this.dad = dad;
+
GraphicsDevice[] devices = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices();
if( screenNr >= devices.length ){
System.err.println( "FullScreen API: You requested to use screen nr. " + screenNr + ", " );
@@ -92,8 +102,9 @@ public FullScreen( final PApplet dad, int screenNr ){
}
fsDevice = devices[screenNr];
-
-
+ fsFrame = new Frame();
+ fsFrame.setTitle( dad.frame.getTitle() );
+ fsFrame.setUndecorated( true );
if( dad.width > 0 ){
setResolution( dad.width, dad.height );
}
@@ -113,7 +124,7 @@ public FullScreen( PApplet dad ){
* @returns true if so, yes if not
*/
public boolean isFullScreen(){
- return fsDevice.getFullScreenWindow() == dad.frame;
+ return fsDevice.getFullScreenWindow() == fsFrame;
}
@@ -134,6 +145,13 @@ public boolean available(){
* @returns true on success
*/
public void setFullScreen( boolean fullScreen ){
+ new DelayedModeChange( fullScreen );
+ }
+
+ /**
+ * Don't use this!
+ */
+ public void setFullScreenImpl( boolean fullScreen ){
if( fullScreen == isFullScreen() ){
// no change required!
return;
@@ -142,44 +160,47 @@ else if( fullScreen ){
// go to fullScreen mode...
if( available() ){
- // reshape frame and get it all excited about going fs
- dad.frame.dispose();
- dad.frame.setUndecorated( true );
- dad.frame.setSize( fsDevice.getDisplayMode().getWidth(), fsDevice.getDisplayMode().getHeight() );
- dad.frame.setVisible( true );
- fsDevice.setFullScreenWindow( dad.frame );
+ dad.frame.setVisible( false );
+ dad.frame.remove( dad );
+ fsFrame.setVisible( true );
+ fsFrame.setLayout( null );
+ fsFrame.setSize( dad.width, dad.height );
+ fsFrame.add( dad );
+ fsDevice.setFullScreenWindow( fsFrame );
+ setResolution( 0, 0 );
- dad.requestFocus();
+ dad.requestFocus();
+ dad.setLocation( 0, 0 );
- // set default resolution...
- setResolution( 0, 0 );
+ GLDrawableHelper.reAllocate( this );
+ GLTextureUpdateHelper.update( dad );
// Tell the sketch about the resolution change
- notifySketch( dad );
-
- return;
+ notifySketch( getSketch() );
}
else{
- System.err.println( "FullScreen API: Fullscreen mode not available" );
- return;
+ System.err.println( "FullScreen API: Not available in applets. " );
}
}
else{
fsDevice.setFullScreenWindow( null );
- dad.frame.dispose();
- dad.frame.setUndecorated( false );
+ fsFrame.setVisible( false );
+ fsFrame.remove( dad );
+
+ dad.frame.add( dad );
dad.frame.setVisible( true );
dad.setLocation( dad.frame.insets().left, dad.frame.insets().top );
- dad.frame.setSize(
+ /*dad.frame.setSize(
dad.width + dad.frame.insets().left + dad.frame.insets().right,
dad.height + dad.frame.insets().top + dad.frame.insets().bottom
- );
+ );*/
dad.requestFocus();
- // Tell the sketch about the resolution change
- notifySketch( dad );
+ GLDrawableHelper.reAllocate( this );
+ GLTextureUpdateHelper.update( dad );
- return;
+ // Tell the sketch about the resolution change
+ notifySketch( getSketch() );
}
}
@@ -208,7 +229,7 @@ public void setResolution( int xRes, int yRes ){
// Change resolution only if values are somehow meaningfull
if( fsResolutionX <= 0 || fsResolutionY <= 0 ){
- dad.setLocation( ( fsDevice.getDisplayMode().getWidth() - dad.width ) / 2, ( fsDevice.getDisplayMode().getHeight() - dad.height ) / 2 );
+ // dad.setLocation( ( fsDevice.getDisplayMode().getWidth() - dad.width ) / 2, ( fsDevice.getDisplayMode().getHeight() - dad.height ) / 2 );
return;
}
@@ -216,7 +237,6 @@ public void setResolution( int xRes, int yRes ){
DisplayMode theMode = null;
for( int i = 0; i < modes.length; i++ ){
-
if( modes[ i ].getWidth() == fsResolutionX && modes[ i ].getHeight() == fsResolutionY ){
if( refreshRate == 0 || refreshRate == modes[i].getRefreshRate() ){
theMode = modes[ i ];
@@ -228,7 +248,7 @@ public void setResolution( int xRes, int yRes ){
// Resolution not supported?
if( theMode == null ){
System.err.println( "FullScreen API: Display mode not supported: " + fsResolutionX + "x" + fsResolutionY );
- dad.setLocation( ( fsDevice.getDisplayMode().getWidth() - dad.width ) / 2, ( fsDevice.getDisplayMode().getHeight() - dad.height ) / 2 );
+ // dad.setLocation( ( fsDevice.getDisplayMode().getWidth() - dad.width ) / 2, ( fsDevice.getDisplayMode().getHeight() - dad.height ) / 2 );
return;
}
@@ -236,7 +256,7 @@ public void setResolution( int xRes, int yRes ){
// Wait until we are in fullScreen exclusive mode..
try{
fsDevice.setDisplayMode( theMode );
- dad.frame.setSize( fsResolutionX, fsResolutionY );
+ fsFrame.setSize( fsResolutionX, fsResolutionY );
}
catch( Exception e ){
System.err.println( "FullScreen API: Failed to go to fullScreen mode" );
@@ -244,7 +264,7 @@ public void setResolution( int xRes, int yRes ){
return;
}
- dad.setLocation( ( fsDevice.getDisplayMode().getWidth() - dad.width ) / 2, ( fsDevice.getDisplayMode().getHeight() - dad.height ) / 2 );
+ dad.setLocation( ( fsDevice.getDisplayMode().getWidth() - dad.width ) / 2, ( fsDevice.getDisplayMode().getHeight() - dad.height ) / 2 );
}
@@ -339,4 +359,22 @@ public void setRefreshRate( int rate ){
return result;
}
+ public class DelayedModeChange{
+ private boolean state;
+ private int skippedFrames = 0;
+
+ public DelayedModeChange( boolean state ){
+ this.state = state;
+ dad.registerPost( this );
+ }
+
+ public void post(){
+ skippedFrames ++;
+
+ if( skippedFrames >= 2 ){
+ setFullScreenImpl( state );
+ dad.unregisterPost( this );
+ }
+ }
+ }
}
View
39 src/fullscreen/FullScreenBase.java
@@ -8,7 +8,6 @@
import java.awt.event.WindowEvent;
import java.lang.reflect.Method;
-import processing.core.GLFullScreenHelper;
import processing.core.PApplet;
public abstract class FullScreenBase {
@@ -25,6 +24,9 @@
// The previous key event
static KeyEvent lastEvent = null;
+ // Is opengl being used in this sketch?
+ private boolean isGL;
+
/**
* Create a fullscreen thingie
*/
@@ -33,13 +35,19 @@ public FullScreenBase( PApplet dad ){
// Listen to processings key events
dad.registerKeyEvent( this );
-
- // Make this sketch gl aware
- try{
- GLFullScreenHelper.addOpenGLSupport( dad );
+
+ Class clazz = dad.g.getClass();
+ while( clazz != null ){
+ if( clazz.getName().equals( "processing.opengl.PGraphicsOpenGL" ) )
+ isGL = true;
+
+ clazz = clazz.getSuperclass();
}
- catch( Throwable t ){
- t.printStackTrace();
+
+ if( isGL ){
+ // Make ppl aware that gl doesn't always work!
+ System.err.println( "FullScreen API: Warning, OPENGL Support is experimental! " );
+ System.err.println( "Keep checking http://www.superduper.org/processing/fullscreen_api/ for updates!" );
}
}
@@ -158,4 +166,21 @@ protected static void notifySketch( PApplet dad ){
}
}
+ /**
+ * Is opengl somehow being used in this sketch?
+ */
+ public boolean isGL(){
+ return isGL;
+ }
+
+ /**
+ * Returns the sketch
+ *
+ * @return
+ */
+ public PApplet getSketch() {
+ return dad;
+ }
+
+
}
View
32 src/fullscreen/SoftFullScreen.java
@@ -24,8 +24,10 @@
import java.awt.Frame;
import java.awt.GraphicsDevice;
+import processing.core.GLTextureUpdateHelper;
import processing.core.PApplet;
import processing.core.PConstants;
+import processing.opengl.GLDrawableHelper;
/**
* FullScreen support for processing.
@@ -120,6 +122,10 @@ public boolean available(){
* @returns true on success
*/
public void setFullScreen( boolean fullScreen ){
+ new DelayedModeChange( fullScreen );
+ }
+
+ public void setFullScreenImpl( boolean fullScreen ){
if( fullScreen == isFullScreen() ){
// no change required!
return;
@@ -139,7 +145,11 @@ else if( fullScreen ){
fsFrame.setLocation( 0, 0 );
dad.setLocation( ( fsFrame.getWidth() - dad.width ) / 2, ( fsFrame.getHeight() - dad.height ) / 2 );
- notifySketch( dad );
+ GLDrawableHelper.reAllocate( this );
+ GLTextureUpdateHelper.update( dad );
+
+ notifySketch( dad );
+
return;
}
else{
@@ -174,5 +184,23 @@ public void setResolution( int xRes, int yRes ) {
System.err.println( "Use the normal FullScreen mode to make use of that functionality. " );
}
-
+
+ public class DelayedModeChange{
+ private boolean state;
+ private int skippedFrames = 0;
+
+ public DelayedModeChange( boolean state ){
+ this.state = state;
+ dad.registerPost( this );
+ }
+
+ public void post(){
+ skippedFrames ++;
+
+ if( skippedFrames >= 2 ){
+ setFullScreenImpl( state );
+ dad.unregisterPost( this );
+ }
+ }
+ }
}
View
13 src/processing/opengl/GLDrawableHelper.java
@@ -0,0 +1,13 @@
+package processing.opengl;
+
+import fullscreen.FullScreenBase;
+
+public class GLDrawableHelper {
+
+ public static void reAllocate( FullScreenBase fs ){
+ if( fs.isGL() ){
+ ( (PGraphicsOpenGL) fs.getSketch().g).context = null;
+ ( (PGraphicsOpenGL) fs.getSketch().g).allocate();
+ }
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.