/* ================================================================================== TUIOSmoke - a TUIO/OSC client implementation of the popular smoke demo Copyright (C) 2009 Patrick King This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ================================================================================== */ #ifndef INCLUDED_TUIOSMOKE_H #define INCLUDED_TUIOSMOKE_H #include "TuioListener.h" #include "TuioClient.h" #include "TuioCursor.h" #include #include #include #include #include #include #include #ifndef WIN32 #include #endif #include "SDL.h" #include "SDL_opengl.h" #include "glText.h" #include "fluid2d.h" #include "touchMap.h" using namespace TUIO; class TuioSmoke : public TuioListener { public: TuioClient *tuioClient; TuioSmoke( int port, bool setDebug ); ~TuioSmoke() { tuioClient->disconnect(); delete tuioClient; } void addTuioObject(TuioObject *tobj); void updateTuioObject(TuioObject *tobj); void removeTuioObject(TuioObject *tobj); void addTuioCursor(TuioCursor *tcur); void updateTuioCursor(TuioCursor *tcur); void removeTuioCursor(TuioCursor *tcur); void refresh(TuioTime frameTime); void initSmoke( std::string setWindowName, int w, int h, bool setFullscreen, int fW, int fH ); void drawFingers(); void drawFluidField(); void drawVelocityMap(); bool initSDL(); bool initGL(); void drawWindow(); void resizeWindow( int w, int h, bool setFullscreen ); void handleSDLEvent(); void setFrameDelay ( int delayTime ); void toggleFPS( bool toggle ); void toggleVelocityMap( bool toggle ); void setFontFile( std::string font ); void setupFluid ( int mesh, float tstep, float visc ); void s_spinFluid(); // thread dedicated to fftw calculation void s_spinDisplay(); // thread dedicated to display std::string itos( int i ); private: int windowID; int width, height; // width / height for windowed mode int f_width, f_height; // width / height for fullscreen int c_width, c_height; // current width/height int colordepth; const char *windowName; bool debug; bool fullscreen; bool draw_fingers; bool draw_velocity_map; int frameDelay; SDL_Surface *screen; SDL_Event event; const SDL_VideoInfo *info; static const int defaultFlags = SDL_OPENGL | SDL_GL_DOUBLEBUFFER | SDL_HWPALETTE; static const int fullscreenFlags = SDL_FULLSCREEN | SDL_NOFRAME ; static const int windowedFlags = SDL_RESIZABLE; // gl Lists //GLuint *fluidField; //GLuint *nFluidField; GLuint *velocityField; GLuint *nVelocityField; // FPS vars int timebase; int s_time; int frame; int fps; bool calcFPS; GLText *framerate; std::string fontfile; // Fluid2D vars Fluid2D *fluid; int fl_meshsize; float fl_timestep; float fl_viscosity; bool wireframe; int fluid_fps; // number of times fluid gets updates / sec int fluid_count; // This map keeps track of the colors assigned to each cursor ID typedef std::map ColorMap; ColorMap colormap; // This map holds the data for each cursor typedef std::map FingerMap; FingerMap fingermap; bool isInitialized; }; #endif /* INCLUDED_TUIODUMP_H */