From c1a054ec8a2004a142006ab26e8fbcfc457dc222 Mon Sep 17 00:00:00 2001 From: benfry Date: Tue, 23 Oct 2007 20:58:28 +0000 Subject: [PATCH] fix focus issues, endRaw() problems, P3D and background() with raw, update docs --- build/shared/libraries/howto.txt | 26 +++-------- core/src/processing/core/PApplet.java | 2 +- core/src/processing/core/PGraphics.java | 3 +- core/src/processing/core/PGraphics3D.java | 30 ++++++++++++- core/src/processing/core/PGraphicsJava2D.java | 3 +- core/todo.txt | 43 ++++++++----------- .../processing/opengl/PGraphicsOpenGL.java | 19 +------- todo.txt | 18 ++------ 8 files changed, 60 insertions(+), 84 deletions(-) diff --git a/build/shared/libraries/howto.txt b/build/shared/libraries/howto.txt index 1a14d7e23..ed38aade0 100644 --- a/build/shared/libraries/howto.txt +++ b/build/shared/libraries/howto.txt @@ -350,7 +350,7 @@ there's no need to use "Import Library". ////////////////////////////////////////////////////////////// -Getting a UnsupportedClassVersionError? (especially with Java 1.5) +Getting a UnsupportedClassVersionError? (Java 1.5 and later) When I compiled blah.jar (using the successful method mentioned earlier) under Java 1.5, I get the following error from Processing: @@ -359,25 +359,11 @@ java.lang.UnsupportedClassVersionError: blah/SomeClass (Unsupported major.minor version 49.0) This is because more recent versions of Java like to use their own -class file format that's not backwards compatible. Pretty annoying, -since it's rare that newer language features are actually used (and -shouldn't be with Processing anyway, since most likely you want to -make things work on Java 1.1) +class file format that's not backwards compatible. -The fix is to compile with "-target 1.1" which will create class -files that are compatible with Java 1.1. This is necessary for any -code that will run in a browser, since approximately 30-40% of web -users are still using Microsoft's Java 1.1.4 JVM (as of April 2005). - -K. Damkjer adds: Depending on the version of Java that you're using, -specifying -target 1.1 when compiling libraries for distribution may -not be enough to get a 1.1 compatible class file. You may also need to -indicate source compatibility. It seems that -source 1.3 is the most -recent Java release that is capable of creating 1.1 targeted .class -files. All that said, here's a typical compile string for me: - -javac -source 1.3 -target 1.1 -d . - -classpath %P5_HOME%\lib\core.jar package/dirs/*.java +When compiling a library, use somtehing like: + javac -source 1.4 -target 1.4 -d . \ + -classpath /path/to/core.jar path/to/java/source/*.java ////////////////////////////////////////////////////////////// @@ -479,4 +465,4 @@ official things as well. ////////////////////////////////////////////////////////////// -Ben Fry, Last updated 12 October 2007 +Ben Fry, Last updated 23 October 2007 diff --git a/core/src/processing/core/PApplet.java b/core/src/processing/core/PApplet.java index ae8960ed6..6c1297120 100644 --- a/core/src/processing/core/PApplet.java +++ b/core/src/processing/core/PApplet.java @@ -7061,7 +7061,7 @@ in */ //System.out.println("showing frame"); //System.out.println("applet requesting focus"); - //applet.requestFocus(); // ask for keydowns + applet.requestFocus(); // ask for keydowns //System.out.println("exiting main()"); } catch (Exception e) { diff --git a/core/src/processing/core/PGraphics.java b/core/src/processing/core/PGraphics.java index 4eac7f4a5..aa31c9895 100644 --- a/core/src/processing/core/PGraphics.java +++ b/core/src/processing/core/PGraphics.java @@ -4310,7 +4310,8 @@ public abstract class PGraphics extends PImage implements PConstants { public void endRaw() { if (raw != null) { // for 3D, need to flush any geometry that's been stored for sorting - raw.flush(); // this should be called by endDraw() instead + // (particularly if the ENABLE_DEPTH_SORT hint is set) + flush(); // just like beginDraw, this will have to be called because // endDraw() will be happening outside of draw() diff --git a/core/src/processing/core/PGraphics3D.java b/core/src/processing/core/PGraphics3D.java index 48ea5243d..834abef8e 100644 --- a/core/src/processing/core/PGraphics3D.java +++ b/core/src/processing/core/PGraphics3D.java @@ -423,6 +423,11 @@ public class PGraphics3D extends PGraphics { } render_lines(); } + // Clear this out in case flush() is called again. + // For instance, with hint(ENABLE_DEPTH_SORT), it will be called + // once on endRaw(), and once again at endDraw(). + triangleCount = 0; + lineCount = 0; } @@ -1347,8 +1352,6 @@ public class PGraphics3D extends PGraphics { protected void render_triangles() { - //System.out.println("rendering " + triangleCount + " triangles"); - if (raw != null) { raw.colorMode(RGB, 1); raw.noStroke(); @@ -3874,7 +3877,30 @@ public class PGraphics3D extends PGraphics { */ Arrays.fill(pixels, backgroundColor); Arrays.fill(zbuffer, Float.MAX_VALUE); + + clearRaw(); } + + + protected void clearRaw() { + if (raw != null) { + raw.colorMode(RGB, 1); + raw.noStroke(); + raw.fill(backgroundR, backgroundG, backgroundB); + raw.beginShape(TRIANGLES); + + raw.vertex(0, 0); + raw.vertex(width, 0); + raw.vertex(0, height); + + raw.vertex(width, 0); + raw.vertex(width, height); + raw.vertex(0, height); + + raw.endShape(); + } + } + diff --git a/core/src/processing/core/PGraphicsJava2D.java b/core/src/processing/core/PGraphicsJava2D.java index 301c28e5b..f1e598d6d 100644 --- a/core/src/processing/core/PGraphicsJava2D.java +++ b/core/src/processing/core/PGraphicsJava2D.java @@ -29,8 +29,7 @@ import java.awt.image.*; /** - * Subclass for PGraphics that implements the graphics API - * in Java 1.3+ using Java 2D. + * Subclass for PGraphics that implements the graphics API using Java2D. * *

