add: support sdl3 + opengl 3.3 and opengles 3.0 #834
add: support sdl3 + opengl 3.3 and opengles 3.0 #834vsaint1 wants to merge 2 commits intoImmediate-Mode-UI:masterfrom
Conversation
| { | ||
|
|
||
| nk_glyph glyph; | ||
| memcpy(glyph, evt->text.text, NK_UTF_SIZE); |
There was a problem hiding this comment.
This doesn't work. The type of evt->text.text changed between SDL2 and SDL3. With SDL2, this is an array of size SDL_TEXTINPUTEVENT_TEXT_SIZE, so while it isn't correct, it wouldn't crash. With SDL3, this is now a pointer to a UTF-8 string, so this will now crash reading OOB.
The OOB issue can be fixed by using strncpy(glyph, evt->text.text, NK_UTF_SIZE) instead of memcpy(), but that doesn't fix the issue that evt->text.text can have more than one character.
For the latter issue, smth like the following should work afaict:
nk_rune unicode;
int glyph_len;
int byte_len;
const char *text = evt->text.text;
glyph_len = byte_len = nk_utf_decode(text, &unicode, 4);
while (unicode != '\0' && glyph_len) {
nk_input_unicode(ctx, unicode);
glyph_len = nk_utf_decode(text+byte_len, &unicode, 4);
byte_len += glyph_len;
}
(This will be able to store up to NK_INPUT_MAX from the SDL3 text input buffer)
There was a problem hiding this comment.
this is correct, didn't crashed but i need to make some minor changes, thanks for showing this!!!
|
@vsaint1 Since #852 has been merged, you can probably take as much stuff from demo/sdl3_renderer as possible, and simply swap the rendering backend to the openGL ones. That demo has been extremely tested by multiple people and on multiple platforms. It should solve most of the problems you encounter here. |


Here are some examples tested on different platforms: