controller.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
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];
00067 float* _dVel[2];
00068
00069 int _devID;
00070 cudaDeviceProp _props;
00071
00072 unsigned int _pbo[2];
00073 unsigned int _currentRead;
00074 unsigned int _currentWrite;
00075 float _pointSize;
00076 };
00077 }
00078
00079 #endif // EQNBODY_NBODYSYSTEM_H