diff options
author | Brian Paul <brianp@vmware.com> | 2015-10-26 15:59:04 -0600 |
---|---|---|
committer | Jose Fonseca <jfonseca@vmware.com> | 2015-10-28 16:42:46 +0000 |
commit | cb68a607780acdf41048cbd9c869d6a4627f0a2a (patch) | |
tree | 1ea39a7b4f0433a8cae520878f5c6542d06a46cb | |
parent | 3bae06c5f6935703c7c7142bb5eb55fdf0b66722 (diff) |
glretrace: add API dispatch for WGL_ARB_render_texture
With this, we now support WGL_ARB_render_texture.
-rw-r--r-- | retrace/glretrace.hpp | 13 | ||||
-rw-r--r-- | retrace/glretrace_wgl.cpp | 88 | ||||
-rw-r--r-- | retrace/glretrace_ws.cpp | 21 |
3 files changed, 120 insertions, 2 deletions
diff --git a/retrace/glretrace.hpp b/retrace/glretrace.hpp index 10309883..7e26d6de 100644 --- a/retrace/glretrace.hpp +++ b/retrace/glretrace.hpp @@ -136,6 +136,19 @@ blockOnFence(trace::Call &call, GLsync sync, GLbitfield flags); GLenum clientWaitSync(trace::Call &call, GLsync sync, GLbitfield flags, GLuint64 timeout); + +// WGL_ARB_render_texture +bool +bindTexImage(glws::Drawable *pBuffer, int iBuffer); + +// WGL_ARB_render_texture +bool +releaseTexImage(glws::Drawable *pBuffer, int iBuffer); + +// WGL_ARB_render_texture +bool +setPbufferAttrib(glws::Drawable *pBuffer, const int *attribList); + } /* namespace glretrace */ diff --git a/retrace/glretrace_wgl.cpp b/retrace/glretrace_wgl.cpp index 7b73da20..c17b09ee 100644 --- a/retrace/glretrace_wgl.cpp +++ b/retrace/glretrace_wgl.cpp @@ -280,8 +280,92 @@ static void retrace_wglCreateContextAttribsARB(trace::Call &call) { context_map[orig_context] = context; } + +static GLenum +wgl_buffer_to_enum(int iBuffer) +{ + switch (iBuffer) { + case WGL_FRONT_LEFT_ARB: + return GL_FRONT_LEFT; + case WGL_BACK_LEFT_ARB: + return GL_BACK_LEFT; + case WGL_FRONT_RIGHT_ARB: + return GL_FRONT_RIGHT; + case WGL_BACK_RIGHT_ARB: + return GL_BACK_RIGHT; + case WGL_AUX0_ARB: + return GL_AUX0; + default: + std::cerr << "error: invalid iBuffer in wgl_buffer_to_enum()\n"; + return GL_FRONT_LEFT; + } +} + +static void retrace_wglBindTexImageARB(trace::Call &call) { + glws::Drawable *pbuffer = pbuffer_map[call.arg(0).toUIntPtr()]; + signed long long iBuffer = call.arg(1).toSInt(); + + glretrace::bindTexImage(pbuffer, wgl_buffer_to_enum(iBuffer)); +} + +static void retrace_wglReleaseTexImageARB(trace::Call &call) { + glws::Drawable *pbuffer = pbuffer_map[call.arg(0).toUIntPtr()]; + signed long long iBuffer = call.arg(1).toSInt(); + + glretrace::releaseTexImage(pbuffer, wgl_buffer_to_enum(iBuffer)); +} + +static void retrace_wglSetPbufferAttribARB(trace::Call &call) { + glws::Drawable *pbuffer = pbuffer_map[call.arg(0).toUIntPtr()]; + const trace::Value * attribList = &call.arg(1); + + // call the window system's setPbufferAttrib function. + { + int attribs[100], j = 0; + const trace::Array *attribs_ = attribList ? attribList->toArray() : NULL; + + for (size_t i = 0; i + 1 < attribs_->values.size(); i += 2) { + int param_i = attribs_->values[i]->toSInt(); + if (param_i == 0) { + attribs[j] = 0; + } + + attribs[j] = param_i; + attribs[j+1] = attribs_->values[i+1]->toSInt(); + } + + glretrace::setPbufferAttrib(pbuffer, attribs); + } + + if (!pbuffer || !attribList) + return; + + // Update the glws::Drawable's fields + const int undefined = -99999; + int val; + + val = parseAttrib(attribList, WGL_MIPMAP_LEVEL_ARB, undefined); + if (val != undefined) { + pbuffer->mipmapLevel = val; + } + + val = parseAttrib(attribList, WGL_CUBE_MAP_FACE_ARB, undefined); + if (val != undefined) { + // Drawable::cubeFace is integer in [0..5] + val -= WGL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB; + if (val < 0 || val > 5) { + fprintf(stderr, "Invalid WGL_CUBE_MAP_FACE_ARB value!\n"); + } + else { + pbuffer->cubeFace = val; + } + } +} + + const retrace::Entry glretrace::wgl_callbacks[] = { {"glAddSwapHintRectWIN", &retrace::ignore}, + {"wglBindTexImageARB", &retrace_wglBindTexImageARB}, {"wglChoosePixelFormat", &retrace::ignore}, {"wglChoosePixelFormatARB", &retrace::ignore}, {"wglChoosePixelFormatEXT", &retrace::ignore}, @@ -312,8 +396,8 @@ const retrace::Entry glretrace::wgl_callbacks[] = { {"wglMakeCurrent", &retrace_wglMakeCurrent}, {"wglQueryPbufferARB", &retrace::ignore}, {"wglReleasePbufferDCARB", &retrace::ignore}, - {"wglReleaseTexImageARB", &retrace::ignore}, - {"wglSetPbufferAttribARB", &retrace::ignore}, + {"wglReleaseTexImageARB", &retrace_wglReleaseTexImageARB}, + {"wglSetPbufferAttribARB", &retrace_wglSetPbufferAttribARB}, {"wglSetPixelFormat", &retrace::ignore}, {"wglShareLists", &retrace_wglShareLists}, {"wglSwapBuffers", &retrace_wglSwapBuffers}, diff --git a/retrace/glretrace_ws.cpp b/retrace/glretrace_ws.cpp index 4eaa4fe9..4d617f74 100644 --- a/retrace/glretrace_ws.cpp +++ b/retrace/glretrace_ws.cpp @@ -85,6 +85,9 @@ createDrawableHelper(glprofile::Profile profile, int width = 32, int height = 32 exit(1); } + if (pbInfo) + draw->pbInfo = *pbInfo; + return draw; } @@ -315,4 +318,22 @@ parseContextAttribList(const trace::Value *attribs) } +// WGL_ARB_render_texture / wglBindTexImageARB() +bool +bindTexImage(glws::Drawable *pBuffer, int iBuffer) { + return glws::bindTexImage(pBuffer, iBuffer); +} + +// WGL_ARB_render_texture / wglReleaseTexImageARB() +bool +releaseTexImage(glws::Drawable *pBuffer, int iBuffer) { + return glws::releaseTexImage(pBuffer, iBuffer); +} + +// WGL_ARB_render_texture / wglSetPbufferAttribARB() +bool +setPbufferAttrib(glws::Drawable *pBuffer, const int *attribs) { + return glws::setPbufferAttrib(pBuffer, attribs); +} + } /* namespace glretrace */ |