Made Context.setVSync static. Added synchronization.
This commit is contained in:
parent
2586270d03
commit
2e03a6426b
|
@ -208,7 +208,7 @@ final class Context {
|
||||||
* the monitor vertical refresh synchronization of the context, and is not guaranteed to be successful.
|
* the monitor vertical refresh synchronization of the context, and is not guaranteed to be successful.
|
||||||
* @param sync true to synchronize; false to ignore synchronization
|
* @param sync true to synchronize; false to ignore synchronization
|
||||||
*/
|
*/
|
||||||
public synchronized void setVSync(boolean enable) {
|
public static void setVSync(boolean enable) {
|
||||||
implementation.setVSync(enable);
|
implementation.setVSync(enable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,10 +43,6 @@ import org.lwjgl.BufferUtils;
|
||||||
* @version $Revision$
|
* @version $Revision$
|
||||||
*/
|
*/
|
||||||
final class LinuxContextImplementation implements ContextImplementation {
|
final class LinuxContextImplementation implements ContextImplementation {
|
||||||
private static PeerInfo getCurrentPeerInfo() {
|
|
||||||
return Context.getCurrentContext().getPeerInfo();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ByteBuffer create(PeerInfo peer_info, ByteBuffer shared_context_handle) throws LWJGLException {
|
public ByteBuffer create(PeerInfo peer_info, ByteBuffer shared_context_handle) throws LWJGLException {
|
||||||
LinuxDisplay.lockAWT();
|
LinuxDisplay.lockAWT();
|
||||||
try {
|
try {
|
||||||
|
@ -64,9 +60,11 @@ final class LinuxContextImplementation implements ContextImplementation {
|
||||||
private static native ByteBuffer nCreate(ByteBuffer peer_handle, ByteBuffer shared_context_handle) throws LWJGLException;
|
private static native ByteBuffer nCreate(ByteBuffer peer_handle, ByteBuffer shared_context_handle) throws LWJGLException;
|
||||||
|
|
||||||
public void swapBuffers() throws LWJGLException {
|
public void swapBuffers() throws LWJGLException {
|
||||||
PeerInfo current_peer_info = getCurrentPeerInfo();
|
Context current_context = Context.getCurrentContext();
|
||||||
if (current_peer_info == null)
|
if (current_context == null)
|
||||||
throw new IllegalStateException("No context is current");
|
throw new IllegalStateException("No context is current");
|
||||||
|
synchronized (current_context) {
|
||||||
|
PeerInfo current_peer_info = current_context.getPeerInfo();
|
||||||
LinuxDisplay.lockAWT();
|
LinuxDisplay.lockAWT();
|
||||||
try {
|
try {
|
||||||
ByteBuffer peer_handle = current_peer_info.lockAndGetHandle();
|
ByteBuffer peer_handle = current_peer_info.lockAndGetHandle();
|
||||||
|
@ -79,12 +77,15 @@ final class LinuxContextImplementation implements ContextImplementation {
|
||||||
LinuxDisplay.unlockAWT();
|
LinuxDisplay.unlockAWT();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
private static native void nSwapBuffers(ByteBuffer peer_info_handle) throws LWJGLException;
|
private static native void nSwapBuffers(ByteBuffer peer_info_handle) throws LWJGLException;
|
||||||
|
|
||||||
public void releaseCurrentContext() throws LWJGLException {
|
public void releaseCurrentContext() throws LWJGLException {
|
||||||
PeerInfo current_peer_info = getCurrentPeerInfo();
|
Context current_context = Context.getCurrentContext();
|
||||||
if (current_peer_info == null)
|
if (current_context == null)
|
||||||
return; // No context is current
|
throw new IllegalStateException("No context is current");
|
||||||
|
synchronized (current_context) {
|
||||||
|
PeerInfo current_peer_info = current_context.getPeerInfo();
|
||||||
LinuxDisplay.lockAWT();
|
LinuxDisplay.lockAWT();
|
||||||
try {
|
try {
|
||||||
ByteBuffer peer_handle = current_peer_info.lockAndGetHandle();
|
ByteBuffer peer_handle = current_peer_info.lockAndGetHandle();
|
||||||
|
@ -97,6 +98,7 @@ final class LinuxContextImplementation implements ContextImplementation {
|
||||||
LinuxDisplay.unlockAWT();
|
LinuxDisplay.unlockAWT();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
private static native void nReleaseCurrentContext(ByteBuffer peer_info_handle) throws LWJGLException;
|
private static native void nReleaseCurrentContext(ByteBuffer peer_info_handle) throws LWJGLException;
|
||||||
|
|
||||||
public void update(ByteBuffer context_handle) {
|
public void update(ByteBuffer context_handle) {
|
||||||
|
|
|
@ -43,10 +43,6 @@ import org.lwjgl.BufferUtils;
|
||||||
* @version $Revision$
|
* @version $Revision$
|
||||||
*/
|
*/
|
||||||
final class MacOSXContextImplementation implements ContextImplementation {
|
final class MacOSXContextImplementation implements ContextImplementation {
|
||||||
private static PeerInfo getCurrentPeerInfo() {
|
|
||||||
return Context.getCurrentContext().getPeerInfo();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ByteBuffer create(PeerInfo peer_info, ByteBuffer shared_context_handle) throws LWJGLException {
|
public ByteBuffer create(PeerInfo peer_info, ByteBuffer shared_context_handle) throws LWJGLException {
|
||||||
ByteBuffer peer_handle = peer_info.lockAndGetHandle();
|
ByteBuffer peer_handle = peer_info.lockAndGetHandle();
|
||||||
try {
|
try {
|
||||||
|
@ -59,8 +55,12 @@ final class MacOSXContextImplementation implements ContextImplementation {
|
||||||
|
|
||||||
public void swapBuffers() throws LWJGLException {
|
public void swapBuffers() throws LWJGLException {
|
||||||
Context current_context = Context.getCurrentContext();
|
Context current_context = Context.getCurrentContext();
|
||||||
|
if (current_context == null)
|
||||||
|
throw new IllegalStateException("No context is current");
|
||||||
|
synchronized (current_context) {
|
||||||
nSwapBuffers(current_context.getHandle());
|
nSwapBuffers(current_context.getHandle());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
private static native void nSwapBuffers(ByteBuffer context_handle) throws LWJGLException;
|
private static native void nSwapBuffers(ByteBuffer context_handle) throws LWJGLException;
|
||||||
|
|
||||||
public void update(ByteBuffer context_handle) {
|
public void update(ByteBuffer context_handle) {
|
||||||
|
@ -70,8 +70,11 @@ final class MacOSXContextImplementation implements ContextImplementation {
|
||||||
|
|
||||||
public void releaseCurrentContext() throws LWJGLException {
|
public void releaseCurrentContext() throws LWJGLException {
|
||||||
Context current_context = Context.getCurrentContext();
|
Context current_context = Context.getCurrentContext();
|
||||||
if (current_context != null)
|
if (current_context != null) {
|
||||||
|
synchronized (current_context) {
|
||||||
clearDrawable(current_context.getHandle());
|
clearDrawable(current_context.getHandle());
|
||||||
|
}
|
||||||
|
}
|
||||||
nReleaseCurrentContext();
|
nReleaseCurrentContext();
|
||||||
}
|
}
|
||||||
private static native void nReleaseCurrentContext() throws LWJGLException;
|
private static native void nReleaseCurrentContext() throws LWJGLException;
|
||||||
|
@ -97,7 +100,10 @@ final class MacOSXContextImplementation implements ContextImplementation {
|
||||||
private static native boolean nIsCurrent(ByteBuffer context_handle) throws LWJGLException;
|
private static native boolean nIsCurrent(ByteBuffer context_handle) throws LWJGLException;
|
||||||
|
|
||||||
public void setVSync(boolean enabled) {
|
public void setVSync(boolean enabled) {
|
||||||
nSetVSync(Context.getCurrentContext().getHandle(), enabled);
|
Context current_context = Context.getCurrentContext();
|
||||||
|
synchronized (current_context) {
|
||||||
|
nSetVSync(current_context.getHandle(), enabled);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
private static native void nSetVSync(ByteBuffer context_handle, boolean enabled);
|
private static native void nSetVSync(ByteBuffer context_handle, boolean enabled);
|
||||||
|
|
||||||
|
|
|
@ -43,10 +43,6 @@ import org.lwjgl.BufferUtils;
|
||||||
* @version $Revision$
|
* @version $Revision$
|
||||||
*/
|
*/
|
||||||
final class Win32ContextImplementation implements ContextImplementation {
|
final class Win32ContextImplementation implements ContextImplementation {
|
||||||
private static PeerInfo getCurrentPeerInfo() {
|
|
||||||
return Context.getCurrentContext().getPeerInfo();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ByteBuffer create(PeerInfo peer_info, ByteBuffer shared_context_handle) throws LWJGLException {
|
public ByteBuffer create(PeerInfo peer_info, ByteBuffer shared_context_handle) throws LWJGLException {
|
||||||
ByteBuffer peer_handle = peer_info.lockAndGetHandle();
|
ByteBuffer peer_handle = peer_info.lockAndGetHandle();
|
||||||
try {
|
try {
|
||||||
|
@ -58,9 +54,11 @@ final class Win32ContextImplementation implements ContextImplementation {
|
||||||
private static native ByteBuffer nCreate(ByteBuffer peer_handle, ByteBuffer shared_context_handle) throws LWJGLException;
|
private static native ByteBuffer nCreate(ByteBuffer peer_handle, ByteBuffer shared_context_handle) throws LWJGLException;
|
||||||
|
|
||||||
public void swapBuffers() throws LWJGLException {
|
public void swapBuffers() throws LWJGLException {
|
||||||
PeerInfo current_peer_info = getCurrentPeerInfo();
|
Context current_context = Context.getCurrentContext();
|
||||||
if (current_peer_info == null)
|
if (current_context == null)
|
||||||
throw new IllegalStateException("No context is current");
|
throw new IllegalStateException("No context is current");
|
||||||
|
synchronized (current_context) {
|
||||||
|
PeerInfo current_peer_info = current_context.getPeerInfo();
|
||||||
ByteBuffer peer_handle = current_peer_info.lockAndGetHandle();
|
ByteBuffer peer_handle = current_peer_info.lockAndGetHandle();
|
||||||
try {
|
try {
|
||||||
nSwapBuffers(peer_handle);
|
nSwapBuffers(peer_handle);
|
||||||
|
@ -68,6 +66,7 @@ final class Win32ContextImplementation implements ContextImplementation {
|
||||||
current_peer_info.unlock();
|
current_peer_info.unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
private static native void nSwapBuffers(ByteBuffer peer_info_handle) throws LWJGLException;
|
private static native void nSwapBuffers(ByteBuffer peer_info_handle) throws LWJGLException;
|
||||||
|
|
||||||
public void update(ByteBuffer context_handle) {
|
public void update(ByteBuffer context_handle) {
|
||||||
|
|
Loading…
Reference in New Issue