Page 1 of 1

Particle Engine written in C (source code available)

Posted: Sat Jan 14, 2017 6:23 am
by MCU
I remember watching Falco demonstrate DCParticles a really long time ago, and I always thought it was badass. :bow:

So I made my own in a similar style.
Its controls are position, gravity, velocity, angle, size, lifespan, and RGBA color.

I wrote this a while ago, rewrote it recently and I decided to share it cuz why not.




It's not locked into a constant framerate. On my laptop it runs at 1500fps, and my desktop PC it's nowhere near that.
If you want to compile and run it for some reason, and it's too slow, you can increase the tick rate to speed it up.

If you want to check the source code it's here
https://github.com/pxcland/GLParticles

Re: Particle Engine written in C (source code available)

Posted: Sat Jan 14, 2017 9:38 pm
by dandymcgee
Very cool! The Proof of Concept tile engine is impressive as well. What do you plan on doing with the particle engine?

Also, I noticed you're using immediate mode rendering. If you want to learn modern OpenGL and speed it up even more, I suggest https://learnopengl.com/. Great website. In particular, the section on "instanced rendering" would help you make your particle system even faster than it already is.

Your code is very well organized and commented. Kudos on that.

Oh, and welcome to the forums Patrick!

Re: Particle Engine written in C (source code available)

Posted: Sat Jan 14, 2017 11:13 pm
by MCU
dandymcgee wrote:Very cool! The Proof of Concept tile engine is impressive as well. What do you plan on doing with the particle engine?

Also, I noticed you're using immediate mode rendering. If you want to learn modern OpenGL and speed it up even more, I suggest https://learnopengl.com/. Great website. In particular, the section on "instanced rendering" would help you make your particle system even faster than it already is.

Your code is very well organized and commented. Kudos on that.

Oh, and welcome to the forums Patrick!
Thanks!

Haha, to be honest there really isn't much of a purpose for it. It was more of an educational thing, to get under my belt so I understand how to make one. It was pretty sloppy and slow the first time I wrote it since every particle stored way more state and took twice the memory. On the first version I was learning as I made it, this version I rewrote the code to remove all the superfluous stuff.

But now since I've made it, if I ever want to incorporate it into a project, I have a working model and won't have to write it from scratch 8-)

I'm aware that my OpenGL usage has been long deprecated :lol: When I learned basic OpenGL a while ago I went with the simplest route to get the visuals I wanted, but it's obviously not sustainable for the future.
I looked through that website and it's unbelievable how well it explains everything. I'll definitely go through it :bow:

Re: Particle Engine written in C (source code available)

Posted: Sun Jan 15, 2017 11:33 am
by dandymcgee
MCU wrote:I'm aware that my OpenGL usage has been long deprecated :lol: When I learned basic OpenGL a while ago I went with the simplest route to get the visuals I wanted, but it's obviously not sustainable for the future.
I looked through that website and it's unbelievable how well it explains everything. I'll definitely go through it :bow:
Cool. Ping me with @dandymcgee in Discord if you ever wanna chat.

Re: Particle Engine written in C (source code available)

Posted: Mon Jan 16, 2017 4:52 pm
by K-Bal
Great stuff, well done!

Reminds me of my own experiments I did for my bachelor's thesis. You can speed this up a lot by updating the particles in a geometry shader.


Re: Particle Engine written in C (source code available)

Posted: Mon Jan 16, 2017 5:20 pm
by dandymcgee
K-Bal wrote:Great stuff, well done!

Reminds me of my own experiments I did for my bachelor's thesis. You can speed this up a lot by updating the particles in a geometry shader.
Vouch. This guy's legit ^

Re: Particle Engine written in C (source code available)

Posted: Thu Apr 20, 2017 7:47 pm
by Falco Girgis
dandymcgee wrote:Very cool! The Proof of Concept tile engine is impressive as well. What do you plan on doing with the particle engine?

Also, I noticed you're using immediate mode rendering. If you want to learn modern OpenGL and speed it up even more, I suggest https://learnopengl.com/.
I wouldn't go so far as to say that using the OpenGL core and ditching immediate mode is necessarily going to give you a speed-up for anything like this. If you're doing something that requires shitloads of updates or basically resubmitting geometry to the GPU every frame (which is basically how immediate mode and client-side vertex arrays worked), I can basically guarantee you that the piss-poor, convoluted, highly unstandardized piece of shit GL 3+ drivers are going to absolutely rape your performance.

You will ONLY see a speedup for this type of thing if you do as K-Bal said and update the particles on the GPU itself, as you no longer have to worry about the piss-poor transfer performance. Otherwise, despite what everyone wants to think, you may very well get better performance with the legacy GL versions, and you will DEFINITELY get better performance with client-side vertex arrays.

Re: Particle Engine written in C (source code available)

Posted: Mon Apr 24, 2017 5:58 pm
by dandymcgee
Falco Girgis wrote:
dandymcgee wrote:Very cool! The Proof of Concept tile engine is impressive as well. What do you plan on doing with the particle engine?

Also, I noticed you're using immediate mode rendering. If you want to learn modern OpenGL and speed it up even more, I suggest https://learnopengl.com/.
I wouldn't go so far as to say that using the OpenGL core and ditching immediate mode is necessarily going to give you a speed-up for anything like this. If you're doing something that requires shitloads of updates or basically resubmitting geometry to the GPU every frame (which is basically how immediate mode and client-side vertex arrays worked), I can basically guarantee you that the piss-poor, convoluted, highly unstandardized piece of shit GL 3+ drivers are going to absolutely rape your performance.

You will ONLY see a speedup for this type of thing if you do as K-Bal said and update the particles on the GPU itself, as you no longer have to worry about the piss-poor transfer performance. Otherwise, despite what everyone wants to think, you may very well get better performance with the legacy GL versions, and you will DEFINITELY get better performance with client-side vertex arrays.
I'll admit, I made the assumption he wanted to future-proof his knowledge for bigger OpenGL projects using the modern pipeline. I probably shouldn't have said "speed it up" without backing it up because you're right; for his tile engine any number of things could "speed it up" and without profiling his code I'm in no position to make specific recommendations. I meant it as general educational advice rather than an optimization tip.