17 #include <grass/nviz.h> 
   19 #ifndef GL_CLAMP_TO_EDGE 
   20 #define GL_CLAMP_TO_EDGE 0x812F 
   23 static int sort_surfs_max(
int *, 
int *, 
int *, 
int);
 
   35     int sortSurfs[MAX_SURFS], sorti[MAX_SURFS];
 
   49     sort_surfs_max(surf_list, sortSurfs, sorti, nsurfs);
 
   58     for (i = 0; i < nsurfs; i++) {
 
   63     for (i = 0; i < MAX_CPLANES; i++) {
 
   84 int sort_surfs_max(
int *surf, 
int *id_sort, 
int *indices, 
int num)
 
   87     float maxvals[MAX_SURFS];
 
   88     float tmp, 
max = 0., tmin, tmax, tmid;
 
   90     for (i = 0; i < 
num; i++) {
 
   95             max = max < tmax ? tmax : 
max;
 
   99     for (i = 0; i < 
num; i++) {
 
  102         for (j = 0; j < 
num; j++) {
 
  103             if (maxvals[j] < tmp) {
 
  109         maxvals[indices[i]] = max + 1;
 
  110         id_sort[i] = surf[indices[i]];
 
  149     int *site_list, nsites;
 
  158     for (i = 0; i < nsites; i++) {
 
  177     int *vol_list, nvols, i;
 
  186     for (i = 0; i < nvols; i++) {
 
  207     int draw_surf, draw_vect, draw_site, draw_vol;
 
  241     for(i = 0; i < data->num_fringes; i++) {
 
  242         struct fringe_data * f = data->fringe[i];
 
  247     if (data->draw_arrow) {
 
  249                         (GLuint)
NULL, data->arrow->color, data->arrow->color);
 
  253     for (i = 0; i < data->num_scalebars; i++) {
 
  254         struct scalebar_data *
s = data->scalebar[i];
 
  287     if (draw_mode & DRAW_QUICK_SURFACE)
 
  291     if (draw_mode & DRAW_QUICK_VLINES)
 
  295     if (draw_mode & DRAW_QUICK_VPOINTS)
 
  299     if (draw_mode & DRAW_QUICK_VOLUME) {
 
  317     unsigned int texture_id;
 
  331     glGenTextures( 1, &texture_id);
 
  332     glBindTexture(GL_TEXTURE_2D, texture_id);
 
  333     glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
 
  335     glTexImage2D(GL_TEXTURE_2D, 0, in_format, width, height, 0,format,
 
  336                  GL_UNSIGNED_BYTE, image_data);
 
  338     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
 
  339     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
 
  344     glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); 
 
  357     glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
 
  359     glMatrixMode(GL_PROJECTION);
 
  361     glOrtho(0, width, 0, height, -1, 1);
 
  365     glTranslatef(0, -height, 0);
 
  367     glMatrixMode(GL_MODELVIEW);
 
  380     glBindTexture(GL_TEXTURE_2D, texture_id);
 
  383     glEnable(GL_TEXTURE_2D);
 
  387     glTexCoord2d(0.0,1.0);
 
  389     glTexCoord2d(0.0,0.0);
 
  390     glVertex2d(x, y + height);
 
  391     glTexCoord2d(1.0,0.0);
 
  392     glVertex2d(x + width, y + height);
 
  393     glTexCoord2d(1.0,1.0);
 
  394     glVertex2d(x + width, y);
 
  399     glDisable(GL_TEXTURE_2D);
 
  412     glDeleteTextures(1, t);
 
  421     glGetIntegerv(GL_MAX_TEXTURE_SIZE, size);
 
int * GP_get_site_list(int *numsites)
Get list of point sets. 
void G_free(void *buf)
Free allocated memory. 
void GP_draw_site(int id)
Draw point set. 
void Nviz_set_2D(int width, int height)
Set ortho view for drawing images. 
int Nviz_draw_all(nv_data *data)
Draw all map objects (in full resolution) and decorations. 
int Nviz_draw_all_vol()
Draw all loaded volume sets. 
void GS_done_draw(void)
Draw done, swap buffers. 
void Nviz_draw_image(int x, int y, int width, int height, int texture_id)
Draw image as texture. 
int Nviz_draw_all_site()
Draw all loaded vector point sets. 
int gsd_north_arrow(float *pos2, float len, GLuint fontbase, unsigned long arw_clr, unsigned long text_clr)
Draw North Arrow takes OpenGL coords and size. 
void GS_clear(int col)
Clear view. 
void GP_alldraw_site(void)
Draw all available point sets. 
void GV_alldraw_vect(void)
Draw all vector sets. 
void GVL_alldraw_wire(void)
Draw all volume sets in wire mode. 
void GS_draw_fringe(int id, unsigned long clr, float elev, int *where)
Draw fringe around data (surface) at selected corners. 
int GS_draw_cplane_fence(int hs1, int hs2, int num)
Draw cplace fence ? 
void GVL_draw_vol(int vid)
Draw volume set. 
void Nviz_del_texture(int texture_id)
Delete texture. 
void GS_alldraw_wire(void)
Draw all wires. 
int Nviz_draw_all_surf(nv_data *dc)
Draw all loaded surfaces. 
int Nviz_draw_quick(nv_data *data, int draw_mode)
Draw all surfaces in wireframe (quick mode) 
int Nviz_draw_all_vect()
Draw all loaded vector sets (lines) 
int GS_get_zextents(int id, float *min, float *max, float *mid)
Get z-extent for a single surface. 
void Nviz_get_max_texture(int *size)
Get maximum texture size. 
int * GVL_get_vol_list(int *numvols)
Get list of loaded volume sets. 
int * GS_get_surf_list(int *numsurfs)
Get surface list. 
void GS_draw_surf(int id)
Draw surface. 
int gsd_scalebar_v2(float *pos, float len, GLuint fontbase, unsigned long bar_clr, unsigned long text_clr)
Draw Scalebar (as lines) 
int Nviz_load_image(GLubyte *image_data, int width, int height, int alpha)
Load image into texture. 
void GS_set_draw(int where)
Sets which buffer to draw to. 
void GS_setlight_position(int num, float xpos, float ypos, float zpos, int local)
Set light position.