Display timerexec delay limits [message #452251] |
Tue, 15 March 2005 22:57 |
Asim Ullah Messages: 24 Registered: July 2009 |
Junior Member |
|
|
I'm trying to run some SWT OpenGL test programs
at high frames per seconds, but I keep running into a 64fps
speed limit.
I'm using timerexec with various small millisecond delays,
in the sub 30 ms range. The time slices is this range
tend to have a higher discrepancy to the specified delay values.
I've written a small example of my use of the timerexec below.
Perhaps there is a better way of doing this.
Has anyone run into anything similar?
I'm using SWT3.1M5a on WinXP pro Sp2, card:ATI X800XT @ 75Hz.
----------------------------------------------
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;
public class TimerTest {
int framecount, fps;
long prevTime, currTime;
Shell shell;
Display display;
Canvas canvas;
public void run() {
display = new Display();
shell = new Shell(display);
shell.setSize(100, 100);
shell.setLayout(new FillLayout());
canvas = new Canvas(shell, SWT.NONE);
prevTime = System.currentTimeMillis();
canvas.addPaintListener(new PaintListener() {
public void paintControl(PaintEvent event) {
event.gc.drawText(String.valueOf(fps), 10, 10);
}
});
new Runnable() {
public void run() {
if (canvas.isDisposed())
return;
canvas.redraw();
framecount++;
currTime = System.currentTimeMillis();
if ((currTime - prevTime) >= 1000) {
fps=(int)((float)framecount/
(currTime-prevTime)*1000.0f);
framecount = 0;
prevTime = System.currentTimeMillis();
// System.out.println(fps);
}
canvas.getDisplay().timerExec(9, this);
}
}.run();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
public static void main(String[] args) {
new TimerTest().run();
}
}
|
|
|
Powered by
FUDForum. Page generated in 0.02827 seconds