GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
gsd_prim.c File Reference

OGSF library - primitive drawing functions (lower level functions) More...

#include <stdlib.h>
#include <string.h>
#include <grass/config.h>
#include <grass/gis.h>
#include <grass/gstypes.h>
#include <grass/glocale.h>
Include dependency graph for gsd_prim.c:

Go to the source code of this file.

Macros

#define USE_GL_NORMALIZE
 
#define RED_MASK   0x000000FF
 
#define GRN_MASK   0x0000FF00
 
#define BLU_MASK   0x00FF0000
 
#define ALP_MASK   0xFF000000
 
#define INT_TO_RED(i, r)   (r = (i & RED_MASK))
 
#define INT_TO_GRN(i, g)   (g = (i & GRN_MASK) >> 8)
 
#define INT_TO_BLU(i, b)   (b = (i & BLU_MASK) >> 16)
 
#define INT_TO_ALP(i, a)   (a = (i & ALP_MASK) >> 24)
 
#define MAX_OBJS   64
 
#define border   15
 

Functions

void gsd_flush (void)
 Mostly for flushing drawing commands accross a network. More...
 
void gsd_colormode (int cm)
 Set color mode. More...
 
void show_colormode (void)
 Print color mode to stderr. More...
 
void gsd_circ (float x, float y, float rad)
 ADD. More...
 
void gsd_disc (float x, float y, float z, float rad)
 ADD. More...
 
void gsd_sphere (float *center, float siz)
 ADD. More...
 
void gsd_zwritemask (unsigned long n)
 Write out z-mask. More...
 
void gsd_backface (int n)
 ADD. More...
 
void gsd_linewidth (short n)
 Set width of rasterized lines. More...
 
void gsd_bgnqstrip (void)
 ADD. More...
 
void gsd_endqstrip (void)
 ADD. More...
 
void gsd_bgntmesh (void)
 ADD. More...
 
void gsd_endtmesh (void)
 ADD. More...
 
void gsd_bgntstrip (void)
 ADD. More...
 
void gsd_endtstrip (void)
 ADD. More...
 
void gsd_bgntfan (void)
 ADD. More...
 
void gsd_endtfan (void)
 ADD. More...
 
void gsd_swaptmesh (void)
 ADD. More...
 
void gsd_bgnpolygon (void)
 Delimit the vertices of a primitive or a group of like primitives. More...
 
void gsd_endpolygon (void)
 Delimit the vertices of a primitive or a group of like primitives. More...
 
void gsd_bgnline (void)
 Begin line. More...
 
void gsd_endline (void)
 End line. More...
 
void gsd_shademodel (int bool)
 Set shaded model. More...
 
int gsd_getshademodel (void)
 Get shaded model. More...
 
void gsd_bothbuffer (void)
 ADD. More...
 
void gsd_frontbuffer (int bool)
 Specify which color buffers are to be drawn into. More...
 
void gsd_backbuffer (int bool)
 Specify which color buffers are to be drawn into. More...
 
void gsd_swapbuffers (void)
 Swap buffers. More...
 
void gsd_popmatrix (void)
 Pop the current matrix stack. More...
 
void gsd_pushmatrix (void)
 Push the current matrix stack. More...
 
void gsd_scale (float xs, float ys, float zs)
 Multiply the current matrix by a general scaling matrix. More...
 
void gsd_translate (float dx, float dy, float dz)
 Multiply the current matrix by a translation matrix. More...
 
void gsd_getwindow (int *window, int *viewport, double *modelMatrix, double *projMatrix)
 Get viewport. More...
 
int gsd_checkpoint (float pt[4], int window[4], int viewport[4], double modelMatrix[16], double projMatrix[16])
 ADD. More...
 
void gsd_rot (float angle, char axis)
 ADD. More...
 
void gsd_litvert_func (float *norm, unsigned long col, float *pt)
 Set the current normal vector & specify vertex. More...
 
void gsd_litvert_func2 (float *norm, unsigned long col, float *pt)
 ADD. More...
 
void gsd_vert_func (float *pt)
 ADD. More...
 
void gsd_color_func (unsigned int col)
 Set current color. More...
 
void gsd_init_lightmodel (void)
 Initialize model light. More...
 
void gsd_set_material (int set_shin, int set_emis, float sh, float em, int emcolor)
 Set material. More...
 
