Use WeakHashMap in the static mapping from contexts to vbo trackers in VBOTracker.java.

This commit is contained in:
Elias Naur 2004-07-24 16:29:15 +00:00
parent 1187d0e3e8
commit 20537ab57e
3 changed files with 3 additions and 15 deletions

View File

@ -252,7 +252,7 @@ public final class GLContext {
GL11.initNativeStubs();
loadStubs();
currentContext = new WeakReference(context);
VBOTracker.setCurrent(currentContext);
VBOTracker.setCurrent(context);
} catch (LWJGLException e) {
if (did_auto_load)
unloadOpenGLLibrary();

View File

@ -244,7 +244,6 @@ public final class Pbuffer {
* the current rendering context or not.
*/
public synchronized void destroy() {
VBOTracker.remove(this);
try {
makeCurrent();
int error = GL11.glGetError();

View File

@ -31,7 +31,7 @@
*/
package org.lwjgl.opengl;
import java.util.HashMap;
import java.util.WeakHashMap;
import java.util.Map;
/**
@ -40,7 +40,7 @@ import java.util.Map;
class VBOTracker {
private static VBOTracker current_tracker = null;
private static final Map contextToTracker = new HashMap(3, 1.0f);
private static final Map contextToTracker = new WeakHashMap(3, 1.0f);
private final StateStack vbo_array_stack;
private final StateStack vbo_element_stack;
@ -77,15 +77,4 @@ class VBOTracker {
contextToTracker.put(context, current_tracker);
}
}
/**
* Remove a context when it is about to be destroyed.
* @param context
*/
static synchronized void remove(Object context) {
contextToTracker.remove(context);
if (current_tracker == context) {
current_tracker = null;
}
}
}