namespace glretrace {
-glws::Drawable *currentDrawable = NULL;
Context *currentContext = NULL;
}
-glws::Drawable *
-createDrawable(glws::Profile profile) {
- glws::Drawable *draw = glws::createDrawable(getVisual(profile));
+static glws::Drawable *
+createDrawableHelper(glws::Profile profile, int width = 32, int height = 32, bool pbuffer = false) {
+ glws::Drawable *draw = glws::createDrawable(getVisual(profile), width, height, pbuffer);
if (!draw) {
std::cerr << "error: failed to create OpenGL drawable\n";
exit(1);
}
+glws::Drawable *
+createDrawable(glws::Profile profile) {
+ return createDrawableHelper(profile);
+}
+
+
glws::Drawable *
createDrawable(void) {
- return glretrace::createDrawable(getDefaultProfile());
+ return createDrawable(getDefaultProfile());
+}
+
+
+glws::Drawable *
+createPbuffer(int width, int height) {
+ return createDrawableHelper(getDefaultProfile(), width, height, true);
}
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->pbuffer) {
return;
}