Changeset 5228 for anuga_work/development
- Timestamp:
- Apr 22, 2008, 1:36:01 PM (17 years ago)
- Location:
- anuga_work/development/anugavis
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_work/development/anugavis/configure.ac
r5227 r5228 14 14 15 15 # Checks for libraries. 16 AX_CHECK_GL 16 AX_CHECK_GLU 17 17 AM_PATH_SDL([1.2.12], [], [AC_MSG_ERROR([SDL is required to build.])]) 18 18 AC_CACHE_CHECK([for SDL library path], -
anuga_work/development/anugavis/src/anugavis_simple/anugavis_simple.c
r5220 r5228 3 3 4 4 int main(int argc, char *argv[]){ 5 if(AnugaVis_Init(640, 480, "") == -1){ 6 printf("AnugaVis_Init() Error: %s", AnugaVis_GetError()); 5 if(argc != 2){ 6 printf("Usage: anugavis_simple sww_file_name\n"); 7 return 1; 8 } 9 if(AnugaVis_Init(640, 480, argv[1]) == -1){ 10 printf("AnugaVis_Init() Error: %s\n", AnugaVis_GetError()); 11 return 1; 12 } 13 if(AnugaVis_DefineHeightQuantity("elevation", 0, 1, 128, 128, 128) == -1){ 14 printf("AnugaVis_DefineHeightQuantity() Error: %s\n", AnugaVis_GetError()); 15 return 1; 16 } 17 if(AnugaVis_DefineHeightQuantity("stage", 0, 1, 0, 0, 128) == -1){ 18 printf("AnugaVis_DefineHeightQuantity() Error: %s\n", AnugaVis_GetError()); 7 19 return 1; 8 20 } -
anuga_work/development/anugavis/src/libanugavis/Makefile.am
r5220 r5228 10 10 height_quantity.h \ 11 11 init.c 12 libanugavis_la_CFLAGS = @SDL_CFLAGS@ 13 libanugavis_la_LIBADD = -lSDL 12 libanugavis_la_CFLAGS = @SDL_CFLAGS@ @GLU_CFLAGS@ 13 libanugavis_la_LIBADD = -lSDL @GLU_LIBS@ 14 14 libanugavis_la_LDFLAGS = @SDL_LIBPATH@ -no-undefined -version-info 0:0:0 -
anuga_work/development/anugavis/src/libanugavis/anugavis.h
r5220 r5228 11 11 * given offset, scale, and color. Returns 0 on success, -1 on error. 12 12 */ 13 extern int AnugaVis_DefineHeightQuantity(c har *name,13 extern int AnugaVis_DefineHeightQuantity(const char *name, 14 14 double offset, double scale, 15 15 int red, int green, int blue); -
anuga_work/development/anugavis/src/libanugavis/error.c
r5220 r5228 1 1 #include <stdarg.h> 2 #include <netcdf.h> 2 3 #include <SDL.h> 3 4 #include "anugavis.h" … … 23 24 SDL_ClearError(); 24 25 } 26 27 void AnugaVis_NetCDFError(int ncerr){ 28 AnugaVis_SetError("NetCDF Error: %s", nc_strerror(ncerr)); 29 } -
anuga_work/development/anugavis/src/libanugavis/error.h
r5220 r5228 10 10 void AnugaVis_SDLError(void); 11 11 12 /* Report a NetCDF error. 13 */ 14 void AnugaVis_NetCDFError(int ncerr); 15 12 16 #endif -
anuga_work/development/anugavis/src/libanugavis/globals.h
r5220 r5228 7 7 typedef struct{ 8 8 SDL_Surface *screen; 9 int netcdfId; 9 10 struct height_quantity_simple *heights; 10 11 } ANUGAVIS; -
anuga_work/development/anugavis/src/libanugavis/height_quantity.c
r5220 r5228 1 1 #include <stdlib.h> 2 2 #include <string.h> 3 #include <netcdf.h> 3 4 #include <SDL.h> 4 5 #include "anugavis.h" … … 7 8 #include "height_quantity.h" 8 9 9 int AnugaVis_DefineHeightQuantity(c har *name,10 int AnugaVis_DefineHeightQuantity(const char *name, 10 11 double offset, double scale, 11 12 int red, int green, int blue){ 12 13 struct height_quantity_simple *height; 14 int ncstatus; 15 int ncvarid; 16 int numdims; 17 /* Check that it's actually in the NetCDF file */ 18 if((ncstatus = nc_inq_varid(anugavis.netcdfId, name, &ncvarid)) != NC_NOERR){ 19 AnugaVis_NetCDFError(ncstatus); 20 return -1; 21 } 22 13 23 /* Redefining a quantity? */ 14 24 for(height = anugavis.heights ; height != NULL ; height = height->next) … … 26 36 } 27 37 28 /* TODO: use NetCDF to check if the quantity is dynamic */ 38 /* If the NetCDF variable is 2-dimensional, then it's dynamic. */ 39 if((ncstatus = nc_inq_varndims(anugavis.netcdfId, 40 ncvarid, &numdims)) != NC_NOERR){ 41 AnugaVis_NetCDFError(ncstatus); 42 return -1; 43 } 44 height->dynamic = (numdims == 2); 29 45 height->offset = offset; 30 46 height->scale = scale; -
anuga_work/development/anugavis/src/libanugavis/init.c
r5220 r5228 1 #ifdef HAVE_CONFIG_H 2 # include "config.h" 3 #endif 4 5 #ifdef HAVE_GL_GL_H 6 # include <GL/gl.h> 7 #elif HAVE_OPENGL_GL_H 8 # include <OpenGL/gl.h> 9 #endif 10 #ifdef HAVE_GL_GLU_H 11 # include <GL/glu.h> 12 #elif HAVE_OPENGL_GLU_H 13 # include <OpenGL/glu.h> 14 #endif 15 #include <netcdf.h> 1 16 #include <SDL.h> 2 17 #include "anugavis.h" … … 5 20 6 21 int AnugaVis_Init(int width, int height, const char *swwFilePath){ 22 int ncstatus; 7 23 if((SDL_Init(SDL_INIT_VIDEO) == -1) || 8 24 (SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5) == -1) || … … 16 32 return -1; 17 33 } 34 35 glEnable(GL_DEPTH_TEST); 36 glShadeModel(GL_FLAT); 37 glEnable(GL_NORMALIZE); 38 glMatrixMode(GL_PROJECTION); 39 gluPerspective(45.0, ((GLdouble)width)/((GLdouble)height), 0.1, 1000); 40 glMatrixMode(GL_MODELVIEW); 41 glLoadIdentity(); 42 43 if((ncstatus = nc_open(swwFilePath, NC_SHARE, 44 &anugavis.netcdfId)) != NC_NOERR){ 45 AnugaVis_NetCDFError(ncstatus); 46 SDL_Quit(); 47 return -1; 48 } 18 49 anugavis.heights = NULL; 19 50 return 0; … … 23 54 while(anugavis.heights != NULL) 24 55 AnugaVis_UndefineHeightQuantity(anugavis.heights->name); 56 nc_close(anugavis.netcdfId); 25 57 SDL_Quit(); 26 58 }
Note: See TracChangeset
for help on using the changeset viewer.