I tried to reproduce the problem, but i can't. This (very old) example of mine doesn't change speed on my machine when adding a MouseMotionListener. How does it behave on your system?
import com.threed.jpct.*;
import com.threed.jpct.util.*;
import java.awt.*;
import java.awt.event.*;
public class AWTTest extends Frame {
public static void main(String[] args) {
new AWTTest();
System.exit(0);
}
AWTTest() {
Canvas canvas = null;
Config.maxPolysVisible = 5000;
Config.saveMemory = true;
setTitle("AWTTest");
setSize(640, 480);
setLayout(null);
final FrameBuffer buffer = new FrameBuffer(640, 480, FrameBuffer.SAMPLINGMODE_NORMAL);
buffer.disableRenderer(IRenderer.RENDERER_SOFTWARE);
canvas = buffer.enableGLCanvasRenderer();
add(canvas);
canvas.addMouseMotionListener(new MouseMotionAdapter() {
public void mouseMoved(MouseEvent me) {
System.out.println(me.getX()+"/"+me.getY());
}
});
World world = new World();
Object3D box = Primitives.getSphere(30, 10);
world.addObject(box);
box.calcNormals();
world.setAmbientLight(055, 055, 055);
world.getCamera().moveCamera(Camera.CAMERA_MOVEOUT, 50);
world.getCamera().lookAt(SimpleVector.ORIGIN);
world.addLight(new SimpleVector(10, -50, 0), Color.red);
world.getLights().setRGBScale(Lights.RGB_SCALE_2X);
TextureManager.getInstance().addTexture("test", new Texture("test.jpg"));
TextureManager.getInstance().addTexture("test2", new Texture("test2.jpg"));
Texture text = new Texture("text.jpg");
box.calcTextureWrap();
TextureInfo ti = new TextureInfo(TextureManager.getInstance().getTextureID("test"));
ti.add(TextureManager.getInstance().getTextureID("test2"), TextureInfo.MODE_MODULATE);
box.setTexture(ti);
box.build();
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
setResizable(true);
setVisible(true);
boolean exit = false;
KeyMapper mapper = new KeyMapper(this);
while (!exit) {
if (buffer.isInitialized()) {
try {
KeyState ks = null;
do {
ks = mapper.poll();
if (ks.getKeyCode() == KeyEvent.VK_ESCAPE) {
exit = true;
}
} while (ks != KeyState.NONE);
buffer.clear(Color.blue);
world.renderScene(buffer);
world.draw(buffer);
buffer.blit(text, 0, 0, 100, 100, 256, 256, FrameBuffer.TRANSPARENT_BLITTING);
buffer.update();
buffer.displayGLOnly();
box.rotateX(0.003f);
canvas.repaint();
Thread.yield();
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
}
Edit: Added a Thread.yield() to work better on single cores. However, even when restricting the application to one core, i can't reproduce the problem.