Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 23 Jan 2012
Offline Last Active Apr 23 2014 01:53 AM

#5148141 Drawing 2D shadows with "pure" SDL2

Posted by on 19 April 2014 - 08:38 AM

I take my words back the performance is really good, tried to draw like 60 small objects and get 2000+ draw calls the performance didnt drop below 60fps, it seems the more i draw the less the performence is impacted, if i add even more objects and draw more shadows, then the performence bearly drop.


Tested with 100 small object and I get nearly perfect 60, so if I make good level designe, the performence will be excellent always.

#5147944 Drawing 2D shadows with "pure" SDL2

Posted by on 18 April 2014 - 11:20 AM

I don't have a solution for you but I'd love to see how you're currently doing it if you're interested in posting the source code.

Will do it, but its very bruteforce way(found a way to improve it), will post everything and try to add little comments in the code.

#5147092 Drawing 2D shadows with "pure" SDL2

Posted by on 15 April 2014 - 06:35 AM

As the title say I want to draw 2d shadows only unsing sdl2 without openg, I have done it but the performence isnt the best,
I get like from 300fps+ to 90fps+ with 17 rectangles.



Pc Spec:
Cpu i3-3110M
Gpu Nvidia 630M

Render everything in: 1280x720


when I get low fps My shadow drawing algorithm call 300+ drawing call to draw shadow for every object thats is on the screen;

to draw shadows I use triangles(still rectangle just the texture is triangle) and few rectangles pic:



In the code I calculate the position from the mouse to the rectangle ant how much should the shadow go until it reaches the screen end,the calculation doesnt hit much in performence, but the drawing is just killing everything, I need somehow to lower the drawing calls.


Does anybody know any better way to draw without OpenGL?


Some tutorials that I saw draw the light itself, but I dont know how would I do it with out OpenGL for triangle drawing.








Added source and executable (you can compile the code on android too)


Attached Files