Use currentContext->drawable instead.
struct Context {
Context(glws::Context* context)
: wsContext(context),
+ drawable(0),
activeProgram(0),
used(false)
{
}
glws::Context* wsContext;
+
+ // Bound drawable
+ glws::Drawable *drawable;
+
GLuint activeProgram;
bool used;
extern bool insideGlBeginEnd;
-extern glws::Drawable *currentDrawable;
extern Context *currentContext;
static void retrace_CGLFlushDrawable(trace::Call &call) {
- if (currentDrawable && currentContext) {
+ unsigned long long ctx = call.arg(0).toUIntPtr();
+ Context *context = getContext(ctx);
+
+ if (context) {
if (retrace::doubleBuffer) {
- currentDrawable->swapBuffers();
+ context->drawable->swapBuffers();
} else {
glFlush();
}
it = drawable_map.find(orig_surface);
if (it != drawable_map.end()) {
- if (it->second != currentDrawable) {
+ if (!currentContext || it->second != currentContext->drawable) {
// TODO: reference count
delete it->second;
}
static void retrace_eglSwapBuffers(trace::Call &call) {
+ glws::Drawable *drawable = getDrawable(call.arg(1).toUIntPtr());
+
frame_complete(call);
- if (retrace::doubleBuffer && currentDrawable) {
- currentDrawable->swapBuffers();
+ if (retrace::doubleBuffer) {
+ if (drawable) {
+ drawable->swapBuffers();
+ }
} else {
glFlush();
}
}
static void retrace_glXSwapBuffers(trace::Call &call) {
+ glws::Drawable *drawable = getDrawable(call.arg(1).toUInt());
+
frame_complete(call);
if (retrace::doubleBuffer) {
- currentDrawable->swapBuffers();
+ if (drawable) {
+ drawable->swapBuffers();
+ }
} else {
glFlush();
}
retrace::frameComplete(call);
- if (!currentDrawable) {
+ if (!currentContext) {
return;
}
- if (retrace::debug && !currentDrawable->visible) {
+ if (retrace::debug && !currentContext->drawable->visible) {
retrace::warning(call) << "could not infer drawable size (glViewport never called)\n";
}
}
image::Image *
retrace::getSnapshot(void) {
- if (!glretrace::currentDrawable) {
+ if (!glretrace::currentContext) {
return NULL;
}
retrace::dumpState(std::ostream &os)
{
if (glretrace::insideGlBeginEnd ||
- !glretrace::currentDrawable ||
!glretrace::currentContext) {
return false;
}
}
static void retrace_wglSwapBuffers(trace::Call &call) {
+ glws::Drawable *drawable = getDrawable(call.arg(0).toUIntPtr());
+
frame_complete(call);
if (retrace::doubleBuffer) {
- currentDrawable->swapBuffers();
+ if (drawable) {
+ drawable->swapBuffers();
+ } else if (currentContext) {
+ currentContext->drawable->swapBuffers();
+ }
} else {
glFlush();
}
Context *new_context = glretrace::createContext(share_context);
if (new_context) {
if (currentContext == old_context) {
- glretrace::makeCurrent(call, currentDrawable, new_context);
+ glretrace::makeCurrent(call, currentContext->drawable, new_context);
}
context_map[hglrc2] = new_context;
namespace glretrace {
-glws::Drawable *currentDrawable = NULL;
Context *currentContext = NULL;
bool
makeCurrent(trace::Call &call, glws::Drawable *drawable, Context *context)
{
+ glws::Drawable *currentDrawable = currentContext ? currentContext->drawable : NULL;
+
if (drawable == currentDrawable && context == currentContext) {
return true;
}
- if (currentDrawable && currentContext) {
+ if (currentContext) {
glFlush();
if (!retrace::doubleBuffer) {
frame_complete(call);
return false;
}
+ if (currentContext) {
+ currentContext->drawable = NULL;
+ }
+
if (drawable && context) {
- currentDrawable = drawable;
currentContext = context;
+ currentContext->drawable = drawable;
if (!context->used) {
initContext();
context->used = true;
}
} else {
- currentDrawable = NULL;
currentContext = NULL;
}
*/
void
updateDrawable(int width, int height) {
- if (!currentDrawable) {
+ if (!currentContext) {
return;
}
+ glws::Drawable *currentDrawable = currentContext->drawable;
+ assert(currentDrawable);
+
if (currentDrawable->visible &&
width <= currentDrawable->width &&
height <= currentDrawable->height) {