use of org.lwjgl.LWJGLException in project lwjgl by LWJGL.
the class LinuxCanvasImplementation method getVisualIDFromConfiguration.
private static int getVisualIDFromConfiguration(final GraphicsConfiguration configuration) throws LWJGLException {
try {
Method getVisual_method = AccessController.doPrivileged(new PrivilegedExceptionAction<Method>() {
public Method run() throws Exception {
return configuration.getClass().getMethod("getVisual");
}
});
Integer visual = (Integer) getVisual_method.invoke(configuration);
return visual;
} catch (Exception e) {
throw new LWJGLException(e);
}
}
use of org.lwjgl.LWJGLException in project lwjgl by LWJGL.
the class LinuxContextImplementation method setSwapInterval.
public void setSwapInterval(int value) {
ContextGL current_context = ContextGL.getCurrentContext();
if (current_context == null)
throw new IllegalStateException("No context is current");
PeerInfo peer_info = current_context.getPeerInfo();
synchronized (current_context) {
LinuxDisplay.lockAWT();
try {
ByteBuffer peer_handle = peer_info.lockAndGetHandle();
try {
nSetSwapInterval(peer_handle, current_context.getHandle(), value);
} finally {
peer_info.unlock();
}
} catch (LWJGLException e) {
// API CHANGE - this methods should throw LWJGLException
e.printStackTrace();
} finally {
LinuxDisplay.unlockAWT();
}
}
}
use of org.lwjgl.LWJGLException in project lwjgl by LWJGL.
the class CL method create.
public static void create() throws LWJGLException {
if (created)
return;
//throw new IllegalStateException("OpenCL has already been created.");
final String libname;
final String[] library_names;
switch(LWJGLUtil.getPlatform()) {
case LWJGLUtil.PLATFORM_WINDOWS:
libname = "OpenCL";
library_names = new String[] { "OpenCL.dll" };
break;
case LWJGLUtil.PLATFORM_LINUX:
libname = "OpenCL";
// TODO: Fix this
library_names = new String[] { "libOpenCL64.so", "libOpenCL.so" };
break;
case LWJGLUtil.PLATFORM_MACOSX:
libname = "OpenCL";
// TODO: Fix this
library_names = new String[] { "OpenCL.dylib" };
break;
default:
throw new LWJGLException("Unknown platform: " + LWJGLUtil.getPlatform());
}
final String[] oclPaths = LWJGLUtil.getLibraryPaths(libname, library_names, CL.class.getClassLoader());
LWJGLUtil.log("Found " + oclPaths.length + " OpenCL paths");
for (String oclPath : oclPaths) {
try {
nCreate(oclPath);
created = true;
break;
} catch (LWJGLException e) {
LWJGLUtil.log("Failed to load " + oclPath + ": " + e.getMessage());
}
}
if (!created && LWJGLUtil.getPlatform() == LWJGLUtil.PLATFORM_MACOSX) {
// Try to load OpenCL from the framework instead
nCreateDefault();
created = true;
}
if (!created)
throw new LWJGLException("Could not locate OpenCL library.");
if (!CLCapabilities.OpenCL10)
throw new RuntimeException("OpenCL 1.0 not supported.");
}
use of org.lwjgl.LWJGLException in project lwjgl by LWJGL.
the class DrawableGLES method initialize.
public void initialize(final long window, final long display_id, final int eglSurfaceType, final org.lwjgl.opengles.PixelFormat pf) throws LWJGLException {
synchronized (GlobalLock.lock) {
if (eglSurface != null) {
eglSurface.destroy();
eglSurface = null;
}
if (eglDisplay != null) {
eglDisplay.terminate();
eglDisplay = null;
}
final EGLDisplay eglDisplay = eglGetDisplay((int) display_id);
int[] attribs = { EGL_LEVEL, 0, EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, EGL_NATIVE_RENDERABLE, EGL_FALSE };
final EGLConfig[] configs = eglDisplay.chooseConfig(pf.getAttribBuffer(eglDisplay, eglSurfaceType, attribs), null, BufferUtils.createIntBuffer(1));
if (configs.length == 0)
throw new LWJGLException("No EGLConfigs found for the specified PixelFormat.");
final EGLConfig eglConfig = pf.getBestMatch(configs);
final EGLSurface eglSurface = eglDisplay.createWindowSurface(eglConfig, window, null);
pf.setSurfaceAttribs(eglSurface);
this.eglDisplay = eglDisplay;
this.eglConfig = eglConfig;
this.eglSurface = eglSurface;
// This can happen when switching in and out of full-screen mode.
if (context != null)
context.getEGLContext().setDisplay(eglDisplay);
}
}
use of org.lwjgl.LWJGLException in project lwjgl by LWJGL.
the class LinuxAWTGLCanvasPeerInfo method doLockAndInitHandle.
protected void doLockAndInitHandle() throws LWJGLException {
ByteBuffer surface_handle = awt_surface.lockAndGetHandle(component);
if (screen == -1) {
try {
screen = getScreenFromSurfaceInfo(surface_handle);
} catch (LWJGLException e) {
LWJGLUtil.log("Got exception while trying to determine screen: " + e);
screen = 0;
}
}
nInitHandle(screen, surface_handle, getHandle());
}
Aggregations