Conversation
87c4ba0 to
987dfa8
Compare
|
Also, I need a recommendation for the new rectangle struct's name... First i called it So what should I call it? Other than Maybe |
|
Just call it |
|
It took years for most projects to migrate to SDL2 so i wouldn't stress about work being wasted with improving what we have now. |
|
|
|
987dfa8 to
992a5e1
Compare
|
Ok, went with the less controversial |
|
Wish I hadn’t said anything. I prefer |
2b981be to
3d4654b
Compare
|
@weirddan455 @kcgen Any further thoughts on this guys? For the record, in my upcoming PR there will be improvements to Then, as an alternative idea, if sometime in the far future we start using the window, desktop, canvas, viewport, rendered image size, draw size, etc. terms 100% consistently, we might drop the So yeah, I guess I just want to merge it and let it evolve over time, plus eventually we'll clean up the whole sdlmain and make things non-ambiguous. There's lots of further adding of px postfixes and clarifying terms in my upcoming WIP PR. |
kcgen
left a comment
There was a problem hiding this comment.
Just one minor suggestion.
This is a nice clarification in names, and more use of optional<> will help root out initialization order-of-operation problems.
3d4654b to
71bcdba
Compare
Description
A bunch of mostly non-functional changes separated out of my upcoming viewport resolution/ aspect ratio enhancement PR.
Definitely review by commit.
Main changes:
SDL_Rectis not leaking into the core emulation layers anymore; I've introduced a customRectangletype for this purpose.For people who are not experienced with logical/physical coordinates, here's a quick rundown:
Using logical coordinates is the way forward for most use cases now that high DPI displays are increasingly the norm, especially for general GUI development and scalable vector graphics. You just use logical coordinates and things work fine on high DPI displays (if your framework is good), no need to think about it (that's what I'm doing in my other GLFW + OpenGL based programs that feature scalable vector graphics, and I can confirm, ThingsJustWork(tm)).
But when you're dealing with bitmap graphics and OpenGL, you need to deal with physical pixels as well. Also, understanding how things to map to physical pixels is important because of the OpenGL shaders, for instance. So the code will be naturally a mixture of logical and physical units, therefore we must encode the units in the variable and function names, otherwise you can only guess things when reading the code.
Should I multiply this quantity by the DPI scale factor?
Should I not? 😕
Should I divide it by the DPI factor? 🤔
It's anyone's guess if the var is just called something like
sdl.clip.w! 🥶That is bad, very bad, and it results in copious amounts of trace logging and intense hair loss during a compressed duration of time. Now, you don't wish that on your fellow devs, do you? 😎
So the system I started adopting is as follows:
widthandget_widthmean logical coordinates, whilewidth_px, andget_width_in_pixelsmeans—I'm sure you can figure that out 😎 SDL has also started adding the*InPixelspostfix to function names in its API (although I'm not sure how consistent they are with that)._pxand_in_pixelspostfixes; it's implicit thatwidth,height, etc. are always in pixels in the core layers. I stress it again: only sdlmain should deal with logical pixels! (Well, and the upcoming OSD layer as well, because it will draw the UI as scaleable vector graphics, but that's for later and it's another special case 😎)_pxpostfix for function arguments that have anything to do with window sizes, canvas sizes, viewport dimensions, etc. Can be a little bit redundant in some cases, but I'd rather be a little redundant than a little confusing 😄I'm hoping this is all not much controversial 😄 I don't think this is wasted effort because we don't know when we'll migrate to SDL3, plus clarifying the current sdlmain mess would help the transition effort too (I'm sure some of the current code could be (will be?) even lifted into the SDL3 branch).
Manual testing
Tried the shaders and the various integer scaling and viewport resolution modes, fullscreen / windowed, etc., and there are no regressions.
Checklist
Please tick the items as you have addressed them. Don't remove items; leave the ones that are not applicable unchecked.
I have: