/** * Create the OpenGL ES context with the given minimum parameters. If isFullscreen() is true or if * windowed context are not supported on the platform, the display mode will be switched to the * mode returned by getDisplayMode(), and a fullscreen context will be created. If isFullscreen() * is false, a windowed context will be created with the dimensions given in the mode returned by * getDisplayMode(). If a context can't be created with the given parameters, a LWJGLException * will be thrown. * * <p> * * <p>The window created will be set up in orthographic 2D projection, with 1:1 pixel ratio with * GL coordinates. * * @param pixel_format Describes the minimum specifications the context must fulfill. Must be an * instance of org.lwjgl.opengles.PixelFormat. * @param shared_drawable The Drawable to share context with. (optional, may be null) * @param attribs The ContextAttribs to use when creating the context. (optional, may be null) * @throws LWJGLException */ public static void create( PixelFormatLWJGL pixel_format, Drawable shared_drawable, org.lwjgl.opengles.ContextAttribs attribs) throws LWJGLException { synchronized (GlobalLock.lock) { if (isCreated()) throw new IllegalStateException( "Only one LWJGL context may be instantiated at any one time."); if (pixel_format == null) throw new NullPointerException("pixel_format cannot be null"); removeShutdownHook(); registerShutdownHook(); if (isFullscreen()) switchDisplayMode(); final DrawableGLES drawable = new DrawableGLES() { public void setPixelFormat(final PixelFormatLWJGL pf, final ContextAttribs attribs) throws LWJGLException { throw new UnsupportedOperationException(); } public void destroy() { synchronized (GlobalLock.lock) { if (!isCreated()) return; releaseDrawable(); super.destroy(); destroyWindow(); x = y = -1; cached_icons = null; reset(); removeShutdownHook(); } } }; Display.drawable = drawable; try { drawable.setPixelFormat(pixel_format); try { createWindow(); try { drawable.createContext(attribs, shared_drawable); try { makeCurrentAndSetSwapInterval(); initContext(); } catch (LWJGLException e) { drawable.destroy(); throw e; } } catch (LWJGLException e) { destroyWindow(); throw e; } } catch (LWJGLException e) { drawable.destroy(); throw e; } } catch (LWJGLException e) { display_impl.resetDisplayMode(); throw e; } } }
/** * Create the OpenGL context with the given minimum parameters. If isFullscreen() is true or if * windowed context are not supported on the platform, the display mode will be switched to the * mode returned by getDisplayMode(), and a fullscreen context will be created. If isFullscreen() * is false, a windowed context will be created with the dimensions given in the mode returned by * getDisplayMode(). If a context can't be created with the given parameters, a LWJGLException * will be thrown. * * <p> * * <p>The window created will be set up in orthographic 2D projection, with 1:1 pixel ratio with * GL coordinates. * * @param pixel_format Describes the minimum specifications the context must fulfill. * @param shared_drawable The Drawable to share context with. (optional, may be null) * @param attribs The ContextAttribs to use when creating the context. (optional, may be null) * @throws LWJGLException */ public static void create( PixelFormat pixel_format, Drawable shared_drawable, ContextAttribs attribs) throws LWJGLException { synchronized (GlobalLock.lock) { if (isCreated()) throw new IllegalStateException( "Only one LWJGL context may be instantiated at any one time."); if (pixel_format == null) throw new NullPointerException("pixel_format cannot be null"); removeShutdownHook(); registerShutdownHook(); if (isFullscreen()) switchDisplayMode(); final DrawableGL drawable = new DrawableGL() { public void destroy() { synchronized (GlobalLock.lock) { if (!isCreated()) return; releaseDrawable(); super.destroy(); destroyWindow(); x = y = -1; cached_icons = null; reset(); removeShutdownHook(); } } }; Display.drawable = drawable; try { drawable.setPixelFormat(pixel_format, attribs); try { createWindow(); try { drawable.context = new ContextGL( drawable.peer_info, attribs, shared_drawable != null ? ((DrawableGL) shared_drawable).getContext() : null); try { makeCurrentAndSetSwapInterval(); initContext(); } catch (LWJGLException e) { drawable.destroy(); throw e; } } catch (LWJGLException e) { destroyWindow(); throw e; } } catch (LWJGLException e) { drawable.destroy(); throw e; } } catch (LWJGLException e) { display_impl.resetDisplayMode(); throw e; } } }