use of org.lwjgl.LWJGLException in project lwjgl by LWJGL.
the class LinuxDisplay method init.
public DisplayMode init() throws LWJGLException {
lockAWT();
try {
Compiz.init();
delete_atom = internAtom("WM_DELETE_WINDOW", false);
current_displaymode_extension = getBestDisplayModeExtension();
if (current_displaymode_extension == NONE)
throw new LWJGLException("No display mode extension is available");
DisplayMode[] modes = getAvailableDisplayModes();
if (modes == null || modes.length == 0)
throw new LWJGLException("No modes available");
switch(current_displaymode_extension) {
case XRANDR:
saved_mode = AccessController.doPrivileged(new PrivilegedAction<DisplayMode>() {
public DisplayMode run() {
return XRandR.ScreentoDisplayMode(XRandR.getConfiguration());
}
});
break;
case XF86VIDMODE:
saved_mode = modes[0];
break;
default:
throw new LWJGLException("Unknown display mode extension: " + current_displaymode_extension);
}
current_mode = saved_mode;
saved_gamma = getCurrentGammaRamp();
current_gamma = saved_gamma;
return saved_mode;
} finally {
unlockAWT();
}
}
use of org.lwjgl.LWJGLException in project lwjgl by LWJGL.
the class LinuxDisplay method createWindow.
public void createWindow(final DrawableLWJGL drawable, DisplayMode mode, Canvas parent, int x, int y) throws LWJGLException {
lockAWT();
try {
incDisplay();
try {
if (drawable instanceof DrawableGLES)
peer_info = new LinuxDisplayPeerInfo();
ByteBuffer handle = peer_info.lockAndGetHandle();
try {
current_window_mode = getWindowMode(Display.isFullscreen());
// we may have trouble with stuff overlapping our fullscreen window.
if (current_window_mode != WINDOWED)
Compiz.setLegacyFullscreenSupport(true);
// Setting _MOTIF_WM_HINTS in fullscreen mode is problematic for certain window
// managers. We do not set MWM_HINTS_DECORATIONS in fullscreen mode anymore,
// unless org.lwjgl.opengl.Window.undecorated_fs has been specified.
// See native/linux/org_lwjgl_opengl_Display.c, createWindow function.
boolean undecorated = Display.getPrivilegedBoolean("org.lwjgl.opengl.Window.undecorated") || (current_window_mode != WINDOWED && Display.getPrivilegedBoolean("org.lwjgl.opengl.Window.undecorated_fs"));
this.parent = parent;
parent_window = parent != null ? getHandle(parent) : getRootWindow(getDisplay(), getDefaultScreen());
resizable = Display.isResizable();
resized = false;
window_x = x;
window_y = y;
window_width = mode.getWidth();
window_height = mode.getHeight();
// this is required to let the fullscreen window appear on the primary screen
if (mode.isFullscreenCapable() && current_displaymode_extension == XRANDR) {
Screen primaryScreen = XRandR.DisplayModetoScreen(Display.getDisplayMode());
x = primaryScreen.xPos;
y = primaryScreen.yPos;
}
current_window = nCreateWindow(getDisplay(), getDefaultScreen(), handle, mode, current_window_mode, x, y, undecorated, parent_window, resizable);
// Set the WM_CLASS hint which is needed by some WM's e.g. Gnome Shell
wm_class = Display.getPrivilegedString("LWJGL_WM_CLASS");
if (wm_class == null)
wm_class = Display.getTitle();
setClassHint(Display.getTitle(), wm_class);
mapRaised(getDisplay(), current_window);
xembedded = parent != null && isAncestorXEmbedded(parent_window);
blank_cursor = createBlankCursor();
current_cursor = None;
focused = false;
input_released = false;
pointer_grabbed = false;
keyboard_grabbed = false;
close_requested = false;
grab = false;
minimized = false;
dirty = true;
if (drawable instanceof DrawableGLES)
((DrawableGLES) drawable).initialize(current_window, getDisplay(), EGL.EGL_WINDOW_BIT, (org.lwjgl.opengles.PixelFormat) drawable.getPixelFormat());
if (parent != null) {
parent.addFocusListener(focus_listener);
parent_focused = parent.isFocusOwner();
parent_focus_changed = true;
}
} finally {
peer_info.unlock();
}
} catch (LWJGLException e) {
decDisplay();
throw e;
}
} finally {
unlockAWT();
}
}
use of org.lwjgl.LWJGLException in project lwjgl by LWJGL.
the class WindowsDisplay method createWindow.
public void createWindow(DrawableLWJGL drawable, DisplayMode mode, Canvas parent, int x, int y) throws LWJGLException {
this.parent = parent;
hasParent = parent != null;
parent_hwnd = parent != null ? getHwnd(parent) : 0;
this.hwnd = nCreateWindow(x, y, mode.getWidth(), mode.getHeight(), Display.isFullscreen() || isUndecorated(), parent != null, parent_hwnd);
if (Display.isResizable() && parent == null) {
setResizable(true);
}
if (hwnd == 0) {
throw new LWJGLException("Failed to create window");
}
this.hdc = getDC(hwnd);
if (hdc == 0) {
nDestroyWindow(hwnd);
throw new LWJGLException("Failed to get dc");
}
try {
if (drawable instanceof DrawableGL) {
int format = WindowsPeerInfo.choosePixelFormat(getHdc(), 0, 0, (PixelFormat) drawable.getPixelFormat(), null, true, true, false, true);
WindowsPeerInfo.setPixelFormat(getHdc(), format);
} else {
peer_info = new WindowsDisplayPeerInfo(true);
((DrawableGLES) drawable).initialize(hwnd, hdc, EGL.EGL_WINDOW_BIT, (org.lwjgl.opengles.PixelFormat) drawable.getPixelFormat());
}
peer_info.initDC(getHwnd(), getHdc());
showWindow(getHwnd(), SW_SHOWDEFAULT);
updateWidthAndHeight();
if (parent == null) {
setForegroundWindow(getHwnd());
} else {
parent_focused = new AtomicBoolean(false);
parent.addFocusListener(parent_focus_tracker = new FocusAdapter() {
public void focusGained(FocusEvent e) {
parent_focused.set(true);
clearAWTFocus();
}
});
SwingUtilities.invokeLater(new Runnable() {
public void run() {
clearAWTFocus();
}
});
}
grabFocus();
} catch (LWJGLException e) {
nReleaseDC(hwnd, hdc);
nDestroyWindow(hwnd);
throw e;
}
}
use of org.lwjgl.LWJGLException in project lwjgl by LWJGL.
the class LinuxCanvasImplementation method getScreenFromDevice.
static int getScreenFromDevice(final GraphicsDevice device) throws LWJGLException {
try {
Method getScreen_method = AccessController.doPrivileged(new PrivilegedExceptionAction<Method>() {
public Method run() throws Exception {
return device.getClass().getMethod("getScreen");
}
});
Integer screen = (Integer) getScreen_method.invoke(device);
return screen;
} catch (Exception e) {
throw new LWJGLException(e);
}
}
use of org.lwjgl.LWJGLException in project lwjgl by LWJGL.
the class MacOSXDisplay method createWindow.
public void createWindow(final DrawableLWJGL drawable, DisplayMode mode, Canvas parent, int x, int y) throws LWJGLException {
boolean fullscreen = Display.isFullscreen();
boolean resizable = Display.isResizable();
boolean parented = (parent != null) && !fullscreen;
// OS X fullscreen mode API is only available on OS X 10.7+
boolean enableFullscreenModeAPI = LWJGLUtil.isMacOSXEqualsOrBetterThan(10, 7) && parent == null && !Display.getPrivilegedBoolean("org.lwjgl.opengl.Display.disableOSXFullscreenModeAPI");
// OS X high DPI mode is only available on OS X 10.7+
enableHighDPI = LWJGLUtil.isMacOSXEqualsOrBetterThan(10, 7) && parent == null && (Display.getPrivilegedBoolean("org.lwjgl.opengl.Display.enableHighDPI") || fullscreen);
if (parented)
this.canvas = parent;
else
this.canvas = null;
close_requested = false;
DrawableGL gl_drawable = (DrawableGL) Display.getDrawable();
PeerInfo peer_info = gl_drawable.peer_info;
ByteBuffer peer_handle = peer_info.lockAndGetHandle();
ByteBuffer window_handle = parented ? ((MacOSXCanvasPeerInfo) peer_info).window_handle : window;
try {
window = nCreateWindow(x, y, mode.getWidth(), mode.getHeight(), fullscreen, isUndecorated(), resizable, parented, enableFullscreenModeAPI, enableHighDPI, peer_handle, window_handle);
if (fullscreen) {
// when going to fullscreen viewport is set to screen size by Cocoa, ignore this value
skipViewportValue = true;
// if starting in fullscreen then set initial viewport to displaymode size
current_viewport.put(2, mode.getWidth());
current_viewport.put(3, mode.getHeight());
}
native_mode = nIsNativeMode(peer_handle);
if (!native_mode) {
robot = AWTUtil.createRobot(canvas);
}
} catch (LWJGLException e) {
destroyWindow();
throw e;
} finally {
peer_info.unlock();
}
}
Aggregations