-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added new hint: SDL_HINT_EMSCRIPTEN_CANVAS_ELEMENT #6134
Conversation
I have almost the same patch: Daft-Freak@b0ed9e0. Though I went with It should probably be mentioned that everything rendering related is going to ignore this and use (I was about to PR the first four commits from Daft-Freak/SDL@main...Daft-Freak:SDL:create-window-from-2 after being reminded about #5260.) |
@@ -218,14 +218,19 @@ Emscripten_CreateWindow(_THIS, SDL_Window * window) | |||
SDL_WindowData *wdata; | |||
double scaled_w, scaled_h; | |||
double css_w, css_h; | |||
const char *canvasElement = SDL_GetHint(SDL_HINT_EMSCRIPTEN_CANVAS_ELEMENT);; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be canvas_element
(or even canvas_selector
), also there's an extra semicolon.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok for the semicolon, I've updated the PR, but I've used canvasElement
according to:
https://github.com/libsdl-org/SDL/blob/main/src/video/emscripten/SDL_emscriptenevents.c#L722
and anyway all the code calls it element, e.g. emscripten_set_canvas_element_size
The variable name is not really a problem for me, I can change it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that one is also wrong... most names are in snake_case now. (You could argue that that one is even more wrong as some of the options aren't even elements... But uh, it is also 8 year old code 😄 )
... and yeah there's a bit of inconsistent naming going on, mostly because it used to be an element id(+ some magic values) and is now a CSS selector (+ some other magic values).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so? @slouken @Daft-Freak going for canvas_element
or canvas_selector
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and yes I handle directly specialHTMLTargets
object because my canvas is in a shadow dom, emscripten wouldn't be able to find it without the shadow dom root
This helps emscripten to find the canvas HTML element
I'm going to close this for now in favor of @Daft-Freak's work in progress. |
This helps emscripten to find the canvas HTML element
Description
This patch add the possibility to specify the canvas using a new hint SDL_HINT_EMSCRIPTEN_CANVAS_ELEMENT
Existing Issue(s)
fixes #5260
Non related, a strange side effect while testing the patch, calling
SDL_CreateWindow
with an overside dimension takes the path (I've added an fprintf before):but
SDL_GetError()
returnsSDL not built with thread support
, that is the output ofSDL_CreateSemaphore()
insrc/thread/generic/SDL_syssem.c
, I don't known who calls it, perhaps I may make a PR that prefixes the name of the function called in that fileThe only possible caller looks like
SDL_TimerInit()
, butthat shouldn't be compiled in