Hi!
I can’t get it synched with the screen when I render my graphics on a CanvasJAI how is it? I’ve got average at 13 fps w JAI.
This is the draw method I called from the paint(Graphics) of CanvasJAI
/** draws the offscreen to the graphics on given component
* @param g the Graphics instance
* @param c the component to draw on (Graphics g should be those from that component)*/
protected void draw(Graphics g, Component c) {
int pty = Thread.currentThread().getPriority();
Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
GraphicsJAI graphics = (g instanceof GraphicsJAI)?(GraphicsJAI)g:GraphicsJAI.createGraphicsJAI((Graphics2D)g, c);
Sprite off = getOffscreen();
off.getGraphics().dispose();
Rectangle box = new Rectangle(getWidth(), getWidth());
graphics.setClip(box);
//graphics.clearRect(box.x, box.y, box.width, box.height);
off.setObserver(c);
if(off != null) {
off.draw(graphics);
}
drawString("F4 : switch full-screen mode", GUIConsoleOutput.LEFT, GUIConsoleOutput.BOTTOM);
drawString(device.getDisplayMode().getWidth() + "x" + device.getDisplayMode().getHeight() + "@ " + refreshRate + " Hz " + device.getDisplayMode().getBitDepth() + " bits", GUIConsoleOutput.RIGHT, GUIConsoleOutput.BOTTOM);
drawString("PGUp/PGDown : increase/decrease offscreen refresh-rate (" + (int)(1000/refresh_off.getDelay()) + "Hz)", GUIConsoleOutput.LEFT, -1);
//str = "FPS = " + String.valueOf(((Animation)off).getFPS());
//graphics.drawString(str, 10, 10);
Thread.currentThread().setPriority(pty);
}
And this is the screen refresh Action called by a Javax.Swing.Timer instance @ DisplayMode.refreshRate delay:
/** default action for the refresh timers*/
final AbstractAction action_default = new AbstractAction() { public void actionPerformed(ActionEvent e) {
int pty = Thread.currentThread().getPriority();
Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
synchronized(before_action_list){
for(Iterator<Action> i = before_action_list.iterator(); i.hasNext();)
i.next().actionPerformed(e);
}
System.out.println("******refresh frame");
repaint();
frame.repaint();
synchronized(after_action_list){
for(Iterator<Action> i = after_action_list.iterator(); i.hasNext();)
i.next().actionPerformed(e);
}
Thread.currentThread().setPriority(pty);
}};
??? Everything is buffered and Threaded at maximal resolution both offscreen and on-screen, but it still shows “hashed”.