extern glws::Drawable *drawable;
extern glws::Context *context;
-extern int window_width;
-extern int window_height;
-
extern unsigned frame;
extern long long startTime;
extern bool wait;
def call_function(self, function):
if function.name == "glViewport":
- print ' bool reshape_window = false;'
- print ' if (x + width > glretrace::window_width) {'
- print ' glretrace::window_width = x + width;'
- print ' reshape_window = true;'
- print ' }'
- print ' if (y + height > glretrace::window_height) {'
- print ' glretrace::window_height = y + height;'
- print ' reshape_window = true;'
- print ' }'
- print ' if (reshape_window) {'
- print ' // XXX: does not always work'
- print ' glretrace::drawable->resize(glretrace::window_width, glretrace::window_height);'
- print ' reshape_window = false;'
+ print ' if (glretrace::drawable) {'
+ print ' int drawable_width = x + width;'
+ print ' int drawable_height = y + height;'
+ print ' if (drawable_width > (int)glretrace::drawable->width ||'
+ print ' drawable_height > (int)glretrace::drawable->height) {'
+ print ' glretrace::drawable->resize(drawable_width, drawable_height);'
+ print ' }'
print ' }'
if function.name == "glEnd":
def extract_arg(self, function, arg, arg_type, lvalue, rvalue):
if function.name in self.array_pointer_function_names and arg.name == 'pointer':
- print ' %s = static_cast<%s>(%s.blob());' % (lvalue, arg_type, rvalue)
+ print ' %s = static_cast<%s>(%s.toPointer());' % (lvalue, arg_type, rvalue)
return
if function.name in self.draw_elements_function_names and arg.name == 'indices':
- print ' %s = %s.blob();' % (lvalue, rvalue)
+ print ' %s = %s.toPointer();' % (lvalue, rvalue)
return
if function.name.startswith('glUniform') and function.args[0].name == arg.name == 'location':
using namespace glretrace;
+typedef std::map<unsigned long, glws::Drawable *> DrawableMap;
+typedef std::map<void *, glws::Context *> ContextMap;
+static DrawableMap drawable_map;
+static ContextMap context_map;
+
+
+static glws::Drawable *
+getDrawable(unsigned long drawable_id) {
+ if (drawable_id == 0) {
+ return NULL;
+ }
+
+ DrawableMap::const_iterator it;
+ it = drawable_map.find(drawable_id);
+ if (it == drawable_map.end()) {
+ return (drawable_map[drawable_id] = ws->createDrawable(visual));
+ }
+
+ return it->second;
+}
+
static void retrace_glXChooseVisual(Trace::Call &call) {
}
static void retrace_glXCreateContext(Trace::Call &call) {
+ void * orig_context = call.ret->toPointer();
+ glws::Context *context = ws->createContext(glretrace::visual);
+ context_map[orig_context] = context;
}
static void retrace_glXDestroyContext(Trace::Call &call) {
}
static void retrace_glXMakeCurrent(Trace::Call &call) {
- glFlush();
- if (!double_buffer) {
- frame_complete(call.no);
+ if (drawable && context) {
+ glFlush();
+ if (!double_buffer) {
+ frame_complete(call.no);
+ }
+ }
+
+ glws::Drawable *new_drawable = getDrawable(static_cast<unsigned long>(call.arg(1)));
+ glws::Context *new_context = context_map[call.arg(2).toPointer()];
+
+ bool result = ws->makeCurrent(new_drawable, new_context);
+
+ if (new_drawable && new_context && result) {
+ drawable = new_drawable;
+ context = new_context;
+ } else {
+ drawable = NULL;
+ context = NULL;
}
}
}
static void retrace_glXCreateNewContext(Trace::Call &call) {
+ retrace_glXCreateContext(call);
}
static void retrace_glXMakeContextCurrent(Trace::Call &call) {
+ if (drawable && context) {
+ glFlush();
+ if (!double_buffer) {
+ frame_complete(call.no);
+ }
+ }
+
+ glws::Drawable *new_drawable = getDrawable(static_cast<unsigned long>(call.arg(1)));
+ glws::Context *new_context = context_map[call.arg(3).toPointer()];
+
+ bool result = ws->makeCurrent(new_drawable, new_context);
+
+ if (new_drawable && new_context && result) {
+ drawable = new_drawable;
+ context = new_context;
+ } else {
+ drawable = NULL;
+ context = NULL;
+ }
}
static void retrace_glXGetCurrentReadDrawable(Trace::Call &call) {
glws::Drawable *drawable = NULL;
glws::Context *context = NULL;
-int window_width = 256, window_height = 256;
-
unsigned frame = 0;
long long startTime = 0;
bool wait = false;
void frame_complete(unsigned call_no) {
++frame;
- if (snapshot_prefix || compare_prefix) {
+ if (drawable &&
+ (snapshot_prefix || compare_prefix)) {
Image::Image *ref = NULL;
if (compare_prefix) {
char filename[PATH_MAX];
std::cout << "Read " << filename << "\n";
}
- Image::Image src(window_width, window_height, true);
+ Image::Image src(drawable->width, drawable->height, true);
snapshot(src);
if (snapshot_prefix) {
retrace::retrace_call(*call);
}
- if (!insideGlBeginEnd && call->no >= dump_state) {
+ if (!insideGlBeginEnd &&
+ drawable && context &&
+ call->no >= dump_state) {
state_dump(std::cout);
exit(0);
}
ws = glws::createNativeWindowSystem();
visual = ws->createVisual(double_buffer);
- drawable = ws->createDrawable(visual);
- drawable->resize(window_width, window_height);
- context = ws->createContext(visual);
- ws->makeCurrent(drawable, context);
for ( ; i < argc; ++i) {
if (parser.open(argv[i])) {
using namespace glretrace;
+typedef std::map<unsigned long long, glws::Drawable *> DrawableMap;
+typedef std::map<unsigned long long, glws::Context *> ContextMap;
+static DrawableMap drawable_map;
+static DrawableMap pbuffer_map;
+static ContextMap context_map;
+
+
+static glws::Drawable *
+getDrawable(unsigned long long hdc) {
+ if (hdc == 0) {
+ return NULL;
+ }
+
+ DrawableMap::const_iterator it;
+ it = drawable_map.find(hdc);
+ if (it == drawable_map.end()) {
+ return (drawable_map[hdc] = ws->createDrawable(visual));
+ }
+
+ return it->second;
+}
+
static void retrace_wglCreateContext(Trace::Call &call) {
+ unsigned long long orig_context = call.ret->toUIntPtr();
+ glws::Context *context = ws->createContext(glretrace::visual);
+ context_map[orig_context] = context;
}
static void retrace_wglDeleteContext(Trace::Call &call) {
}
static void retrace_wglMakeCurrent(Trace::Call &call) {
- glFlush();
- if (!double_buffer) {
- frame_complete(call.no);
+ if (drawable && context) {
+ glFlush();
+ if (!double_buffer) {
+ frame_complete(call.no);
+ }
+ }
+
+ glws::Drawable *new_drawable = getDrawable(call.arg(0).toUIntPtr());
+ glws::Context *new_context = context_map[call.arg(1).toUIntPtr()];
+
+ bool result = ws->makeCurrent(new_drawable, new_context);
+
+ if (new_drawable && new_context && result) {
+ drawable = new_drawable;
+ context = new_context;
+ } else {
+ drawable = NULL;
+ context = NULL;
}
}
}
static void retrace_wglCreateLayerContext(Trace::Call &call) {
+ retrace_wglCreateContext(call);
}
static void retrace_wglDescribeLayerPlane(Trace::Call &call) {
}
static void retrace_wglSwapLayerBuffers(Trace::Call &call) {
+ retrace_wglSwapBuffers(call);
}
static void retrace_wglUseFontBitmapsA(Trace::Call &call) {
}
static void retrace_wglCreatePbufferARB(Trace::Call &call) {
+ unsigned iWidth = call.arg(2);
+ unsigned iHeight = call.arg(3);
+
+ unsigned long long orig_pbuffer = call.ret->toUIntPtr();
+ glws::Drawable *drawable = ws->createDrawable(glretrace::visual);
+
+ drawable->resize(iWidth, iHeight);
+
+ pbuffer_map[orig_pbuffer] = drawable;
+}
+
+static void retrace_wglGetPbufferDCARB(Trace::Call &call) {
+ glws::Drawable *pbuffer = pbuffer_map[call.arg(0).toUIntPtr()];
+
+ unsigned long long orig_hdc = call.ret->toUIntPtr();
+
+ drawable_map[orig_hdc] = pbuffer;
}
static void retrace_wglReleasePbufferDCARB(Trace::Call &call) {
case 'g':
if (name[1] == 'l' && name[2] == 'A' && name[3] == 'd' && name[4] == 'd' && name[5] == 'S' && name[6] == 'w' && name[7] == 'a' && name[8] == 'p' && name[9] == 'H' && name[10] == 'i' && name[11] == 'n' && name[12] == 't' && name[13] == 'R' && name[14] == 'e' && name[15] == 'c' && name[16] == 't' && name[17] == 'W' && name[18] == 'I' && name[19] == 'N' && name[20] == '\0') {
// glAddSwapHintRectWIN
- retrace_glAddSwapHintRectWIN(call);
- return;
+ retrace_glAddSwapHintRectWIN(call);
+ return;
}
break;
case 'w':
case 'A':
if (name[4] == 'l' && name[5] == 'l' && name[6] == 'o' && name[7] == 'c' && name[8] == 'a' && name[9] == 't' && name[10] == 'e' && name[11] == 'M' && name[12] == 'e' && name[13] == 'm' && name[14] == 'o' && name[15] == 'r' && name[16] == 'y' && name[17] == 'N' && name[18] == 'V' && name[19] == '\0') {
// wglAllocateMemoryNV
- retrace_wglAllocateMemoryNV(call);
- return;
+ retrace_wglAllocateMemoryNV(call);
+ return;
}
break;
case 'B':
if (name[4] == 'i' && name[5] == 'n' && name[6] == 'd' && name[7] == 'T' && name[8] == 'e' && name[9] == 'x' && name[10] == 'I' && name[11] == 'm' && name[12] == 'a' && name[13] == 'g' && name[14] == 'e' && name[15] == 'A' && name[16] == 'R' && name[17] == 'B' && name[18] == '\0') {
// wglBindTexImageARB
- retrace_wglBindTexImageARB(call);
- return;
+ retrace_wglBindTexImageARB(call);
+ return;
}
break;
case 'C':
switch (name[20]) {
case '\0':
// wglChoosePixelFormat
- retrace_wglChoosePixelFormat(call);
- return;
+ retrace_wglChoosePixelFormat(call);
+ return;
break;
case 'A':
if (name[21] == 'R' && name[22] == 'B' && name[23] == '\0') {
// wglChoosePixelFormatARB
- retrace_wglChoosePixelFormatARB(call);
- return;
+ retrace_wglChoosePixelFormatARB(call);
+ return;
}
break;
case 'E':
if (name[21] == 'X' && name[22] == 'T' && name[23] == '\0') {
// wglChoosePixelFormatEXT
- retrace_wglChoosePixelFormatEXT(call);
- return;
+ retrace_wglChoosePixelFormatEXT(call);
+ return;
}
break;
}
case 'o':
if (name[5] == 'p' && name[6] == 'y' && name[7] == 'C' && name[8] == 'o' && name[9] == 'n' && name[10] == 't' && name[11] == 'e' && name[12] == 'x' && name[13] == 't' && name[14] == '\0') {
// wglCopyContext
- retrace_wglCopyContext(call);
- return;
+ retrace_wglCopyContext(call);
+ return;
}
break;
case 'r':
case 'B':
if (name[10] == 'u' && name[11] == 'f' && name[12] == 'f' && name[13] == 'e' && name[14] == 'r' && name[15] == 'R' && name[16] == 'e' && name[17] == 'g' && name[18] == 'i' && name[19] == 'o' && name[20] == 'n' && name[21] == 'A' && name[22] == 'R' && name[23] == 'B' && name[24] == '\0') {
// wglCreateBufferRegionARB
- retrace_wglCreateBufferRegionARB(call);
- return;
+ retrace_wglCreateBufferRegionARB(call);
+ return;
}
break;
case 'C':
switch (name[16]) {
case '\0':
// wglCreateContext
- retrace_wglCreateContext(call);
- return;
+ retrace_wglCreateContext(call);
+ return;
break;
case 'A':
if (name[17] == 't' && name[18] == 't' && name[19] == 'r' && name[20] == 'i' && name[21] == 'b' && name[22] == 's' && name[23] == 'A' && name[24] == 'R' && name[25] == 'B' && name[26] == '\0') {
// wglCreateContextAttribsARB
- retrace_wglCreateContextAttribsARB(call);
- return;
+ retrace_wglCreateContextAttribsARB(call);
+ return;
}
break;
}
case 'L':
if (name[10] == 'a' && name[11] == 'y' && name[12] == 'e' && name[13] == 'r' && name[14] == 'C' && name[15] == 'o' && name[16] == 'n' && name[17] == 't' && name[18] == 'e' && name[19] == 'x' && name[20] == 't' && name[21] == '\0') {
// wglCreateLayerContext
- retrace_wglCreateLayerContext(call);
- return;
+ retrace_wglCreateLayerContext(call);
+ return;
}
break;
case 'P':
if (name[10] == 'b' && name[11] == 'u' && name[12] == 'f' && name[13] == 'f' && name[14] == 'e' && name[15] == 'r' && name[16] == 'A' && name[17] == 'R' && name[18] == 'B' && name[19] == '\0') {
// wglCreatePbufferARB
- retrace_wglCreatePbufferARB(call);
- return;
+ retrace_wglCreatePbufferARB(call);
+ return;
}
break;
}
case 'B':
if (name[10] == 'u' && name[11] == 'f' && name[12] == 'f' && name[13] == 'e' && name[14] == 'r' && name[15] == 'R' && name[16] == 'e' && name[17] == 'g' && name[18] == 'i' && name[19] == 'o' && name[20] == 'n' && name[21] == 'A' && name[22] == 'R' && name[23] == 'B' && name[24] == '\0') {
// wglDeleteBufferRegionARB
- retrace_wglDeleteBufferRegionARB(call);
- return;
+ retrace_wglDeleteBufferRegionARB(call);
+ return;
}
break;
case 'C':
if (name[10] == 'o' && name[11] == 'n' && name[12] == 't' && name[13] == 'e' && name[14] == 'x' && name[15] == 't' && name[16] == '\0') {
// wglDeleteContext
- retrace_wglDeleteContext(call);
- return;
+ retrace_wglDeleteContext(call);
+ return;
}
break;
}
case 'L':
if (name[12] == 'a' && name[13] == 'y' && name[14] == 'e' && name[15] == 'r' && name[16] == 'P' && name[17] == 'l' && name[18] == 'a' && name[19] == 'n' && name[20] == 'e' && name[21] == '\0') {
// wglDescribeLayerPlane
- retrace_wglDescribeLayerPlane(call);
- return;
+ retrace_wglDescribeLayerPlane(call);
+ return;
}
break;
case 'P':
if (name[12] == 'i' && name[13] == 'x' && name[14] == 'e' && name[15] == 'l' && name[16] == 'F' && name[17] == 'o' && name[18] == 'r' && name[19] == 'm' && name[20] == 'a' && name[21] == 't' && name[22] == '\0') {
// wglDescribePixelFormat
- retrace_wglDescribePixelFormat(call);
- return;
+ retrace_wglDescribePixelFormat(call);
+ return;
}
break;
}
case 't':
if (name[7] == 'r' && name[8] == 'o' && name[9] == 'y' && name[10] == 'P' && name[11] == 'b' && name[12] == 'u' && name[13] == 'f' && name[14] == 'f' && name[15] == 'e' && name[16] == 'r' && name[17] == 'A' && name[18] == 'R' && name[19] == 'B' && name[20] == '\0') {
// wglDestroyPbufferARB
- retrace_wglDestroyPbufferARB(call);
- return;
+ retrace_wglDestroyPbufferARB(call);
+ return;
}
break;
}
case 'F':
if (name[4] == 'r' && name[5] == 'e' && name[6] == 'e' && name[7] == 'M' && name[8] == 'e' && name[9] == 'm' && name[10] == 'o' && name[11] == 'r' && name[12] == 'y' && name[13] == 'N' && name[14] == 'V' && name[15] == '\0') {
// wglFreeMemoryNV
- retrace_wglFreeMemoryNV(call);
- return;
+ retrace_wglFreeMemoryNV(call);
+ return;
}
break;
case 'G':
case 'C':
if (name[14] == 'o' && name[15] == 'n' && name[16] == 't' && name[17] == 'e' && name[18] == 'x' && name[19] == 't' && name[20] == '\0') {
// wglGetCurrentContext
- return;
+ return;
}
break;
case 'D':
if (name[14] == 'C' && name[15] == '\0') {
// wglGetCurrentDC
- return;
+ return;
}
break;
case 'R':
case 'A':
if (name[20] == 'R' && name[21] == 'B' && name[22] == '\0') {
// wglGetCurrentReadDCARB
- return;
+ return;
}
break;
case 'E':
if (name[20] == 'X' && name[21] == 'T' && name[22] == '\0') {
// wglGetCurrentReadDCEXT
- return;
+ return;
}
break;
}
case 'D':
if (name[7] == 'e' && name[8] == 'f' && name[9] == 'a' && name[10] == 'u' && name[11] == 'l' && name[12] == 't' && name[13] == 'P' && name[14] == 'r' && name[15] == 'o' && name[16] == 'c' && name[17] == 'A' && name[18] == 'd' && name[19] == 'd' && name[20] == 'r' && name[21] == 'e' && name[22] == 's' && name[23] == 's' && name[24] == '\0') {
// wglGetDefaultProcAddress
- return;
+ return;
}
break;
case 'E':
case 'A':
if (name[23] == 'R' && name[24] == 'B' && name[25] == '\0') {
// wglGetExtensionsStringARB
- return;
+ return;
}
break;
case 'E':
if (name[23] == 'X' && name[24] == 'T' && name[25] == '\0') {
// wglGetExtensionsStringEXT
- return;
+ return;
}
break;
}
case 'L':
if (name[7] == 'a' && name[8] == 'y' && name[9] == 'e' && name[10] == 'r' && name[11] == 'P' && name[12] == 'a' && name[13] == 'l' && name[14] == 'e' && name[15] == 't' && name[16] == 't' && name[17] == 'e' && name[18] == 'E' && name[19] == 'n' && name[20] == 't' && name[21] == 'r' && name[22] == 'i' && name[23] == 'e' && name[24] == 's' && name[25] == '\0') {
// wglGetLayerPaletteEntries
- return;
+ return;
}
break;
case 'P':
case 'b':
if (name[8] == 'u' && name[9] == 'f' && name[10] == 'f' && name[11] == 'e' && name[12] == 'r' && name[13] == 'D' && name[14] == 'C' && name[15] == 'A' && name[16] == 'R' && name[17] == 'B' && name[18] == '\0') {
// wglGetPbufferDCARB
- return;
+ retrace_wglGetPbufferDCARB(call);
+ return;
}
break;
case 'i':
switch (name[17]) {
case '\0':
// wglGetPixelFormat
- return;
+ return;
break;
case 'A':
switch (name[18]) {
case 'A':
if (name[26] == 'R' && name[27] == 'B' && name[28] == '\0') {
// wglGetPixelFormatAttribfvARB
- return;
+ return;
}
break;
case 'E':
if (name[26] == 'X' && name[27] == 'T' && name[28] == '\0') {
// wglGetPixelFormatAttribfvEXT
- return;
+ return;
}
break;
}
case 'A':
if (name[26] == 'R' && name[27] == 'B' && name[28] == '\0') {
// wglGetPixelFormatAttribivARB
- return;
+ return;
}
break;
case 'E':
if (name[26] == 'X' && name[27] == 'T' && name[28] == '\0') {
// wglGetPixelFormatAttribivEXT
- return;
+ return;
}
break;
}
case 'r':
if (name[8] == 'o' && name[9] == 'c' && name[10] == 'A' && name[11] == 'd' && name[12] == 'd' && name[13] == 'r' && name[14] == 'e' && name[15] == 's' && name[16] == 's' && name[17] == '\0') {
// wglGetProcAddress
- retrace_wglGetProcAddress(call);
- return;
+ retrace_wglGetProcAddress(call);
+ return;
}
break;
}
case 'S':
if (name[7] == 'w' && name[8] == 'a' && name[9] == 'p' && name[10] == 'I' && name[11] == 'n' && name[12] == 't' && name[13] == 'e' && name[14] == 'r' && name[15] == 'v' && name[16] == 'a' && name[17] == 'l' && name[18] == 'E' && name[19] == 'X' && name[20] == 'T' && name[21] == '\0') {
// wglGetSwapIntervalEXT
- return;
+ return;
}
break;
}
case 'A':
if (name[22] == 'R' && name[23] == 'B' && name[24] == '\0') {
// wglMakeContextCurrentARB
- retrace_wglMakeContextCurrentARB(call);
- return;
+ retrace_wglMakeContextCurrentARB(call);
+ return;
}
break;
case 'E':
if (name[22] == 'X' && name[23] == 'T' && name[24] == '\0') {
// wglMakeContextCurrentEXT
- retrace_wglMakeContextCurrentEXT(call);
- return;
+ retrace_wglMakeContextCurrentEXT(call);
+ return;
}
break;
}
case 'u':
if (name[9] == 'r' && name[10] == 'r' && name[11] == 'e' && name[12] == 'n' && name[13] == 't' && name[14] == '\0') {
// wglMakeCurrent
- retrace_wglMakeCurrent(call);
- return;
+ retrace_wglMakeCurrent(call);
+ return;
}
break;
}
case 'Q':
if (name[4] == 'u' && name[5] == 'e' && name[6] == 'r' && name[7] == 'y' && name[8] == 'P' && name[9] == 'b' && name[10] == 'u' && name[11] == 'f' && name[12] == 'f' && name[13] == 'e' && name[14] == 'r' && name[15] == 'A' && name[16] == 'R' && name[17] == 'B' && name[18] == '\0') {
// wglQueryPbufferARB
- retrace_wglQueryPbufferARB(call);
- return;
+ retrace_wglQueryPbufferARB(call);
+ return;
}
break;
case 'R':
case 'a':
if (name[6] == 'l' && name[7] == 'i' && name[8] == 'z' && name[9] == 'e' && name[10] == 'L' && name[11] == 'a' && name[12] == 'y' && name[13] == 'e' && name[14] == 'r' && name[15] == 'P' && name[16] == 'a' && name[17] == 'l' && name[18] == 'e' && name[19] == 't' && name[20] == 't' && name[21] == 'e' && name[22] == '\0') {
// wglRealizeLayerPalette
- retrace_wglRealizeLayerPalette(call);
- return;
+ retrace_wglRealizeLayerPalette(call);
+ return;
}
break;
case 'l':
case 'P':
if (name[11] == 'b' && name[12] == 'u' && name[13] == 'f' && name[14] == 'f' && name[15] == 'e' && name[16] == 'r' && name[17] == 'D' && name[18] == 'C' && name[19] == 'A' && name[20] == 'R' && name[21] == 'B' && name[22] == '\0') {
// wglReleasePbufferDCARB
- retrace_wglReleasePbufferDCARB(call);
- return;
+ retrace_wglReleasePbufferDCARB(call);
+ return;
}
break;
case 'T':
if (name[11] == 'e' && name[12] == 'x' && name[13] == 'I' && name[14] == 'm' && name[15] == 'a' && name[16] == 'g' && name[17] == 'e' && name[18] == 'A' && name[19] == 'R' && name[20] == 'B' && name[21] == '\0') {
// wglReleaseTexImageARB
- retrace_wglReleaseTexImageARB(call);
- return;
+ retrace_wglReleaseTexImageARB(call);
+ return;
}
break;
}
case 's':
if (name[6] == 't' && name[7] == 'o' && name[8] == 'r' && name[9] == 'e' && name[10] == 'B' && name[11] == 'u' && name[12] == 'f' && name[13] == 'f' && name[14] == 'e' && name[15] == 'r' && name[16] == 'R' && name[17] == 'e' && name[18] == 'g' && name[19] == 'i' && name[20] == 'o' && name[21] == 'n' && name[22] == 'A' && name[23] == 'R' && name[24] == 'B' && name[25] == '\0') {
// wglRestoreBufferRegionARB
- retrace_wglRestoreBufferRegionARB(call);
- return;
+ retrace_wglRestoreBufferRegionARB(call);
+ return;
}
break;
}
case 'a':
if (name[5] == 'v' && name[6] == 'e' && name[7] == 'B' && name[8] == 'u' && name[9] == 'f' && name[10] == 'f' && name[11] == 'e' && name[12] == 'r' && name[13] == 'R' && name[14] == 'e' && name[15] == 'g' && name[16] == 'i' && name[17] == 'o' && name[18] == 'n' && name[19] == 'A' && name[20] == 'R' && name[21] == 'B' && name[22] == '\0') {
// wglSaveBufferRegionARB
- retrace_wglSaveBufferRegionARB(call);
- return;
+ retrace_wglSaveBufferRegionARB(call);
+ return;
}
break;
case 'e':
case 'L':
if (name[7] == 'a' && name[8] == 'y' && name[9] == 'e' && name[10] == 'r' && name[11] == 'P' && name[12] == 'a' && name[13] == 'l' && name[14] == 'e' && name[15] == 't' && name[16] == 't' && name[17] == 'e' && name[18] == 'E' && name[19] == 'n' && name[20] == 't' && name[21] == 'r' && name[22] == 'i' && name[23] == 'e' && name[24] == 's' && name[25] == '\0') {
// wglSetLayerPaletteEntries
- retrace_wglSetLayerPaletteEntries(call);
- return;
+ retrace_wglSetLayerPaletteEntries(call);
+ return;
}
break;
case 'P':
case 'b':
if (name[8] == 'u' && name[9] == 'f' && name[10] == 'f' && name[11] == 'e' && name[12] == 'r' && name[13] == 'A' && name[14] == 't' && name[15] == 't' && name[16] == 'r' && name[17] == 'i' && name[18] == 'b' && name[19] == 'A' && name[20] == 'R' && name[21] == 'B' && name[22] == '\0') {
// wglSetPbufferAttribARB
- retrace_wglSetPbufferAttribARB(call);
- return;
+ retrace_wglSetPbufferAttribARB(call);
+ return;
}
break;
case 'i':
if (name[8] == 'x' && name[9] == 'e' && name[10] == 'l' && name[11] == 'F' && name[12] == 'o' && name[13] == 'r' && name[14] == 'm' && name[15] == 'a' && name[16] == 't' && name[17] == '\0') {
// wglSetPixelFormat
- retrace_wglSetPixelFormat(call);
- return;
+ retrace_wglSetPixelFormat(call);
+ return;
}
break;
}
case 'h':
if (name[5] == 'a' && name[6] == 'r' && name[7] == 'e' && name[8] == 'L' && name[9] == 'i' && name[10] == 's' && name[11] == 't' && name[12] == 's' && name[13] == '\0') {
// wglShareLists
- retrace_wglShareLists(call);
- return;
+ retrace_wglShareLists(call);
+ return;
}
break;
case 'w':
case 'B':
if (name[8] == 'u' && name[9] == 'f' && name[10] == 'f' && name[11] == 'e' && name[12] == 'r' && name[13] == 's' && name[14] == '\0') {
// wglSwapBuffers
- retrace_wglSwapBuffers(call);
- return;
+ retrace_wglSwapBuffers(call);
+ return;
}
break;
case 'I':
if (name[8] == 'n' && name[9] == 't' && name[10] == 'e' && name[11] == 'r' && name[12] == 'v' && name[13] == 'a' && name[14] == 'l' && name[15] == 'E' && name[16] == 'X' && name[17] == 'T' && name[18] == '\0') {
// wglSwapIntervalEXT
- retrace_wglSwapIntervalEXT(call);
- return;
+ retrace_wglSwapIntervalEXT(call);
+ return;
}
break;
case 'L':
if (name[8] == 'a' && name[9] == 'y' && name[10] == 'e' && name[11] == 'r' && name[12] == 'B' && name[13] == 'u' && name[14] == 'f' && name[15] == 'f' && name[16] == 'e' && name[17] == 'r' && name[18] == 's' && name[19] == '\0') {
// wglSwapLayerBuffers
- retrace_wglSwapLayerBuffers(call);
- return;
+ retrace_wglSwapLayerBuffers(call);
+ return;
}
break;
case 'M':
if (name[8] == 'u' && name[9] == 'l' && name[10] == 't' && name[11] == 'i' && name[12] == 'p' && name[13] == 'l' && name[14] == 'e' && name[15] == 'B' && name[16] == 'u' && name[17] == 'f' && name[18] == 'f' && name[19] == 'e' && name[20] == 'r' && name[21] == 's' && name[22] == '\0') {
// wglSwapMultipleBuffers
- retrace_wglSwapMultipleBuffers(call);
- return;
+ retrace_wglSwapMultipleBuffers(call);
+ return;
}
break;
}
case 'A':
if (name[18] == '\0') {
// wglUseFontBitmapsA
- retrace_wglUseFontBitmapsA(call);
- return;
+ retrace_wglUseFontBitmapsA(call);
+ return;
}
break;
case 'W':
if (name[18] == '\0') {
// wglUseFontBitmapsW
- retrace_wglUseFontBitmapsW(call);
- return;
+ retrace_wglUseFontBitmapsW(call);
+ return;
}
break;
}
case 'A':
if (name[19] == '\0') {
// wglUseFontOutlinesA
- retrace_wglUseFontOutlinesA(call);
- return;
+ retrace_wglUseFontOutlinesA(call);
+ return;
}
break;
case 'W':
if (name[19] == '\0') {
// wglUseFontOutlinesW
- retrace_wglUseFontOutlinesW(call);
- return;
+ retrace_wglUseFontOutlinesW(call);
+ return;
}
break;
}
static inline void
writeDrawBufferImage(JSONWriter &json, GLenum format)
{
- GLint width = glretrace::window_width;
- GLint height = glretrace::window_height;
-
GLint channels = __gl_format_channels(format);
- if (!width || !height) {
+ if (!glretrace::drawable) {
json.writeNull();
} else {
+ GLint width = glretrace::drawable->width;
+ GLint height = glretrace::drawable->height;
+
json.beginObject();
// Tell the GUI this is no ordinary object, but an image
{
public:
const Visual *visual;
- unsigned width;
- unsigned height;
+ int width;
+ int height;
- Drawable(const Visual *vis) :
- visual(vis)
+ Drawable(const Visual *vis, int w, int h) :
+ visual(vis),
+ width(w),
+ height(h)
{}
virtual ~Drawable() {}
virtual void
- resize(unsigned w, unsigned h) {
+ resize(int w, int h) {
width = w;
height = h;
}
createVisual(bool doubleBuffer = false) = 0;
virtual Drawable *
- createDrawable(const Visual *visual) = 0;
+ createDrawable(const Visual *visual, int width = 256, int height = 256) = 0;
virtual Context *
createContext(const Visual *visual) = 0;
namespace glws {
+static Display *display = NULL;
+static int screen = 0;
+
class GlxVisual : public Visual
{
public:
class GlxDrawable : public Drawable
{
public:
- Display *display;
Window window;
- GlxDrawable(const Visual *vis, Display *dpy, Window win) :
- Drawable(vis),
- display(dpy),
- window(win)
- {}
+ GlxDrawable(const Visual *vis, int w, int h) :
+ Drawable(vis, w, h)
+ {
+ XVisualInfo *visinfo = dynamic_cast<const GlxVisual *>(visual)->visinfo;
+
+ Window root = RootWindow(display, screen);
+
+ /* window attributes */
+ XSetWindowAttributes attr;
+ attr.background_pixel = 0;
+ attr.border_pixel = 0;
+ attr.colormap = XCreateColormap(display, root, visinfo->visual, AllocNone);
+ attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask;
+
+ unsigned long mask;
+ mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
+
+ int x = 0, y = 0;
+
+ window = XCreateWindow(
+ display, root,
+ x, y, width, height,
+ 0,
+ visinfo->depth,
+ InputOutput,
+ visinfo->visual,
+ mask,
+ &attr);
+
+ XSizeHints sizehints;
+ sizehints.x = x;
+ sizehints.y = y;
+ sizehints.width = width;
+ sizehints.height = height;
+ sizehints.flags = USSize | USPosition;
+ XSetNormalHints(display, window, &sizehints);
+
+ const char *name = "glretrace";
+ XSetStandardProperties(
+ display, window, name, name,
+ None, (char **)NULL, 0, &sizehints);
+
+ XMapWindow(display, window);
+ }
~GlxDrawable() {
XDestroyWindow(display, window);
}
-
+
void
- resize(unsigned w, unsigned h) {
+ resize(int w, int h) {
glXWaitGL();
Drawable::resize(w, h);
XResizeWindow(display, window, w, h);
class GlxContext : public Context
{
public:
- Display *display;
GLXContext context;
-
- GlxContext(const Visual *vis, Display *dpy, GLXContext ctx) :
+
+ GlxContext(const Visual *vis, GLXContext ctx) :
Context(vis),
- display(dpy),
context(ctx)
{}
class GlxWindowSystem : public WindowSystem
{
-private:
- Display *display;
- int screen;
-
public:
GlxWindowSystem() {
- display = XOpenDisplay(NULL);
- if (!display) {
- std::cerr << "error: unable to open display " << XDisplayName(NULL) << "\n";
- exit(1);
+ if (!display) {
+ display = XOpenDisplay(NULL);
+ if (!display) {
+ std::cerr << "error: unable to open display " << XDisplayName(NULL) << "\n";
+ exit(1);
+ }
+ screen = DefaultScreen(display);
}
- screen = DefaultScreen(display);
}
~GlxWindowSystem() {
};
XVisualInfo *visinfo;
-
+
visinfo = glXChooseVisual(display, screen, doubleBuffer ? double_attribs : single_attribs);
return new GlxVisual(visinfo);
}
-
+
Drawable *
- createDrawable(const Visual *visual)
+ createDrawable(const Visual *visual, int width, int height)
{
- XVisualInfo *visinfo = dynamic_cast<const GlxVisual *>(visual)->visinfo;
-
- Window root = RootWindow(display, screen);
-
- /* window attributes */
- XSetWindowAttributes attr;
- attr.background_pixel = 0;
- attr.border_pixel = 0;
- attr.colormap = XCreateColormap(display, root, visinfo->visual, AllocNone);
- attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask;
-
- unsigned long mask;
- mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
-
- int x = 0, y = 0, width = 256, height = 256;
-
- Window window = XCreateWindow(
- display, root,
- x, y, width, height,
- 0,
- visinfo->depth,
- InputOutput,
- visinfo->visual,
- mask,
- &attr);
-
- XSizeHints sizehints;
- sizehints.x = x;
- sizehints.y = y;
- sizehints.width = width;
- sizehints.height = height;
- sizehints.flags = USSize | USPosition;
- XSetNormalHints(display, window, &sizehints);
-
- const char *name = "glretrace";
- XSetStandardProperties(
- display, window, name, name,
- None, (char **)NULL, 0, &sizehints);
-
- XMapWindow(display, window);
-
- return new GlxDrawable(visual, display, window);
+ return new GlxDrawable(visual, width, height);
}
Context *
{
XVisualInfo *visinfo = dynamic_cast<const GlxVisual *>(visual)->visinfo;
GLXContext context = glXCreateContext(display, visinfo, NULL, True);
- return new GlxContext(visual, display, context);
+ return new GlxContext(visual, context);
}
bool
PIXELFORMATDESCRIPTOR pfd;
int iPixelFormat;
- WglDrawable(const Visual *vis) :
- Drawable(vis)
+ WglDrawable(const Visual *vis, int width, int height) :
+ Drawable(vis, width, height)
{
static bool first = TRUE;
RECT rect;
dwExStyle = 0;
dwStyle = WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VISIBLE | WS_OVERLAPPEDWINDOW;
- int x = 0, y = 0, width = 256, height = 256;
+ int x = 0, y = 0;
rect.left = x;
rect.top = y;
}
void
- resize(unsigned w, unsigned h) {
+ resize(int w, int h) {
Drawable::resize(w, h);
RECT rClient, rWindow;
GetClientRect(hWnd, &rClient);
}
Drawable *
- createDrawable(const Visual *visual)
+ createDrawable(const Visual *visual, int width, int height)
{
- return new WglDrawable(visual);
+ return new WglDrawable(visual, width, height);
}
Context *
print ' %s = %s;' % (lvalue, new_lvalue)
def visit_blob(self, blob, lvalue, rvalue):
- print ' %s = static_cast<%s>((%s).blob());' % (lvalue, blob, rvalue)
+ print ' %s = static_cast<%s>((%s).toPointer());' % (lvalue, blob, rvalue)
def visit_string(self, string, lvalue, rvalue):
- print ' %s = (%s)((%s).string());' % (lvalue, string.expr, rvalue)
+ print ' %s = (%s)((%s).toString());' % (lvalue, string.expr, rvalue)
class OpaqueValueExtractor(ValueExtractor):
in the context of handles.'''
def visit_opaque(self, opaque, lvalue, rvalue):
- print ' %s = static_cast<%s>((%s).blob());' % (lvalue, opaque, rvalue)
+ print ' %s = static_cast<%s>((%s).toPointer());' % (lvalue, opaque, rvalue)
class ValueWrapper(stdapi.Visitor):
Enum ::operator double (void) const { return static_cast<unsigned long long>(*sig->second); }
-// blob cast
-void * Value ::blob(void) const { assert(0); return NULL; }
-void * Null ::blob(void) const { return NULL; }
-void * Blob ::blob(void) const { return buf; }
-void * Pointer::blob(void) const { return (void *)value; }
+// pointer cast
+void * Value ::toPointer(void) const { assert(0); return NULL; }
+void * Null ::toPointer(void) const { return NULL; }
+void * Blob ::toPointer(void) const { return buf; }
+void * Pointer::toPointer(void) const { return (void *)value; }
+
+
+// pointer cast
+unsigned long long Value ::toUIntPtr(void) const { assert(0); return 0; }
+unsigned long long Null ::toUIntPtr(void) const { return 0; }
+unsigned long long Pointer::toUIntPtr(void) const { return value; }
+
+
+// string cast
+const char * Value ::toString(void) const { assert(0); return NULL; }
+const char * Null ::toString(void) const { return NULL; }
+const char * String::toString(void) const { return value.c_str(); }
// virtual Value::visit()
return null;
}
-const char * Value::string(void) const {
- const String *string = dynamic_cast<const String *>(unwrap(this));
- if (string)
- return string->value.c_str();
- const Null *null = dynamic_cast<const Null *>(unwrap(this));
- if (null)
- return NULL;
- assert(0);
- return NULL;
-}
-
std::ostream & operator <<(std::ostream &os, Call &call) {
Dumper d(os);
os << call.no << " ";
virtual operator unsigned long long (void) const;
virtual operator double (void) const;
- virtual void *blob(void) const;
- const char *string(void) const;
+ virtual void *toPointer(void) const;
+ virtual unsigned long long toUIntPtr(void) const;
+ virtual const char *toString(void) const;
inline operator signed char (void) const {
return static_cast<signed long long>(*this);
operator signed long long (void) const;
operator unsigned long long (void) const;
operator double (void) const;
- void *blob(void) const;
+ void *toPointer(void) const;
+ unsigned long long toUIntPtr(void) const;
+ const char *toString(void) const;
void visit(Visitor &visitor);
};
String(std::string _value) : value(_value) {}
operator bool (void) const;
+ const char *toString(void) const;
void visit(Visitor &visitor);
std::string value;
~Blob();
operator bool (void) const;
- void *blob(void) const;
+ void *toPointer(void) const;
void visit(Visitor &visitor);
size_t size;
Pointer(unsigned long long value) : UInt(value) {}
operator bool (void) const;
- void *blob(void) const;
+ void *toPointer(void) const;
+ unsigned long long toUIntPtr(void) const;
void visit(Visitor &visitor);
};
# WGL_ARB_pbuffer
StdFunction(HPBUFFERARB, "wglCreatePbufferARB", [(HDC, "hDC"), (Int, "iPixelFormat"), (Int, "iWidth"), (Int, "iHeight"), (Const(Array(WGLenum, "__AttribList_size(piAttribList)")), "piAttribList")]),
- StdFunction(HDC, "wglGetPbufferDCARB", [(HPBUFFERARB, "hPbuffer")], sideeffects=False),
+ StdFunction(HDC, "wglGetPbufferDCARB", [(HPBUFFERARB, "hPbuffer")]),
StdFunction(Int, "wglReleasePbufferDCARB", [(HPBUFFERARB, "hPbuffer"), (HDC, "hDC")]),
StdFunction(BOOL, "wglDestroyPbufferARB", [(HPBUFFERARB, "hPbuffer")]),
- StdFunction(BOOL, "wglQueryPbufferARB", [(HPBUFFERARB, "hPbuffer"), (WGLenum, "iAttribute"), Out(Pointer(Int), "piValue")]),
+ StdFunction(BOOL, "wglQueryPbufferARB", [(HPBUFFERARB, "hPbuffer"), (WGLenum, "iAttribute"), Out(Pointer(Int), "piValue")], sideeffects=False),
# WGL_ARB_render_texture
StdFunction(BOOL, "wglBindTexImageARB", [(HPBUFFERARB, "hPbuffer"), (Int, "iBuffer")]),