SDL icon indicating copy to clipboard operation
SDL copied to clipboard

cleanup of SDL_video.c (mainly Re(create)window)

Open pionere opened this issue 3 years ago • 3 comments

  1. solve FIXMEs in SDL_GetDisplayBounds and SDL_GetDisplayUsableBounds by returning SDL_InvalidParamError("rect") in case rect is NULL
  2. consistently check against ANDROID (instead of ANDROID)
  3. add SDL_ContextNotSupported to create error message in case the given graphics backend is not supported
  4. use SDL_ContextNotSupported in SDL_GL_LoadLibrary instead of a custom error message
  5. add NOT_AN_OPENGL_WINDOW define similar to NOT_A_VULKAN_WINDOW
  6. no need to check if _this->Metal_CreateView, since it is already checked in Re(create)Window (similar to GL_CreateContext and Vulkan_CreateSurface)
  7. set only one of SDL_WINDOW_OPENGL/SDL_WINDOW_METAL as default backend (might want to extend CMakeList to warn the user)
  8. simplify check of SDL_WINDOW_UTILITY/SDL_WINDOW_TOOLTIP/SDL_WINDOW_POPUP_MENU flags assuming each of these is a single bit flag
  9. simplify check of SDL_WINDOW_OPENGL/SDL_WINDOW_METAL/SDL_WINDOW_VULKAN flags assuming each of these is a single bit flag

pionere avatar Feb 05 '22 15:02 pionere

Is this eligible for 2.0.22 (reviewed?) or should wait for later?

sezero avatar Mar 24 '22 19:03 sezero

We're close enough on 2.0.22 that these should wait for the next milestone.

slouken avatar Mar 24 '22 19:03 slouken

@pionere, can you rebase this PR on the latest main?

slouken avatar Jun 17 '22 17:06 slouken

It looks like you're submitting each change as a separate PR. That's a good way for us to review and easily accept individual changes, thanks!

slouken avatar Nov 11 '22 17:11 slouken

@slouken : with the latest PR all but one commits are integrated.

I'm hesitating now how to proceed, because I'm not really sure what is the best way to solve the issue of possible conflicting flags in SDL_CreateWindow. I think there are three options:

  1. don't touch the code at all.
    • Pros: no change necessary
    • Cons: possible conflicting flags based on the conditions
  2. use my commit/change.
    • Pros: no conflicting flags are set
    • Cons: code is a bit more complicated than necessary
  3. alter the conditions (e.g. change it to #elsif, or change the checks).
    • Pros: no conflicting flags are set
    • Cons: if it is not just a change of if ->elseif, then someone else has to do it.

Which one would you prefer?

pionere avatar Nov 14 '22 16:11 pionere

We should look at what actually happens when both OpenGL and Metal are set, especially in the macOS Cocoa case. I'm inclined not to touch this right now, and revisit in SDL 3.0, where Metal would be the default on any platform that supports it.

slouken avatar Nov 14 '22 17:11 slouken

We did end up needing your last patch, to fix window recreation on macOS.

Thanks!

slouken avatar Nov 17 '22 01:11 slouken