glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
//glShadeModel(GL_FLAT);
+ g_mutex_lock(opengl->sphere_lock);
roam_sphere_update_view(opengl->sphere);
+ g_mutex_unlock(opengl->sphere_lock);
}
if (lat[2] == 90 || lat[2] == -90) xy[2][0] = 0.5;
glEnable(GL_TEXTURE_2D);
+ glEnable(GL_POLYGON_OFFSET_FILL);
glBindTexture(GL_TEXTURE_2D, *(guint*)tile->data);
+ glPolygonOffset(0, -tile->zindex);
glBegin(GL_TRIANGLES);
glNormal3dv(tri->p.r->norm); glTexCoord2dv(xy[0]); glVertex3dv((double*)tri->p.r);
glNormal3dv(tri->p.m->norm); glTexCoord2dv(xy[1]); glVertex3dv((double*)tri->p.m);
gis_viewer_project(GIS_VIEWER(opengl),
point->lat, point->lon, point->elev,
&px, &py, &pz);
+
gint win_width = GTK_WIDGET(opengl)->allocation.width;
gint win_height = GTK_WIDGET(opengl)->allocation.height;
py = win_height - py;
//g_debug("GisOpenGL: draw_object");
/* Skip out of range objects */
if (object->lod > 0) {
+ /* LOD test */
gdouble eye[3], obj[3];
gis_viewer_get_location(GIS_VIEWER(opengl), &eye[0], &eye[1], &eye[2]);
+ gdouble elev = eye[2];
lle2xyz(eye[0], eye[1], eye[2], &eye[0], &eye[1], &eye[2]);
lle2xyz(object->center.lat, object->center.lon, object->center.elev,
&obj[0], &obj[1], &obj[2]);
gdouble dist = distd(obj, eye);
if (object->lod < dist)
return;
+
+ /* Horizon testing */
+ gdouble c = EARTH_R+elev;
+ gdouble a = EARTH_R;
+ gdouble horizon = sqrt(c*c - a*a);
+ if (dist > horizon)
+ return;
}
/* Draw */
} else if (GIS_IS_TILE(object)) {
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);
+ g_mutex_lock(opengl->sphere_lock);
_draw_tiles(opengl, GIS_TILE(object));
+ g_mutex_unlock(opengl->sphere_lock);
}
glPopAttrib();
glMatrixMode(GL_PROJECTION); glPopMatrix();
static gboolean _update_errors_cb(gpointer _opengl)
{
GisOpenGL *opengl = _opengl;
+ g_mutex_lock(opengl->sphere_lock);
roam_sphere_update_errors(opengl->sphere);
+ g_mutex_unlock(opengl->sphere_lock);
opengl->ue_source = 0;
return FALSE;
}