Permalink
Browse files

More improvements on issue 10+12, more unit-tests

  • Loading branch information...
1 parent e82a5a1 commit 483cf994b2df7b759932d68f6b4d01eb7de9e908 @kritzikratzi committed Feb 13, 2010
Showing with 194 additions and 36 deletions.
  1. +4 −3 .classpath
  2. +5 −5 build.xml
  3. +5 −4 dependencies/README
  4. BIN dependencies/Silkscreen-32.vlw
  5. BIN dependencies/{processing-core.jar → core.jar}
  6. +15 −0 dependencies/opengl/export.txt
  7. BIN dependencies/opengl/gluegen-rt-natives-linux-amd64.jar
  8. BIN dependencies/opengl/gluegen-rt-natives-linux-i586.jar
  9. BIN dependencies/opengl/gluegen-rt-natives-macosx-ppc.jar
  10. BIN dependencies/opengl/gluegen-rt-natives-macosx-universal.jar
  11. BIN dependencies/opengl/gluegen-rt-natives-windows-amd64.jar
  12. BIN dependencies/opengl/gluegen-rt-natives-windows-i586.jar
  13. BIN dependencies/opengl/gluegen-rt.dll
  14. BIN dependencies/opengl/gluegen-rt.jar
  15. BIN dependencies/opengl/gluegen-rt.jar.pack.gz
  16. BIN dependencies/opengl/jogl-natives-linux-amd64.jar
  17. BIN dependencies/opengl/jogl-natives-linux-i586.jar
  18. BIN dependencies/opengl/jogl-natives-macosx-ppc.jar
  19. BIN dependencies/opengl/jogl-natives-macosx-universal.jar
  20. BIN dependencies/opengl/jogl-natives-windows-amd64.jar
  21. BIN dependencies/opengl/jogl-natives-windows-i586.jar
  22. BIN dependencies/opengl/jogl.dll
  23. BIN dependencies/{ → opengl}/jogl.jar
  24. BIN dependencies/opengl/jogl.jar.pack.gz
  25. BIN dependencies/opengl/jogl.zip
  26. BIN dependencies/opengl/jogl_awt.dll
  27. BIN dependencies/opengl/jogl_cg.dll
  28. BIN dependencies/opengl/libgluegen-rt.jnilib
  29. BIN dependencies/opengl/libgluegen-rt.so
  30. BIN dependencies/opengl/libjogl.jnilib
  31. BIN dependencies/opengl/libjogl.so
  32. BIN dependencies/opengl/libjogl_awt.jnilib
  33. BIN dependencies/opengl/libjogl_awt.so
  34. BIN dependencies/opengl/libjogl_cg.jnilib
  35. BIN dependencies/opengl/libjogl_cg.so
  36. BIN dependencies/{processing-opengl.jar → opengl/opengl.jar}
  37. +6 −4 src/fullscreen/FullScreen.java
  38. +79 −12 src/fullscreen/tests/Demo.java
  39. +80 −8 src/fullscreen/tests/Tests.java
