SDL_SurfaceEx library released under MIT license

Hello good people.

I made a small little library to do effects on SDL_Surfaces. The main ones are inverting colors, grayscaling, flipping , recoloring and making circles.

I will like to expand the functionality more to make cooler effects for using RAW SDL based projects.

I added the source and example to Github:

I opted to go the route of C++, but maybe I will make a c version with just functions. But one of the functions used std::min, but probably is a c alternative available.

Please give it a look and all feedback is welcome.

Hello!
Thanks for sharing.
If your only need for C++ is using std::min, you could simply define your own function: int imin(int a, int b) { return a < b ? a : b; } for integers, and for float you can use the standard fmin.
Moreover, there is dead code in your .cpp (code that is commented). Because you are using git (or any other versioning tool), you should simply delete the code you no longer need. If later you want to get it back, you can use git to see previous version of your code where this code appeared.
Finally, you are not consistent on variables declarations, sometimes int x is inside the for-loop parenthesis, and sometimes outside (guideline : there should be inside the for-loop parenthesis if you don’t need x outside the loop).

1 Like

You can also use SDL_min()

1 Like

Thank you all for the support.

I will be applying an update soon with this.

Also,do you all think I should make it in c instead or do you all like the namespace?

I’ve updated the github to reflect snake_case_lower and also am now using SDL_min and SDL_max for less includes needed. Also I’ve ran into a bug in which the prerendered circles are not removing from memory when calling SDL_FreeSurface, would anyone be able to assist with this goal?