Don't repaint() from a separate thread in AWT demos. This results in a smoother rendering.
This commit is contained in:
parent
9f7da6d483
commit
d9e94b2d54
|
@ -51,12 +51,12 @@ final class LinuxAWTGLCanvasPeerInfo extends LinuxPeerInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void doLockAndInitHandle() throws LWJGLException {
|
protected void doLockAndInitHandle() throws LWJGLException {
|
||||||
int screen = -1;
|
int screen = 0;//-1;
|
||||||
try {
|
/* try {
|
||||||
screen = LinuxCanvasImplementation.getScreenFromDevice(canvas.getGraphicsConfiguration().getDevice());
|
screen = LinuxCanvasImplementation.getScreenFromDevice(canvas.getGraphicsConfiguration().getDevice());
|
||||||
} catch (LWJGLException e) {
|
} catch (LWJGLException e) {
|
||||||
LWJGLUtil.log("Got exception while trying to determine screen: " + e);
|
LWJGLUtil.log("Got exception while trying to determine screen: " + e);
|
||||||
}
|
}*/
|
||||||
nInitHandle(screen, awt_surface.lockAndGetHandle(canvas), getHandle());
|
nInitHandle(screen, awt_surface.lockAndGetHandle(canvas), getHandle());
|
||||||
}
|
}
|
||||||
private static native void nInitHandle(int screen, ByteBuffer surface_buffer, ByteBuffer peer_info_handle) throws LWJGLException;
|
private static native void nInitHandle(int screen, ByteBuffer surface_buffer, ByteBuffer peer_info_handle) throws LWJGLException;
|
||||||
|
|
|
@ -116,6 +116,7 @@ public class AWTGears extends Frame {
|
||||||
|
|
||||||
GL11.glPopMatrix();
|
GL11.glPopMatrix();
|
||||||
swapBuffers();
|
swapBuffers();
|
||||||
|
repaint();
|
||||||
} catch (LWJGLException e) {
|
} catch (LWJGLException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
@ -139,17 +140,6 @@ public class AWTGears extends Frame {
|
||||||
});
|
});
|
||||||
setResizable(true);
|
setResizable(true);
|
||||||
setVisible(true);
|
setVisible(true);
|
||||||
|
|
||||||
new Thread() {
|
|
||||||
{
|
|
||||||
setDaemon(true);
|
|
||||||
}
|
|
||||||
public void run() {
|
|
||||||
for (;;) {
|
|
||||||
canvas0.repaint();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}.start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setup() {
|
private void setup() {
|
||||||
|
|
|
@ -53,7 +53,7 @@ public class AWTTest extends Frame {
|
||||||
/** AWT GL canvas */
|
/** AWT GL canvas */
|
||||||
private AWTGLCanvas canvas0, canvas1;
|
private AWTGLCanvas canvas0, canvas1;
|
||||||
|
|
||||||
private float angle;
|
private volatile float angle;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* C'tor
|
* C'tor
|
||||||
|
@ -80,6 +80,7 @@ public class AWTTest extends Frame {
|
||||||
GL11.glRectf(-50.0f, -50.0f, 50.0f, 50.0f);
|
GL11.glRectf(-50.0f, -50.0f, 50.0f, 50.0f);
|
||||||
GL11.glPopMatrix();
|
GL11.glPopMatrix();
|
||||||
swapBuffers();
|
swapBuffers();
|
||||||
|
repaint();
|
||||||
} catch (LWJGLException e) {
|
} catch (LWJGLException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
@ -89,6 +90,7 @@ public class AWTTest extends Frame {
|
||||||
add(canvas1 = new AWTGLCanvas() {
|
add(canvas1 = new AWTGLCanvas() {
|
||||||
public void paintGL() {
|
public void paintGL() {
|
||||||
try {
|
try {
|
||||||
|
angle += 1.0f;
|
||||||
makeCurrent();
|
makeCurrent();
|
||||||
GL11.glViewport(0, 0, getWidth(), getHeight());
|
GL11.glViewport(0, 0, getWidth(), getHeight());
|
||||||
GL11.glClearColor(0.0f, 1.0f, 0.0f, 1.0f);
|
GL11.glClearColor(0.0f, 1.0f, 0.0f, 1.0f);
|
||||||
|
@ -103,6 +105,7 @@ public class AWTTest extends Frame {
|
||||||
GL11.glRectf(-50.0f, -50.0f, 50.0f, 50.0f);
|
GL11.glRectf(-50.0f, -50.0f, 50.0f, 50.0f);
|
||||||
GL11.glPopMatrix();
|
GL11.glPopMatrix();
|
||||||
swapBuffers();
|
swapBuffers();
|
||||||
|
repaint();
|
||||||
} catch (LWJGLException e) {
|
} catch (LWJGLException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
@ -117,24 +120,6 @@ public class AWTTest extends Frame {
|
||||||
});
|
});
|
||||||
setResizable(true);
|
setResizable(true);
|
||||||
setVisible(true);
|
setVisible(true);
|
||||||
|
|
||||||
new Thread() {
|
|
||||||
{
|
|
||||||
setDaemon(true);
|
|
||||||
}
|
|
||||||
public void run() {
|
|
||||||
for (;;) {
|
|
||||||
angle += 1.0f;
|
|
||||||
canvas0.repaint();
|
|
||||||
canvas1.repaint();
|
|
||||||
try {
|
|
||||||
sleep(20);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}.start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) throws LWJGLException {
|
public static void main(String[] args) throws LWJGLException {
|
||||||
|
|
Loading…
Reference in New Issue