View
@@ -1,10 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
- <classpathentry kind="lib" path="dependencies/jogl.jar"/>
- <classpathentry kind="lib" path="dependencies/processing-core.jar"/>
- <classpathentry kind="lib" path="dependencies/processing-opengl.jar"/>
<classpathentry kind="lib" path="dependencies/junit-4.7.jar"/>
+ <classpathentry kind="lib" path="dependencies/core.jar"/>
+ <classpathentry kind="lib" path="dependencies/opengl/jogl.jar"/>
+ <classpathentry kind="lib" path="dependencies/opengl/opengl.jar"/>
+ <classpathentry kind="lib" path="dependencies/opengl/gluegen-rt.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
</classpath>
View
@@ -24,9 +24,9 @@
<property name="sketch.path" value="${user.home}/Documents/Processing" />
<property name="version" value="0.98.4-testing" />
- <fileset id="cp" includes="dependencies/*.jar" />
+ <fileset id="cp" includes="dependencies/**/*.jar" />
<path id="cp">
- <fileset dir="." includes="dependencies/*.jar" />
+ <fileset dir="." includes="dependencies/**/*.jar" />
</path>
<!-- empty the binary folder -->
@@ -55,10 +55,10 @@
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" excludes="fullscreen/tests/**" />
+ <fileset dir="src" includes="**/*.java" excludes="fullscreen/tests/**" />
</javadoc>
</target>
-
+
<!-- create the files for the website -->
<target name="dist" depends="compile, reference" description="export library to the dist folder">
@@ -116,7 +116,7 @@
<formatter type="plain"/>
<classpath refid="cp" />
<classpath location="bin" />
- <jvmarg value="-Djava.library.path=lib"/>
+ <jvmarg value="-Djava.library.path=lib${path.separator}dependencies/opengl"/>
<test name="fullscreen.tests.Tests"/>
</junit>
</target>
View
@@ -7,14 +7,15 @@ under the gpl. The sources can fetched from here:
core.jar,
-opengl.jar: Part of processing
+opengl/*: Part of processing/jogl
http://www.processing.org
-
-jogl.jar: Part of Java-OpenGL,
https://jogl.dev.java.net/
stylesheet.css: Part of the processing-library-template project
http://code.google.com/p/processing-library-template/
junit-4.7.jar: JUnit Testing Framework
- http://www.junit.org
+ http://www.junit.org
+
+Silkscreen-32.vlw: A font by kottke
+ http://kottke.org/plus/type/silkscreen/
Binary file not shown.
File renamed without changes.
@@ -0,0 +1,15 @@
+# If you want to support more platforms, see the jogl.dev.java.net to get the
+# natives libraries for the platform in question (i.e. solaris). Then, add it
+# them to the applet line for export. For applications, you'll have to make the
+# changes by hand, i.e. use the linux version of the export, and modify its
+# contents to include the necessary files for your platform.
+
+name = OpenGL
+
+application.macosx = opengl.jar, jogl.jar, libjogl.jnilib, libjogl_awt.jnilib, libjogl_cg.jnilib, gluegen-rt.jar, libgluegen-rt.jnilib
+
+application.windows = opengl.jar, jogl.jar, jogl.dll, jogl_awt.dll, jogl_cg.dll, gluegen-rt.jar, gluegen-rt.dll
+
+application.linux = opengl.jar, jogl.jar, gluegen-rt.jar, libjogl.so, libjogl_awt.so, libjogl_cg.so, libgluegen-rt.so
+
+applet = opengl.jar, jogl.jar, jogl.jar.pack.gz, jogl-natives-linux-i586.jar, jogl-natives-linux-amd64.jar, jogl-natives-macosx-ppc.jar, jogl-natives-macosx-universal.jar, jogl-natives-windows-i586.jar, jogl-natives-windows-amd64.jar, gluegen-rt.jar, gluegen-rt.jar.pack.gz, gluegen-rt-natives-linux-amd64.jar, gluegen-rt-natives-windows-amd64.jar, gluegen-rt-natives-linux-i586.jar, gluegen-rt-natives-windows-i586.jar, gluegen-rt-natives-macosx-ppc.jar, gluegen-rt-natives-macosx-universal.jar
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File renamed without changes.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -27,6 +27,7 @@
import java.awt.Frame;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
+import java.awt.Window;
import processing.core.PApplet;
@@ -88,10 +89,11 @@ public FullScreen( final PApplet dad, int screenNr ){
}
fsDevice = devices[screenNr];
- fsFrame = new Frame();
+ fsFrame = new Frame( dad.frame == null? "":dad.frame.getTitle() );
fsFrame.setTitle( dad.frame.getTitle() );
fsFrame.setUndecorated( true );
- fsFrame.setBackground( Color.black );
+ fsFrame.setBackground( Color.black );
+ fsFrame.setIgnoreRepaint( true );
if( dad.width > 0 ){
setResolution( dad.width, dad.height );
}
@@ -157,11 +159,11 @@ else if( fullScreen ){
dad.frame.remove( dad );
fsFrame.setVisible( true );
fsFrame.setLayout( null );
- fsFrame.setSize( dad.width, dad.height );
+ fsFrame.setSize( dad.width, dad.height );
fsFrame.add( dad );
fsDevice.setFullScreenWindow( fsFrame );
- fsFrame.setExtendedState( Frame.MAXIMIZED_BOTH );
setResolution( 0, 0 );
+ fsFrame.setExtendedState( Frame.MAXIMIZED_BOTH );
dad.setLocation( ( fsFrame.getWidth() - dad.width ) / 2, ( fsFrame.getHeight() - dad.height ) / 2 );
@@ -21,38 +21,105 @@
private static final long serialVersionUID = 1L;
/**
- * This is a simple Sketch using the JAVA-2D renderer
+ * This is a simple Sketch
* @author hansi
- *
*/
public static class Simple extends LaunchablePApplet{
private static final long serialVersionUID = 1L;
+ // Which renderer should we use?
+ private final String renderThing;
+
+ // What size do we want?
+ private final int w, h;
+
+ private String title;
+ private boolean reloadFont;
+
+ /**
+ * Creates the simple sketch using the JAVA2D renderer
+ */
+ public Simple( String title ){
+ this( title, 800, 600, JAVA2D );
+ }
+
+ /**
+ * Creates a simple sketch using any renderer at 800x600 px
+ */
+ public Simple( String title, String renderer ){
+ this( title, 800, 600, renderer );
+ }
+
+ /**
+ * Creates a simple sketch using a special renderer
+ */
+ public Simple( String title, int width, int height, String renderer ){
+ super( false );
+ this.title = title;
+ this.renderThing = renderer;
+ this.w = width;
+ this.h = height;
+
+ startPApplet();
+ }
+
+ /**
+ * FS-Api tells us that we switched mode
+ */
+ public void displayChanged(){
+ reloadFont = true;
+ }
+
@Override
public void setup(){
- size( 400, 400 );
+ size( w, h, renderThing );
+ frameRate( 200 );
+ reloadFont = true;
+ smooth();
}
@Override
public void draw(){
- noStroke();
+ if( reloadFont ){
+ textFont( loadFont( "dependencies/Silkscreen-32.vlw" ) );
+ reloadFont = false;
+ }
- for( int i = 0; i < min( width/2, height/2 ); i+= 20 ){
- fill( ( i/5 + frameCount )%255 );
- rect( i, i, width - 2*i, height - 2*i );
+ background( 255 );
+ stroke( 0 );
+
+ background(0);
+ fill(255, 0, 0);
+
+ text( title + " @" + (int)frameRate + "fps", 10, 40 );
+ for(int i = 0; i < width; i += 40 ){
+ for( int j = 80; j < height; j+= 40 ){
+ char text = (char)((i*width/20+j+frameCount)%255);
+ text( text, i, j );
+ }
}
}
-
}
+
/**
* This is a PApplet that actually launches itself when instantized.
* (That means no trouble with the main-method...)
*/
- private static class LaunchablePApplet extends PApplet{
+ public static class LaunchablePApplet extends PApplet{
private static final long serialVersionUID = 1L;
public LaunchablePApplet(){
+ this( true );
+ }
+
+ public LaunchablePApplet( boolean autostart ){
+ if( autostart ){
+ startPApplet();
+ }
+ }
+
+ public void startPApplet(){
// Disable abyssmally slow Sun renderer on OS X 10.5.
if ( PApplet.platform == PApplet.MACOSX ){
// Only run this on OS X otherwise it can cause a permissions error.
@@ -141,8 +208,8 @@ public void windowClosing(WindowEvent e) {
if (this.displayable()) {
frame.setVisible(true);
}
- this.requestFocus(); // ask for keydowns
- //System.out.println("exiting main()");
+ this.requestFocus(); // ask for keydowns
+ //System.out.println("exiting main()");
+ }
}
}
-}
@@ -1,12 +1,17 @@
package fullscreen.tests;
+import java.awt.GraphicsEnvironment;
+import java.lang.reflect.InvocationTargetException;
+
import japplemenubar.JAppleMenuBar;
import org.junit.Test;
+import static org.junit.Assert.*;
import processing.core.PApplet;
import fullscreen.FullScreen;
+import fullscreen.FullScreenBase;
import fullscreen.SoftFullScreen;
/**
@@ -15,6 +20,9 @@
*/
public class Tests {
+ final int SCREEN_W = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDisplayMode().getWidth();
+ final int SCREEN_H = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDisplayMode().getHeight();
+
/**
* Tests if hiding the menu-bar works on mac-os
* @throws InterruptedException
@@ -35,7 +43,7 @@ public void testMenuBar() throws InterruptedException{
@Test
public void softFS() throws Exception{
for( int screenNr = 0; screenNr < 2; screenNr ++ ){
- Demo.Simple sketch = new Demo.Simple();
+ Demo.Simple sketch = new Demo.Simple( "SoftFullScreen: screen " + screenNr );
SoftFullScreen fs = new SoftFullScreen( sketch, screenNr );
fs.setFullScreen( true );
@@ -44,9 +52,7 @@ public void softFS() throws Exception{
Thread.sleep( 2000 );
- sketch.frame.setVisible( false );
- sketch.stop();
- sketch.destroy();
+ killSketch( sketch );
}
// if we haven't crashed until now we're good!
}
@@ -57,7 +63,7 @@ public void softFS() throws Exception{
@Test
public void classicFS() throws Exception{
for( int screenNr = 0; screenNr < 2; screenNr ++ ){
- Demo.Simple sketch = new Demo.Simple();
+ Demo.Simple sketch = new Demo.Simple( "FSEM: screen " + screenNr );
FullScreen fs = new FullScreen( sketch, screenNr );
fs.setFullScreen( true );
@@ -66,9 +72,75 @@ public void classicFS() throws Exception{
Thread.sleep( 2000 );
- sketch.frame.setVisible( false );
- sketch.stop();
- sketch.destroy();
+ killSketch( sketch );
}
}
+
+ /**
+ * Make's sure the framerate is >30fps.
+ * Bug: http://github.com/kritzikratzi/fullscreen-p5/issues#issue/10
+ */
+ @Test
+ public void issue10_1() throws Exception{
+ assertFrameRate( SCREEN_W, SCREEN_H, FullScreen.class );
+ }
+
+ @Test
+ public void issue10_2() throws Exception{
+ assertFrameRate( 640, 480, FullScreen.class );
+ }
+
+ @Test
+ public void issue10_3() throws Exception{
+ assertFrameRate( SCREEN_W, SCREEN_H, SoftFullScreen.class );
+ }
+
+ @Test
+ public void issue10_4() throws Exception{
+ assertFrameRate( 640, 480, SoftFullScreen.class );
+ }
+
+
+ /**
+ * Tests if the framerate is larger than a certain value.
+ * @throws NoSuchMethodException
+ * @throws InvocationTargetException
+ * @throws IllegalAccessException
+ * @throws InstantiationException
+ * @throws SecurityException
+ * @throws IllegalArgumentException
+ * @throws InterruptedException
+ */
+ private void assertFrameRate( int width, int height, Class<? extends FullScreenBase> fsClass ) throws IllegalArgumentException, SecurityException, InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException, InterruptedException{
+ String title = "Framerate using " + fsClass.getName() + " [" + width + "x" + height + "]";
+ Demo.Simple sketch = new Demo.Simple( title, width, height, PApplet.OPENGL );
+ sketch.frameRate( 100 );
+
+ FullScreenBase fs = fsClass.getConstructor( PApplet.class ).newInstance( sketch );
+ fs.setFullScreen( true );
+
+ Thread.sleep( 2000 );
+ if( sketch.frameRate < 90 ){
+ fs.leave();
+ killSketch( sketch );
+ fail(
+ "Framerate too low on " + fsClass.getName() + ": " +
+ "[" + width + "x" + height + "@" + sketch.frameRate + "fps]"
+ );
+ }
+ else{
+ fs.leave();
+ killSketch( sketch );
+ }
+ }
+
+
+ /**
+ * Kill a sketch
+ */
+ private void killSketch( PApplet sketch ){
+ sketch.frame.setVisible( false );
+ sketch.stop();
+ sketch.destroy();
+ }
}

0 comments on commit 483cf99

Please sign in to comment.