|
40 | 40 | import org.lwjgl.input.Keyboard; |
41 | 41 | import org.lwjgl.input.Mouse; |
42 | 42 | import org.lwjgl.opengl.Display; |
| 43 | +import org.lwjgl.opengl.DisplayMode; |
43 | 44 | import org.lwjgl.opengl.EXTFramebufferObject; |
44 | 45 | import org.lwjgl.opengl.EXTTextureFilterAnisotropic; |
45 | 46 | import org.lwjgl.opengl.GL11; |
@@ -349,7 +350,7 @@ public class PGL extends processing.opengl.PGL { |
349 | 350 | protected static Thread glThread; |
350 | 351 |
|
351 | 352 | /** Just holds a unique ID */ |
352 | | - protected static DummyContext context; |
| 353 | + protected static int context; |
353 | 354 |
|
354 | 355 | /** The PGraphics object using this interface */ |
355 | 356 | protected PGraphicsOpenGL pg; |
@@ -394,15 +395,15 @@ public class PGL extends processing.opengl.PGL { |
394 | 395 | protected static int tex2DShaderProgram; |
395 | 396 | protected static int tex2DVertShader; |
396 | 397 | protected static int tex2DFragShader; |
397 | | - protected static DummyContext tex2DShaderContext; |
| 398 | + protected static int tex2DShaderContext; |
398 | 399 | protected static int tex2DVertLoc; |
399 | 400 | protected static int tex2DTCoordLoc; |
400 | 401 |
|
401 | 402 | protected static boolean loadedTexRectShader = false; |
402 | 403 | protected static int texRectShaderProgram; |
403 | 404 | protected static int texRectVertShader; |
404 | 405 | protected static int texRectFragShader; |
405 | | - protected static DummyContext texRectShaderContext; |
| 406 | + protected static int texRectShaderContext; |
406 | 407 | protected static int texRectVertLoc; |
407 | 408 | protected static int texRectTCoordLoc; |
408 | 409 |
|
@@ -500,27 +501,29 @@ protected void initSurface(int antialias) { |
500 | 501 | } |
501 | 502 |
|
502 | 503 | canvas = new Canvas(); |
503 | | - canvas.setBounds(0, 0, pg.parent.width, pg.parent.height); |
504 | 504 | canvas.setFocusable(true); |
505 | 505 | canvas.requestFocus(); |
506 | 506 | canvas.setIgnoreRepaint(true); |
507 | 507 | canvas.setBackground(Color.BLACK); |
508 | | - |
| 508 | + canvas.setForeground(Color.BLACK); |
| 509 | + |
509 | 510 | pg.parent.setLayout(new BorderLayout()); |
510 | | - pg.parent.add(canvas, BorderLayout.CENTER); |
511 | | - |
512 | | - try { |
513 | | - Display.setParent(canvas); |
| 511 | + pg.parent.add(canvas, BorderLayout.CENTER); |
| 512 | + canvas.setBounds(0, 0, pg.parent.width, pg.parent.height); |
| 513 | + |
| 514 | + try { |
514 | 515 | PixelFormat format = new PixelFormat(32, request_alpha_bits, |
515 | 516 | request_depth_bits, |
516 | 517 | request_stencil_bits, 0); |
| 518 | + Display.setDisplayMode(new DisplayMode(pg.parent.width, pg.parent.height)); |
| 519 | + Display.setParent(canvas); |
517 | 520 | Display.create(format); |
518 | 521 | Display.setVSyncEnabled(true); |
519 | 522 | } catch (LWJGLException e) { |
520 | 523 | e.printStackTrace(); |
521 | 524 | } |
522 | | - |
523 | | - context = new DummyContext(Display.getDrawable().hashCode()); |
| 525 | + |
| 526 | + context = Display.getDrawable().hashCode(); |
524 | 527 |
|
525 | 528 | keyPoller = new KeyPoller(pg.parent); |
526 | 529 | keyPoller.start(); |
@@ -1614,7 +1617,7 @@ protected int createEmptyContext() { |
1614 | 1617 |
|
1615 | 1618 |
|
1616 | 1619 | protected int getCurrentContext() { |
1617 | | - return context.hashCode(); |
| 1620 | + return context; |
1618 | 1621 | } |
1619 | 1622 |
|
1620 | 1623 |
|
@@ -1719,7 +1722,7 @@ public void combine(double[] coords, Object[] data, |
1719 | 1722 |
|
1720 | 1723 |
|
1721 | 1724 | protected boolean contextIsCurrent(int other) { |
1722 | | - return other == -1 || other == context.hashCode(); |
| 1725 | + return other == -1 || other == context; |
1723 | 1726 | } |
1724 | 1727 |
|
1725 | 1728 |
|
@@ -1818,8 +1821,7 @@ protected void drawTexture(int target, int id, int width, int height, |
1818 | 1821 | protected void drawTexture2D(int id, int width, int height, |
1819 | 1822 | int texX0, int texY0, int texX1, int texY1, |
1820 | 1823 | int scrX0, int scrY0, int scrX1, int scrY1) { |
1821 | | - if (!loadedTex2DShader || |
1822 | | - tex2DShaderContext.hashCode() != context.hashCode()) { |
| 1824 | + if (!loadedTex2DShader || tex2DShaderContext != context) { |
1823 | 1825 | tex2DVertShader = createShader(VERTEX_SHADER, texVertShaderSource); |
1824 | 1826 | tex2DFragShader = createShader(FRAGMENT_SHADER, tex2DFragShaderSource); |
1825 | 1827 | if (0 < tex2DVertShader && 0 < tex2DFragShader) { |
@@ -1922,8 +1924,7 @@ protected void drawTexture2D(int id, int width, int height, |
1922 | 1924 | protected void drawTextureRect(int id, int width, int height, |
1923 | 1925 | int texX0, int texY0, int texX1, int texY1, |
1924 | 1926 | int scrX0, int scrY0, int scrX1, int scrY1) { |
1925 | | - if (!loadedTexRectShader || |
1926 | | - texRectShaderContext.hashCode() != context.hashCode()) { |
| 1927 | + if (!loadedTexRectShader || texRectShaderContext != context) { |
1927 | 1928 | texRectVertShader = createShader(VERTEX_SHADER, texVertShaderSource); |
1928 | 1929 | texRectFragShader = createShader(FRAGMENT_SHADER, texRectFragShaderSource); |
1929 | 1930 | if (0 < texRectVertShader && 0 < texRectFragShader) { |
@@ -2989,13 +2990,6 @@ public void requestStop() { |
2989 | 2990 | } |
2990 | 2991 | } |
2991 | 2992 |
|
2992 | | - protected class DummyContext { |
2993 | | - int id; |
2994 | | - DummyContext(int id) { |
2995 | | - this.id = id; |
2996 | | - } |
2997 | | - } |
2998 | | - |
2999 | 2993 | // To complete later... |
3000 | 2994 | // http://docs.oracle.com/javase/6/docs/api/java/awt/event/KeyEvent.html |
3001 | 2995 | // http://processing.org/reference/keyCode.html |
|
0 commit comments