void gsd_deflight (int num, struct lightdefs *vals)
 Define light. More...
 
void gsd_switchlight (int num, int on)
 Switch light on/off. More...
 
int gsd_getimage (unsigned char **pixbuf, unsigned int *xsize, unsigned int *ysize)
 Get image of current GL screen. More...
 
int gsd_getViewport (GLint tmp[4], GLint num[2])
 Get viewpoint. More...
 
int gsd_writeView (unsigned char **pixbuf, unsigned int xsize, unsigned int ysize)
 Write view. More...
 
void gsd_blend (int yesno)
 Specify pixel arithmetic. More...
 
void gsd_def_clipplane (int num, double *params)
 Define clip plane. More...
 
void gsd_set_clipplane (int num, int able)
 Set clip plane. More...
 
void gsd_finish (void)
 Finish. More...
 
void gsd_viewport (int l, int r, int b, int t)
 Set the viewport. More...
 
int gsd_makelist (void)
 ADD. More...
 
void gsd_bgnlist (int listno, int do_draw)
 ADD. More...
 
void gsd_endlist (void)
 End list. More...
 
void gsd_deletelist (GLuint listno, int range)
 Delete list. More...
 
void gsd_calllist (int listno)
 ADD. More...
 
void gsd_calllists (int listno)
 ADD. More...
 

Detailed Description

OGSF library - primitive drawing functions (lower level functions)

GRASS OpenGL gsurf OGSF Library

(C) 1999-2008 by the GRASS Development Team

This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.

Author
Bill Brown USACERL (January 1993)
Doxygenized by Martin Landa <landa.martin gmail.com> (May 2008)

Definition in file gsd_prim.c.

Macro Definition Documentation

#define ALP_MASK   0xFF000000

Definition at line 41 of file gsd_prim.c.

#define BLU_MASK   0x00FF0000

Definition at line 40 of file gsd_prim.c.

Referenced by iso_calc_cube(), Nviz_color_from_str(), and slice_calc().

#define border   15

Definition at line 52 of file gsd_prim.c.

Referenced by gsd_getwindow().

#define GRN_MASK   0x0000FF00

Definition at line 39 of file gsd_prim.c.

Referenced by iso_calc_cube(), Nviz_color_from_str(), and slice_calc().

#define INT_TO_ALP (   i,
 
)    (a = (i & ALP_MASK) >> 24)

Definition at line 46 of file gsd_prim.c.

Referenced by gsd_color_func().

#define INT_TO_BLU (   i,
  b 
)    (b = (i & BLU_MASK) >> 16)

Definition at line 45 of file gsd_prim.c.

Referenced by GS_get_val_at_xy(), and gsd_color_func().

#define INT_TO_GRN (   i,
  g 
)    (g = (i & GRN_MASK) >> 8)

Definition at line 44 of file gsd_prim.c.

Referenced by GS_get_val_at_xy(), and gsd_color_func().

#define INT_TO_RED (   i,
  r 
)    (r = (i & RED_MASK))

Definition at line 43 of file gsd_prim.c.

Referenced by GS_get_val_at_xy(), and gsd_color_func().

#define MAX_OBJS   64

Definition at line 48 of file gsd_prim.c.

Referenced by gsd_calllists(), gsd_deletelist(), and gsd_makelist().

#define RED_MASK   0x000000FF

Definition at line 38 of file gsd_prim.c.

Referenced by iso_calc_cube(), Nviz_color_from_str(), and slice_calc().

#define USE_GL_NORMALIZE

Definition at line 36 of file gsd_prim.c.

Function Documentation

void gsd_backbuffer ( int  bool)

Specify which color buffers are to be drawn into.

Parameters
boolnon-zero for enable otherwise disable back buffer

Definition at line 464 of file gsd_prim.c.

Referenced by GS_set_draw().

void gsd_backface ( int  n)

ADD.

Parameters
n

Definition at line 244 of file gsd_prim.c.

References n.

Referenced by GS_draw_lighting_model(), GS_draw_lighting_model1(), and gsd_3darrow().

void gsd_bgnlist ( int  listno,
int  do_draw 
)

ADD.

Parameters
listno
do_draw

Definition at line 1106 of file gsd_prim.c.

Referenced by gsd_3darrow(), and gsd_put_legend().

void gsd_bgnpolygon ( void  )

