use of com.jogamp.nativewindow.util.Dimension in project jmonkeyengine by jMonkeyEngine.
the class NewtMouseInput method setNativeCursor.
@Override
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.getHeight() - cursor.getYHotSpot());
component.setPointerIcon(joglCursor);
}
use of com.jogamp.nativewindow.util.Dimension in project jmonkeyengine by jMonkeyEngine.
the class JoglNewtDisplay method applySettings.
protected void applySettings(AppSettings settings) {
active.set(true);
canvas.addWindowListener(new WindowAdapter() {
@Override
public void windowDestroyNotify(WindowEvent e) {
windowCloseRequest.set(true);
}
@Override
public void windowGainedFocus(WindowEvent e) {
active.set(true);
}
@Override
public void windowLostFocus(WindowEvent e) {
active.set(false);
}
});
canvas.setSize(settings.getWidth(), settings.getHeight());
canvas.setUndecorated(settings.isFullscreen());
canvas.setFullscreen(settings.isFullscreen());
/**
* uses the filtering relying on resolution with the size to fetch only
* the screen mode matching with the current resolution
*/
Screen screen = canvas.getScreen();
/**
* The creation of native resources is lazy in JogAmp, i.e they are
* created only when they are used for the first time. When the GLWindow
* is not yet visible, its screen might have been unused for now and
* then its native counterpart has not yet been created. That's why
* forcing the creation of this resource is necessary
*/
screen.addReference();
if (settings.isFullscreen()) {
List<MonitorMode> screenModes = canvas.getMainMonitor().getSupportedModes();
//the resolution is provided by the user
Dimension dimension = new Dimension(settings.getWidth(), settings.getHeight());
screenModes = MonitorModeUtil.filterByResolution(screenModes, dimension);
screenModes = MonitorModeUtil.getHighestAvailableBpp(screenModes);
if (settings.getFrequency() > 0) {
screenModes = MonitorModeUtil.filterByRate(screenModes, settings.getFrequency());
} else {
screenModes = MonitorModeUtil.getHighestAvailableRate(screenModes);
}
canvas.getMainMonitor().setCurrentMode(screenModes.get(0));
}
MonitorMode currentScreenMode = canvas.getMainMonitor().getCurrentMode();
logger.log(Level.FINE, "Selected display mode: {0}x{1}x{2} @{3}", new Object[] { currentScreenMode.getRotatedWidth(), currentScreenMode.getRotatedHeight(), currentScreenMode.getSurfaceSize().getBitsPerPixel(), currentScreenMode.getRefreshRate() });
}
use of com.jogamp.nativewindow.util.Dimension in project processing by processing.
the class PSurfaceJOGL method setCursor.
public void setCursor(PImage image, int hotspotX, int hotspotY) {
Display disp = window.getScreen().getDisplay();
BufferedImage bimg = (BufferedImage) image.getNative();
DataBufferInt dbuf = (DataBufferInt) bimg.getData().getDataBuffer();
int[] ipix = dbuf.getData();
ByteBuffer pixels = ByteBuffer.allocate(ipix.length * 4);
pixels.asIntBuffer().put(ipix);
PixelFormat format = PixelFormat.ARGB8888;
final Dimension size = new Dimension(bimg.getWidth(), bimg.getHeight());
PixelRectangle pixelrect = new PixelRectangle.GenericPixelRect(format, size, 0, false, pixels);
final PointerIcon pi = disp.createPointerIcon(pixelrect, hotspotX, hotspotY);
display.getEDTUtil().invoke(false, new Runnable() {
@Override
public void run() {
window.setPointerIcon(pi);
}
});
}
Aggregations