| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 5c9f730 commit f5245f9
6 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2981,12 +2981,17 @@ public void exit() { | |||
| 2981 | 2981 | } | |
| 2982 | 2982 | ||
| 2983 | 2983 | ||
| 2984 | + public boolean exitCalled() { | ||
| 2985 | + return exitCalled; | ||
| 2986 | + } | ||
| 2987 | + | ||
| 2988 | + | ||
| 2984 | 2989 | /** | |
| 2985 | 2990 | * Some subclasses (I'm looking at you, processing.py) might wish to do something | |
| 2986 | 2991 | * other than actually terminate the JVM. This gives them a chance to do whatever | |
| 2987 | 2992 | * they have in mind when cleaning up. | |
| 2988 | 2993 | */ | |
| 2989 | - protected void exitActual() { | ||
| 2994 | + public void exitActual() { | ||
| 2990 | 2995 | try { | |
| 2991 | 2996 | System.exit(0); | |
| 2992 | 2997 | } catch (SecurityException e) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -612,11 +612,16 @@ protected void endDraw(boolean clear0) { | |||
| 612 | 612 | // protected abstract void swapBuffers(); | |
| 613 | 613 | ||
| 614 | 614 | ||
| 615 | - protected boolean threadIsCurrent() { | ||
| 615 | + public boolean threadIsCurrent() { | ||
| 616 | 616 | return Thread.currentThread() == glThread; | |
| 617 | 617 | } | |
| 618 | 618 | ||
| 619 | 619 | ||
| 620 | + public void setThread(Thread thread) { | ||
| 621 | + glThread = thread; | ||
| 622 | + } | ||
| 623 | + | ||
| 624 | + | ||
| 620 | 625 | protected void beginGL() { } | |
| 621 | 626 | ||
| 622 | 627 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -647,7 +647,7 @@ protected void getGL(PGL pgl) { | |||
| 647 | 647 | this.drawable = pjogl.drawable; | |
| 648 | 648 | this.context = pjogl.context; | |
| 649 | 649 | this.glContext = pjogl.glContext; | |
| 650 | - this.glThread = pjogl.glThread; | ||
| 650 | + setThread(pjogl.glThread); | ||
| 651 | 651 | ||
| 652 | 652 | this.gl = pjogl.gl; | |
| 653 | 653 | this.gl2 = pjogl.gl2; | |
@@ -659,7 +659,7 @@ protected void getGL(PGL pgl) { | |||
| 659 | 659 | protected void getGL(GLAutoDrawable glDrawable) { | |
| 660 | 660 | context = glDrawable.getContext(); | |
| 661 | 661 | glContext = context.hashCode(); | |
| 662 | - glThread = Thread.currentThread(); | ||
| 662 | + setThread(Thread.currentThread()); | ||
| 663 | 663 | ||
| 664 | 664 | gl = context.getGL(); | |
| 665 | 665 | gl2 = gl.getGL2ES2(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -467,9 +467,9 @@ public void display(GLAutoDrawable drawable) { | |||
| 467 | 467 | public void dispose(GLAutoDrawable drawable) { | |
| 468 | 468 | pgl.getGL(drawable); | |
| 469 | 469 | sketch.dispose(); | |
| 470 | - // if (sketch.exitCalled) { | ||
| 471 | - // sketch.exitActual(); | ||
| 472 | - // } | ||
| 470 | + if (sketch.exitCalled()) { | ||
| 471 | + sketch.exitActual(); | ||
| 472 | + } | ||
| 473 | 473 | } | |
| 474 | 474 | public void init(GLAutoDrawable drawable) { | |
| 475 | 475 | pgl.init(drawable); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -23,12 +23,9 @@ | |||
| 23 | 23 | ||
| 24 | 24 | package processing.lwjgl; | |
| 25 | 25 | ||
| 26 | - import java.awt.BorderLayout; | ||
| 27 | 26 | import java.awt.Canvas; | |
| 28 | - import java.awt.Color; | ||
| 29 | 27 | import java.awt.Font; | |
| 30 | 28 | import java.awt.FontMetrics; | |
| 31 | - import java.awt.Graphics2D; | ||
| 32 | 29 | import java.awt.Shape; | |
| 33 | 30 | import java.awt.font.FontRenderContext; | |
| 34 | 31 | import java.awt.font.GlyphVector; | |
@@ -40,12 +37,8 @@ | |||
| 40 | 37 | import java.nio.ShortBuffer; | |
| 41 | 38 | ||
| 42 | 39 | import org.lwjgl.BufferUtils; | |
| 43 | - import org.lwjgl.LWJGLException; | ||
| 44 | - import org.lwjgl.input.Keyboard; | ||
| 45 | - import org.lwjgl.input.Mouse; | ||
| 46 | 40 | import org.lwjgl.opengl.ARBES2Compatibility; | |
| 47 | 41 | import org.lwjgl.opengl.Display; | |
| 48 | - import org.lwjgl.opengl.DisplayMode; | ||
| 49 | 42 | import org.lwjgl.opengl.EXTFramebufferObject; | |
| 50 | 43 | import org.lwjgl.opengl.EXTTextureFilterAnisotropic; | |
| 51 | 44 | import org.lwjgl.opengl.GL11; | |
@@ -59,13 +52,7 @@ | |||
| 59 | 52 | import org.lwjgl.util.glu.GLU; | |
| 60 | 53 | import org.lwjgl.util.glu.GLUtessellator; | |
| 61 | 54 | import org.lwjgl.util.glu.GLUtessellatorCallbackAdapter; | |
| 62 | - import org.lwjgl.opengl.PixelFormat; | ||
| 63 | 55 | ||
| 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; | ||
| 69 | 56 | import processing.opengl.PGL; | |
| 70 | 57 | import processing.opengl.PGraphicsOpenGL; | |
| 71 | 58 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -68,19 +68,6 @@ public Frame initFrame(PApplet sketch, Color backgroundColor, | |||
| 68 | 68 | ||
| 69 | 69 | sketchWidth = sketch.sketchWidth(); | |
| 70 | 70 | 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(); | ||
| 84 | 71 | ||
| 85 | 72 | frame = new DummyFrame(); | |
| 86 | 73 | return frame; | |
@@ -252,6 +239,20 @@ public AnimationThread() { | |||
| 252 | 239 | */ | |
| 253 | 240 | @Override | |
| 254 | 241 | 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 | + | ||
| 255 | 256 | long beforeTime = System.nanoTime(); | |
| 256 | 257 | long overSleepTime = 0L; | |
| 257 | 258 | ||
@@ -272,6 +273,7 @@ public void run() { // not good to make this synchronized, locks things up | |||
| 272 | 273 | sketch.start(); | |
| 273 | 274 | ||
| 274 | 275 | while ((Thread.currentThread() == thread) && !sketch.finished) { | |
| 276 | + pgl.setThread(thread); | ||
| 275 | 277 | checkPause(); | |
| 276 | 278 | ||
| 277 | 279 | // 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 | |||
| 327 | 329 | ||
| 328 | 330 | // If the user called the exit() function, the window should close, | |
| 329 | 331 | // 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 | + } | ||
| 334 | 335 | } | |
| 335 | 336 | } | |
| 336 | 337 | ||
@@ -495,7 +496,7 @@ public void run() { | |||
| 495 | 496 | } | |
| 496 | 497 | ||
| 497 | 498 | int x = Mouse.getX(); | |
| 498 | - int y = parent.height - Mouse.getY(); | ||
| 499 | + int y = sketchHeight - Mouse.getY(); | ||
| 499 | 500 | int button = 0; | |
| 500 | 501 | if (Mouse.isButtonDown(0)) { | |
| 501 | 502 | button = PConstants.LEFT; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments