/*
- * Copyright (C) 2009 Andy Spencer <spenceal@rose-hulman.edu>
+ * Copyright (C) 2009-2010 Andy Spencer <andy753421@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
#define TILE_WIDTH 1024
#define TILE_HEIGHT 512
+const guchar colormap[][2][4] = {
+ {{0x73, 0x91, 0xad}, {0x73, 0x91, 0xad, 0x20}}, // Oceans
+ {{0xf6, 0xee, 0xee}, {0xf6, 0xee, 0xee, 0x00}}, // Ground
+ {{0xff, 0xff, 0xff}, {0xff, 0xff, 0xff, 0xff}}, // Borders
+ {{0x73, 0x93, 0xad}, {0x73, 0x93, 0xad, 0x40}}, // Lakes
+ {{0xff, 0xe1, 0x80}, {0xff, 0xe1, 0x80, 0x60}}, // Cities
+};
+
struct _LoadTileData {
GisPluginMap *self;
- GisTile *tile;
- GdkPixbuf *pixbuf;
+ GisTile *tile;
+ GdkPixbuf *pixbuf;
};
+#include <stdlib.h>
static gboolean _load_tile_cb(gpointer _data)
{
struct _LoadTileData *data = _data;
GisPluginMap *self = data->self;
- GisTile *tile = data->tile;
- GdkPixbuf *pixbuf = data->pixbuf;
+ GisTile *tile = data->tile;
+ GdkPixbuf *pixbuf = data->pixbuf;
g_free(data);
/* Create Texture */
gint width = gdk_pixbuf_get_width(pixbuf);
gint height = gdk_pixbuf_get_height(pixbuf);
+ for (int i = 0; i < width*height; i++) {
+ for (int j = 0; j < G_N_ELEMENTS(colormap); j++) {
+ if (pixels[i*4+0] == colormap[j][0][0] &&
+ pixels[i*4+1] == colormap[j][0][1] &&
+ pixels[i*4+2] == colormap[j][0][2]) {
+ pixels[i*4+0] = colormap[j][1][0];
+ pixels[i*4+1] = colormap[j][1][1];
+ pixels[i*4+2] = colormap[j][1][2];
+ pixels[i*4+3] = colormap[j][1][3];
+ break;
+ }
+ }
+ }
+
guint *tex = g_new0(guint, 1);
gis_viewer_begin(self->viewer);
glGenTextures(1, tex);
glPixelStorei(GL_PACK_ALIGNMENT, 1);
glTexImage2D(GL_TEXTURE_2D, 0, 4, width, height, 0,
(alpha ? GL_RGBA : GL_RGB), GL_UNSIGNED_BYTE, pixels);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
glFlush();
/* Add renderers */
GisCallback *callback = gis_callback_new(_expose, self);
- gis_viewer_add(viewer, GIS_OBJECT(callback), GIS_LEVEL_WORLD, 0);
+ gis_viewer_add(viewer, GIS_OBJECT(callback), GIS_LEVEL_OVERLAY, 0);
return self;
}