Don't repaint() from a separate thread in AWT demos. This results in a smoother rendering.

This commit is contained in:
Elias Naur 2006-10-20 10:42:43 +00:00
parent 9f7da6d483
commit d9e94b2d54
3 changed files with 8 additions and 33 deletions

View File

@ -51,12 +51,12 @@ final class LinuxAWTGLCanvasPeerInfo extends LinuxPeerInfo {
}
protected void doLockAndInitHandle() throws LWJGLException {
int screen = -1;
try {
int screen = 0;//-1;
/* try {
screen = LinuxCanvasImplementation.getScreenFromDevice(canvas.getGraphicsConfiguration().getDevice());
} catch (LWJGLException e) {
LWJGLUtil.log("Got exception while trying to determine screen: " + e);
}
}*/
nInitHandle(screen, awt_surface.lockAndGetHandle(canvas), getHandle());
}
private static native void nInitHandle(int screen, ByteBuffer surface_buffer, ByteBuffer peer_info_handle) throws LWJGLException;

View File

@ -116,6 +116,7 @@ public class AWTGears extends Frame {
GL11.glPopMatrix();
swapBuffers();
repaint();
} catch (LWJGLException e) {
throw new RuntimeException(e);
}
@ -139,17 +140,6 @@ public class AWTGears extends Frame {
});
setResizable(true);
setVisible(true);
new Thread() {
{
setDaemon(true);
}
public void run() {
for (;;) {
canvas0.repaint();
}
}
}.start();
}
private void setup() {

View File

@ -53,7 +53,7 @@ public class AWTTest extends Frame {
/** AWT GL canvas */
private AWTGLCanvas canvas0, canvas1;
private float angle;
private volatile float angle;
/**
* C'tor
@ -80,6 +80,7 @@ public class AWTTest extends Frame {
GL11.glRectf(-50.0f, -50.0f, 50.0f, 50.0f);
GL11.glPopMatrix();
swapBuffers();
repaint();
} catch (LWJGLException e) {
throw new RuntimeException(e);
}
@ -89,6 +90,7 @@ public class AWTTest extends Frame {
add(canvas1 = new AWTGLCanvas() {
public void paintGL() {
try {
angle += 1.0f;
makeCurrent();
GL11.glViewport(0, 0, getWidth(), getHeight());
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.glPopMatrix();
swapBuffers();
repaint();
} catch (LWJGLException e) {
throw new RuntimeException(e);
}
@ -117,24 +120,6 @@ public class AWTTest extends Frame {
});
setResizable(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 {