Render vs Renderer

Hi

I am currently writing SDL3 bindings for the OCaml language, and in the process of grouping functions into modules I came across this question:
Why do some SDL functions have the name “Render” and others “Renderer”?

(for instance SDL_GetRenderOutputSize versus SDL_GetRendererProperties)

Would it be acceptable to group them and have, say, OCaml functions like

Sdl.Renderer.get_output_size
Sdl.Renderer.get_properties

?

Render is a verb and renderer is a noun. Render is a thing you do and renderer is the name of the thing.

1 Like

Making a Language Binding for SDL3:
If I were using OCaml and SDL3, I would rather the bindings be as similar to the original API as possible.
My reasoning is that I would want to be able to use the official SDL3 documentation to figure out how to call functions, what inputs are expected, and what the results should be. It would be frustrating to feel like I was fighting the official docs every time that I’m expecting to rely on them.

Having said that:
If you are making your own framework to make programming with SDL3 in OCaml easier, then it is more acceptable to provide “help” whenever you think it clarifies the language or feature. This would mean that you need to be very good at writing your own documentation.

  • I think that a Language Binding should have as much in common with the original as possible, each building block should have the same shape and feel as in the original language.
  • A Framework is when you start to sort, reshape, and combine some of the blocks to show the user how you expect them to interact with the model.
2 Likes

that is what I thought but is not completely true: (or at least not that clear)

SDL_GetRenderDrawColor

SDL_RenderClear

etc

that’s good advice, but I think bindings are often inbetween what you call pure binding and framework: yes, they have to be close to original library so that one can use its documentation, but also yes they have to follow the common usage of the target language so that users are not disoriented and forced to adopt a non natural style. Well at least that what I feel is my dilemma :wink:

to return to my original question, I don’t want to have two different modules : Render and Renderer. I’m inclined to keep only Renderer. Then it would mean that I slighly deviate from the original SDL names by defining, for instance:
Sdl.Renderer.clear, Sdl.Renderer.get_draw_color

It seems reasonable to me, and I will add a pointer in the doc to the original SDL names.

Of course another possibility would be to not create any module at all and have all functions in a flat space:

Sdl.render_clear, Sdl.get_render_draw_color

but in my binding scheme I still need some modules to deal with C structs (sorry this becomes technical here) so I feel that having modules for functions would be more consistent, I dunno…

I would expect there to be one module, Render, and Renderer is a type that lives in that module. That’s how the bindings for Zig, Rust, and Odin work.