17#include <grass/nviz.h>
19#ifndef GL_CLAMP_TO_EDGE
20#define GL_CLAMP_TO_EDGE 0x812F
23static 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++) {
84int 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++) {
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];
248 if (data->draw_arrow) {
250 data->arrow->color, data->arrow->color);
254 for (i = 0; i < data->num_scalebars; i++) {
255 if (data->scalebar[i]) {
256 struct scalebar_data *s = data->scalebar[i];
290 if (draw_mode & DRAW_QUICK_SURFACE)
294 if (draw_mode & DRAW_QUICK_VLINES)
298 if (draw_mode & DRAW_QUICK_VPOINTS)
302 if (draw_mode & DRAW_QUICK_VOLUME) {
320 unsigned int texture_id;
332 glGenTextures(1, &texture_id);
333 glBindTexture(GL_TEXTURE_2D, texture_id);
334 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
336 glTexImage2D(GL_TEXTURE_2D, 0, in_format, width, height, 0, format,
337 GL_UNSIGNED_BYTE, image_data);
339 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
340 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
345 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
358 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
360 glMatrixMode(GL_PROJECTION);
362 glOrtho(0, width, 0, height, -1, 1);
366 glTranslatef(0, -height, 0);
368 glMatrixMode(GL_MODELVIEW);
381 glBindTexture(GL_TEXTURE_2D, texture_id);
384 glEnable(GL_TEXTURE_2D);
388 glTexCoord2d(0.0, 1.0);
390 glTexCoord2d(0.0, 0.0);
391 glVertex2d(
x, y + height);
392 glTexCoord2d(1.0, 0.0);
393 glVertex2d(
x + width, y + height);
394 glTexCoord2d(1.0, 1.0);
395 glVertex2d(
x + width, y);
400 glDisable(GL_TEXTURE_2D);
413 glDeleteTextures(1,
t);
422 glGetIntegerv(GL_MAX_TEXTURE_SIZE, size);
void G_free(void *buf)
Free allocated memory.
int * GP_get_site_list(int *numsites)
Get list of point sets.
void GP_draw_site(int id)
Draw point set.
void GP_alldraw_site(void)
Draw all available point sets.
int GS_get_zextents(int id, float *min, float *max, float *mid)
Get z-extent for a single surface.
void GS_draw_surf(int id)
Draw surface.
void GS_alldraw_wire(void)
Draw all wires.
void GS_clear(int col)
Clear view.
int * GS_get_surf_list(int *numsurfs)
Get surface list.
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 GS_setlight_position(int num, float xpos, float ypos, float zpos, int local)
Set light position.
void GS_set_draw(int where)
Sets which buffer to draw to.
void GS_done_draw(void)
Draw done, swap buffers.
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.
int gsd_scalebar_v2(float *pos, float len, GLuint fontbase UNUSED, unsigned long bar_clr, unsigned long text_clr UNUSED)
Draw Scalebar (as lines)
void GV_alldraw_vect(void)
Draw all loaded vector sets.
void GVL_alldraw_wire(void)
Draw all volume sets in wire mode.
int * GVL_get_vol_list(int *numvols)
Get list of loaded volume sets.
void GVL_draw_vol(int vid)
Draw volume set.
int Nviz_load_image(GLubyte *image_data, int width, int height, int alpha)
Load image into texture.
void Nviz_get_max_texture(int *size)
Get maximum texture size.
int Nviz_draw_all_vect(void)
Draw all loaded vector sets (lines)
void Nviz_draw_image(int x, int y, int width, int height, int texture_id)
Draw image as texture.
int Nviz_draw_all_surf(nv_data *dc)
Draw all loaded surfaces.
void Nviz_set_2D(int width, int height)
Set ortho view for drawing images.
int Nviz_draw_quick(nv_data *data, int draw_mode)
Draw all surfaces in wireframe (quick mode)
int Nviz_draw_all(nv_data *data)
Draw all map objects (in full resolution) and decorations.
void Nviz_del_texture(int texture_id)
Delete texture.
int Nviz_draw_all_vol(void)
Draw all loaded volume sets.
int Nviz_draw_all_site(void)
Draw all loaded vector point sets.