From f1fee0624b28bab04515236187e0f5ac994675fe Mon Sep 17 00:00:00 2001 From: Ioannis Tsakpinis Date: Sun, 10 Jul 2011 17:45:43 +0000 Subject: [PATCH] Replaced Display.createES() with Display.create(ContextType.GLES). --- src/java/org/lwjgl/opengl/ContextType.java | 45 +++++++++++++++++++++ src/java/org/lwjgl/opengl/Display.java | 47 +++++++++++++--------- 2 files changed, 72 insertions(+), 20 deletions(-) create mode 100644 src/java/org/lwjgl/opengl/ContextType.java diff --git a/src/java/org/lwjgl/opengl/ContextType.java b/src/java/org/lwjgl/opengl/ContextType.java new file mode 100644 index 00000000..d719fec9 --- /dev/null +++ b/src/java/org/lwjgl/opengl/ContextType.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2002-2011 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.lwjgl.opengl; + +/** + * This enum can be used in the default Display.create method to specify + * the context type that will be created. + * + * @author Spasi + */ +public enum ContextType { + + GL, + GLES, + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/opengl/Display.java b/src/java/org/lwjgl/opengl/Display.java index ed28129e..c4a13e57 100644 --- a/src/java/org/lwjgl/opengl/Display.java +++ b/src/java/org/lwjgl/opengl/Display.java @@ -729,6 +729,32 @@ public final class Display { }); } + /** + * Create the Display with the specified context type. 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. + *

+ *

The window created will be set up in orthographic 2D projection, with 1:1 pixel ratio with GL coordinates. + * + * @param type the context type to create + * + * @throws LWJGLException + */ + public static void create(ContextType type) throws LWJGLException { + synchronized ( GlobalLock.lock ) { + switch ( type ) { + case GL: + create(new PixelFormat()); + break; + case GLES: + create(new org.lwjgl.opengles.PixelFormat()); + break; + } + } + } + /** * Create the OpenGL context. 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 @@ -741,9 +767,7 @@ public final class Display { * @throws LWJGLException */ public static void create() throws LWJGLException { - synchronized ( GlobalLock.lock ) { - create(new PixelFormat()); - } + create(ContextType.GL); } /** @@ -877,23 +901,6 @@ public final class Display { } } - /** - * Create the OpenGL ES context. 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. - *

- *

The window created will be set up in orthographic 2D projection, with 1:1 pixel ratio with GL coordinates. - * - * @throws LWJGLException - */ - public static void createES() throws LWJGLException { - synchronized ( GlobalLock.lock ) { - create(new org.lwjgl.opengles.PixelFormat()); - } - } - /** * 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