]> Pileus Git - grits/commitdiff
Add split depth buffer for world/overlay
authorAndy Spencer <andy753421@gmail.com>
Sun, 20 Jan 2013 04:22:38 +0000 (04:22 +0000)
committerAndy Spencer <andy753421@gmail.com>
Sun, 20 Jan 2013 04:28:17 +0000 (04:28 +0000)
The top 1 percent gets used for the overlay/hud layers, while the back
99 percent gets used for the world. This allows the HUD to use depth
testing without interacting with the world.

This fixes a bug in the compass rose.

src/grits-opengl.c
src/plugins/env.c

index 0e803baf3b5abd6a30e141bde022075254223123..861bfc933a8cd5a38674e926f6df6ebabd456b3f 100644 (file)
@@ -40,6 +40,8 @@
 
 // #define ROAM_DEBUG
 
 
 // #define ROAM_DEBUG
 
+#define OVERLAY_SLICE 0.01
+
 /* Tessellation, "finding intersecting triangles" */
 /* http://research.microsoft.com/pubs/70307/tr-2006-81.pdf */
 /* http://www.opengl.org/wiki/Alpha_Blending */
 /* Tessellation, "finding intersecting triangles" */
 /* http://research.microsoft.com/pubs/70307/tr-2006-81.pdf */
 /* http://www.opengl.org/wiki/Alpha_Blending */
@@ -312,9 +314,10 @@ static void _draw_level(gpointer _level, gpointer _opengl)
                /* Enable depth and alpha for world levels */
                glEnable(GL_ALPHA_TEST);
                glAlphaFunc(GL_GREATER, 0.1);
                /* Enable depth and alpha for world levels */
                glEnable(GL_ALPHA_TEST);
                glAlphaFunc(GL_GREATER, 0.1);
+               glDepthRange(OVERLAY_SLICE, 1);
        } else {
        } else {
-               /* Disable depth for Overlay/HUD levels */
-               glDepthMask(FALSE);
+               /* Draw overlay in front of world */
+               glDepthRange(0, OVERLAY_SLICE);
        }
 
        /* Start ortho */
        }
 
        /* Start ortho */
@@ -512,6 +515,7 @@ static void grits_opengl_unproject(GritsViewer *_opengl,
                glReadPixels(px, py, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &tmp);
                pz = tmp;
        }
                glReadPixels(px, py, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &tmp);
                pz = tmp;
        }
+       pz = (pz-OVERLAY_SLICE) * (1.0/(1-OVERLAY_SLICE));
        gluUnProject(px, py, pz,
                opengl->sphere->view->model,
                opengl->sphere->view->proj,
        gluUnProject(px, py, pz,
                opengl->sphere->view->model,
                opengl->sphere->view->proj,
index 6312f3b2ae7e7f9e76d0058ff720061dd2aabf02..4b6ed795db783d4a6b47c70ada7612fb8c3a2f3a 100644 (file)
@@ -327,7 +327,7 @@ GritsPluginEnv *grits_plugin_env_new(GritsViewer *viewer, GritsPrefs *prefs)
 
        /* Add compass */
        GritsCallback *compass = grits_callback_new(compass_expose, env);
 
        /* Add compass */
        GritsCallback *compass = grits_callback_new(compass_expose, env);
-       grits_viewer_add(viewer, GRITS_OBJECT(compass), GRITS_LEVEL_HUD, FALSE);
+       grits_viewer_add(viewer, GRITS_OBJECT(compass), GRITS_LEVEL_HUD, TRUE);
        g_signal_connect(compass, "clicked", G_CALLBACK(compass_click), viewer);
        grits_object_set_cursor(GRITS_OBJECT(compass), GDK_CROSS);
        env->refs = g_list_prepend(env->refs, compass);
        g_signal_connect(compass, "clicked", G_CALLBACK(compass_click), viewer);
        grits_object_set_cursor(GRITS_OBJECT(compass), GDK_CROSS);
        env->refs = g_list_prepend(env->refs, compass);