http://code.google.com/p/bullet/source/browse/branches/OpenCL/Demos/SpheresOpenCL/Shared/btIntegrationDemoDynamicsWorld.cpp?r=1756
Working Opencl CreateImage2D sample:
http://www.cse.ohio-state.edu/~suttmill/Float_2D_Texture_files/CPlusPlusCode.txt
Bitmap format:
http://www.fileformat.info/mirror/egff/ch03_04.htm
A test using opencl and openframeworks=>5000 particles interact with each other and mouse cursor.
this runs easily at 30fps but snapz killed the framerate a little
this is running only on cpu and letting opencl do its thing.
source for this can be downloaded here: code.google.com/p/ruisource/
it includes a slightly modified version of the ofxOpenCL addon by Memo Akten.
OpenCL in openFrameworks example - 1 milion particles @ 100-200fps
This example is based on Rui's opencl example at http://vimeo.com/7298380.
Discussion on the matter at http://www.openframeworks.cc/forum/viewtopic.php?f=10&t=2728&p=15107#p15...
source code for ofxOpenCL and the above example at
http://code.google.com/p/ofxmsaof/downloads/list
__kernel void updateParticleWithoutCollision(__global Particle* pIn, __global float2* pOut, const float2 mousePos, const float2 dimensions){
int id = get_global_id(0);
__global Particle *p = &pIn[id];
float2 diff = mousePos - pOut[id];
float invDistSQ = 1.0f / dot(diff, diff);
diff *= 300.0f * invDistSQ;
p->vel += (dimensions*0.5 - pOut[id]) * CENTER_FORCE2 - diff* p->mass;
pOut[id] += p->vel;
p->vel *= DAMP2;
float speed2 = dot(p->vel, p->vel);
if(speed2
}
沒有留言:
張貼留言