Waterflow
Visualize water in terrain
src/shallowGPU.h
Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 #ifndef SHALLOWGPU_H
00006 #define SHALLOWGPU_H
00007 #include "readData.h"
00008 #include "glm.hpp"
00009 #include "gtc/type_ptr.hpp"
00010 #include <vector>
00011 #include "xmlParsing.h"
00012 
00015 class ShallowGPU{
00016 private:
00017 
00018   static bool DEBUG; 
00019   GLint texWidth; 
00020   GLint texHeight; 
00021 
00022   float* flow; 
00023 
00024   DataHandler* terr; 
00025   GLuint cycle; 
00026 
00027   GLuint bufferOut; 
00028 
00032   int clip(int n, int lower, int upper);
00033 
00037   float clipf(GLfloat n, GLfloat lower, GLfloat upper);
00038 
00039 
00040   GLfloat totTime; 
00041 
00042   std::vector<Flood_Fill_data*> flood; 
00043 
00044 
00048   void initFloodFill(float* u);
00049 
00053   void floodFill(float* u, int x, int z, float height);
00054 
00058   void Print(GLuint bID, std::string msg, int iter) const;
00059 
00062   void PrintNumber(float value) const;
00063 
00066   void PrintHelper(std::string start_end, std::string msg, int iter) const;
00067 
00068 public:
00069 
00072   void cycleBuffer();
00073 
00074 
00075   GLuint advectWaterProgram; 
00076   GLuint addProgram;
00077   GLuint advectVelocityXProgram;
00078   GLuint advectVelocityYProgram;
00079   GLuint updateHeightProgram; 
00080   GLuint updateVelocityProgram;
00081   GLuint shallowBuffers[9];
00082 
00086   ShallowGPU(DataHandler *t,std::vector<Flood_Fill_data*> FFDataIn) { terr = t; texWidth = t->getDataWidth();
00087   texHeight = t->getDataHeight(); totTime = 0.0f; flood = FFDataIn; bufferOut = 0; cycle = 0;};
00088 
00091   void initGPU();
00092 
00096   void runSimGPU(GLfloat dt = 1.0f/30.0f);
00097 };
00098 
00099 
00100 
00101 #endif
 All Classes Files Functions Variables Enumerations