FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fixes to lwjgl renderer · sailuo/processing@f5245f9 · GitHub

Repository navigation

Commit f5245f9

Browse files
committed
fixes to lwjgl renderer
1 parent 5c9f730 commit f5245f9

6 files changed

Lines changed: 36 additions & 38 deletions

File tree

‎core/src/processing/core/PApplet.java‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2981,12 +2981,17 @@ public void exit() {
29812981
}
29822982

29832983

2984+
public boolean exitCalled() {
2985+
return exitCalled;
2986+
}
2987+
2988+
29842989
/**
29852990
* Some subclasses (I'm looking at you, processing.py) might wish to do something
29862991
* other than actually terminate the JVM. This gives them a chance to do whatever
29872992
* they have in mind when cleaning up.
29882993
*/
2989-
protected void exitActual() {
2994+
public void exitActual() {
29902995
try {
29912996
System.exit(0);
29922997
} catch (SecurityException e) {

‎core/src/processing/opengl/PGL.java‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -612,11 +612,16 @@ protected void endDraw(boolean clear0) {
612612
// protected abstract void swapBuffers();
613613

614614

615-
protected boolean threadIsCurrent() {
615+
public boolean threadIsCurrent() {
616616
return Thread.currentThread() == glThread;
617617
}
618618

619619

620+
public void setThread(Thread thread) {
621+
glThread = thread;
622+
}
623+
624+
620625
protected void beginGL() { }
621626

622627

‎core/src/processing/opengl/PJOGL.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ protected void getGL(PGL pgl) {
647647
this.drawable = pjogl.drawable;
648648
this.context = pjogl.context;
649649
this.glContext = pjogl.glContext;
650-
this.glThread = pjogl.glThread;
650+
setThread(pjogl.glThread);
651651

652652
this.gl = pjogl.gl;
653653
this.gl2 = pjogl.gl2;
@@ -659,7 +659,7 @@ protected void getGL(PGL pgl) {
659659
protected void getGL(GLAutoDrawable glDrawable) {
660660
context = glDrawable.getContext();
661661
glContext = context.hashCode();
662-
glThread = Thread.currentThread();
662+
setThread(Thread.currentThread());
663663

664664
gl = context.getGL();
665665
gl2 = gl.getGL2ES2();

‎core/src/processing/opengl/PSurfaceNEWT.java‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -467,9 +467,9 @@ public void display(GLAutoDrawable drawable) {
467467
public void dispose(GLAutoDrawable drawable) {
468468
pgl.getGL(drawable);
469469
sketch.dispose();
470-
// if (sketch.exitCalled) {
471-
// sketch.exitActual();
472-
// }
470+
if (sketch.exitCalled()) {
471+
sketch.exitActual();
472+
}
473473
}
474474
public void init(GLAutoDrawable drawable) {
475475
pgl.init(drawable);

‎java/libraries/lwjgl/src/processing/lwjgl/PLWJGL.java‎

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,9 @@
2323

2424
package processing.lwjgl;
2525

26-
import java.awt.BorderLayout;
2726
import java.awt.Canvas;
28-
import java.awt.Color;
2927
import java.awt.Font;
3028
import java.awt.FontMetrics;
31-
import java.awt.Graphics2D;
3229
import java.awt.Shape;
3330
import java.awt.font.FontRenderContext;
3431
import java.awt.font.GlyphVector;
@@ -40,12 +37,8 @@
4037
import java.nio.ShortBuffer;
4138

4239
import org.lwjgl.BufferUtils;
43-
import org.lwjgl.LWJGLException;
44-
import org.lwjgl.input.Keyboard;
45-
import org.lwjgl.input.Mouse;
4640
import org.lwjgl.opengl.ARBES2Compatibility;
4741
import org.lwjgl.opengl.Display;
48-
import org.lwjgl.opengl.DisplayMode;
4942
import org.lwjgl.opengl.EXTFramebufferObject;
5043
import org.lwjgl.opengl.EXTTextureFilterAnisotropic;
5144
import org.lwjgl.opengl.GL11;
@@ -59,13 +52,7 @@
5952
import org.lwjgl.util.glu.GLU;
6053
import org.lwjgl.util.glu.GLUtessellator;
6154
import org.lwjgl.util.glu.GLUtessellatorCallbackAdapter;
62-
import org.lwjgl.opengl.PixelFormat;
6355

64-
import processing.core.PApplet;
65-
import processing.core.PConstants;
66-
import processing.event.Event;
67-
import processing.event.KeyEvent;
68-
import processing.event.MouseEvent;
6956
import processing.opengl.PGL;
7057
import processing.opengl.PGraphicsOpenGL;
7158

‎java/libraries/lwjgl/src/processing/lwjgl/PSurfaceLWJGL.java‎

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -68,19 +68,6 @@ public Frame initFrame(PApplet sketch, Color backgroundColor,
6868

6969
sketchWidth = sketch.sketchWidth();
7070
sketchHeight = sketch.sketchHeight();
71-
try {
72-
Display.setDisplayMode(new DisplayMode(sketchWidth, sketchHeight));
73-
Display.create();
74-
} catch (LWJGLException e) {
75-
e.printStackTrace();
76-
System.exit(0);
77-
}
78-
79-
keyPoller = new KeyPoller(sketch);
80-
keyPoller.start();
81-
82-
mousePoller = new MousePoller(sketch);
83-
mousePoller.start();
8471

8572
frame = new DummyFrame();
8673
return frame;
@@ -252,6 +239,20 @@ public AnimationThread() {
252239
*/
253240
@Override
254241
public void run() { // not good to make this synchronized, locks things up
242+
try {
243+
Display.setDisplayMode(new DisplayMode(sketchWidth, sketchHeight));
244+
Display.create();
245+
} catch (LWJGLException e) {
246+
e.printStackTrace();
247+
System.exit(0);
248+
}
249+
250+
keyPoller = new KeyPoller(sketch);
251+
keyPoller.start();
252+
253+
mousePoller = new MousePoller(sketch);
254+
mousePoller.start();
255+
255256
long beforeTime = System.nanoTime();
256257
long overSleepTime = 0L;
257258

@@ -272,6 +273,7 @@ public void run() { // not good to make this synchronized, locks things up
272273
sketch.start();
273274

274275
while ((Thread.currentThread() == thread) && !sketch.finished) {
276+
pgl.setThread(thread);
275277
checkPause();
276278

277279
// Don't resize the renderer from the EDT (i.e. from a ComponentEvent),
@@ -327,10 +329,9 @@ public void run() { // not good to make this synchronized, locks things up
327329

328330
// If the user called the exit() function, the window should close,
329331
// rather than the sketch just halting.
330-
// TODO: these methods need to be public...
331-
// if (sketch.exitCalled) {
332-
// sketch.exitActual();
333-
// }
332+
if (sketch.exitCalled()) {
333+
sketch.exitActual();
334+
}
334335
}
335336
}
336337

@@ -495,7 +496,7 @@ public void run() {
495496
}
496497

497498
int x = Mouse.getX();
498-
int y = parent.height - Mouse.getY();
499+
int y = sketchHeight - Mouse.getY();
499500
int button = 0;
500501
if (Mouse.isButtonDown(0)) {
501502
button = PConstants.LEFT;

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL