ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'm writing a 2d particle engine using OpenGL, and I use points, lines and point sprites to represent particles. I'm using glBegin()-glEnd() way of drawing. I'd like to use glDrawArrays(), but I have a problem with that : every particle has it's own size, but glDrawArrays() doesn't allow me to draw primitives/point sprites of different sizes, as far as I know. Is there any way I can do this?
It looks like there is no standard way to set point size in array for glDrawArrays.
Also I don't think this would give serious performance boost since particle data changes frequently (every frame).
I think you should be able to do same thing by writing simple shader (GLSL (OpenGL 2.0), or any other). In this case, though, you'll have to use triangles to build sprites and textures to make points look round. Shader will deform triangles according to point size and texture coordinates of vertex. In this case you will be able to feed per-vertex data using glVertexAttribPointer (OpenGL 2.0) or any similar function available through extensions.
If that is too much for you, then just stick to glBegin-glEnd method, until particle system will produce serious slowdown.
Somehow it seems to me that I the small boost I will get from using the array method will be lost if I use shaders and triangles. Well, I'll stick to this for now. It's going to be an open source project (when I make it useable and embed Lua), so someone will hopefully improve on my code.
Last edited by POW R TOC H; 01-16-2009 at 12:21 PM.
Somehow it seems to me that I the small boost I will get from using the array method will be lost if I use shaders and triangles.
Well, it won't be lost (you'll need just vertex shader, not pixel), but this system will need a lot of redundant data to work.
I implemented such thing on DirecX many years ago when I've run into troubles with pointsprites (maximum size limit, no rotation, etc) in 3D particle system.
Implementing what I've described makes sense only if you need large quantites (over 1000) of really large (possibly larger than screen), rotating, perspective-corrected textured sprites acting as particles. If you are using points and they are sufficient for your task, then writing this will be (probably) a waste of time.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.