Delimit the vertices of a primitive or a group of like primitives.

Definition at line 362 of file gsd_prim.c.

Referenced by gsd_box(), gsd_cube(), gsd_diamond(), gsd_draw_cplane(), gsd_fringe_horiz_poly(), gsd_fringe_vert_poly(), gsd_north_arrow(), gsd_scalebar(), gsd_surf_const(), and gvld_isosurf().

void gsd_bgnqstrip ( void  )

ADD.

Definition at line 267 of file gsd_prim.c.

Referenced by primitive_cylinder().

void gsd_bgntfan ( void  )

ADD.

Definition at line 327 of file gsd_prim.c.

Referenced by gsd_coarse_surf_map(), gsd_surf_map(), primitive_cone(), and primitive_cylinder().

void gsd_bgntmesh ( void  )
void gsd_bgntstrip ( void  )

ADD.

Definition at line 307 of file gsd_prim.c.

void gsd_blend ( int  yesno)

Specify pixel arithmetic.

Parameters
yesnoturn on/off

Definition at line 974 of file gsd_prim.c.

Referenced by gsd_coarse_surf_map(), gsd_draw_cplane(), gsd_ortho_wall(), gsd_surf_const(), gsd_surf_map(), gsd_surf_map_old(), gvld_isosurf(), gvld_slice(), and gvld_slices().

void gsd_bothbuffer ( void  )

ADD.

Definition at line 436 of file gsd_prim.c.

void gsd_calllist ( int  listno)

ADD.

Parameters
listno

Definition at line 1154 of file gsd_prim.c.

Referenced by GS_draw_list(), and gsd_3darrow().

void gsd_calllists ( int  listno)

ADD.

Parameters
listno

Definition at line 1167 of file gsd_prim.c.

References gsd_call_label(), gsd_popmatrix(), gsd_pushmatrix(), and MAX_OBJS.

Referenced by GS_draw_all_list().

int gsd_checkpoint ( float  pt[4],
int  window[4],
int  viewport[4],
double  modelMatrix[16],
double  projMatrix[16] 
)

ADD.

Parameters
pt
widnow
viewport
doubleMatrix
projMatrix
Returns
0
1

Definition at line 573 of file gsd_prim.c.

References X, and Y.

Referenced by gpd_2dsite(), gpd_3dsite(), gsd_surf_const(), gsd_surf_map(), and gsd_surf_map_old().

void gsd_circ ( float  x,
float  y,
float  rad 
)

ADD.

Parameters
x,y
rad

Definition at line 157 of file gsd_prim.c.

Referenced by gsd_draw_gyro().

void gsd_def_clipplane ( int  num,
double *  params 
)

Define clip plane.

Parameters
num
params

Definition at line 994 of file gsd_prim.c.

Referenced by gsd_def_cplane().

void gsd_deflight ( int  num,
struct lightdefs *  vals 
)

Define light.

Parameters
numlight id (starts with 1)
valsposition(x,y,z,w), color, ambientm, emission

Definition at line 827 of file gsd_prim.c.

References X, and Y.

Referenced by GS_new_light(), GS_setlight_ambient(), GS_setlight_color(), and GS_setlight_position().

void gsd_deletelist ( GLuint  listno,
int  range 
)

Delete list.

Parameters
listno
range

Definition at line 1134 of file gsd_prim.c.

References MAX_OBJS.

Referenced by GS_delete_list().

void gsd_disc ( float  x,
float  y,
float  z,
float  rad 
)

ADD.

Parameters
x,y,z
rad

Definition at line 177 of file gsd_prim.c.

Referenced by gsd_arrow_onsurf().

void gsd_endlist ( void  )

End list.

Definition at line 1121 of file gsd_prim.c.

Referenced by gsd_3darrow(), and gsd_put_legend().

void gsd_endpolygon ( void  )

Delimit the vertices of a primitive or a group of like primitives.

Definition at line 377 of file gsd_prim.c.

Referenced by gsd_box(), gsd_cube(), gsd_diamond(), gsd_draw_cplane(), gsd_fringe_horiz_poly(), gsd_fringe_vert_poly(), gsd_north_arrow(), gsd_scalebar(), gsd_surf_const(), and gvld_isosurf().

void gsd_endqstrip ( void  )

ADD.

Definition at line 277 of file gsd_prim.c.

Referenced by primitive_cylinder().

