HWND
createWindow(int width, int height);
+void
+resizeWindow(HWND hWnd, int width, int height);
+
+bool
+processEvents(void);
+
} /* namespace d3dretrace */
if 'hFocusWindow' in method.argNames():
print r' hFocusWindow = hWnd;'
+ if method.name in ('Reset', 'ResetEx'):
+ print r' if (pPresentationParameters->Windowed) {'
+ print r' d3dretrace::resizeWindow(pPresentationParameters->hDeviceWindow, pPresentationParameters->BackBufferWidth, pPresentationParameters->BackBufferHeight);'
+ print r' }'
+
# notify frame has been completed
if method.name == 'Present':
print r' retrace::frameComplete(call);'
Retracer.invokeInterfaceMethod(self, interface, method)
+ # process events after presents
+ if method.name == 'Present':
+ print r' d3dretrace::processEvents();'
+
# check errors
if str(method.type) == 'HRESULT':
print r' if (FAILED(_result)) {'
{
MINMAXINFO *pMMI;
switch (uMsg) {
+ case WM_KEYDOWN:
+ switch (wParam) {
+ case VK_ESCAPE:
+ PostMessage(hWnd, WM_CLOSE, 0, 0);
+ break;
+ }
+ break;
case WM_GETMINMAXINFO:
// Allow to create a window bigger than the desktop
pMMI = (MINMAXINFO *)lParam;
pMMI->ptMaxTrackSize.x = 60000;
pMMI->ptMaxTrackSize.y = 60000;
break;
+ case WM_CLOSE:
+ exit(0);
+ break;
default:
break;
}
}
+void
+resizeWindow(HWND hWnd, int width, int height) {
+ RECT rClient;
+ GetClientRect(hWnd, &rClient);
+ if (width == rClient.right - rClient.left &&
+ height == rClient.bottom - rClient.top) {
+ return;
+ }
+
+ RECT rWindow;
+ GetWindowRect(hWnd, &rWindow);
+ width += (rWindow.right - rWindow.left) - rClient.right;
+ height += (rWindow.bottom - rWindow.top) - rClient.bottom;
+ SetWindowPos(hWnd, NULL, rWindow.left, rWindow.top, width, height, SWP_NOMOVE);
+}
+bool
+processEvents(void) {
+ MSG uMsg;
+ while (PeekMessage(&uMsg, NULL, 0, 0, PM_REMOVE)) {
+ if (uMsg.message == WM_QUIT) {
+ return false;
+ }
+
+ if (!TranslateAccelerator(uMsg.hwnd, NULL, &uMsg)) {
+ TranslateMessage(&uMsg);
+ DispatchMessage(&uMsg);
+ }
+ }
+ return true;
+}
+
} /* namespace d3dretrace */
{
GLint channels = _gl_format_channels(format);
+ if (internalFormat == GL_NONE) {
+ internalFormat = format;
+ }
+
Context context;
json.beginObject();
eglWaitNative(EGL_CORE_NATIVE_ENGINE);
}
+ void
+ recreate(void) {
+ EGLContext currentContext = eglGetCurrentContext();
+ EGLSurface currentDrawSurface = eglGetCurrentSurface(EGL_DRAW);
+ EGLSurface currentReadSurface = eglGetCurrentSurface(EGL_DRAW);
+ bool rebindDrawSurface = currentDrawSurface == surface;
+ bool rebindReadSurface = currentReadSurface == surface;
+
+ if (rebindDrawSurface || rebindReadSurface) {
+ eglMakeCurrent(eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
+ }
+
+ eglDestroySurface(eglDisplay, surface);
+
+ EGLConfig config = static_cast<const EglVisual *>(visual)->config;
+ surface = eglCreateWindowSurface(eglDisplay, config, (EGLNativeWindowType)window, NULL);
+
+ if (rebindDrawSurface || rebindReadSurface) {
+ eglMakeCurrent(eglDisplay, surface, surface, currentContext);
+ }
+ }
+
void
resize(int w, int h) {
if (w == width && h == height) {
waitForEvent(ConfigureNotify);
eglWaitNative(EGL_CORE_NATIVE_ENGINE);
+
+ /*
+ * Some implementations won't update the backbuffer unless we recreate
+ * the EGL surface.
+ */
+
+ int eglWidth;
+ int eglHeight;
+
+ eglQuerySurface(eglDisplay, surface, EGL_WIDTH, &eglWidth);
+ eglQuerySurface(eglDisplay, surface, EGL_HEIGHT, &eglHeight);
+
+ if (eglWidth != width || eglHeight != height) {
+ recreate();
+
+ eglQuerySurface(eglDisplay, surface, EGL_WIDTH, &eglWidth);
+ eglQuerySurface(eglDisplay, surface, EGL_HEIGHT, &eglHeight);
+ }
+
+ assert(eglWidth == width);
+ assert(eglHeight == height);
}
void show(void) {
#include <stddef.h>
#include <wchar.h>
+#ifdef _MSC_VER
+# include <float.h>
+# define isfinite _finite
+#else
+# include <math.h> // isfinite
+#endif
+
#include <iomanip>
#include <limits>
#include <ostream>
template<class T>
inline void writeNumber(T n) {
- if (n != n) {
- // NaN
+ if (!isfinite(n)) {
+ // NaN/Inf
writeNull();
} else {
separator();
-
if __name__ == '__main__':
print '#include <stdlib.h>'
print '#include <string.h>'
"glXGetProcAddressARB",
]
+ createContextFunctionNames = [
+ 'glXCreateContext',
+ 'glXCreateContextAttribsARB',
+ 'glXCreateContextWithConfigSGIX',
+ 'glXCreateNewContext',
+ ]
+
+ destroyContextFunctionNames = [
+ 'glXDestroyContext',
+ ]
+
+ makeCurrentFunctionNames = [
+ 'glXMakeCurrent',
+ 'glXMakeContextCurrent',
+ 'glXMakeCurrentReadSGI',
+ ]
+
def traceFunctionImplBody(self, function):
- if function.name == 'glXDestroyContext':
+ if function.name in self.destroyContextFunctionNames:
print ' gltrace::releaseContext((uintptr_t)ctx);'
GlTracer.traceFunctionImplBody(self, function)
- if function.name == 'glXCreateContext':
+ if function.name in self.createContextFunctionNames:
print ' if (_result != NULL)'
print ' gltrace::createContext((uintptr_t)_result);'
- if function.name == 'glXMakeCurrent':
+ if function.name in self.makeCurrentFunctionNames:
print ' if (_result) {'
print ' if (ctx != NULL)'
print ' gltrace::setContext((uintptr_t)ctx);'
"wglGetProcAddress",
]
+ createContextFunctionNames = [
+ 'wglCreateContext',
+ 'wglCreateContextAttribsARB',
+ 'wglCreateLayerContext',
+ ]
+
+ destroyContextFunctionNames = [
+ 'wglDeleteContext',
+ ]
+
+ makeCurrentFunctionNames = [
+ 'wglMakeCurrent',
+ 'wglMakeContextCurrentARB',
+ 'wglMakeContextCurrentEXT',
+ ]
+
def traceFunctionImplBody(self, function):
- if function.name == 'wglDeleteContext':
+ if function.name in self.destroyContextFunctionNames:
# Unlike other GL APIs like EGL or GLX, WGL will make the context
# inactive if it's currently the active context.
print ' if (_wglGetCurrentContext() == hglrc) {'
GlTracer.traceFunctionImplBody(self, function)
- if function.name == 'wglCreateContext':
+ if function.name in self.createContextFunctionNames:
print ' if (_result)'
print ' gltrace::createContext((uintptr_t)_result);'
- if function.name == 'wglMakeCurrent':
+ if function.name in self.makeCurrentFunctionNames:
print ' if (_result) {'
print ' if (hglrc != NULL)'
print ' gltrace::setContext((uintptr_t)hglrc);'