]> Pileus Git - grits/blobdiff - src/gis-opengl.c
Fix compiler warnings
[grits] / src / gis-opengl.c
index fc0c55e05cf6062fcd6a14cc8e137f66fa546cc0..ecbf47a4c140fa457de449051e88eb39696ceb00 100644 (file)
@@ -133,6 +133,17 @@ static void _draw_tile(GisOpenGL *opengl, GisTile *tile, GList *triangles)
                        tile->edge.n, tile->edge.s, tile->edge.e, tile->edge.w);
        //g_message("drawing %4d triangles for tile edges=%7.2f,%7.2f,%7.2f,%7.2f",
        //              g_list_length(triangles), tile->edge.n, tile->edge.s, tile->edge.e, tile->edge.w);
+       gdouble n = tile->edge.n;
+       gdouble s = tile->edge.s;
+       gdouble e = tile->edge.e;
+       gdouble w = tile->edge.w;
+
+       gdouble londist = e - w;
+       gdouble latdist = n - s;
+
+       gdouble xscale = tile->coords.e - tile->coords.w;
+       gdouble yscale = tile->coords.s - tile->coords.n;
+
        for (GList *cur = triangles; cur; cur = cur->next) {
                RoamTriangle *tri = cur->data;
 
@@ -145,14 +156,6 @@ static void _draw_tile(GisOpenGL *opengl, GisTile *tile, GList *triangles)
                        if (lon[2] > 90) lon[2] -= 360;
                }
 
-               gdouble n = tile->edge.n;
-               gdouble s = tile->edge.s;
-               gdouble e = tile->edge.e;
-               gdouble w = tile->edge.w;
-
-               gdouble londist = e - w;
-               gdouble latdist = n - s;
-
                gdouble xy[3][2] = {
                        {(lon[0]-w)/londist, 1-(lat[0]-s)/latdist},
                        {(lon[1]-w)/londist, 1-(lat[1]-s)/latdist},
@@ -177,6 +180,12 @@ static void _draw_tile(GisOpenGL *opengl, GisTile *tile, GList *triangles)
                if (lat[1] == 90 || lat[1] == -90) xy[1][0] = 0.5;
                if (lat[2] == 90 || lat[2] == -90) xy[2][0] = 0.5;
 
+               /* Scale to tile coords */
+               for (int i = 0; i < 3; i++) {
+                       xy[i][0] = tile->coords.w + xy[i][0]*xscale;
+                       xy[i][1] = tile->coords.n + xy[i][1]*yscale;
+               }
+
                glEnable(GL_TEXTURE_2D);
                glEnable(GL_POLYGON_OFFSET_FILL);
                glBindTexture(GL_TEXTURE_2D, *(guint*)tile->data);
@@ -279,6 +288,10 @@ static void _draw_callback(GisOpenGL *opengl, GisCallback *callback)
 static void _draw_object(GisOpenGL *opengl, GisObject *object)
 {
        //g_debug("GisOpenGL: draw_object");
+       /* Skip hidden objects */
+       if (object->hidden)
+               return;
+
        /* Skip out of range objects */
        if (object->lod > 0) {
                /* LOD test */
@@ -535,7 +548,6 @@ GisViewer *gis_opengl_new(GisPlugins *plugins, GisPrefs *prefs)
 
 static void gis_opengl_center_position(GisViewer *_opengl, gdouble lat, gdouble lon, gdouble elev)
 {
-       GisOpenGL *opengl = GIS_OPENGL(_opengl);
        glRotatef(lon, 0, 1, 0);
        glRotatef(-lat, 1, 0, 0);
        glTranslatef(0, 0, elev2rad(elev));