mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
working on opengl integration and fixing graphics
This commit is contained in:
+2
-2
@@ -49,7 +49,7 @@ public class PdeBase {
|
||||
|
||||
static String openedAtStartup;
|
||||
|
||||
static ClassLoader loader;
|
||||
//static ClassLoader loader;
|
||||
|
||||
PdeEditor editor;
|
||||
|
||||
@@ -144,7 +144,7 @@ public class PdeBase {
|
||||
|
||||
|
||||
// maybe?
|
||||
loader = new PdeClassLoader();
|
||||
//loader = new PdeClassLoader();
|
||||
}
|
||||
|
||||
|
||||
|
||||
+7
-87
@@ -99,7 +99,6 @@ public class PdeRuntime implements PdeMessageConsumer {
|
||||
// sketch.libraryPath might be ""
|
||||
// librariesClassPath will always have sep char prepended
|
||||
sketch.libraryPath +
|
||||
//PdeSketchbook.librariesClassPath +
|
||||
File.pathSeparator + System.getProperty("java.library.path"),
|
||||
"-cp",
|
||||
sketch.classPath + PdeSketchbook.librariesClassPath,
|
||||
@@ -107,30 +106,18 @@ public class PdeRuntime implements PdeMessageConsumer {
|
||||
location,
|
||||
PApplet.EXT_SKETCH_FOLDER + sketch.folder.getAbsolutePath(),
|
||||
sketch.mainClassName
|
||||
|
||||
//, "1>", "C:\\net1.txt"
|
||||
//, "2>", "C:\\net2.txt"
|
||||
};
|
||||
//PApplet.printarr(command);
|
||||
//PApplet.println(PApplet.join(command, " "));
|
||||
|
||||
//for (int i = 0; i < command.length; i++) {
|
||||
// System.out.println(i + " = " + command[i]);
|
||||
//}
|
||||
|
||||
//PApplet.println(PApplet.join(command, " "));
|
||||
process = Runtime.getRuntime().exec(command);
|
||||
processInput = new SystemOutSiphon(process.getInputStream());
|
||||
processError = new PdeMessageSiphon(process.getErrorStream(), this);
|
||||
processOutput = process.getOutputStream();
|
||||
|
||||
//processOutput.write(' ');
|
||||
//processOutput.flush();
|
||||
|
||||
} else { // !externalRuntime
|
||||
//Class c = Class.forName(className);
|
||||
//Class c = Class.forName(sketch.mainClassName);
|
||||
Class c = PdeBase.loader.loadClass(sketch.mainClassName);
|
||||
PdeClassLoader loader = new PdeClassLoader();
|
||||
Class c = loader.loadClass(sketch.mainClassName);
|
||||
applet = (PApplet) c.newInstance();
|
||||
|
||||
// replaces setRuntime with PApplet having leechErr [fry]
|
||||
@@ -152,34 +139,6 @@ public class PdeRuntime implements PdeMessageConsumer {
|
||||
}
|
||||
applet.start();
|
||||
|
||||
/*
|
||||
// appears to be no longer necessary now that draw()
|
||||
// is gonna be run inside of setup()
|
||||
|
||||
// check to see if it's a draw mode applet
|
||||
boolean drawMode = false;
|
||||
try {
|
||||
Method meth[] = c.getDeclaredMethods();
|
||||
for (int i = 0; i < meth.length; i++) {
|
||||
//System.out.println(meth[i].getName());
|
||||
if (meth[i].getName().equals("draw")) drawMode = true;
|
||||
}
|
||||
} catch (SecurityException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
// if it's a draw mode app, don't even show on-screen
|
||||
// until it's finished rendering, otherwise the width/height
|
||||
// may not have been properly set.
|
||||
if (drawMode) {
|
||||
//System.out.println("draw mode");
|
||||
while ((applet.frame != 1) && (!applet.finished)) {
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
} catch (InterruptedException e) { }
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
if (editor.presenting) {
|
||||
//window = new Window(new Frame());
|
||||
// toxi_030903: attach applet window to editor's presentation window
|
||||
@@ -210,44 +169,16 @@ public class PdeRuntime implements PdeMessageConsumer {
|
||||
if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
|
||||
stop();
|
||||
editor.doClose();
|
||||
//new DelayedClose(editor);
|
||||
//editor.doClose();
|
||||
}
|
||||
//System.out.println("consuming1");
|
||||
//e.consume();
|
||||
//System.out.println("consuming2");
|
||||
}
|
||||
});
|
||||
y1 += parentInsets.top;
|
||||
}
|
||||
// toxi_030903: moved this in the above else branch
|
||||
// if (!(window instanceof Frame)) y1 += parentInsets.top;
|
||||
|
||||
window.add(applet);
|
||||
|
||||
// @#$((* java 1.3
|
||||
// removed because didn't seem to be needed anymore
|
||||
// also, was causing offset troubles
|
||||
/*
|
||||
window.addMouseListener(applet);
|
||||
window.addMouseMotionListener(applet);
|
||||
window.addKeyListener(applet);
|
||||
*/
|
||||
|
||||
Dimension screen =
|
||||
Toolkit.getDefaultToolkit().getScreenSize();
|
||||
|
||||
//System.out.println(SystemColor.windowBorder.toString());
|
||||
|
||||
/*
|
||||
int appletWidth = applet.width;
|
||||
int appletHeight = applet.height;
|
||||
if ((appletWidth == 0) || (appletHeight == 0)) {
|
||||
appletWidth = PApplet.DEFAULT_WIDTH;
|
||||
appletWidth = PApplet.DEFAULT_HEIGHT;
|
||||
}
|
||||
*/
|
||||
|
||||
window.setLayout(null);
|
||||
if (editor.presenting) {
|
||||
window.setBounds((screen.width - applet.width) / 2,
|
||||
@@ -315,38 +246,25 @@ public class PdeRuntime implements PdeMessageConsumer {
|
||||
}
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
//System.out.println();
|
||||
//System.out.println("PdeRuntime.stop()");
|
||||
|
||||
public void stop() {
|
||||
// check for null in case stop is called during compilation
|
||||
if (applet != null) {
|
||||
applet.stop();
|
||||
//if (window != null) window.hide();
|
||||
|
||||
// above avoids NullPointerExceptions
|
||||
// but still threading is too complex, and so
|
||||
// some boogers are being left behind
|
||||
|
||||
applet = null;
|
||||
//window = null;
|
||||
|
||||
} else if (process != null) { // running externally
|
||||
//System.out.println("killing external process");
|
||||
|
||||
try {
|
||||
//System.out.println("writing to stop process");
|
||||
processOutput.write('s');
|
||||
//System.out.println("written");
|
||||
processOutput.write(PApplet.EXTERNAL_STOP);
|
||||
processOutput.flush();
|
||||
//System.out.println("flushing");
|
||||
|
||||
} catch (IOException e) {
|
||||
//System.err.println("error stopping external applet");
|
||||
//e.printStackTrace();
|
||||
close();
|
||||
}
|
||||
//System.out.println("out");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -486,7 +404,6 @@ java.lang.NullPointerException
|
||||
if (codeIndex != -1) {
|
||||
// lineIndex is 1-indexed, but editor wants zero-indexed
|
||||
lineIndex = Integer.parseInt(fileAndLine.substring(colonIndex + 1));
|
||||
//System.out.println("code/line is " + codeIndex + " " + lineIndex);
|
||||
exception = new PdeException(exception.getMessage(),
|
||||
codeIndex, lineIndex - 1, -1);
|
||||
exception.hideStackTrace = true;
|
||||
@@ -556,6 +473,9 @@ java.lang.NullPointerException
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
/**
|
||||
* Siphons from an InputStream of System.out (from a Process)
|
||||
* and sends it to the real System.out.
|
||||
|
||||
+15
-4
@@ -4528,17 +4528,19 @@ v PApplet.this.stop();
|
||||
|
||||
int locationX = location[0] - 20;
|
||||
int locationY = location[1];
|
||||
//System.out.println("x,y " + locationX + " " + locationY);
|
||||
|
||||
//frame.setTitle(str(setupComplete));
|
||||
// applet.width and .height are zero here
|
||||
/*
|
||||
int minW = 120;
|
||||
int minH = 120;
|
||||
int windowW =
|
||||
Math.max(applet.width, minW) + insets.left + insets.right;
|
||||
int windowH =
|
||||
Math.max(applet.height, minH) + insets.top + insets.bottom;
|
||||
*/
|
||||
int windowW = 120 + insets.left + insets.right;
|
||||
int windowH = 120 + insets.top + insets.bottom;
|
||||
frame.setSize(windowW, windowH);
|
||||
//frame.setTitle(windowW + " " + windowH);
|
||||
|
||||
if (exactLocation) {
|
||||
frame.setLocation(location[0], location[1]);
|
||||
@@ -4547,6 +4549,7 @@ v PApplet.this.stop();
|
||||
if (locationX - windowW > 10) {
|
||||
// if it fits to the left of the window
|
||||
frame.setLocation(locationX - windowW, locationY);
|
||||
|
||||
} else {
|
||||
// if it fits inside the editor window,
|
||||
// offset slightly from upper lefthand corner
|
||||
@@ -4563,19 +4566,27 @@ v PApplet.this.stop();
|
||||
frame.setLocation(locationX, locationY);
|
||||
}
|
||||
}
|
||||
//System.out.println("applet izzat: " + applet.width + " " +
|
||||
// applet.height);
|
||||
|
||||
frame.setLayout(null);
|
||||
frame.add(applet);
|
||||
frame.setBackground(SystemColor.control);
|
||||
/*
|
||||
applet.setBounds((windowW - applet.width)/2,
|
||||
insets.top + ((windowH - insets.top - insets.bottom) -
|
||||
applet.height)/2,
|
||||
windowW, windowH);
|
||||
*/
|
||||
applet.setBounds((windowW - 100) / 2,
|
||||
insets.top + ((windowH - insets.top - insets.bottom) -
|
||||
100)/2,
|
||||
windowW, windowH);
|
||||
|
||||
applet.setupExternal(frame);
|
||||
|
||||
} else { // !external
|
||||
System.out.println("applet not external");
|
||||
//System.out.println("applet not external");
|
||||
|
||||
// remove applet name from args passed in
|
||||
applet.args = new String[args.length - 1];
|
||||
|
||||
+3
-1
@@ -478,7 +478,7 @@ public class PGraphics extends PImage implements PMethods, PConstants {
|
||||
lightSpecularB = new float[MAX_LIGHTS];
|
||||
|
||||
// reset the cameraMode if PERSPECTIVE or ORTHOGRAPHIC
|
||||
// otherwise just hose the user if it's custom
|
||||
// will just be ignored if CUSTOM, the user's hosed anyways
|
||||
if (depth) cameraMode(this.cameraMode);
|
||||
}
|
||||
|
||||
@@ -545,6 +545,8 @@ public class PGraphics extends PImage implements PMethods, PConstants {
|
||||
textFont = null;
|
||||
//text_mode = ALIGN_LEFT;
|
||||
//text_space = OBJECT_SPACE;
|
||||
|
||||
noDepth(); // actually has effect of calling depth() on opengl
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -75,6 +75,9 @@ _ this way can avoid duplicating / breaking things
|
||||
_ depth() shouldn't be needed for opengl unless actually 3D
|
||||
_ right now the camera doesn't get set up unless you call depth()
|
||||
|
||||
_ don't show applet frame until first frame
|
||||
_ but don't do it if it's a subclass, ie opengl..
|
||||
|
||||
_ how to handle full screen (opengl especially) or no screen (for scripts)
|
||||
_ implement fullsize().. this takes over the screen as best it can
|
||||
_ or should it be more like present mode?
|
||||
|
||||
Reference in New Issue
Block a user