Changeset 5271


Ignore:
Timestamp:
May 2, 2008, 2:19:54 PM (16 years ago)
Author:
jack
Message:

AnugaVis?: Something's drawing. Starting work on event handling to get motion.

Location:
anuga_work/development/anugavis/src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • anuga_work/development/anugavis/src/anugavis_simple.c

    r5267 r5271  
    1414    return 1;
    1515  }
    16   printf("%d\n", anugavis.number_of_timesteps);
    17   if(AnugaVis_DefineHeightQuantity("elevation", 0, 1, 128, 128, 128) == -1){
     16  if(AnugaVis_DefineHeightQuantity("elevation", 0, 1, 0.5, 0.5, 0.5) == -1){
    1817    printf("AnugaVis_DefineHeightQuantity() Error: %s\n", AnugaVis_GetError());
    1918    return 1;
    2019  }
    21   if(AnugaVis_DefineHeightQuantity("stage", 0, 1, 0, 0, 128) == -1){
     20  if(AnugaVis_DefineHeightQuantity("stage", 0, 1, 0.0, 0.0, 0.5) == -1){
    2221    printf("AnugaVis_DefineHeightQuantity() Error: %s\n", AnugaVis_GetError());
    2322    return 1;
  • anuga_work/development/anugavis/src/error.h

    r5267 r5271  
    1414/* Set the error message with a printf-style format string.
    1515 */
    16 void AnugaVis_SetError(const char *format, ...);
     16extern void AnugaVis_SetError(const char *format, ...);
    1717/* Report a SDL error.
    1818 */
    19 void AnugaVis_SDLError(void);
     19extern void AnugaVis_SDLError(void);
    2020/* Report a NetCDF error.
    2121 */
    22 void AnugaVis_NetCDFError(int ncerr);
     22extern void AnugaVis_NetCDFError(int ncerr);
    2323/* Report an OpenGL error.
    2424 */
    25 void AnugaVis_OpenGLError(GLenum errorCode);
     25extern void AnugaVis_OpenGLError(GLenum errorCode);
    2626
    2727/* Get detailed error information. The returned string should not be
  • anuga_work/development/anugavis/src/events.c

    r5261 r5271  
    88#  include <OpenGL/gl.h>
    99#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
    1015#include <SDL.h>
    1116#include "events.h"
    1217#include "globals.h"
     18#include "height_quantity.h"
    1319
    1420int AnugaVis_Step(void){
    1521  SDL_Event event;
    1622  int more = 1;
     23  struct height_quantity_simple *height;
    1724
    1825  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
     26  glMatrixMode(GL_MODELVIEW);
     27  glLoadIdentity();
     28  gluLookAt(anugavis.eye[0], anugavis.eye[1], anugavis.eye[2],
     29            anugavis.focus[0], anugavis.focus[1], anugavis.focus[2],
     30            0, 0, 1);
     31  for(height = anugavis.heights ; height != NULL ; height = height->next)
     32    AnugaVis_DrawHeightQuantity(height);
    1933  SDL_GL_SwapBuffers();
    2034
     
    2236    switch(event.type){
    2337    case SDL_KEYDOWN:
    24       if(event.key.keysym.sym == SDLK_ESCAPE) more = 0;
     38      switch(event.key.keysym.sym){
     39      case SDLK_ESCAPE:
     40        more = 0;
     41        break;
     42      default:
     43        break;
     44      }
     45      break;
     46    case SDL_KEYUP:
     47      switch(event.key.keysym.sym){
     48      default:
     49        break;
     50      }
    2551      break;
    2652    }
  • anuga_work/development/anugavis/src/events.h

    r5261 r5271  
    11#ifndef EVENTS_H
    22#define EVENTS_H
     3
     4typedef enum {KEY_FORWARD = 0,
     5              KEY_BACKWARD,
     6              KEY_STRAFE_LEFT,
     7              KEY_STRAFE_RIGHT,
     8              KEY_MAX} KEYS;
    39
    410/* Execute a single step of the visualiser. Provided for situations
  • anuga_work/development/anugavis/src/globals.h

    r5267 r5271  
    22#define GLOBALS_H
    33
     4#ifdef HAVE_CONFIG_H
     5#  include "config.h"
     6#endif
     7
     8#if HAVE_STDINT_H
     9#  include <stdint.h>
     10#endif
     11#ifdef HAVE_GL_GL_H
     12#  include <GL/gl.h>
     13#elif HAVE_OPENGL_GL_H
     14#  include <OpenGL/gl.h>
     15#endif
    416#include <SDL.h>
     17#include "events.h"
    518#include "height_quantity.h"
    619
     
    1629  float *y;
    1730  int *volumes;
     31
     32  GLfloat eye[3];
     33  GLfloat focus[3];
     34  uint8_t keys[KEY_MAX];
     35
    1836  struct height_quantity_simple *heights;
    1937} ANUGAVIS;
  • anuga_work/development/anugavis/src/height_quantity.c

    r5270 r5271  
    7777int AnugaVis_DefineHeightQuantity(const char *name,
    7878                                  double offset, double scale,
    79                                   int red, int green, int blue){
     79                                  GLfloat red, GLfloat green, GLfloat blue){
    8080  struct height_quantity_simple *height;
    8181  int ncstatus;
     
    134134  height->offset = offset;
    135135  height->scale = scale;
    136   height->color = SDL_MapRGB(anugavis.screen->format, red, green, blue);
     136  height->red = red;
     137  height->green = green;
     138  height->blue = blue;
    137139  return 0;
     140}
     141
     142void AnugaVis_DrawHeightQuantity(struct height_quantity_simple *height){
     143  glPushMatrix();
     144  /*  glScalef(0, 0, height->scale);
     145      glTranslatef(0, 0, height->offset); */
     146  glColor3f(height->red, height->green, height->blue);
     147  glCallList(height->displayLists);
     148  glPopMatrix();
    138149}
    139150
  • anuga_work/development/anugavis/src/height_quantity.h

    r5270 r5271  
    66#endif
    77
     8#if HAVE_STDINT_H
     9#  include <stdint.h>
     10#endif
    811#ifdef HAVE_GL_GL_H
    912#  include <GL/gl.h>
     
    1114#  include <OpenGL/gl.h>
    1215#endif
    13 #include <SDL.h>
    14 
    15 struct height_quantity_simple{
     16struct height_quantity_simple {
    1617  char *name;
    1718  uint8_t frames;
    1819  double offset;
    1920  double scale;
    20   Uint32 color;
     21  GLfloat red;
     22  GLfloat green;
     23  GLfloat blue;
    2124  GLuint displayLists;
    2225  struct height_quantity_simple *next;
     
    2831extern int AnugaVis_DefineHeightQuantity(const char *name,
    2932                                         double offset, double scale,
    30                                          int red, int green, int blue);
     33                                         GLfloat red, GLfloat green,
     34                                         GLfloat blue);
     35/* Draw a height quantity.
     36 */
     37extern void AnugaVis_DrawHeightQuantity(struct height_quantity_simple *height);
    3138/* Undefine a given simple height quantity.
    3239 */
  • anuga_work/development/anugavis/src/init.c

    r5267 r5271  
    3131  anugavis.y = NULL;
    3232  anugavis.volumes = NULL;
     33  /* FIXME derive this from the dataset? */
     34  anugavis.eye[0] = 5.0;
     35  anugavis.eye[1] = 5.0;
     36  anugavis.eye[2] = 20.0;
     37  anugavis.focus[0] = 0.0;
     38  anugavis.focus[1] = 0.0;
     39  anugavis.focus[2] = 0.0;
    3340  anugavis.heights = NULL;
    3441  if((SDL_Init(SDL_INIT_VIDEO) == -1) ||
Note: See TracChangeset for help on using the changeset viewer.