Adds the support of the native cursor into the JOGL NEWT backend (not tested)

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10977 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
experimental
jul..om 11 years ago
parent 36235521b8
commit e5f0c32fe3
  1. 19
      engine/src/jogl/com/jme3/input/jogl/NewtMouseInput.java

@ -37,11 +37,18 @@ import com.jme3.input.MouseInput;
import com.jme3.input.RawInputListener;
import com.jme3.input.event.MouseButtonEvent;
import com.jme3.input.event.MouseMotionEvent;
import com.jogamp.common.nio.Buffers;
import com.jogamp.newt.Display.PointerIcon;
import com.jogamp.newt.event.MouseEvent;
import com.jogamp.newt.event.MouseListener;
import com.jogamp.newt.opengl.GLWindow;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.logging.Logger;
import javax.media.nativewindow.util.Dimension;
import javax.media.nativewindow.util.DimensionImmutable;
import javax.media.nativewindow.util.PixelFormat;
import javax.media.nativewindow.util.PixelRectangle;
import javax.media.nativewindow.util.Point;
public class NewtMouseInput implements MouseInput, MouseListener {
@ -175,9 +182,9 @@ public class NewtMouseInput implements MouseInput, MouseListener {
// listener.onMouseButtonEvent(evt);
}
public void mousePressed(MouseEvent awtEvt) {
MouseButtonEvent evt = new MouseButtonEvent(getJMEButtonIndex(awtEvt), true, awtEvt.getX(), awtEvt.getY());
evt.setTime(awtEvt.getWhen());
public void mousePressed(MouseEvent newtEvt) {
MouseButtonEvent evt = new MouseButtonEvent(getJMEButtonIndex(newtEvt), true, newtEvt.getX(), newtEvt.getY());
evt.setTime(newtEvt.getWhen());
synchronized (eventQueue) {
eventQueue.add(evt);
}
@ -281,5 +288,11 @@ public class NewtMouseInput implements MouseInput, MouseListener {
}
public void setNativeCursor(JmeCursor cursor) {
final ByteBuffer pixels = Buffers.copyIntBufferAsByteBuffer(cursor.getImagesData());
final DimensionImmutable size = new Dimension(cursor.getWidth(), cursor.getHeight());
final PixelFormat pixFormat = PixelFormat.RGBA8888;
final PixelRectangle.GenericPixelRect rec = new PixelRectangle.GenericPixelRect(pixFormat, size, 0, true, pixels);
final PointerIcon joglCursor = component.getScreen().getDisplay().createPointerIcon(rec, cursor.getXHotSpot(), cursor.getYHotSpot());
component.setPointerIcon(joglCursor);
}
}
Loading…
Cancel
Save