Refactor so that the peer_info variable in ContextGL does not need to be static

This commit is contained in:
kappa1 2012-03-04 13:41:49 +00:00
parent 6010657389
commit 093bfe9698
5 changed files with 8 additions and 6 deletions

View File

@ -64,7 +64,7 @@ final class ContextGL implements Context {
/** 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 @@ final class ContextGL implements Context {
* 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);
}
/**

View File

@ -81,7 +81,7 @@ interface ContextImplementation {
*/
boolean isCurrent(ByteBuffer handle) throws LWJGLException;
void setSwapInterval(PeerInfo peer_info, int value);
void setSwapInterval(int value);
/**
* Destroys the Context.

View File

@ -141,8 +141,10 @@ final class LinuxContextImplementation implements ContextImplementation {
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 ) {

View File

@ -118,7 +118,7 @@ final class MacOSXContextImplementation implements ContextImplementation {
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);

View File

@ -106,7 +106,7 @@ final class WindowsContextImplementation implements ContextImplementation {
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");