Search in sources :

Example 36 with LWJGLException

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);
    }
}
Also used : Method(java.lang.reflect.Method) LWJGLException(org.lwjgl.LWJGLException) LWJGLException(org.lwjgl.LWJGLException)

Example 37 with LWJGLException

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();
        }
    }
}
Also used : ByteBuffer(java.nio.ByteBuffer) LWJGLException(org.lwjgl.LWJGLException)

Example 38 with LWJGLException

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.");
}
Also used : LWJGLException(org.lwjgl.LWJGLException)

Example 39 with LWJGLException

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);
    }
}
Also used : LWJGLException(org.lwjgl.LWJGLException)

Example 40 with LWJGLException

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());
}
Also used : ByteBuffer(java.nio.ByteBuffer) LWJGLException(org.lwjgl.LWJGLException)

Aggregations

LWJGLException (org.lwjgl.LWJGLException)44 ByteBuffer (java.nio.ByteBuffer)6 Pbuffer (org.lwjgl.opengl.Pbuffer)4 EnhancedRuntimeException (net.minecraftforge.fml.common.EnhancedRuntimeException)3 GLCanvas (org.eclipse.swt.opengl.GLCanvas)3 GLData (org.eclipse.swt.opengl.GLData)3 DisplayMode (org.lwjgl.opengl.DisplayMode)3 PixelFormat (org.lwjgl.opengl.PixelFormat)3 GdxRuntimeException (com.badlogic.gdx.utils.GdxRuntimeException)2 Method (java.lang.reflect.Method)2 FloatBuffer (java.nio.FloatBuffer)2 IntBuffer (java.nio.IntBuffer)2 ArrayList (java.util.ArrayList)2 StringTokenizer (java.util.StringTokenizer)2 Sphere (org.lwjgl.util.glu.Sphere)2 LifecycleListener (com.badlogic.gdx.LifecycleListener)1 LwjglApplication (com.badlogic.gdx.backends.lwjgl.LwjglApplication)1 LwjglApplicationConfiguration (com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration)1 JmeCursor (com.jme3.cursors.plugins.JmeCursor)1 DefaultPlatformChooser (com.jme3.opencl.DefaultPlatformChooser)1