lispgames / cl-sdl2

Common Lisp bindings for SDL2 using C2FFI.
MIT License
304 stars 82 forks source link

Add with-renderer-draw-color macro #157

Closed Filipp-Druan closed 1 year ago

Filipp-Druan commented 1 year ago

I wrote a simple game and used colored triangles to draw objects. Each object had its own color, in order to render it, I needed to temporarily change the color of the renderer. That's why I wrote the proposed macro.

TatriX commented 1 year ago

Hey! Thanks for the contribution! My personal take on this would be to not have it in the core but instead perhaps demonstrate it in the examples. Or maybe have an optional convenience package with some utils that are not a part of SDL2 itself. But let's see what @mfiano has to say about that.

Filipp-Druan commented 1 year ago

Well, okay. And when will the @mfiano give his opinion? I really look forward to, dreaming that my contribution will be accepted.

mfiano commented 1 year ago

Sorry for the late response. Actually, this is quite early for me -- we all have lives and some of us do this only in our spare time :)

Anyway, yes, thank you for the contribution! I definitely agree with @TatriX here, though. It is a bit opinionated and higher level than what SDL provides. There is a lot of mistakes in the code that I have fixed over the years, due to macros such as these. I have been slowly trying to remove the un-necessary features over time, unless enough people complain, which hasn't happened yet. I think cl-sdl2 should map closely to SDL itself. The with- macros currently available present a lot of challenges with game engines working with multiple threads, which is why we now have things like `sdl2:initin addition tosdl2:init` which assumes this complicated threading API to be used.

Long story short, my point is there is a lot wrong with cl-sdl2 still due to seemingly innocent macros. Secondly, I think this doesn't fit the scope of cl-sdl2, and would be much better served as an example, to show people how to solve a real problem you found a solution for.

Filipp-Druan commented 1 year ago

Understood! And I thought that you want to collect more functions. Could it really be harmful?

mfiano commented 1 year ago

Any code could be harmful if you consider the wide array of playforms, implementations, and existing users' reliance on semantics. Thanks.

It has been decided that such a macro does not meet the scope of a low-level wrapper analogous to C code. If SDL2 doesn't do it, cl-sdl2 probably shouldn't do it. It should be provided at a different level of abstraction or as a recipe in an example.