Don't create an initial window.
authorJosé Fonseca <jose.r.fonseca@gmail.com>
Fri, 6 May 2011 19:50:52 +0000 (20:50 +0100)
committerJosé Fonseca <jose.r.fonseca@gmail.com>
Fri, 6 May 2011 19:50:52 +0000 (20:50 +0100)
glretrace.hpp
glretrace.py
glretrace_main.cpp
glstate.py

index 9d74641..24268fe 100644 (file)
@@ -43,9 +43,6 @@ extern glws::Visual *visual;
 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;
index 91176e1..d5b254f 100644 (file)
@@ -127,19 +127,13 @@ class GlRetracer(Retracer):
 
     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":
index e8567dc..0e9e6bd 100644 (file)
@@ -42,8 +42,6 @@ glws::Visual *visual = NULL;
 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;
@@ -118,7 +116,8 @@ static void snapshot(Image::Image &image) {
 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];
@@ -131,7 +130,7 @@ void frame_complete(unsigned call_no) {
                 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) {
@@ -171,7 +170,9 @@ static void display(void) {
             retrace::retrace_call(*call);
         }
 
-        if (!insideGlBeginEnd && call->no >= dump_state) {
+        if (!insideGlBeginEnd &&
+            drawable && context &&
+            call->no >= dump_state) {
             state_dump(std::cout);
             exit(0);
         }
@@ -256,10 +257,6 @@ int main(int argc, char **argv)
 
     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])) {
index a42148e..51afb96 100644 (file)
@@ -419,14 +419,14 @@ writeTextureImage(JSONWriter &json, GLenum target, GLint level)
 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