:eek: Hey guys any one knows how to draw n spheres wihout a loop?
:o To simplify the problem, I have an array of vertices, and i used to just make a loop to draw the spheres with glutSolidSpheres, and each sphere has its origin as corresponding vertex in the array. But this time i cant use loop because a loop will affect my current program’s rendering speed(maybe its due to my poor architecture design :whistle: ). So my question is, how to draw those spheres using vertices in the array as origins, without a loop???
Someone might say i can use point sprites. But the spheres might overlap each others, so maybe point sprite is not ok, since sprites simpliy put a texture on a square(point)
Hi thamk you very much for the reply. By the way, actually my project is applying CG gpu shader language. And the link u gave me is cuda. Is there any way to solve my problem using CG?
If u look carefully (see render_particles.cpp) it renders the particles with OpenGL using glsl shader hardcoded in the file (lines 237-265) copied to show u
Just updating u. I managed to piece the application up. It renders the particles as spheres as shown here. I adapted the code from the sdk sample i told u earlier. Here is the fragment shader for u and attached is the output. Let me know if u need the source.