OpenGL point sprites - how can I change their size?
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.
OpenGL point sprites - how can I change their size?
hi
I am writing a particle engine using point sprites, and i want to change the size of the points in relation to how far they are from the camera (you know, like in the real world). I've borrowed code from places and it uses glext to get the right functions.
so my questions are:
* How can i change the point size based on how far they are from the camera
* Do i used glext for linux (if it exists) or is there an alternative?
Try using small triangles instead. Points technically don't have any size at all, but in order to actually make them visible, pipelines make them 1 pixel large. Triangles do have size, so the pipeline should adjust their size properly. However, (without antialiasing) pipelines usually don't color the edges so very small or distant triangles will disappear.
As for glext, if you're using SDL, load the functions you want from with SDL_GL_GetProcAddress(). Be careful when using extensions cause you can easily lock out people who have older GPUs.
thankyou very much for that - i have gone back to using not triangles but textured squares for my particles, with no apparent decrease in framerate, which is odd. anyway, i've run into another problem being that the squares are rendered facing the vector (0, 0, 1) as in facing towards the screen with a reset camera. what i need to do now is make them face the camera wherver it is. The screenshots should explain this further. so, what i want to do is combine the point sprite turn-to-camera functionality with the rendering-squares-that-change-size functionality to produce particles that face the camera AND change their size according to the camera position. i have tried using glPointPerameterf(/glPointPerameteri, etc) to no avail as g++ says it hasn't been defined. do i need a particular library for this or should i use SDL which i dont really want to do. apologies for the long post, but this is the last problem to overcome before i have almost finished my particle engine (collision detection with normals next)
james
ps. particular libraries like glew, glext, all those opengl ones as i'd like to keep everything pure OpenGL to keep dependencies as low as possible (the only external libraries im using are GLPNG, which is excellent for png textures).
i've run into another problem being that the squares are rendered facing the vector (0, 0, 1) as in facing towards the screen with a reset camera. what i need to do now is make them face the camera wherver it is
This effect is called billboarding, there are numerous articles on how to do this but in this instance you probably want to use screen oriented billboarding. This involves using the inverse normal of the cameras view plane to orientate the polygon.
yeah, um... i've sorted everything out now with the point sprites - i have managed to get attenuation to work with a lib called GLee. really useful it is too. thanks anyway everyone and i apologise for wasting your time
ps. particular libraries like glew, glext, all those opengl ones as i'd like to keep everything pure OpenGL to keep dependencies as low as possible (the only external libraries im using are GLPNG, which is excellent for png textures).
If you want to use an extension, you have to either must use a platform-dependent API to get the extension function pointers from the GL library, or an external library that makes the using extensions cross-platform. I understand that you don't like dependencies, but I personally use SDL as my one dependency because it provides a lot of nice stuff and is one of the easiest libraries to set up in VS. The event system is a lot easier to deal with than GLUT. Loading pngs are pretty easy with SDL_Image. SDL_Image is technically a different library than base SDL, but in practice SDL_Image and SDL_Mixer don't act like separate dependancies.
thankyou for the SDL suggestion, but i have found a library called GLee which has come in really handy. loading PNGs is a cinch with GLPNG, so everything's sorted. thankyou for your time anyway
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.