From: José Fonseca Date: Wed, 12 Jun 2013 22:13:09 +0000 (+0100) Subject: gltrace: Emit fake glViewport/glScissor calls the first time a context is bound. X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;h=1e3950ddd30086449eeda4a3d537383586e67b36;hp=3689f22598ffa39bd299191897e988d1b32fadbb;p=apitrace gltrace: Emit fake glViewport/glScissor calls the first time a context is bound. This addresses issue #59. --- diff --git a/wrappers/gltrace.hpp b/wrappers/gltrace.hpp index 04c64b6..dd8058c 100644 --- a/wrappers/gltrace.hpp +++ b/wrappers/gltrace.hpp @@ -97,6 +97,9 @@ public: bool user_arrays_nv; unsigned retain_count; + // Whether it has been bound before + bool bound; + // TODO: This will fail for buffers shared by multiple contexts. std::map buffers; @@ -105,7 +108,8 @@ public: user_arrays(false), user_arrays_arb(false), user_arrays_nv(false), - retain_count(0) + retain_count(0), + bound(false) { } inline bool diff --git a/wrappers/gltrace_state.cpp b/wrappers/gltrace_state.cpp index 60eada6..a8476b0 100644 --- a/wrappers/gltrace_state.cpp +++ b/wrappers/gltrace_state.cpp @@ -34,8 +34,9 @@ #include #endif -#include #include +#include +#include namespace gltrace { @@ -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)