#include <assert.h>
#include <map>
+#if defined(_MSC_VER)
+#include <memory>
+#else
#include <tr1/memory>
+#endif
#include <gltrace.hpp>
#include <os_thread.hpp>
}
};
-static os::thread_specific_ptr<struct ThreadState> thread_state;
+static thread_specific ThreadState *thread_state;
static ThreadState *get_ts(void)
{
- ThreadState *ts = thread_state.get();
-
+ ThreadState *ts = thread_state;
if (!ts) {
- ts = new ThreadState;
- thread_state.reset(ts);
+ thread_state = ts = new ThreadState;
}
return ts;
*/
bool releaseContext(uintptr_t context_id)
{
- bool res;
+ bool res = false;
context_map_mutex.lock();
/*
void createContext(uintptr_t context_id)
{
+ // wglCreateContextAttribsARB causes internal calls to wglCreateContext to be
+ // traced, causing context to be defined twice.
+ if (context_map.find(context_id) != context_map.end()) {
+ return;
+ }
+
context_ptr_t ctx(new Context);
context_map_mutex.lock();
_retainContext(ctx);
- assert(context_map.find(context_id) == context_map.end());
context_map[context_id] = ctx;
context_map_mutex.unlock();
}
-/*
- * return true if the context has been destroyed, false otherwise. See
- * the note at releaseContext about the actual ccontext lifetime.
- */
-bool destroyContext(uintptr_t context_id)
-{
- return releaseContext(context_id);
-}
-
void setContext(uintptr_t context_id)
{
ThreadState *ts = get_ts();