typedef std::map<unsigned long long, glws::Context *> ContextMap;
static DrawableMap drawable_map;
static ContextMap context_map;
+static glws::Context *sharedContext = NULL;
static glws::Drawable *
return NULL;
}
+ /* XXX: Support multiple drawables. */
+ drawable_id = 1;
+
DrawableMap::const_iterator it;
it = drawable_map.find(drawable_id);
if (it == drawable_map.end()) {
ContextMap::const_iterator it;
it = context_map.find(ctx);
if (it == context_map.end()) {
- return (context_map[ctx] = ws->createContext(visual));
+ glws::Context *context;
+ context_map[ctx] = context = ws->createContext(visual, sharedContext);
+ if (!sharedContext) {
+ sharedContext = context;
+ }
+ return context;
}
return it->second;
}
+
static void retrace_CGLSetCurrentContext(Trace::Call &call) {
unsigned long long ctx = call.arg(0).toUIntPtr();
- /*
- * XXX: Frame termination is mostly a guess, because we don't trace enough
- * of the CGL API to know that.
- */
- if (drawable && context) {
- if (double_buffer) {
- drawable->swapBuffers();
- } else {
- glFlush();
- }
-
- frame_complete(call.no);
- }
-
glws::Drawable *new_drawable = getDrawable(ctx);
glws::Context *new_context = getContext(ctx);
}
+static void retrace_CGLFlushDrawable(Trace::Call &call) {
+ if (drawable && context) {
+ if (double_buffer) {
+ drawable->swapBuffers();
+ } else {
+ glFlush();
+ }
+
+ frame_complete(call.no);
+ }
+}
+
+
void glretrace::retrace_call_cgl(Trace::Call &call) {
- const char *name = call.name().c_str();
+ const char *name = call.name();
if (strcmp(name, "CGLSetCurrentContext") == 0) {
retrace_CGLSetCurrentContext(call);
return;
}
- if (strcmp(name, "CGLGetCurrentContext") == 0) {
+ if (strcmp(name, "CGLFlushDrawable") == 0) {
+ retrace_CGLFlushDrawable(call);
return;
}
- retrace::retrace_unknown(call);
+ return;
}