Particle Engine written in C (source code available)

Anything related in any way to game development as a whole is welcome here. Tell us about your game, grace us with your project, show us your new YouTube video, etc.

Moderator: PC Supremacists

Particle Engine written in C (source code available)

Postby MCU on Sat Jan 14, 2017 8:23 am

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
MCU
Chaos Rift Newbie
Chaos Rift Newbie
 
Posts: 3
Joined: Sat Jan 14, 2017 8:11 am

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

Postby dandymcgee on Sat Jan 14, 2017 11:38 pm

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!
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches! :twisted:
User avatar
dandymcgee
ES Beta Backer
ES Beta Backer
 
Posts: 4911
Joined: Tue Apr 29, 2008 4:24 pm
Location: New Hampshire

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

Postby MCU on Sun Jan 15, 2017 1:13 am

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:
MCU
Chaos Rift Newbie
Chaos Rift Newbie
 
Posts: 3
Joined: Sat Jan 14, 2017 8:11 am

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

Postby dandymcgee on Sun Jan 15, 2017 1:33 pm

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.
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches! :twisted:
User avatar
dandymcgee
ES Beta Backer
ES Beta Backer
 
Posts: 4911
Joined: Tue Apr 29, 2008 4:24 pm
Location: New Hampshire

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

Postby K-Bal on Mon Jan 16, 2017 6:52 pm

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.

User avatar
K-Bal
ES Beta Backer
ES Beta Backer
 
Posts: 719
Joined: Sun Mar 15, 2009 4:21 pm
Location: Germany, Aachen

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

Postby dandymcgee on Mon Jan 16, 2017 7:20 pm

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 ^
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches! :twisted:
User avatar
dandymcgee
ES Beta Backer
ES Beta Backer
 
Posts: 4911
Joined: Tue Apr 29, 2008 4:24 pm
Location: New Hampshire

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

Postby Falco Girgis on Thu Apr 20, 2017 8:47 pm

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.
"So what happens if the Elysian Shadows Kickstarter fails?"
Image
User avatar
Falco Girgis
Elysian Shadows Team
Elysian Shadows Team
 
Posts: 10693
Joined: Thu May 20, 2004 3:04 pm
Location: Studio Vorbis, AL

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

Postby dandymcgee on Mon Apr 24, 2017 6:58 pm

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.
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches! :twisted:
User avatar
dandymcgee
ES Beta Backer
ES Beta Backer
 
Posts: 4911
Joined: Tue Apr 29, 2008 4:24 pm
Location: New Hampshire


Return to Game Development

Who is online

Users browsing this forum: No registered users and 3 guests

cron