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 (context) {
- if (!context->used) {
- initContext();
- context->used = true;
- }
+ 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) {
}
+int
+parseAttrib(const trace::Value *attribs, int param, int default_ = 0) {
+ const trace::Array *attribs_ = dynamic_cast<const trace::Array *>(attribs);
+
+ if (attribs_) {
+ for (size_t i = 0; i + 1 < attribs_->values.size(); i += 2) {
+ int param_i = attribs_->values[i]->toSInt();
+ if (param_i == 0) {
+ break;
+ }
+
+ if (param_i == param) {
+ int value = attribs_->values[i + 1]->toSInt();
+ return value;
+ }
+ }
+ }
+
+ return default_;
+}
+
+
} /* namespace glretrace */