Pixel operations too slow? As of release 0085 (the first beta), * the default renderer uses Java2D. It's more accurate than the renderer diff --git a/core/todo.txt b/core/todo.txt index f8c1f98ca..e66a21f8e 100644 --- a/core/todo.txt +++ b/core/todo.txt @@ -3,6 +3,13 @@ X fix problem with "export to application" and opengl X http://processing.org/discourse/yabb_beta/YaBB.cgi?board=OpenGL;action=display;num=1193142573 X add focus requests so that better chance of keys etc working X http://dev.processing.org/bugs/show_bug.cgi?id=645 +_ argh, these make things worse (P3D run internal) +X add stuff about classversionerrors to the reference +X also update the libraries page +X fix background() with P3D and beginRaw() +X endRaw() has a problem with hint(ENABLE_DEPTH_SORT) +X because the triangles won't be rendered by the time endRaw() is called +X force depth sorted triangles to flush _ image outofmemoryerror for casey's students _ http://dev.processing.org/bugs/show_bug.cgi?id=355 @@ -19,6 +26,10 @@ o finish implementation so 1.1 support can return X http://dev.processing.org/bugs/show_bug.cgi?id=125 o check into ricard's problems with beginRecord() X i believe these were caused by linux java2d issues +X beginFrame()/beginDraw() and defaults() +X when should these be called, when not? +X seems as though the begin/end should happen inside beginRaw/Record +X defaults() gets called by the size() command in PApplet fixed earlier X is the texture[] array in PGraphics3D causing the problems with memory? @@ -64,7 +75,7 @@ _ also add unhint() to the keywords file _ and maybe remove hint() from keywords_base? _ method to go from function name to the included examples where used? -createGraphics() mess +createGraphics() and load/updatePixels() mess _ text characters showing up as opaque rectangles in tga files _ http://dev.processing.org/bugs/show_bug.cgi?id=641 _ solution is to implement alpha compositing across all of P3D @@ -98,6 +109,8 @@ _ or it's the PGraphics object, which does an updatePixels() immediately _ if (modified) don't loadPixels again, just ignore it _ make a note that updatePixels() only sets a flag in PImage _ (but not PGraphics, which does it immediately) +_ copy() should automatically call updatePixels() +_ http://processing.org/discourse/yabb_beta/YaBB.cgi?board=Syntax;action=display;num=1173394373 rework some text/font code _ fix getFontMetrics() warning @@ -115,22 +128,6 @@ _ textAlign(CENTER) with P3D and OPENGL produces messy result _ probably rounding error with the images _ http://dev.processing.org/bugs/show_bug.cgi?id=475 -_ loadBytes() needs optimization -_ don't bother using a buffering stream, just handle internally. gah! - -_ copy() should automatically call updatePixels() -_ http://processing.org/discourse/yabb_beta/YaBB.cgi?board=Syntax;action=display;num=1173394373 - -_ disable key repeat? http://www.cokeandcode.com/node/9 -KeyEvent nextPress = (KeyEvent) Toolkit.getDefaultToolkit(). - getSystemEventQueue(). - peekEvent(KeyEvent.KEY_PRESSED); -if ((nextPress == null) || - (nextPress.getWhen() != e.getWhen()) || - (nextPress.getKeyCode() != e.getKeyCode())) { - keys[e.getKeyCode()] = false; -} - . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . @@ -218,6 +215,9 @@ _ http://processing.org/discourse/yabb_beta/YaBB.cgi?board=SoftwareBugs;action . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . +_ loadBytes() needs optimization +_ don't bother using a buffering stream, just handle internally. gah! + _ modelX/Y/Z still having trouble _ http://dev.processing.org/bugs/show_bug.cgi?id=486 @@ -236,15 +236,6 @@ _ since camera functions don't even look at it or set it _ add notes about fixing serial on the mac to the faq (and link to bug) -_ beginFrame()/beginDraw() and defaults() -_ when should these be called, when not? -_ seems as though the begin/end should happen inside beginRaw/Record -_ defaults() gets called by the size() command in PApplet - -_ endRaw() is a problem with hint(ENABLE_DEPTH_SORT) -_ because the triangles won't be rendered by the time endRaw() is called -_ force depth sorted triangles to flush - _ should beginRecord inherit settings from its parent renderer? _ textFont() is null on beginRecord _ same would be the case for strokeWeight, background, etc. diff --git a/opengl/src/processing/opengl/PGraphicsOpenGL.java b/opengl/src/processing/opengl/PGraphicsOpenGL.java index 7fff5044b..556046c22 100644 --- a/opengl/src/processing/opengl/PGraphicsOpenGL.java +++ b/opengl/src/processing/opengl/PGraphicsOpenGL.java @@ -1930,25 +1930,10 @@ public class PGraphicsOpenGL extends PGraphics3D { public void clear() { - if (raw != null) { - raw.colorMode(RGB, 1); - raw.noStroke(); - raw.fill(backgroundR, backgroundG, backgroundB); - raw.beginShape(TRIANGLES); - - raw.vertex(0, 0); - raw.vertex(width, 0); - raw.vertex(0, height); - - raw.vertex(width, 0); - raw.vertex(width, height); - raw.vertex(0, height); - - raw.endShape(); - } - gl.glClearColor(backgroundR, backgroundG, backgroundB, 1); gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); + + clearRaw(); } diff --git a/todo.txt b/todo.txt index 3caaf3aed..2739f6f2c 100644 --- a/todo.txt +++ b/todo.txt @@ -6,6 +6,9 @@ X cmd-w doesn't close window of opened applet X both when running inside p5, or elsewhere X add variable 'external' set to true when running tethered X make note of new/open behavior (and toolbar) in the getting started ref +o make more fixes to the key bindings +o http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnacc/html/atg_keyboardshortcuts.asp +o http://developer.apple.com/documentation/UserExperience/Conceptual/OSXHIGuidelines/XHIGUserInput/chapter_11_section_3.html#//apple_ref/doc/uid/TP30000361-TPXREF61 _ pdf examples are shot @@ -180,24 +183,9 @@ _ so should make the external version use the actual sketch name not temp _ can't use PApplet.this, doesn't seem to like that _ instead, must pass variable to inner class -_ make more fixes to the key bindings -_ http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnacc/html/atg_keyboardshortcuts.asp -_ http://developer.apple.com/documentation/UserExperience/Conceptual/OSXHIGuidelines/XHIGUserInput/chapter_11_section_3.html#//apple_ref/doc/uid/TP30000361-TPXREF61 - _ install astyle formatter _ build on each platform, then "lipo -create astyle.* -output astyle" -Must have for 1.0: -> a,c) P2D to return, P2D to simply return in its previous form -> f) Java 1.5 support (jikes won't let you use Java 1.5 constructs) -> h) fix auto-format - -For 2.0 -> b) P2D to be accurate like JAVA2D -> e) Java 1.1 support (we're now limited to 1.3) -> g) support for running with user accounts that have umlauts/accents/etc -> d) strokeWeight() for 3D objects, even if it's ugly - LIBRARIES / svg _ when using get(), reset the bounds for the objects