void gsd_endtfan ( void  )

ADD.

Definition at line 337 of file gsd_prim.c.

Referenced by gsd_coarse_surf_map(), gsd_surf_map(), primitive_cone(), and primitive_cylinder().

void gsd_endtmesh ( void  )
void gsd_endtstrip ( void  )

ADD.

Definition at line 317 of file gsd_prim.c.

void gsd_finish ( void  )

Finish.

Does nothing, only called from src.contrib/GMSL/NVIZ2.2/src/glwrappers.c

Definition at line 1039 of file gsd_prim.c.

void gsd_flush ( void  )

Mostly for flushing drawing commands accross a network.

glFlush doesn't block, so if blocking is desired use glFinish.

Definition at line 74 of file gsd_prim.c.

Referenced by GS_clear(), GS_done_draw(), GS_draw_lighting_model(), GS_draw_line_onsurf(), GS_draw_nline_onsurf(), GS_draw_X(), gsd_fringe_horiz_line(), gsd_fringe_horiz_line2(), gsd_fringe_horiz_poly(), gsd_fringe_vert_line(), gsd_fringe_vert_poly(), gsd_north_arrow(), gsd_scalebar(), and gsd_scalebar_v2().

void gsd_frontbuffer ( int  bool)

Specify which color buffers are to be drawn into.

Parameters
boolnon-zero for enable otherwise disable front buffer

Definition at line 450 of file gsd_prim.c.

Referenced by GS_set_draw().

int gsd_getimage ( unsigned char **  pixbuf,
unsigned int xsize,
unsigned int ysize 
)

Get image of current GL screen.

Parameters
pixbufdata buffer
[out]xsize,ysizepicture dimension
Returns
0 on failure
1 on success

Definition at line 893 of file gsd_prim.c.

References b, l, and r.

Referenced by GS_write_ppm(), GS_write_tif(), and gsd_write_mpegframe().

int gsd_getshademodel ( void  )

Get shaded model.

Returns
shade

Definition at line 428 of file gsd_prim.c.

Referenced by gsd_3darrow(), gsd_box(), gsd_cube(), and gsd_diamond().

int gsd_getViewport ( GLint  tmp[4],
GLint  num[2] 
)

Get viewpoint.

Parameters
tmp
num
Returns
1

Definition at line 935 of file gsd_prim.c.

void gsd_getwindow ( int window,
int viewport,
double *  modelMatrix,
double *  projMatrix 
)

Get viewport.

Parameters
[out]window
viewport
modelMatrixmodel matrix
projMatrixprojection matrix

Definition at line 541 of file gsd_prim.c.

References border, gsd_do_scale(), gsd_popmatrix(), and gsd_pushmatrix().

Referenced by gpd_2dsite(), gpd_3dsite(), gsd_surf_const(), gsd_surf_map(), gsd_surf_map_old(), gvld_isosurf(), and gvld_slices().

void gsd_init_lightmodel ( void  )

Initialize model light.

Definition at line 710 of file gsd_prim.c.

Referenced by GS_new_light().

void gsd_linewidth ( short  n)
void gsd_litvert_func ( float *  norm,
unsigned long  col,
float *  pt 
)

Set the current normal vector & specify vertex.

Parameters
normnormal vector
colcolor value
ptpoint (model coordinates)

Definition at line 648 of file gsd_prim.c.

References gsd_color_func().

Referenced by gsd_box(), gsd_coarse_surf_map(), gsd_cube(), gsd_diamond(), gsd_ortho_wall(), gsd_surf_const(), gsd_surf_map(), gsd_surf_map_old(), gsd_triangulated_wall(), gvld_isosurf(), and gvld_slice().

void gsd_litvert_func2 ( float *  norm,
unsigned long  col,
float *  pt 
)

ADD.

Parameters
norm
col
pt

Definition at line 664 of file gsd_prim.c.

Referenced by primitive_cone(), and primitive_cylinder().

int gsd_makelist ( void  )

ADD.

First time called, gets a bunch of objects, then hands them back when needed

Returns
-1 on failure
number of objects

Definition at line 1074 of file gsd_prim.c.

References MAX_OBJS.

Referenced by gsd_3darrow(), and gsd_put_legend().

void gsd_rot ( float  angle,
char  axis 
)

ADD.

Parameters
angle
axis

