X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=wrappers%2Fgltrace_state.cpp;h=a8476b04c1bb247b9fb1131eb2c81852f7723896;hb=0f48706319d715bea08cad23fc233a46b9f9f224;hp=031b5cceb431155a480eebc1d0dd2dd84fde7a8c;hpb=d4dd924850e6fb3b7d150299d08b6d488ff1023a;p=apitrace diff --git a/wrappers/gltrace_state.cpp b/wrappers/gltrace_state.cpp index 031b5cc..a8476b0 100644 --- a/wrappers/gltrace_state.cpp +++ b/wrappers/gltrace_state.cpp @@ -34,8 +34,9 @@ #include #endif -#include #include +#include +#include namespace gltrace { @@ -57,7 +58,7 @@ public: } }; -static thread_specific ThreadState *thread_state; +static OS_THREAD_SPECIFIC_PTR(ThreadState) thread_state; static ThreadState *get_ts(void) { @@ -142,6 +143,29 @@ void setContext(uintptr_t context_id) context_map_mutex.unlock(); ts->current_context = ctx; + + if (!ctx->bound) { + ctx->bound = true; + + /* + * The default viewport and scissor state is set when a context is + * first made current, with values matching the bound drawable. Many + * applications never thouch the default state ever again. + * + * Since we currently don't trace window sizes, and rely on viewport + * calls to deduct, emit fake calls here so that viewport/scissor state + * can be deducated. + * + * FIXME: don't call the real functions here -- just emit the fake + * calls. + */ + GLint viewport[4] = {0, 0, 0, 0}; + GLint scissor_box[4] = {0, 0, 0, 0}; + _glGetIntegerv(GL_VIEWPORT, viewport); + _glGetIntegerv(GL_SCISSOR_BOX, scissor_box); + glViewport(viewport[0], viewport[1], viewport[2], viewport[3]); + glScissor(scissor_box[0], scissor_box[1], scissor_box[2], scissor_box[3]); + } } void clearContext(void)