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.
+#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 */
/* 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);
- /* Disable depth for Overlay/HUD levels */
- glDepthMask(FALSE);
+ /* Draw overlay in front of world */
+ glDepthRange(0, OVERLAY_SLICE);
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,
/* 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);