Permalink
Browse files

minor adaptions to be compatible with processing >=1.0.6

git-svn-id: http://svn.gna.org/svn/fullscreen-p5/trunk@26 2047cd6a-46a1-4efc-9f20-c343b47ea501
  • Loading branch information...
kritzikratzi
kritzikratzi committed Oct 17, 2009
1 parent c263c8b commit 4939cb719dd0a157d73dbd88d8f7c798a0acfcf3
View
@@ -1,12 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="lib" path="dependencies/processing-core.jar"/>
- <classpathentry kind="lib" path="dependencies/processing-opengl.jar" sourcepath="/processing-head/opengl/src"/>
- <classpathentry kind="lib" path="dependencies/jogl.jar"/>
<classpathentry kind="lib" path="assets/processing-opengl.jar"/>
<classpathentry kind="lib" path="assets/jogl.jar"/>
<classpathentry kind="lib" path="assets/processing-core.jar"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
</classpath>
View
@@ -3,7 +3,7 @@ Build-Dependencies
Those files are needed for building the fullscreen api, they're not being
distributed with the library. All the files in this folder are distributed
-under the gpl. The sources can fetched from following sources:
+under the gpl. The sources can fetched from here:
core.jar,
View
@@ -1,3 +1,22 @@
+/*
+ Part of the Processing Fullscreen API
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License as published by the Free Software Foundation; either
+ version 3 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU General
+ Public License along with this library; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ Boston, MA 02111-1307 USA
+*/
+
/* Javadoc style sheet */
/* Define colors, fonts and other style attributes here to override the defaults */
/* processingLibs style by andreas schlegel, sojamo */
View
@@ -23,7 +23,7 @@
<!-- path to the sketch folder -->
<property name="sketch.path" value="${user.home}/Documents/Processing" />
- <property name="version" value="0.97" />
+ <property name="version" value="0.98" />
<fileset id="cp" includes="assets/*.jar" />
<path id="cp">
<fileset dir="." includes="assets/*.jar" />
@@ -53,6 +53,8 @@
doctitle="Javadocs: Fullscreen API"
public="true" version="false"
windowtitle="Javadocs: Fullscreen API">
+ <link href="http://java.sun.com/javase/6/docs/api" />
+ <link href="http://dev.processing.org/reference/everything/javadoc/" />
<fileset dir="src" includes="fullscreen/**/*.java" />
</javadoc>
</target>
View
@@ -1,4 +1,4 @@
-Fullscreen API for Processing, Version 0.96
+Fullscreen API for Processing, Version 0.98
-------------------------------------------
Thanks for download the Fullscreen API for Processing, this is still
@@ -2,14 +2,16 @@
import fullscreen.*;
FullScreen fs;
+PImage img;
void setup(){
// set size to 640x480
size(640, 480);
// 5 fps
frameRate(5);
-
+ img = loadImage( "test.png" );
+
// Create the fullscreen object
fs = new FullScreen(this);
@@ -33,4 +35,6 @@ void draw(){
width - i*20, height - i*20
);
}
+
+ image( img, 10, 10 );
}
Binary file not shown.
@@ -27,9 +27,7 @@
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
-import processing.core.GLTextureUpdateHelper;
import processing.core.PApplet;
-import processing.opengl.GLDrawableHelper;
/**
* Creates a new fullscreen object. <br>
@@ -139,6 +137,7 @@ public void setFullScreen( boolean fullScreen ){
/**
* Don't use this!
*/
+ @SuppressWarnings("deprecation")
private void setFullScreenImpl( boolean fullScreen ){
if( fullScreen == isFullScreen() ){
// no change required!
@@ -161,7 +160,7 @@ else if( fullScreen ){
dad.setLocation( 0, 0 );
GLDrawableHelper.reAllocate( this );
- GLTextureUpdateHelper.update( dad );
+ GLTextureUpdateHelper.update( this );
// Tell the sketch about the resolution change
notifySketch( getSketch() );
@@ -185,7 +184,7 @@ else if( fullScreen ){
dad.requestFocus();
GLDrawableHelper.reAllocate( this );
- GLTextureUpdateHelper.update( dad );
+ GLTextureUpdateHelper.update( this );
// Tell the sketch about the resolution change
notifySketch( getSketch() );
@@ -9,6 +9,7 @@
import java.lang.reflect.Method;
import processing.core.PApplet;
+import processing.core.PConstants;
/**
@@ -43,7 +44,7 @@ public FullScreenBase( PApplet dad ){
// Listen to processings key events
dad.registerKeyEvent( this );
- Class clazz = dad.g.getClass();
+ Class<?> clazz = dad.g.getClass();
while( clazz != null ){
if( clazz.getName().equals( "processing.opengl.PGraphicsOpenGL" ) )
isGL = true;
@@ -148,8 +149,8 @@ public void keyEvent( KeyEvent e ){
// catch the CMD+F combination (ALT+ENTER or CTRL+F for windows)
else if( e.getID() == KeyEvent.KEY_PRESSED ){
- if( ( e.getKeyCode() == e.VK_F && e.getModifiers() == fsControlKey ) ||
- ( dad.platform == dad.WINDOWS && e.getKeyCode() == e.VK_ENTER && e.getModifiers() == e.VK_ALT ) ){
+ if( ( e.getKeyCode() == KeyEvent.VK_F && e.getModifiers() == fsControlKey ) ||
+ ( PApplet.platform == PConstants.WINDOWS && e.getKeyCode() == KeyEvent.VK_ENTER && e.getModifiers() == KeyEvent.VK_ALT ) ){
// toggle fullscreen!
setFullScreen( !isFullScreen() );
}
@@ -0,0 +1,58 @@
+package fullscreen;
+
+
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import processing.core.PGraphics;
+import processing.opengl.PGraphicsOpenGL;
+
+public class GLDrawableHelper {
+
+ public static void reAllocate( FullScreenBase fs ){
+ if( fs.isGL() ){
+ // The next lines are a reflection based version of this:
+ // ( (PGraphicsOpenGL) fs.getSketch().g).context = null;
+ // ( (PGraphicsOpenGL) fs.getSketch().g).allocate();
+ //
+ // which isn't allowed because access to these fields is private :(
+ try{
+ PGraphics g = fs.getSketch().g;
+ Field context = PGraphicsOpenGL.class.getDeclaredField( "context" );
+ context.setAccessible( true ); // make private public
+ context.set( g, null );
+
+ Method allocate = PGraphicsOpenGL.class.getDeclaredMethod( "allocate" );
+ allocate.setAccessible( true );
+ allocate.invoke( g );
+ }
+ catch( SecurityException e ){
+ System.err.println( "FullScreen-API: Unknown error: " + e.getMessage() );
+ e.printStackTrace();
+ }
+ catch( NoSuchFieldException e ){
+ System.err.println( "FullScreen-API: Couldn't find any field 'context' in processing.opengl.PGraphicsOpenGL" );
+ System.err.println( "Seems your processing version doesn't match this version of the fullscreen api" );
+ e.printStackTrace();
+ }
+ catch( IllegalArgumentException e ){
+ System.err.println( "FullScreen-API: Unknown error: " + e.getMessage() );
+ e.printStackTrace();
+ }
+ catch( IllegalAccessException e ){
+ System.err.println( "FullScreen-API: Unknown error: " + e.getMessage() );
+ e.printStackTrace();
+ }
+ catch (NoSuchMethodException e) {
+ System.err.println( "FullScreen-API: Couldn't find any method 'allocate' in processing.opengl.PGraphicsOpenGL" );
+ System.err.println( "Seems your processing version doesn't match this version of the fullscreen api" );
+ e.printStackTrace();
+ }
+ catch ( InvocationTargetException e ){
+ System.err.println( "FullScreen-API: Unknown error: " + e.getMessage() );
+ e.printStackTrace();
+ }
+ }
+ }
+}
@@ -0,0 +1,82 @@
+/*
+ Part of the Processing Fullscreen API
+
+ Copyright (c) 2006-08 Hansi Raber
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License as published by the Free Software Foundation; either
+ version 3 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU General
+ Public License along with this library; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ Boston, MA 02111-1307 USA
+*/
+package fullscreen;
+
+import java.lang.reflect.Field;
+
+import processing.core.PGraphics;
+import processing.core.PGraphics3D;
+import processing.core.PImage;
+
+/**
+ * Opengl tends to erase textures when grabbing/releasing exclusive fullscreen
+ * mode. So this class here helps to update the textures (if in opengl mode)
+ */
+
+public class GLTextureUpdateHelper{
+
+ /**
+ * Update the all the opengl textures belonging to a sketch imediately.
+ *
+ * @param fs The fullscreen object
+ * @throws NoSuchFieldException
+ * @throws SecurityException
+ * @throws IllegalAccessException
+ * @throws IllegalArgumentException
+ */
+ public static void update( FullScreenBase fs ){
+ // Now, if in opengl mode all the textures will be erased,
+ // we'll have to call updatePixels() on all of them!
+ // Oh, and we have to use reflection, because we don't know if
+ // opengl is being used. So the class names might not even be there.
+ if( fs.isGL() ){
+ try {
+ PGraphics g = fs.getSketch().g;
+ Field field = PGraphics3D.class.getDeclaredField( "textures" );
+ field.setAccessible( true ); // make private variable public!
+ PImage textures[] = (PImage[]) field.get( g );
+
+ for( int i = 0; i < textures.length; i++ ){
+ if( textures[i] != null ){
+ textures[i].updatePixels();
+ }
+ }
+ }
+ catch( SecurityException e ){
+ System.err.println( "FullScreen-API: Unknown error: " + e.getMessage() );
+ e.printStackTrace();
+ }
+ catch( NoSuchFieldException e ){
+ System.err.println( "FullScreen-API: Couldn't find any field 'textures' in processing.core.PGraphics3D" );
+ System.err.println( "Seems your processing version doesn't match this version of the fullscreen api" );
+ e.printStackTrace();
+ }
+ catch( IllegalArgumentException e ){
+ System.err.println( "FullScreen-API: Unknown error: " + e.getMessage() );
+ e.printStackTrace();
+ }
+ catch( IllegalAccessException e ){
+ System.err.println( "FullScreen-API: Unknown error: " + e.getMessage() );
+ e.printStackTrace();
+ }
+ }
+ }
+}
@@ -24,10 +24,8 @@
import java.awt.Frame;
import java.awt.GraphicsDevice;
-import processing.core.GLTextureUpdateHelper;
import processing.core.PApplet;
import processing.core.PConstants;
-import processing.opengl.GLDrawableHelper;
/**
* Creates a new softfullscreen object. <br>
@@ -112,6 +110,7 @@ public void setFullScreen( boolean fullScreen ){
new DelayedModeChange( fullScreen );
}
+ @SuppressWarnings("deprecation")
private void setFullScreenImpl( boolean fullScreen ){
if( fullScreen == isFullScreen() ){
// no change required!
@@ -133,7 +132,7 @@ else if( fullScreen ){
dad.setLocation( ( fsFrame.getWidth() - dad.width ) / 2, ( fsFrame.getHeight() - dad.height ) / 2 );
GLDrawableHelper.reAllocate( this );
- GLTextureUpdateHelper.update( dad );
+ GLTextureUpdateHelper.update( this );
notifySketch( dad );
@@ -151,13 +150,17 @@ else if( fullScreen ){
dad.setLocation( dad.frame.insets().left, dad.frame.insets().top );
// processing.core.fullscreen_texturehelper.update( dad );
- if( dad.platform == dad.MACOSX ){
+ if( PApplet.platform == PConstants.MACOSX ){
new NativeOSX().setVisible( true );
}
fsFrame.setVisible( false );
dad.frame.setVisible( true );
- dad.requestFocus();
+ dad.requestFocus();
+
+ GLDrawableHelper.reAllocate( this );
+ GLTextureUpdateHelper.update( this );
+
notifySketch( dad );
return;
Oops, something went wrong.

0 comments on commit 4939cb7

Please sign in to comment.