mirror of
https://github.com/processing/processing4.git
synced 2026-01-29 11:21:06 +01:00
fixes to lwjgl renderer
This commit is contained in:
@@ -23,12 +23,9 @@
|
||||
|
||||
package processing.lwjgl;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Canvas;
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import java.awt.FontMetrics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Shape;
|
||||
import java.awt.font.FontRenderContext;
|
||||
import java.awt.font.GlyphVector;
|
||||
@@ -40,12 +37,8 @@ import java.nio.IntBuffer;
|
||||
import java.nio.ShortBuffer;
|
||||
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.LWJGLException;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.input.Mouse;
|
||||
import org.lwjgl.opengl.ARBES2Compatibility;
|
||||
import org.lwjgl.opengl.Display;
|
||||
import org.lwjgl.opengl.DisplayMode;
|
||||
import org.lwjgl.opengl.EXTFramebufferObject;
|
||||
import org.lwjgl.opengl.EXTTextureFilterAnisotropic;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
@@ -59,13 +52,7 @@ import org.lwjgl.opengl.GL31;
|
||||
import org.lwjgl.util.glu.GLU;
|
||||
import org.lwjgl.util.glu.GLUtessellator;
|
||||
import org.lwjgl.util.glu.GLUtessellatorCallbackAdapter;
|
||||
import org.lwjgl.opengl.PixelFormat;
|
||||
|
||||
import processing.core.PApplet;
|
||||
import processing.core.PConstants;
|
||||
import processing.event.Event;
|
||||
import processing.event.KeyEvent;
|
||||
import processing.event.MouseEvent;
|
||||
import processing.opengl.PGL;
|
||||
import processing.opengl.PGraphicsOpenGL;
|
||||
|
||||
|
||||
@@ -68,19 +68,6 @@ public class PSurfaceLWJGL implements PSurface {
|
||||
|
||||
sketchWidth = sketch.sketchWidth();
|
||||
sketchHeight = sketch.sketchHeight();
|
||||
try {
|
||||
Display.setDisplayMode(new DisplayMode(sketchWidth, sketchHeight));
|
||||
Display.create();
|
||||
} catch (LWJGLException e) {
|
||||
e.printStackTrace();
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
keyPoller = new KeyPoller(sketch);
|
||||
keyPoller.start();
|
||||
|
||||
mousePoller = new MousePoller(sketch);
|
||||
mousePoller.start();
|
||||
|
||||
frame = new DummyFrame();
|
||||
return frame;
|
||||
@@ -252,6 +239,20 @@ public class PSurfaceLWJGL implements PSurface {
|
||||
*/
|
||||
@Override
|
||||
public void run() { // not good to make this synchronized, locks things up
|
||||
try {
|
||||
Display.setDisplayMode(new DisplayMode(sketchWidth, sketchHeight));
|
||||
Display.create();
|
||||
} catch (LWJGLException e) {
|
||||
e.printStackTrace();
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
keyPoller = new KeyPoller(sketch);
|
||||
keyPoller.start();
|
||||
|
||||
mousePoller = new MousePoller(sketch);
|
||||
mousePoller.start();
|
||||
|
||||
long beforeTime = System.nanoTime();
|
||||
long overSleepTime = 0L;
|
||||
|
||||
@@ -272,6 +273,7 @@ public class PSurfaceLWJGL implements PSurface {
|
||||
sketch.start();
|
||||
|
||||
while ((Thread.currentThread() == thread) && !sketch.finished) {
|
||||
pgl.setThread(thread);
|
||||
checkPause();
|
||||
|
||||
// Don't resize the renderer from the EDT (i.e. from a ComponentEvent),
|
||||
@@ -327,10 +329,9 @@ public class PSurfaceLWJGL implements PSurface {
|
||||
|
||||
// If the user called the exit() function, the window should close,
|
||||
// rather than the sketch just halting.
|
||||
// TODO: these methods need to be public...
|
||||
// if (sketch.exitCalled) {
|
||||
// sketch.exitActual();
|
||||
// }
|
||||
if (sketch.exitCalled()) {
|
||||
sketch.exitActual();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -495,7 +496,7 @@ public class PSurfaceLWJGL implements PSurface {
|
||||
}
|
||||
|
||||
int x = Mouse.getX();
|
||||
int y = parent.height - Mouse.getY();
|
||||
int y = sketchHeight - Mouse.getY();
|
||||
int button = 0;
|
||||
if (Mouse.isButtonDown(0)) {
|
||||
button = PConstants.LEFT;
|
||||
|
||||
Reference in New Issue
Block a user