|
From: <eli...@us...> - 2008-09-11 09:52:31
|
Revision: 3126
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3126&view=rev
Author: elias_naur
Date: 2008-09-11 09:52:23 +0000 (Thu, 11 Sep 2008)
Log Message:
-----------
Mac OS X: Be less aggressive when grabbing mouse to allow dragging of lwjgl windows with grabbed mouse
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java
trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXFrame.java
trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXMouseEventQueue.java
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java 2008-09-09 17:58:17 UTC (rev 3125)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java 2008-09-11 09:52:23 UTC (rev 3126)
@@ -283,8 +283,11 @@
GL11.glGetInteger(GL11.GL_VIEWPORT, current_viewport);
GL11.glViewport(current_viewport.get(0), current_viewport.get(1), current_viewport.get(2), current_viewport.get(3));
}
- if (frame != null && frame.syncShouldWarpCursor() && mouse_queue != null) {
- mouse_queue.warpCursor();
+ if (frame != null && mouse_queue != null) {
+ if (frame.syncShouldReleaseCursor())
+ MacOSXMouseEventQueue.nGrabMouse(false);
+ if (frame.syncShouldWarpCursor())
+ mouse_queue.warpCursor();
}
}
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXFrame.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXFrame.java 2008-09-09 17:58:17 UTC (rev 3125)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXFrame.java 2008-09-11 09:52:23 UTC (rev 3126)
@@ -65,6 +65,7 @@
private boolean active;
private boolean minimized;
private boolean should_warp_cursor;
+ private boolean should_release_cursor;
MacOSXFrame(DisplayMode mode, final java.awt.DisplayMode requested_mode, boolean fullscreen, int x, int y) throws LWJGLException {
setResizable(false);
@@ -169,6 +170,8 @@
public void windowDeactivated(WindowEvent e) {
synchronized ( this ) {
active = false;
+ should_release_cursor = true;
+ should_warp_cursor = false;
}
}
@@ -176,6 +179,7 @@
synchronized ( this ) {
active = true;
should_warp_cursor = true;
+ should_release_cursor = false;
}
}
@@ -204,6 +208,15 @@
return canvas;
}
+ public boolean syncShouldReleaseCursor() {
+ boolean result;
+ synchronized ( this ) {
+ result = should_release_cursor;
+ should_release_cursor = false;
+ }
+ return result;
+ }
+
public boolean syncShouldWarpCursor() {
boolean result;
synchronized ( this ) {
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXMouseEventQueue.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXMouseEventQueue.java 2008-09-09 17:58:17 UTC (rev 3125)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXMouseEventQueue.java 2008-09-11 09:52:23 UTC (rev 3126)
@@ -62,7 +62,8 @@
private static synchronized void grabMouse(boolean grab) {
if (is_grabbed != grab) {
is_grabbed = grab;
- nGrabMouse(grab);
+ if (!grab)
+ nGrabMouse(grab);
}
}
@@ -80,6 +81,7 @@
int dy = -delta_buffer.get(1);
if (skip_event) {
skip_event = false;
+ nGrabMouse(isGrabbed());
return;
}
if ( dx != 0 || dy != 0 ) {
@@ -94,13 +96,13 @@
// If we're going to warp the cursor position, we'll skip the next event to avoid bogus delta values
skip_event = isGrabbed();
}
- if (isGrabbed()) {
+/* if (isGrabbed()) {
Rectangle bounds = getComponent().getBounds();
Point location_on_screen = getComponent().getLocationOnScreen();
int x = location_on_screen.x + bounds.width/2;
int y = location_on_screen.y + bounds.height/2;
nWarpCursor(x, y);
- }
+ }*/
}
private static native void getMouseDeltas(IntBuffer delta_buffer);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <eli...@us...> - 2008-10-28 10:06:37
|
Revision: 3141
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3141&view=rev
Author: elias_naur
Date: 2008-10-28 10:05:37 +0000 (Tue, 28 Oct 2008)
Log Message:
-----------
Removed redundant fullscreen argument from DisplayImplementation.createWindow
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java
trunk/LWJGL/src/java/org/lwjgl/opengl/DisplayImplementation.java
trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java
trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java
trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java 2008-10-28 09:54:25 UTC (rev 3140)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java 2008-10-28 10:05:37 UTC (rev 3141)
@@ -305,7 +305,7 @@
tmp_parent.addComponentListener(component_listener);
}
DisplayMode mode = getEffectiveMode();
- display_impl.createWindow(mode, isFullscreen(), tmp_parent, getWindowX(), getWindowY());
+ display_impl.createWindow(mode, tmp_parent, getWindowX(), getWindowY());
window_created = true;
setTitle(title);
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/DisplayImplementation.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/DisplayImplementation.java 2008-10-28 09:54:25 UTC (rev 3140)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/DisplayImplementation.java 2008-10-28 10:05:37 UTC (rev 3141)
@@ -47,7 +47,7 @@
interface DisplayImplementation extends InputImplementation {
- void createWindow(DisplayMode mode, boolean fullscreen, Canvas parent, int x, int y) throws LWJGLException;
+ void createWindow(DisplayMode mode, Canvas parent, int x, int y) throws LWJGLException;
void destroyWindow();
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2008-10-28 09:54:25 UTC (rev 3140)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2008-10-28 10:05:37 UTC (rev 3141)
@@ -417,14 +417,14 @@
ungrabKeyboard();
}
- public void createWindow(DisplayMode mode, boolean fullscreen, Canvas parent, int x, int y) throws LWJGLException {
+ public void createWindow(DisplayMode mode, Canvas parent, int x, int y) throws LWJGLException {
lockAWT();
try {
incDisplay();
try {
ByteBuffer handle = peer_info.lockAndGetHandle();
try {
- current_window_mode = getWindowMode(fullscreen);
+ current_window_mode = getWindowMode(Display.isFullscreen());
boolean undecorated = Display.getPrivilegedBoolean("org.lwjgl.opengl.Window.undecorated") || current_window_mode != WINDOWED;
this.parent = parent;
parent_window = parent != null ? getHandle(parent) : getRootWindow(getDisplay(), getDefaultScreen());
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java 2008-10-28 09:54:25 UTC (rev 3140)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java 2008-10-28 10:05:37 UTC (rev 3141)
@@ -94,7 +94,8 @@
}
}
- public void createWindow(DisplayMode mode, boolean fullscreen, Canvas parent, int x, int y) throws LWJGLException {
+ public void createWindow(DisplayMode mode, Canvas parent, int x, int y) throws LWJGLException {
+ boolean fullscreen = Display.isFullscreen();
hideUI(fullscreen);
close_requested = false;
try {
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2008-10-28 09:54:25 UTC (rev 3140)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2008-10-28 10:05:37 UTC (rev 3141)
@@ -138,7 +138,6 @@
private DisplayMode current_mode;
private boolean mode_set;
- private boolean isFullscreen;
private boolean isMinimized;
private boolean isFocused;
private boolean did_maximize;
@@ -154,16 +153,15 @@
current_display = this;
}
- public void createWindow(DisplayMode mode, boolean fullscreen, Canvas parent, int x, int y) throws LWJGLException {
+ public void createWindow(DisplayMode mode, Canvas parent, int x, int y) throws LWJGLException {
close_requested = false;
is_dirty = false;
- isFullscreen = fullscreen;
isMinimized = false;
isFocused = false;
did_maximize = false;
this.parent = parent;
long parent_hwnd = parent != null ? getHwnd(parent) : 0;
- this.hwnd = nCreateWindow(x, y, mode.getWidth(), mode.getHeight(), fullscreen || isUndecorated(), parent != null, parent_hwnd);
+ this.hwnd = nCreateWindow(x, y, mode.getWidth(), mode.getHeight(), Display.isFullscreen() || isUndecorated(), parent != null, parent_hwnd);
if (hwnd == 0) {
throw new LWJGLException("Failed to create window");
}
@@ -259,7 +257,7 @@
inAppActivate = true;
isFocused = active;
if (active) {
- if (isFullscreen) {
+ if (Display.isFullscreen()) {
restoreDisplayMode();
}
if (parent == null) {
@@ -268,9 +266,9 @@
setFocus(getHwnd());
}
did_maximize = true;
- if (isFullscreen)
+ if (Display.isFullscreen())
updateClipping();
- } else if (isFullscreen) {
+ } else if (Display.isFullscreen()) {
showWindow(getHwnd(), SW_SHOWMINNOACTIVE);
resetDisplayMode();
} else
@@ -420,7 +418,7 @@
private static native void nUpdate();
public void reshape(int x, int y, int width, int height) {
- nReshape(getHwnd(), x, y, width, height, isFullscreen || isUndecorated(), parent != null);
+ nReshape(getHwnd(), x, y, width, height, Display.isFullscreen() || isUndecorated(), parent != null);
}
private static native void nReshape(long hwnd, int x, int y, int width, int height, boolean undecorated, boolean child);
public native DisplayMode[] getAvailableDisplayModes() throws LWJGLException;
@@ -723,7 +721,7 @@
}
private void updateClipping() {
- if ((isFullscreen || (mouse != null && mouse.isGrabbed())) && !isMinimized && isFocused && getForegroundWindow() == getHwnd()) {
+ if ((Display.isFullscreen() || (mouse != null && mouse.isGrabbed())) && !isMinimized && isFocused && getForegroundWindow() == getHwnd()) {
try {
setupCursorClipping(getHwnd());
} catch (LWJGLException e) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <eli...@us...> - 2008-12-28 17:50:14
|
Revision: 3171
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3171&view=rev
Author: elias_naur
Date: 2008-12-28 17:50:08 +0000 (Sun, 28 Dec 2008)
Log Message:
-----------
Renamed DisplayMode.isFullscreen() to DisplayMode.isFullscreenCapable and made it public
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java
trunk/LWJGL/src/java/org/lwjgl/opengl/DisplayMode.java
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java 2008-12-22 16:51:26 UTC (rev 3170)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java 2008-12-28 17:50:08 UTC (rev 3171)
@@ -351,7 +351,7 @@
}
private static void switchDisplayMode() throws LWJGLException {
- if ( !current_mode.isFullscreen() ) {
+ if ( !current_mode.isFullscreenCapable() ) {
throw new IllegalStateException("Only modes acquired from getAvailableDisplayModes() can be used for fullscreen display");
}
display_impl.switchDisplayMode(current_mode);
@@ -524,7 +524,7 @@
/** @return whether the Display is in fullscreen mode */
public static boolean isFullscreen() {
synchronized (GlobalLock.lock) {
- return fullscreen && current_mode.isFullscreen();
+ return fullscreen && current_mode.isFullscreenCapable();
}
}
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/DisplayMode.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/DisplayMode.java 2008-12-22 16:51:26 UTC (rev 3170)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/DisplayMode.java 2008-12-28 17:50:08 UTC (rev 3171)
@@ -76,7 +76,7 @@
}
/** True iff this instance can be used for fullscreen modes */
- boolean isFullscreen() {
+ public boolean isFullscreenCapable() {
return fullscreen;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sp...@us...> - 2010-02-10 11:22:23
|
Revision: 3272
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3272&view=rev
Author: spasi
Date: 2010-02-10 11:22:16 +0000 (Wed, 10 Feb 2010)
Log Message:
-----------
Changed BaseReferences to use GL20.GL_MAX_TEXTURE_IMAGE_UNITS when available (GL13.GL_MAX_TEXTURE_UNITS is deprecated).
Catch and log OpenGL errors during context creation, instead of throwing an exception.
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/opengl/BaseReferences.java
trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/BaseReferences.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/BaseReferences.java 2010-02-09 15:22:58 UTC (rev 3271)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/BaseReferences.java 2010-02-10 11:22:16 UTC (rev 3272)
@@ -58,7 +58,10 @@
glVertexAttribPointer_buffer = new Buffer[max_vertex_attribs];
int max_texture_units;
- if (caps.OpenGL13 || caps.GL_ARB_multitexture) {
+ if (caps.OpenGL20) {
+ GL11.glGetInteger(GL20.GL_MAX_TEXTURE_IMAGE_UNITS, temp);
+ max_texture_units = temp.get(0);
+ } else if (caps.OpenGL13 || caps.GL_ARB_multitexture) {
GL11.glGetInteger(GL13.GL_MAX_TEXTURE_UNITS, temp);
max_texture_units = temp.get(0);
} else
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java 2010-02-09 15:22:58 UTC (rev 3271)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java 2010-02-10 11:22:16 UTC (rev 3272)
@@ -881,7 +881,11 @@
private static void makeCurrentAndSetSwapInterval() throws LWJGLException {
makeCurrent();
- Util.checkGLError();
+ try {
+ Util.checkGLError();
+ } catch (OpenGLException e) {
+ LWJGLUtil.log("OpenGL error during context creation: " + e.getMessage());
+ }
setSwapInterval(swap_interval);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2010-04-22 18:32:53
|
Revision: 3333
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3333&view=rev
Author: kappa1
Date: 2010-04-22 18:32:46 +0000 (Thu, 22 Apr 2010)
Log Message:
-----------
Remove extra permissions from XRandR and just allow minimal permissions needed by the LinuxDisplay.
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java
trunk/LWJGL/src/java/org/lwjgl/opengl/XRandR.java
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2010-04-20 18:21:05 UTC (rev 3332)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2010-04-22 18:32:46 UTC (rev 3333)
@@ -48,6 +48,9 @@
import org.lwjgl.LWJGLUtil;
import org.lwjgl.opengl.XRandR.Screen;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
final class LinuxDisplay implements DisplayImplementation {
/* X11 constants */
public final static int CurrentTime = 0;
@@ -524,7 +527,12 @@
try {
if( current_displaymode_extension == XRANDR && savedXrandrConfig.length > 0 )
{
- XRandR.setConfiguration( savedXrandrConfig );
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ XRandR.setConfiguration( savedXrandrConfig );
+ return null;
+ }
+ });
}
else
{
@@ -615,7 +623,11 @@
throw new LWJGLException("No modes available");
switch (current_displaymode_extension) {
case XRANDR:
- savedXrandrConfig = XRandR.getConfiguration();
+ savedXrandrConfig = (Screen[])AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ return XRandR.getConfiguration();
+ }
+ });
saved_mode = getCurrentXRandrMode();
break;
case XF86VIDMODE:
@@ -890,7 +902,12 @@
try {
if( current_displaymode_extension == XRANDR && savedXrandrConfig.length > 0 )
{
- XRandR.setConfiguration( savedXrandrConfig );
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ XRandR.setConfiguration( savedXrandrConfig );
+ return null;
+ }
+ });
}
else
{
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/XRandR.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/XRandR.java 2010-04-20 18:21:05 UTC (rev 3332)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/XRandR.java 2010-04-22 18:32:46 UTC (rev 3333)
@@ -40,8 +40,6 @@
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
/**
* Utility for working with the xrandr commmand-line utility. Assumes
@@ -105,12 +103,7 @@
* xrandr is not supported
*/
public static Screen[] getConfiguration() {
- AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- populate();
- return null;
- }
- });
+ populate();
return (Screen[]) current.clone();
}
@@ -119,20 +112,11 @@
* @param screens
* The desired screen set, may not be <code>null</code>
*/
- public static void setConfiguration(final Screen[]/* ... */screens) {
+ public static void setConfiguration(Screen[]/* ... */screens) {
if (screens.length == 0) {
throw new IllegalArgumentException("Must specify at least one screen");
}
-
- AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- setScreen(screens);
- return null;
- }
- });
- }
-
- private static void setScreen(Screen[] screens) {
+
List/* <String> */cmd = new ArrayList/* <String> */();
cmd.add("xrandr");
@@ -173,6 +157,7 @@
} catch (IOException e) {
e.printStackTrace();
}
+
}
/**
@@ -180,13 +165,7 @@
* xrandr is not supported
*/
public static String[] getScreenNames() {
- AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- populate();
- return null;
- }
- });
-
+ populate();
return (String[]) screens.keySet().toArray(new String[screens.size()]);
}
@@ -196,13 +175,7 @@
* <code>null</code> if there is no such screen
*/
public static Screen[] getResolutions(String name) {
- AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- populate();
- return null;
- }
- });
-
+ populate();
// clone the array to prevent held copies being altered
return (Screen[]) ((Screen[]) screens.get(name)).clone();
}
@@ -274,4 +247,4 @@
return name + " " + width + "x" + height + " @ " + xPos + "x" + yPos;
}
}
-}
+}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sp...@us...> - 2011-07-10 17:45:50
|
Revision: 3562
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3562&view=rev
Author: spasi
Date: 2011-07-10 17:45:43 +0000 (Sun, 10 Jul 2011)
Log Message:
-----------
Replaced Display.createES() with Display.create(ContextType.GLES).
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java
Added Paths:
-----------
trunk/LWJGL/src/java/org/lwjgl/opengl/ContextType.java
Added: trunk/LWJGL/src/java/org/lwjgl/opengl/ContextType.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/ContextType.java (rev 0)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/ContextType.java 2011-07-10 17:45:43 UTC (rev 3562)
@@ -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
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java 2011-07-10 16:58:16 UTC (rev 3561)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java 2011-07-10 17:45:43 UTC (rev 3562)
@@ -730,7 +730,7 @@
}
/**
- * Create the OpenGL context. If isFullscreen() is true or if windowed
+ * 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
@@ -738,15 +738,39 @@
* <p/>
* <p>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() throws LWJGLException {
+ public static void create(ContextType type) throws LWJGLException {
synchronized ( GlobalLock.lock ) {
- create(new PixelFormat());
+ 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
+ * 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.
+ *
+ * @throws LWJGLException
+ */
+ public static void create() throws LWJGLException {
+ create(ContextType.GL);
+ }
+
+ /**
* 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
@@ -878,23 +902,6 @@
}
/**
- * 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.
- * <p/>
- * <p>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
* getDisplayMode(), and a fullscreen context will be created. If isFullscreen() is false, a windowed context
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2011-07-12 22:07:38
|
Revision: 3582
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3582&view=rev
Author: kappa1
Date: 2011-07-12 22:07:32 +0000 (Tue, 12 Jul 2011)
Log Message:
-----------
Add placeholder methods for initial resizing api for the Display
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java
trunk/LWJGL/src/java/org/lwjgl/opengl/DisplayImplementation.java
trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java
trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java
trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java 2011-07-12 21:30:48 UTC (rev 3581)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java 2011-07-12 22:07:32 UTC (rev 3582)
@@ -1249,4 +1249,47 @@
}
}
}
+
+ /**
+ * Enable or disable the Display window to be resized.
+ *
+ * @param set true to make the Display window resizable;
+ * false to disable resizing on the Display window.
+ */
+ public static void setResizable(boolean resizable) {
+
+ }
+
+ /**
+ * @return true if the Display window is resizable.
+ */
+ public static boolean isResizable() {
+ return false;
+ }
+
+ /**
+ * @return true if the Display window has been resized.
+ * This value will be updated after a call to Display.update().
+ */
+ public static boolean wasResized() {
+ return false;
+ }
+
+ /**
+ * @return this method will return the width of the Display window.
+ *
+ * This value will be updated after a call to Display.update().
+ */
+ public static int getWidth() {
+ return 0;
+ }
+
+ /**
+ * @return this method will return the height of the Display window.
+ *
+ * This value will be updated after a call to Display.update().
+ */
+ public static int getHeight() {
+ return 0;
+ }
}
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/DisplayImplementation.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/DisplayImplementation.java 2011-07-12 21:30:48 UTC (rev 3581)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/DisplayImplementation.java 2011-07-12 22:07:32 UTC (rev 3582)
@@ -159,4 +159,32 @@
* @return number of icons used.
*/
int setIcon(ByteBuffer[] icons);
+
+ /**
+ * Enable or disable the Display window to be resized.
+ *
+ * @param set true to make the Display window resizable;
+ * false to disable resizing on the Display window.
+ */
+ void setResizable(boolean resizable);
+
+ /**
+ * @return true if the Display window is resizable.
+ */
+ boolean isResizable();
+
+ /**
+ * @return true if the Display window has been resized.
+ */
+ boolean wasResized();
+
+ /**
+ * @return this method will return a the width of the Display window.
+ */
+ int getWidth();
+
+ /**
+ * @return this method will return a the height of the Display window.
+ */
+ int getHeight();
}
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2011-07-12 21:30:48 UTC (rev 3581)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2011-07-12 22:07:32 UTC (rev 3582)
@@ -1356,6 +1356,18 @@
public boolean isInsideWindow() {
return mouseInside;
}
+
+ public void setResizable(boolean resizable) {
+
+ }
+
+ public boolean isResizable() {
+ return false;
+ }
+
+ public boolean wasResized() {
+ return false;
+ }
/**
* Helper class for managing Compiz's workarounds. We need this to enable Legacy
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java 2011-07-12 21:30:48 UTC (rev 3581)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java 2011-07-12 22:07:32 UTC (rev 3582)
@@ -504,7 +504,20 @@
return Display.getDisplayMode().getHeight();
}
- public boolean isInsideWindow() {
- return true;
- }
+ public boolean isInsideWindow() {
+ return true;
+ }
+
+ public void setResizable(boolean resizable) {
+
+ }
+
+ public boolean isResizable() {
+ return false;
+ }
+
+ public boolean wasResized() {
+ return false;
+ }
+
}
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2011-07-12 21:30:48 UTC (rev 3581)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2011-07-12 22:07:32 UTC (rev 3582)
@@ -935,11 +935,23 @@
return -1;
}
- private native boolean nTrackMouseEvent(long hwnd);
+ private native boolean nTrackMouseEvent(long hwnd);
- public boolean isInsideWindow() {
- return mouseInside;
- }
+ public boolean isInsideWindow() {
+ return mouseInside;
+ }
+
+ public void setResizable(boolean resizable) {
+
+ }
+
+ public boolean isResizable() {
+ return false;
+ }
+
+ public boolean wasResized() {
+ return false;
+ }
private static final class Rect {
public int top;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2011-07-13 22:15:41
|
Revision: 3586
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3586&view=rev
Author: kappa1
Date: 2011-07-13 22:15:35 +0000 (Wed, 13 Jul 2011)
Log Message:
-----------
Implement Resizing Display API for OS X
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java
trunk/LWJGL/src/java/org/lwjgl/opengl/DisplayImplementation.java
trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java
trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXCanvasListener.java
trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java
trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXFrame.java
trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java 2011-07-13 22:15:25 UTC (rev 3585)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java 2011-07-13 22:15:35 UTC (rev 3586)
@@ -93,6 +93,12 @@
* unlike GL, where it is typically at the bottom of the display.
*/
private static int y = -1;
+
+ /** the width of the Display window */
+ private static int width = 0;
+
+ /** the height of the Display window */
+ private static int height = 0;
/** Title of the window (never null) */
private static String title = "Game";
@@ -109,6 +115,10 @@
private static boolean window_created;
private static boolean parent_resized;
+
+ private static boolean window_resized;
+
+ private static boolean window_resizable;
/** Initial Background Color of Display */
private static float r, g, b;
@@ -295,6 +305,9 @@
DisplayMode mode = getEffectiveMode();
display_impl.createWindow(drawable, mode, tmp_parent, getWindowX(), getWindowY());
window_created = true;
+
+ width = Display.getDisplayMode().getWidth();
+ height = Display.getDisplayMode().getHeight();
setTitle(title);
initControls();
@@ -661,6 +674,13 @@
throw new RuntimeException(e);
}
}
+
+ window_resized = !isFullscreen() && parent == null && display_impl.wasResized();
+
+ if ( window_resized ) {
+ width = display_impl.getWidth();
+ height = display_impl.getHeight();
+ }
if ( parent_resized ) {
reshape();
@@ -1257,14 +1277,17 @@
* false to disable resizing on the Display window.
*/
public static void setResizable(boolean resizable) {
-
+ window_resizable = resizable;
+ if ( isCreated() ) {
+ display_impl.setResizable(resizable);
+ }
}
/**
* @return true if the Display window is resizable.
*/
public static boolean isResizable() {
- return false;
+ return window_resizable;
}
/**
@@ -1274,7 +1297,7 @@
* This will return false if running in fullscreen or with Display.setParent(Canvas parent)
*/
public static boolean wasResized() {
- return false;
+ return window_resized;
}
/**
@@ -1287,7 +1310,16 @@
* This value will be updated after a call to Display.update().
*/
public static int getWidth() {
- return 0;
+
+ if (Display.isFullscreen()) {
+ return Display.getDisplayMode().getWidth();
+ }
+
+ if (parent != null) {
+ return parent.getWidth();
+ }
+
+ return width;
}
/**
@@ -1300,6 +1332,15 @@
* This value will be updated after a call to Display.update().
*/
public static int getHeight() {
- return 0;
+
+ if (Display.isFullscreen()) {
+ return Display.getDisplayMode().getHeight();
+ }
+
+ if (parent != null) {
+ return parent.getHeight();
+ }
+
+ return height;
}
}
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/DisplayImplementation.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/DisplayImplementation.java 2011-07-13 22:15:25 UTC (rev 3585)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/DisplayImplementation.java 2011-07-13 22:15:35 UTC (rev 3586)
@@ -169,13 +169,8 @@
void setResizable(boolean resizable);
/**
- * @return true if the Display window is resizable.
+ * @return true if the Display window has been resized since this method was last called.
*/
- boolean isResizable();
-
- /**
- * @return true if the Display window has been resized.
- */
boolean wasResized();
/**
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2011-07-13 22:15:25 UTC (rev 3585)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2011-07-13 22:15:35 UTC (rev 3586)
@@ -1361,10 +1361,6 @@
}
- public boolean isResizable() {
- return false;
- }
-
public boolean wasResized() {
return false;
}
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXCanvasListener.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXCanvasListener.java 2011-07-13 22:15:25 UTC (rev 3585)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXCanvasListener.java 2011-07-13 22:15:35 UTC (rev 3586)
@@ -47,6 +47,7 @@
private int width;
private int height;
private boolean context_update;
+ private boolean resized;
MacOSXCanvasListener(Canvas canvas) {
this.canvas = canvas;
@@ -102,6 +103,7 @@
public void componentResized(ComponentEvent e) {
setUpdate();
+ resized = true;
}
public void componentMoved(ComponentEvent e) {
@@ -111,4 +113,13 @@
public void hierarchyChanged(HierarchyEvent e) {
setUpdate();
}
+
+ public boolean wasResized() {
+ if (resized) {
+ resized = false;
+ return true;
+ }
+
+ return false;
+ }
}
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java 2011-07-13 22:15:25 UTC (rev 3585)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java 2011-07-13 22:15:35 UTC (rev 3586)
@@ -497,11 +497,11 @@
}
public int getWidth() {
- return Display.getDisplayMode().getWidth();
+ return frame.getWidth();
}
public int getHeight() {
- return Display.getDisplayMode().getHeight();
+ return frame.getHeight();
}
public boolean isInsideWindow() {
@@ -509,15 +509,11 @@
}
public void setResizable(boolean resizable) {
-
+ frame.setResizable(resizable);
}
- public boolean isResizable() {
- return false;
- }
-
public boolean wasResized() {
- return false;
+ return canvas_listener.wasResized();
}
}
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXFrame.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXFrame.java 2011-07-13 22:15:25 UTC (rev 3585)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXFrame.java 2011-07-13 22:15:35 UTC (rev 3586)
@@ -68,7 +68,7 @@
private boolean should_release_cursor;
MacOSXFrame(DisplayMode mode, final java.awt.DisplayMode requested_mode, boolean fullscreen, int x, int y) throws LWJGLException {
- setResizable(false);
+ setResizable(Display.isResizable());
addWindowListener(this);
addComponentListener(this);
canvas = new MacOSXGLCanvas();
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2011-07-13 22:15:25 UTC (rev 3585)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2011-07-13 22:15:35 UTC (rev 3586)
@@ -945,10 +945,6 @@
}
- public boolean isResizable() {
- return false;
- }
-
public boolean wasResized() {
return false;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sp...@us...> - 2011-07-17 09:37:41
|
Revision: 3595
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3595&view=rev
Author: spasi
Date: 2011-07-17 09:37:35 +0000 (Sun, 17 Jul 2011)
Log Message:
-----------
Code cleanup.
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/opengl/APIUtil.java
trunk/LWJGL/src/java/org/lwjgl/opengles/APIUtil.java
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/APIUtil.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/APIUtil.java 2011-07-16 22:40:06 UTC (rev 3594)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/APIUtil.java 2011-07-17 09:37:35 UTC (rev 3595)
@@ -50,20 +50,29 @@
private static final int BUFFERS_SIZE = 32;
- private char[] arrayTL;
- private ByteBuffer bufferTL;
- private IntBuffer lengthsTL;
- private final Buffers buffersTL;
+ private char[] array;
+ private ByteBuffer buffer;
+ private IntBuffer lengths;
+ private final IntBuffer ints;
+ private final LongBuffer longs;
+ private final FloatBuffer floats;
+ private final DoubleBuffer doubles;
+
APIUtil() {
- arrayTL = new char[INITIAL_BUFFER_SIZE];
- bufferTL = BufferUtils.createByteBuffer(INITIAL_BUFFER_SIZE);
- lengthsTL = BufferUtils.createIntBuffer(INITIAL_LENGTHS_SIZE);
- buffersTL = new Buffers();
+ array = new char[INITIAL_BUFFER_SIZE];
+ buffer = BufferUtils.createByteBuffer(INITIAL_BUFFER_SIZE);
+ lengths = BufferUtils.createIntBuffer(INITIAL_LENGTHS_SIZE);
+
+ ints = BufferUtils.createIntBuffer(BUFFERS_SIZE);
+ longs = BufferUtils.createLongBuffer(BUFFERS_SIZE);
+
+ floats = BufferUtils.createFloatBuffer(BUFFERS_SIZE);
+ doubles = BufferUtils.createDoubleBuffer(BUFFERS_SIZE);
}
private static char[] getArray(final ContextCapabilities caps, final int size) {
- char[] array = caps.util.arrayTL;
+ char[] array = caps.util.array;
if ( array.length < size ) {
int sizeNew = array.length << 1;
@@ -71,14 +80,14 @@
sizeNew <<= 1;
array = new char[size];
- caps.util.arrayTL = array;
+ caps.util.array = array;
}
return array;
}
static ByteBuffer getBufferByte(final ContextCapabilities caps, final int size) {
- ByteBuffer buffer = caps.util.bufferTL;
+ ByteBuffer buffer = caps.util.buffer;
if ( buffer.capacity() < size ) {
int sizeNew = buffer.capacity() << 1;
@@ -86,7 +95,7 @@
sizeNew <<= 1;
buffer = BufferUtils.createByteBuffer(size);
- caps.util.bufferTL = buffer;
+ caps.util.buffer = buffer;
} else
buffer.clear();
@@ -94,7 +103,7 @@
}
private static ByteBuffer getBufferByteOffset(final ContextCapabilities caps, final int size) {
- ByteBuffer buffer = caps.util.bufferTL;
+ ByteBuffer buffer = caps.util.buffer;
if ( buffer.capacity() < size ) {
int sizeNew = buffer.capacity() << 1;
@@ -103,7 +112,7 @@
final ByteBuffer bufferNew = BufferUtils.createByteBuffer(size);
bufferNew.put(buffer);
- caps.util.bufferTL = (buffer = bufferNew);
+ caps.util.buffer = (buffer = bufferNew);
} else {
buffer.position(buffer.limit());
buffer.limit(buffer.capacity());
@@ -112,22 +121,20 @@
return buffer;
}
- static ShortBuffer getBufferShort(final ContextCapabilities caps) { return caps.util.buffersTL.shorts; }
+ static IntBuffer getBufferInt(final ContextCapabilities caps) { return caps.util.ints; }
- static IntBuffer getBufferInt(final ContextCapabilities caps) { return caps.util.buffersTL.ints; }
+ static LongBuffer getBufferLong(final ContextCapabilities caps) { return caps.util.longs; }
- static LongBuffer getBufferLong(final ContextCapabilities caps) { return caps.util.buffersTL.longs; }
+ static FloatBuffer getBufferFloat(final ContextCapabilities caps) { return caps.util.floats; }
- static FloatBuffer getBufferFloat(final ContextCapabilities caps) { return caps.util.buffersTL.floats; }
+ static DoubleBuffer getBufferDouble(final ContextCapabilities caps) { return caps.util.doubles; }
- static DoubleBuffer getBufferDouble(final ContextCapabilities caps) { return caps.util.buffersTL.doubles; }
-
static IntBuffer getLengths(final ContextCapabilities caps) {
return getLengths(caps, 1);
}
static IntBuffer getLengths(final ContextCapabilities caps, final int size) {
- IntBuffer lengths = caps.util.lengthsTL;
+ IntBuffer lengths = caps.util.lengths;
if ( lengths.capacity() < size ) {
int sizeNew = lengths.capacity();
@@ -135,7 +142,7 @@
sizeNew <<= 1;
lengths = BufferUtils.createIntBuffer(size);
- caps.util.lengthsTL = lengths;
+ caps.util.lengths = lengths;
} else
lengths.clear();
@@ -286,24 +293,4 @@
return MemoryUtil.getAddress0(getBufferByte(caps, 0));
}
- private static class Buffers {
-
- final ShortBuffer shorts;
- final IntBuffer ints;
- final LongBuffer longs;
-
- final FloatBuffer floats;
- final DoubleBuffer doubles;
-
- Buffers() {
- shorts = BufferUtils.createShortBuffer(BUFFERS_SIZE);
- ints = BufferUtils.createIntBuffer(BUFFERS_SIZE);
- longs = BufferUtils.createLongBuffer(BUFFERS_SIZE);
-
- floats = BufferUtils.createFloatBuffer(BUFFERS_SIZE);
- doubles = BufferUtils.createDoubleBuffer(BUFFERS_SIZE);
- }
-
- }
-
}
\ No newline at end of file
Modified: trunk/LWJGL/src/java/org/lwjgl/opengles/APIUtil.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengles/APIUtil.java 2011-07-16 22:40:06 UTC (rev 3594)
+++ trunk/LWJGL/src/java/org/lwjgl/opengles/APIUtil.java 2011-07-17 09:37:35 UTC (rev 3595)
@@ -39,9 +39,12 @@
import java.nio.ByteBuffer;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
-import java.nio.ShortBuffer;
-/** @author spasi */
+/**
+ * Utility class for OpenGL ES API calls.
+ *
+ * @author spasi
+ */
final class APIUtil {
private static final int INITIAL_BUFFER_SIZE = 256;
@@ -138,14 +141,10 @@
return buffer;
}
- static ShortBuffer getBufferShort() { return buffersTL.get().shorts; }
-
static IntBuffer getBufferInt() { return buffersTL.get().ints; }
static FloatBuffer getBufferFloat() { return buffersTL.get().floats; }
- static PointerBuffer getBufferPointer() { return buffersTL.get().pointers; }
-
static IntBuffer getLengths() {
return getLengths(1);
}
@@ -312,18 +311,12 @@
private static class Buffers {
- final ShortBuffer shorts;
final IntBuffer ints;
final FloatBuffer floats;
- final PointerBuffer pointers;
-
Buffers() {
- shorts = BufferUtils.createShortBuffer(BUFFERS_SIZE);
ints = BufferUtils.createIntBuffer(BUFFERS_SIZE);
floats = BufferUtils.createFloatBuffer(BUFFERS_SIZE);
-
- pointers = BufferUtils.createPointerBuffer(BUFFERS_SIZE);
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sp...@us...> - 2011-08-24 23:19:03
|
Revision: 3621
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3621&view=rev
Author: spasi
Date: 2011-08-24 23:18:56 +0000 (Wed, 24 Aug 2011)
Log Message:
-----------
Fixed Pbuffer init when Display has not been created.
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/opengl/Pbuffer.java
trunk/LWJGL/src/java/org/lwjgl/opengl/PixelFormat.java
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/Pbuffer.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/Pbuffer.java 2011-08-20 16:38:45 UTC (rev 3620)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/Pbuffer.java 2011-08-24 23:18:56 UTC (rev 3621)
@@ -217,11 +217,11 @@
this.width = width;
this.height = height;
this.peer_info = createPbuffer(width, height, pixel_format, renderTexture);
- Context shared_context;
+ Context shared_context = null;
+ if ( shared_drawable == null )
+ shared_drawable = Display.getDrawable(); // May be null
if (shared_drawable != null)
shared_context = ((DrawableLWJGL)shared_drawable).getContext();
- else
- shared_context = ((DrawableLWJGL)Display.getDrawable()).getContext(); // May be null
this.context = new ContextGL(peer_info, attribs, (ContextGL)shared_context);
}
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/PixelFormat.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/PixelFormat.java 2011-08-20 16:38:45 UTC (rev 3620)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/PixelFormat.java 2011-08-24 23:18:56 UTC (rev 3621)
@@ -38,7 +38,7 @@
* <p/>
* Instants of this class are immutable. An example of the expected way to set
* the PixelFormat property values is the following:
- * <code>PixelFormat pf = new PixelFormat().withDepth(24).withSamples(4).withSRGB(true);</code>
+ * <code>PixelFormat pf = new PixelFormat().withDepthBits(24).withSamples(4).withSRGB(true);</code>
* <p/>
* WARNING: Some pixel formats are known to cause troubles on certain buggy drivers.
* Example: Under Windows, specifying samples != 0 will enable the ARB
@@ -47,7 +47,6 @@
* @author eli...@so...
* @version $Revision$
*/
-
public final class PixelFormat implements PixelFormatLWJGL {
/**
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2011-10-11 22:39:38
|
Revision: 3661
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3661&view=rev
Author: kappa1
Date: 2011-10-11 22:39:32 +0000 (Tue, 11 Oct 2011)
Log Message:
-----------
minor tweak to the order in which CALayer support is detected.
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/opengl/AWTSurfaceLock.java
trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXCanvasPeerInfo.java
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/AWTSurfaceLock.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/AWTSurfaceLock.java 2011-10-11 22:30:55 UTC (rev 3660)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/AWTSurfaceLock.java 2011-10-11 22:39:32 UTC (rev 3661)
@@ -80,8 +80,8 @@
// It is only needed on first call, so we avoid it on all subsequent calls
// due to performance..
- // Allow the use of a Core Animation Layer only when using Display.setParent() or AWTGLCanvas and when not in fullscreen
- final boolean allowCALayer = (Display.getParent() != null || component instanceof AWTGLCanvas) && !Display.isFullscreen();
+ // Allow the use of a Core Animation Layer only when using non fullscreen Display.setParent() or AWTGLCanvas
+ final boolean allowCALayer = (Display.getParent() != null && !Display.isFullscreen()) || component instanceof AWTGLCanvas;
if (firstLockSucceeded)
return lockAndInitHandle(lock_buffer, component, allowCALayer);
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXCanvasPeerInfo.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXCanvasPeerInfo.java 2011-10-11 22:30:55 UTC (rev 3660)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXCanvasPeerInfo.java 2011-10-11 22:39:32 UTC (rev 3661)
@@ -50,8 +50,8 @@
}
protected void initHandle(Canvas component) throws LWJGLException {
- // Allow the use of a Core Animation Layer only when using Display.setParent() or AWTGLCanvas and when not in fullscreen
- final boolean allowCALayer = (Display.getParent() != null || component instanceof AWTGLCanvas) && !Display.isFullscreen();
+ // Allow the use of a Core Animation Layer only when using non fullscreen Display.setParent() or AWTGLCanvas
+ final boolean allowCALayer = (Display.getParent() != null && !Display.isFullscreen()) || component instanceof AWTGLCanvas;
nInitHandle(awt_surface.lockAndGetHandle(component), getHandle(), allowCALayer);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sp...@us...> - 2011-11-10 18:46:50
|
Revision: 3690
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3690&view=rev
Author: spasi
Date: 2011-11-10 18:46:43 +0000 (Thu, 10 Nov 2011)
Log Message:
-----------
Changed CallbackUtil to use ContextCapabilities instead of ContextGL.
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/opengl/CallbackUtil.java
trunk/LWJGL/src/java/org/lwjgl/opengl/Context.java
trunk/LWJGL/src/java/org/lwjgl/opengl/GLContext.java
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/CallbackUtil.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/CallbackUtil.java 2011-10-30 14:44:52 UTC (rev 3689)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/CallbackUtil.java 2011-11-10 18:46:43 UTC (rev 3690)
@@ -42,9 +42,9 @@
final class CallbackUtil {
/** Context -> Long */
- private static final Map<ContextGL, Long> contextUserParamsARB = new HashMap<ContextGL, Long>();
+ private static final Map<ContextCapabilities, Long> contextUserParamsARB = new HashMap<ContextCapabilities, Long>();
/** Context -> Long */
- private static final Map<ContextGL, Long> contextUserParamsAMD = new HashMap<ContextGL, Long>();
+ private static final Map<ContextCapabilities, Long> contextUserParamsAMD = new HashMap<ContextCapabilities, Long>();
private CallbackUtil() {}
@@ -84,19 +84,19 @@
*
* @param userParam the global reference pointer
*/
- private static void registerContextCallback(final long userParam, final Map<ContextGL, Long> contextUserData) {
- ContextGL context = ContextGL.getCurrentContext();
- if ( context == null ) {
+ private static void registerContextCallback(final long userParam, final Map<ContextCapabilities, Long> contextUserData) {
+ ContextCapabilities caps = GLContext.getCapabilities();
+ if ( caps == null ) {
deleteGlobalRef(userParam);
throw new IllegalStateException("No context is current.");
}
- final Long userParam_old = contextUserData.remove(context);
+ final Long userParam_old = contextUserData.remove(caps);
if ( userParam_old != null )
deleteGlobalRef(userParam_old);
if ( userParam != 0 )
- contextUserData.put(context, userParam);
+ contextUserData.put(caps, userParam);
}
/**
@@ -104,12 +104,15 @@
*
* @param context the Context to unregister
*/
- static void unregisterCallbacks(final ContextGL context) {
- Long userParam = contextUserParamsARB.remove(context);
+ static void unregisterCallbacks(final Object context) {
+ // TODO: This is never called for custom contexts. Need to fix for LWJGL 3.0
+ final ContextCapabilities caps = GLContext.getCapabilities(context);
+
+ Long userParam = contextUserParamsARB.remove(caps);
if ( userParam != null )
deleteGlobalRef(userParam);
- userParam = contextUserParamsAMD.remove(context);
+ userParam = contextUserParamsAMD.remove(caps);
if ( userParam != null )
deleteGlobalRef(userParam);
}
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/Context.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/Context.java 2011-10-30 14:44:52 UTC (rev 3689)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/Context.java 2011-11-10 18:46:43 UTC (rev 3690)
@@ -32,7 +32,6 @@
package org.lwjgl.opengl;
import org.lwjgl.LWJGLException;
-import org.lwjgl.opengles.PowerManagementEventException;
/**
* @author Spasi
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/GLContext.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/GLContext.java 2011-10-30 14:44:52 UTC (rev 3689)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/GLContext.java 2011-11-10 18:46:43 UTC (rev 3690)
@@ -130,6 +130,17 @@
return getThreadLocalCapabilities();
}
+ /**
+ * Returns the capabilities instance associated with the specified context object.
+ *
+ * @param context the context object
+ *
+ * @return the capabilities instance
+ */
+ static ContextCapabilities getCapabilities(Object context) {
+ return capability_cache.get(context);
+ }
+
private static ContextCapabilities getThreadLocalCapabilities() {
return current_capabilities.get();
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2011-11-12 20:45:41
|
Revision: 3692
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3692&view=rev
Author: kappa1
Date: 2011-11-12 20:45:35 +0000 (Sat, 12 Nov 2011)
Log Message:
-----------
MacOS: further limit CALayer to only be used when running as an Applet
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/opengl/AWTSurfaceLock.java
trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXCanvasPeerInfo.java
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/AWTSurfaceLock.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/AWTSurfaceLock.java 2011-11-12 19:01:28 UTC (rev 3691)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/AWTSurfaceLock.java 2011-11-12 20:45:35 UTC (rev 3692)
@@ -32,6 +32,8 @@
package org.lwjgl.opengl;
import java.awt.Canvas;
+import java.awt.Component;
+import java.applet.Applet;
import java.nio.ByteBuffer;
import java.security.AccessController;
import java.security.PrivilegedActionException;
@@ -81,7 +83,7 @@
// due to performance..
// Allow the use of a Core Animation Layer only when using non fullscreen Display.setParent() or AWTGLCanvas
- final boolean allowCALayer = (Display.getParent() != null && !Display.isFullscreen()) || component instanceof AWTGLCanvas;
+ final boolean allowCALayer = ((Display.getParent() != null && !Display.isFullscreen()) || component instanceof AWTGLCanvas) && isApplet(component);
if (firstLockSucceeded)
return lockAndInitHandle(lock_buffer, component, allowCALayer);
@@ -105,4 +107,22 @@
}
private static native void nUnlock(ByteBuffer lock_buffer) throws LWJGLException;
+
+ /**
+ * This method will return true if the component is running in an applet
+ */
+ public boolean isApplet(Canvas component) {
+
+ Component parent = component.getParent();
+
+ while (parent != null) {
+ if (parent instanceof Applet) {
+ return true;
+ }
+ parent = parent.getParent();
+ }
+
+ // not an applet
+ return false;
+ }
}
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXCanvasPeerInfo.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXCanvasPeerInfo.java 2011-11-12 19:01:28 UTC (rev 3691)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXCanvasPeerInfo.java 2011-11-12 20:45:35 UTC (rev 3692)
@@ -51,7 +51,7 @@
protected void initHandle(Canvas component) throws LWJGLException {
// Allow the use of a Core Animation Layer only when using non fullscreen Display.setParent() or AWTGLCanvas
- final boolean allowCALayer = (Display.getParent() != null && !Display.isFullscreen()) || component instanceof AWTGLCanvas;
+ final boolean allowCALayer = ((Display.getParent() != null && !Display.isFullscreen()) || component instanceof AWTGLCanvas) && awt_surface.isApplet(component);
nInitHandle(awt_surface.lockAndGetHandle(component), getHandle(), allowCALayer);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2012-02-18 16:30:45
|
Revision: 3743
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3743&view=rev
Author: kappa1
Date: 2012-02-18 16:30:38 +0000 (Sat, 18 Feb 2012)
Log Message:
-----------
Added the new public API's Display.getX() and Display.getY(). Currently implemented for Linux and Mac. Windows implementation pending.
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java
trunk/LWJGL/src/java/org/lwjgl/opengl/DisplayImplementation.java
trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java
trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java
trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java 2012-02-18 01:49:46 UTC (rev 3742)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java 2012-02-18 16:30:38 UTC (rev 3743)
@@ -1282,10 +1282,50 @@
}
/**
+ * @return this method will return the x position (top-left) of the Display window.
+ *
+ * If running in fullscreen mode it will return 0.
+ * If Display.setParent(Canvas parent) is being used, the x position of
+ * the parent will be returned.
+ */
+ public static int getX() {
+
+ if (Display.isFullscreen()) {
+ return 0;
+ }
+
+ if (parent != null) {
+ return parent.getX();
+ }
+
+ return display_impl.getX();
+ }
+
+ /**
+ * @return this method will return the y position (top-left) of the Display window.
+ *
+ * If running in fullscreen mode it will return 0.
+ * If Display.setParent(Canvas parent) is being used, the y position of
+ * the parent will be returned.
+ */
+ public static int getY() {
+
+ if (Display.isFullscreen()) {
+ return 0;
+ }
+
+ if (parent != null) {
+ return parent.getY();
+ }
+
+ return display_impl.getY();
+ }
+
+ /**
* @return this method will return the width of the Display window.
*
* If running in fullscreen mode it will return the width of the current set DisplayMode.
- * If running Display.setParent(Canvas parent) is being used, the width of the parent
+ * If Display.setParent(Canvas parent) is being used, the width of the parent
* will be returned.
*
* This value will be updated after a call to Display.update().
@@ -1307,7 +1347,7 @@
* @return this method will return the height of the Display window.
*
* If running in fullscreen mode it will return the height of the current set DisplayMode.
- * If running Display.setParent(Canvas parent) is being used, the height of the parent
+ * If Display.setParent(Canvas parent) is being used, the height of the parent
* will be returned.
*
* This value will be updated after a call to Display.update().
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/DisplayImplementation.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/DisplayImplementation.java 2012-02-18 01:49:46 UTC (rev 3742)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/DisplayImplementation.java 2012-02-18 16:30:38 UTC (rev 3743)
@@ -174,12 +174,22 @@
boolean wasResized();
/**
- * @return this method will return a the width of the Display window.
+ * @return this method will return the width of the Display window.
*/
int getWidth();
/**
- * @return this method will return a the height of the Display window.
+ * @return this method will return the height of the Display window.
*/
int getHeight();
+
+ /**
+ * @return this method will return the top-left x position of the Display window.
+ */
+ int getX();
+
+ /**
+ * @return this method will return the top-left y position of the Display window.
+ */
+ int getY();
}
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2012-02-18 01:49:46 UTC (rev 3742)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2012-02-18 16:30:38 UTC (rev 3743)
@@ -473,6 +473,8 @@
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();
current_window = nCreateWindow(getDisplay(), getDefaultScreen(), handle, mode, current_window_mode, x, y, undecorated, parent_window, resizable);
@@ -1387,6 +1389,14 @@
private static native void nSetWindowIcon(long display, long window, ByteBuffer icon_rgb, int icon_rgb_size, ByteBuffer icon_mask, int icon_mask_size, int width, int height);
+ public int getX() {
+ return window_x;
+ }
+
+ public int getY() {
+ return window_y;
+ }
+
public int getWidth() {
return window_width;
}
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java 2012-02-18 01:49:46 UTC (rev 3742)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java 2012-02-18 16:30:38 UTC (rev 3743)
@@ -495,7 +495,15 @@
// Don't use any icon, since Mac OS X windows don't have window icons
return 0;
}
+
+ public int getX() {
+ return frame.getX();
+ }
+ public int getY() {
+ return frame.getY();
+ }
+
public int getWidth() {
return frame.getWidth();
}
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2012-02-18 01:49:46 UTC (rev 3742)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2012-02-18 16:30:38 UTC (rev 3743)
@@ -1013,7 +1013,15 @@
return defWindowProc(hwnd, msg, wParam, lParam);
}
}
+
+ public int getX() {
+ return 0; // placeholder until implemented
+ }
+ public int getY() {
+ return 0; // placeholder until implemented
+ }
+
public int getWidth() {
return width;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2012-03-04 13:41:55
|
Revision: 3751
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3751&view=rev
Author: kappa1
Date: 2012-03-04 13:41:49 +0000 (Sun, 04 Mar 2012)
Log Message:
-----------
Refactor so that the peer_info variable in ContextGL does not need to be static
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/opengl/ContextGL.java
trunk/LWJGL/src/java/org/lwjgl/opengl/ContextImplementation.java
trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxContextImplementation.java
trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXContextImplementation.java
trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsContextImplementation.java
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/ContextGL.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/ContextGL.java 2012-03-04 03:50:58 UTC (rev 3750)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/ContextGL.java 2012-03-04 13:41:49 UTC (rev 3751)
@@ -64,7 +64,7 @@
/** Handle to the native GL rendering context */
private final ByteBuffer handle;
- private static PeerInfo peer_info;
+ private final PeerInfo peer_info;
private final ContextAttribs contextAttribs;
private final boolean forwardCompatible;
@@ -229,7 +229,7 @@
* A video frame period is the time required to display a full frame of video data.
*/
public static void setSwapInterval(int value) {
- implementation.setSwapInterval(peer_info, value);
+ implementation.setSwapInterval(value);
}
/**
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/ContextImplementation.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/ContextImplementation.java 2012-03-04 03:50:58 UTC (rev 3750)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/ContextImplementation.java 2012-03-04 13:41:49 UTC (rev 3751)
@@ -81,7 +81,7 @@
*/
boolean isCurrent(ByteBuffer handle) throws LWJGLException;
- void setSwapInterval(PeerInfo peer_info, int value);
+ void setSwapInterval(int value);
/**
* Destroys the Context.
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxContextImplementation.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxContextImplementation.java 2012-03-04 03:50:58 UTC (rev 3750)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxContextImplementation.java 2012-03-04 13:41:49 UTC (rev 3751)
@@ -141,8 +141,10 @@
private static native boolean nIsCurrent(ByteBuffer context_handle) throws LWJGLException;
- public void setSwapInterval(PeerInfo peer_info, int value) {
+ public void setSwapInterval(int value) {
ContextGL current_context = ContextGL.getCurrentContext();
+ PeerInfo peer_info = current_context.getPeerInfo();
+
if ( current_context == null )
throw new IllegalStateException("No context is current");
synchronized ( current_context ) {
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXContextImplementation.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXContextImplementation.java 2012-03-04 03:50:58 UTC (rev 3750)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXContextImplementation.java 2012-03-04 13:41:49 UTC (rev 3751)
@@ -118,7 +118,7 @@
private static native boolean nIsCurrent(ByteBuffer context_handle) throws LWJGLException;
- public void setSwapInterval(PeerInfo peer_info, int value) {
+ public void setSwapInterval(int value) {
ContextGL current_context = ContextGL.getCurrentContext();
synchronized ( current_context ) {
nSetSwapInterval(current_context.getHandle(), value);
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsContextImplementation.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsContextImplementation.java 2012-03-04 03:50:58 UTC (rev 3750)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsContextImplementation.java 2012-03-04 13:41:49 UTC (rev 3751)
@@ -106,7 +106,7 @@
private static native boolean nIsCurrent(ByteBuffer context_handle) throws LWJGLException;
- public void setSwapInterval(PeerInfo peer_info, int value) {
+ public void setSwapInterval(int value) {
boolean success = nSetSwapInterval(value);
if ( !success )
LWJGLUtil.log("Failed to set swap interval");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2012-03-24 00:05:05
|
Revision: 3755
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3755&view=rev
Author: kappa1
Date: 2012-03-24 00:04:52 +0000 (Sat, 24 Mar 2012)
Log Message:
-----------
Replace Display.sync(int fps) with an even better implementation, special thanks to Riven.
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java
Added Paths:
-----------
trunk/LWJGL/src/java/org/lwjgl/opengl/Sync.java
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java 2012-03-21 19:34:51 UTC (rev 3754)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java 2012-03-24 00:04:52 UTC (rev 3755)
@@ -79,18 +79,6 @@
/** The current display mode, if created */
private static DisplayMode current_mode;
- /** time at last sync() */
- private static long lastTime;
-
- /** Whether the sync() method has been initiated */
- private static boolean syncInitiated;
-
- /** whether to disable adaptive yield time in sync() method */
- private static boolean adaptiveTimeDisabled;
-
- /** adaptive time to yield instead of sleeping in sync()*/
- private static long adaptiveYieldTime;
-
/** X coordinate of the window */
private static int x = -1;
@@ -411,98 +399,16 @@
}
/**
- * An accurate sync method that adapts automatically
- * to the system it runs on to provide reliable results.
+ * An accurate sync method that will attempt to run an application loop
+ * at a constant frame rate.
*
- * @param fps The desired frame rate, in frames per second
+ * It should be called once every frame.
+ *
+ * @param fps - the desired frame rate, in frames per second
*/
public static void sync(int fps) {
- if (fps <= 0) return;
- if (!syncInitiated) initiateSyncTimer();
-
- long sleepTime = 1000000000 / fps; // nanoseconds to sleep this frame
- // adaptiveYieldTime + remainder micro & nano seconds if smaller than sleepTime
- long yieldTime = adaptiveTimeDisabled ? 0 : Math.min(sleepTime, adaptiveYieldTime + sleepTime % (1000*1000));
- long overSleep = 0; // time the sync goes over by
-
- try {
- while (true) {
- long t = getTime() - lastTime;
-
- if (t < sleepTime - yieldTime) {
- Thread.sleep(1);
- }
- else if (t < sleepTime) {
- // burn the last few CPU cycles to ensure accuracy
- Thread.yield();
- }
- else {
- overSleep = t - sleepTime;
- break; // exit while loop
- }
- }
- } catch (InterruptedException e) {}
-
- lastTime = getTime() - Math.min(overSleep, sleepTime);
-
- if (!adaptiveTimeDisabled) {
- // auto tune the amount of time to yield
- if (overSleep > adaptiveYieldTime) {
- // increase by 200 microseconds (1/5 a ms)
- adaptiveYieldTime = Math.min(adaptiveYieldTime + 200*1000, sleepTime);
- }
- else if (overSleep < adaptiveYieldTime - 2*1000*1000) {
- // fast decrease by 50 microseconds for large under sleeps
- adaptiveYieldTime = Math.max(adaptiveYieldTime - 50*1000, 0);
- }
- else if (overSleep < adaptiveYieldTime - 200*1000) {
- // slower but finer decrease by 2 microseconds
- adaptiveYieldTime = Math.max(adaptiveYieldTime - 2*1000, 0);
- }
- }
+ Sync.sync(fps);
}
-
- /**
- * Get System Nano Time
- * @return will return the current time in nano's
- */
- private static long getTime() {
- return (Sys.getTime() * 1000000000) / Sys.getTimerResolution();
- }
-
- /**
- * Initialise the sync(fps) method.
- */
- private static void initiateSyncTimer() {
- syncInitiated = true;
- lastTime = getTime();
-
- String osName = System.getProperty("os.name");
-
- if (osName.startsWith("Mac") || osName.startsWith("Darwin")) {
- // disabled on mac as it uses too much cpu, besides
- // Thread.sleep is pretty accurate on mac by default
- adaptiveTimeDisabled = true;
- return;
- }
-
- if (osName.startsWith("Win")) {
- // On windows the sleep functions can be highly inaccurate by
- // over 10ms making in unusable. However it can be forced to
- // be a bit more accurate by running a separate sleeping daemon
- // thread.
- Thread timerAccuracyThread = new Thread(new Runnable() {
- public void run() {
- try {
- Thread.sleep(Long.MAX_VALUE);
- } catch (Exception e) {}
- }
- });
-
- timerAccuracyThread.setDaemon(true);
- timerAccuracyThread.start();
- }
- }
/** @return the title of the window */
public static String getTitle() {
Added: trunk/LWJGL/src/java/org/lwjgl/opengl/Sync.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/Sync.java (rev 0)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/Sync.java 2012-03-24 00:04:52 UTC (rev 3755)
@@ -0,0 +1,176 @@
+/*
+ * Copyright (c) 2002-2012 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;
+
+import org.lwjgl.Sys;
+
+/**
+* A highly accurate sync method that continually adapts to the system
+* it runs on to provide reliable results.
+*
+* @author Riven
+* @author kappaOne
+*/
+class Sync {
+
+ /** number of nano seconds in a second */
+ private static final long NANOS_IN_SECOND = 1000L * 1000L * 1000L;
+
+ /** The time to sleep/yield until the next frame */
+ private static long nextFrame = 0;
+
+ /** whether the initialisation code has run */
+ private static boolean initialised = false;
+
+ /** stored results of how long sleep/yields took to calculate averages */
+ private static RunningAvg sleepDurations = new RunningAvg(10);
+ private static RunningAvg yieldDurations = new RunningAvg(10);
+
+
+ /**
+ * An accurate sync method that will attempt to run an application loop
+ * at a constant frame rate.
+ *
+ * It should be called once every frame.
+ *
+ * @param fps - the desired frame rate, in frames per second
+ */
+ public static void sync(int fps) {
+ if (fps <= 0) return;
+ if (!initialised) initialise();
+
+ try {
+ // sleep until the average sleep time is greater than the time remaining till nextFrame
+ for (long t0 = getTime(), t1; (nextFrame - t0) > sleepDurations.avg(); t0 = t1) {
+ Thread.sleep(1);
+ sleepDurations.add((t1 = getTime()) - t0); // update average sleep time
+ }
+
+ // slowly dampen sleep average if too high to avoid over yielding
+ sleepDurations.dampenForLowResTicker();
+
+ // yield until the average yield time is greater than the time remaining till nextFrame
+ for (long t0 = getTime(), t1; (nextFrame - t0) > yieldDurations.avg(); t0 = t1) {
+ Thread.yield();
+ yieldDurations.add((t1 = getTime()) - t0); // update average yield time
+ }
+ } catch (InterruptedException e) {
+
+ }
+
+ // schedule next frame, drop frame(s) if already too late for next frame
+ nextFrame = Math.max(nextFrame + NANOS_IN_SECOND / fps, getTime());
+ }
+
+ /**
+ * This method will initialise the sync method by setting initial
+ * values for sleepDurations/yieldDurations and nextFrame variables.
+ *
+ * If running windows on windows it will start the sleep timer fix.
+ */
+ private static void initialise() {
+ initialised = true;
+
+ sleepDurations.init(1000 * 1000);
+ yieldDurations.init((int) (-(getTime() - getTime()) * 1.333));
+
+ nextFrame = getTime();
+
+ String osName = System.getProperty("os.name");
+
+ if (osName.startsWith("Win")) {
+ // On windows the sleep functions can be highly inaccurate by
+ // over 10ms making in unusable. However it can be forced to
+ // be a bit more accurate by running a separate sleeping daemon
+ // thread.
+ Thread timerAccuracyThread = new Thread(new Runnable() {
+ public void run() {
+ try {
+ Thread.sleep(Long.MAX_VALUE);
+ } catch (Exception e) {}
+ }
+ });
+
+ timerAccuracyThread.setDaemon(true);
+ timerAccuracyThread.start();
+ }
+ }
+
+ /**
+ * Get the system time in nano seconds
+ *
+ * @return will return the current time in nano's
+ */
+ private static long getTime() {
+ return (Sys.getTime() * NANOS_IN_SECOND) / Sys.getTimerResolution();
+ }
+
+ private static class RunningAvg {
+ private final long[] slots;
+ private int offset;
+
+ private static final long DAMPEN_THRESHOLD = 10 * 1000L * 1000L; // 10ms
+ private static final float DAMPEN_FACTOR = 0.9f; // don't change: 0.9f is exactly right!
+
+ public RunningAvg(int slotCount) {
+ this.slots = new long[slotCount];
+ this.offset = 0;
+ }
+
+ public void init(long value) {
+ while (this.offset < this.slots.length) {
+ this.slots[this.offset++] = value;
+ }
+ }
+
+ public void add(long value) {
+ this.slots[this.offset++ % this.slots.length] = value;
+ this.offset %= this.slots.length;
+ }
+
+ public long avg() {
+ long sum = 0;
+ for (int i = 0; i < this.slots.length; i++) {
+ sum += this.slots[i];
+ }
+ return sum / this.slots.length;
+ }
+
+ public void dampenForLowResTicker() {
+ if (this.avg() > DAMPEN_THRESHOLD) {
+ for (int i = 0; i < this.slots.length; i++) {
+ this.slots[i] *= DAMPEN_FACTOR;
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2012-03-24 00:20:09
|
Revision: 3756
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3756&view=rev
Author: kappa1
Date: 2012-03-24 00:20:02 +0000 (Sat, 24 Mar 2012)
Log Message:
-----------
fix minor javadoc typo's
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java
trunk/LWJGL/src/java/org/lwjgl/opengl/Sync.java
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java 2012-03-24 00:04:52 UTC (rev 3755)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java 2012-03-24 00:20:02 UTC (rev 3756)
@@ -399,9 +399,7 @@
}
/**
- * An accurate sync method that will attempt to run an application loop
- * at a constant frame rate.
- *
+ * An accurate sync method that will attempt to run at a constant frame rate.
* It should be called once every frame.
*
* @param fps - the desired frame rate, in frames per second
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/Sync.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/Sync.java 2012-03-24 00:04:52 UTC (rev 3755)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/Sync.java 2012-03-24 00:20:02 UTC (rev 3756)
@@ -32,6 +32,7 @@
package org.lwjgl.opengl;
import org.lwjgl.Sys;
+import org.ninjacave.framework.Sync.RunningAvg;
/**
* A highly accurate sync method that continually adapts to the system
@@ -51,15 +52,13 @@
/** whether the initialisation code has run */
private static boolean initialised = false;
- /** stored results of how long sleep/yields took to calculate averages */
+ /** for calculating the averages the previous sleep/yield times are stored */
private static RunningAvg sleepDurations = new RunningAvg(10);
private static RunningAvg yieldDurations = new RunningAvg(10);
/**
- * An accurate sync method that will attempt to run an application loop
- * at a constant frame rate.
- *
+ * An accurate sync method that will attempt to run at a constant frame rate.
* It should be called once every frame.
*
* @param fps - the desired frame rate, in frames per second
@@ -75,7 +74,7 @@
sleepDurations.add((t1 = getTime()) - t0); // update average sleep time
}
- // slowly dampen sleep average if too high to avoid over yielding
+ // slowly dampen sleep average if too high to avoid yielding too much
sleepDurations.dampenForLowResTicker();
// yield until the average yield time is greater than the time remaining till nextFrame
@@ -93,9 +92,9 @@
/**
* This method will initialise the sync method by setting initial
- * values for sleepDurations/yieldDurations and nextFrame variables.
+ * values for sleepDurations/yieldDurations and nextFrame.
*
- * If running windows on windows it will start the sleep timer fix.
+ * If running on windows it will start the sleep timer fix.
*/
private static void initialise() {
initialised = true;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|