From 32e67c03dc9959b1d448eaf314639a3d36fd7f34 Mon Sep 17 00:00:00 2001 From: Kenneth Russel Date: Tue, 21 Feb 2006 08:34:02 +0000 Subject: Added support for calling makeCurrent() over and over again with different contexts without explicitly calling release() git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@627 232f8b59-042b-4e1e-8c03-345bb8c30851 --- src/classes/com/sun/opengl/impl/GLContextImpl.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/classes/com') diff --git a/src/classes/com/sun/opengl/impl/GLContextImpl.java b/src/classes/com/sun/opengl/impl/GLContextImpl.java index 795b06e9a..a4eee6652 100644 --- a/src/classes/com/sun/opengl/impl/GLContextImpl.java +++ b/src/classes/com/sun/opengl/impl/GLContextImpl.java @@ -81,6 +81,21 @@ public abstract class GLContextImpl extends GLContext { } public int makeCurrent() throws GLException { + // Support calls to makeCurrent() over and over again with + // different contexts without releasing them + // Could implement this more efficiently without explicit + // releasing of the underlying context; would require more error + // checking during the makeCurrentImpl phase + GLContext current = getCurrent(); + if (current != null) { + if (current == this) { + // Assume we don't need to make this context current again + return CONTEXT_CURRENT; + } else { + current.release(); + } + } + lock.lock(); int res = 0; try { -- cgit v1.2.3