GRASS GIS 8 Programmer's Manual  8.5.0dev(2024)-ce44da6b99
GRASS GIS OGSF Library

by GRASS Development Team (https://grass.osgeo.org)

OGSF Library for OpenGL programming

Overview

The OGSF (gsurf) library, consisting of approximately 27,000 lines of C code, contains some 250 public functions and about twice as many internal functions for run-time data storage, manipulation, querying, and visualization using OpenGL. The library handles all drawing and lighting operations, including use of user-defined clipping planes and drawing various style "fences" on clipping planes when drawing multiple surfaces, and treats datasets as objects which can be used for various attributes of the rendering. It allows data sharing (e.g., same data for more than one attribute of same or different surfaces), separate masking for each surface, multiple surfaces, vector sets, or point sets, and will also allow multiple volumes. The library provides all query features such as 3D "point on surface", keyframe animation routines, and full state saving functionality. Database-specific routines for interfacing with the GRASS GIS General Library (aka GIS Library) are kept isolated for easier library reuse with other databases. The gsurf library is not dependent upon any particular interface library, and has been used successfully with both Motif, Tcl/Tk or wxPython. It is used for Nviz visualization tool.

The library is designed to provide a unique "handle" or identifier number to the calling program for each new geographic object added to the model. The object could be a surface, vector set, or point set, which could each be defined by one or more database files. Once created, the application only needs to keep track of the "handles" to the objects (which are returned by the creation routines); for example, to draw a surface the application would make the call:

Naming Conventions

The following naming conventions for function prefixes are used:

  • GS_ - Functions which have to do with loading & manipulating surfaces. Also functions for library initialization, setting global variables, viewer positioning, and lighting.
  • GSU_ - Utility functions for distance calculations, common 2D & 3D unit vector operations such as cross product or vector arithmetic.
  • GV_ - Functions which have to do with loading & manipulating vector sets.
  • GP_ - Functions which have to do with loading & manipulating point sets.
  • GVL_ - Functions which have to do with loading & manipulating 3D volumes.
  • GK_ - Functions which have to do with setting & manipulating keyframes for viewer position animation (fly-bys).

Programmers' documentation is currently incomplete, but see the following for more details of the library design and capabilities in the appendix (PLEASE ADD EXPLANATIONS!!):

  • public function prototypes
  • public include file include/gsurf.h
  • public include file include/keyframe.h
  • public color packing utility macros rgbpack.h
  • private types and defines include/gstypes.h
  • private utilities gsget.h

Major todos

  • remove global variables
  • dynamically allocate items instead of static arrays
  • merge GP_ functions into GV_

Public function prototypes

Initialization and positioning surfaces (GS)

Functions which have to do with loading & manipulating surfaces. Also functions for library initialization, setting global variables, viewer positioning, and lighting.

Loading and manipulation of vector maps (GV)

Functions which have to do with loading & manipulating vector sets.

Loading and manipulation of vector point maps (GP)

Functions which have to do with loading & manipulating point sets.

ogsfGk Keyframe animation

Functions which have to do with setting & manipulating keyframes for viewer position animation (fly-bys).

Loading and manipulation of volume maps (GVL)

Functions which have to do with loading & manipulating 3D volumes.

Loading and manipulation of isosurfaces (GVL)

Functions which have to do with loading & manipulating isosurfaces.

Loading and manipulation of slices (GVL)

Functions which have to do with loading & manipulating slices.

Authors

Bill Brown GMSL/University of Illinois