Definition at line 597 of file gsd_prim.c.

References G_warning(), and y.

Referenced by gsd_3darrow(), gsd_arrow(), gsd_draw_asterisk(), gsd_draw_cplane(), and gsd_draw_gyro().

void gsd_scale ( float  xs,
float  ys,
float  zs 
)

Multiply the current matrix by a general scaling matrix.

Parameters
xsx scale value
ysy scale value
zsz scale value

Definition at line 512 of file gsd_prim.c.

Referenced by gpd_obj(), GS_draw_lighting_model1(), gsd_3darrow(), gsd_arrow(), gsd_box(), gsd_cube(), gsd_diamond(), gsd_do_scale(), gsd_draw_asterisk(), gsd_draw_box(), gsd_draw_cplane(), and gsd_draw_gyro().

void gsd_set_clipplane ( int  num,
int  able 
)

Set clip plane.

Parameters
num
able

Definition at line 1021 of file gsd_prim.c.

Referenced by gsd_cplane_off(), gsd_cplane_on(), gsd_draw_cplane(), and gsd_draw_cplane_fence().

void gsd_set_material ( int  set_shin,
int  set_emis,
float  sh,
float  em,
int  emcolor 
)

Set material.

Parameters
set_shin,set_emisflags
sh,emshould be 0. - 1.
emcolorpacked colors to use for emission

Definition at line 794 of file gsd_prim.c.

References int.

Referenced by gsd_coarse_surf_map(), gsd_surf_map(), gsd_surf_map_old(), gvld_isosurf(), gvld_slices(), and gvld_wire_slices().

void gsd_shademodel ( int  bool)

Set shaded model.

Parameters
booltype non-zero for GL_SMOOTH otherwise GL_FLAT

Definition at line 409 of file gsd_prim.c.

Referenced by GS_draw_lighting_model(), GS_draw_lighting_model1(), GS_draw_surf(), gsd_3darrow(), gsd_box(), gsd_cube(), gsd_diamond(), gvld_isosurf(), gvld_slices(), gvld_wind3_box(), and gvld_wire_slices().

void gsd_sphere ( float *  center,
float  siz 
)

ADD.

Parameters
centercenter-point
sizsize value

Definition at line 197 of file gsd_prim.c.

References first.

Referenced by gpd_obj(), and gsd_drawsphere().

void gsd_swapbuffers ( void  )

Swap buffers.

Definition at line 474 of file gsd_prim.c.

References Swap_func.

Referenced by GS_done_draw().

void gsd_swaptmesh ( void  )

ADD.

Definition at line 347 of file gsd_prim.c.

Referenced by gsd_diamond().

void gsd_switchlight ( int  num,
int  on 
)

Switch light on/off.

Parameters
num
on1 for 'on', 0 turns them off

Definition at line 868 of file gsd_prim.c.

Referenced by GS_lights_off(), GS_lights_on(), GS_new_light(), and GS_switchlight().

void gsd_viewport ( int  l,
int  r,
int  b,
int  t 
)

Set the viewport.

l, b specify the lower left corner of the viewport rectangle, in pixels.

r, t specify the width and height of the viewport.

Parameters
lleft
rright
bbottom
ttop

Definition at line 1057 of file gsd_prim.c.

Referenced by GS_set_viewport().

int gsd_writeView ( unsigned char **  pixbuf,
unsigned int  xsize,
unsigned int  ysize 
)

Write view.

Parameters
pixbufdata buffer
xsize,ysizepicture dimension

Definition at line 951 of file gsd_prim.c.

Referenced by GS_write_zoom().

void gsd_zwritemask ( unsigned long  n)

Write out z-mask.

Enable or disable writing into the depth buffer

Parameters
nSpecifies whether the depth buffer is enabled for writing

Definition at line 231 of file gsd_prim.c.

Referenced by gk_draw_path(), GS_draw_lighting_model(), GS_draw_lighting_model1(), gsd_coarse_surf_map(), gsd_display_fringe(), gsd_draw_cplane(), gsd_ortho_wall(), gsd_surf_const(), gsd_surf_map(), gsd_surf_map_old(), gvld_isosurf(), gvld_slice(), and gvld_slices().

void show_colormode ( void  )

Print color mode to stderr.

Definition at line 141 of file gsd_prim.c.

References G_message().

Referenced by gsd_surf_map_old().