[GRASS-SVN] r56019 - in grass/trunk: lib/nviz misc/m.nviz.image

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Apr 28 08:04:28 PDT 2013


Author: martinl
Date: 2013-04-28 08:04:28 -0700 (Sun, 28 Apr 2013)
New Revision: 56019

Modified:
   grass/trunk/lib/nviz/render.c
   grass/trunk/misc/m.nviz.image/main.c
Log:
m.nviz.image: Nviz_create_render_window(): check return code


Modified: grass/trunk/lib/nviz/render.c
===================================================================
--- grass/trunk/lib/nviz/render.c	2013-04-28 14:52:15 UTC (rev 56018)
+++ grass/trunk/lib/nviz/render.c	2013-04-28 15:04:28 UTC (rev 56019)
@@ -88,7 +88,8 @@
    \param width window width
    \param height window height
 
-   \return 1
+   \return 0 on success
+   \return -1 on error
  */
 int Nviz_create_render_window(struct render_window *rwin, void *display,
 			      int width, int height)
@@ -107,11 +108,16 @@
 
     v = glXChooseVisual(rwin->displayId,
 			DefaultScreen(rwin->displayId), attributeList);
-
+    if (!v) {
+        G_warning(_("Unable to get visual info"));
+        return -1;
+    }
+        
     rwin->contextId = glXCreateContext(rwin->displayId, v, NULL, GL_FALSE);
 
     if (!rwin->contextId) {
-	G_fatal_error(_("Unable to create rendering context"));
+	G_warning(_("Unable to create rendering context"));
+        return -1;
     }
 
     /* create win pixmap to render to (same depth as RootWindow) */
@@ -122,9 +128,7 @@
     /* create an off-screen GLX rendering area */
     rwin->windowId = glXCreateGLXPixmap(rwin->displayId, v, rwin->pixmap);
 
-    if (v) {
-	XFree(v);
-    }
+    XFree(v);
 #elif defined(OPENGL_AQUA)
     int attributeList[] = { AGL_RGBA, AGL_RED_SIZE, 1,
 	AGL_GREEN_SIZE, 1, AGL_BLUE_SIZE, 1,
@@ -170,7 +174,7 @@
     rwin->contextId = wglCreateContext(rwin->displayId);
     /* TODO */
 #endif
-    return 1;
+    return 0;
 }
 
 /*!

Modified: grass/trunk/misc/m.nviz.image/main.c
===================================================================
--- grass/trunk/misc/m.nviz.image/main.c	2013-04-28 14:52:15 UTC (rev 56018)
+++ grass/trunk/misc/m.nviz.image/main.c	2013-04-28 15:04:28 UTC (rev 56019)
@@ -78,7 +78,8 @@
     /* define render window */
     offscreen = Nviz_new_render_window();
     Nviz_init_render_window(offscreen);
-    Nviz_create_render_window(offscreen, NULL, width, height);	/* offscreen display */
+    if (Nviz_create_render_window(offscreen, NULL, width, height) == -1)
+        G_fatal_error(_("Unable to render data"));
     Nviz_make_current_render_window(offscreen);
 
     /* initialize nviz data */



More information about the grass-commit mailing list