controller.h

00001 /*
00002  * Copyright (c) 2009, Philippe Robert <probert@eyescale.ch> 
00003  *
00004  * This library is free software; you can redistribute it and/or modify it under
00005  * the terms of the GNU Lesser General Public License version 2.1 as published
00006  * by the Free Software Foundation.
00007  *  
00008  * This library is distributed in the hope that it will be useful, but WITHOUT
00009  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00010  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
00011  * details.
00012  * 
00013  * You should have received a copy of the GNU Lesser General Public License
00014  * along with this library; if not, write to the Free Software Foundation, Inc.,
00015  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00016  */
00017 
00018 #ifndef EQNBODY_NBODYSYSTEM_H
00019 #define EQNBODY_NBODYSYSTEM_H
00020 
00021 #include <driver_types.h>
00022 
00023 #include "render_particles.h"
00024 #include "frameData.h"
00025 #include "dataProxy.h"
00026 
00027 namespace eqNbody
00028 {
00029     class InitData;
00030     
00031     enum BodyArray 
00032     {
00033         BODYSYSTEM_POSITION,
00034         BODYSYSTEM_VELOCITY,
00035     };
00036         
00037     class Controller
00038     {
00039     public:
00040         Controller();
00041 
00042         bool init( int devID, const InitData& initData, float* hPos = NULL, bool usePBO=true, bool useGL = true);
00043         bool exit();
00044         
00045         void compute(const unsigned int frameID, const FrameData& fd, const eq::Range& range);
00046         void draw(const FrameData& fd);
00047 
00048         void setSoftening(float softening);
00049         
00050         void getArray(BodyArray array, DataProxy& proxy);
00051         void setArray(BodyArray array, const FrameData& fd);
00052 
00053         void synchronizeGPUThreads() const;
00054         
00055     private:
00056         int _getMaxGflopsDeviceId();
00057 
00058         ParticleRenderer _renderer;
00059         
00060         unsigned int    _numBodies;
00061         unsigned int    _p;
00062         unsigned int    _q;
00063         float           _damping;       
00064         bool            _usePBO;
00065 
00066         float*          _dPos[2];       // position data on the GPU
00067         float*          _dVel[2];       // velocity data on the GPU
00068                                 
00069         int             _devID;
00070         cudaDeviceProp  _props;
00071         
00072         unsigned int    _pbo[2];        // buffers
00073         unsigned int    _currentRead;   // current read buffer
00074         unsigned int    _currentWrite;  // current write buffer     
00075         float           _pointSize;
00076     };
00077 }
00078 
00079 #endif // EQNBODY_NBODYSYSTEM_H
Generated on Mon Aug 10 18:58:32 2009 for Equalizer 0.9 by  doxygen 1.5.8