Skip to content

Conversation

vsaint1
Copy link

@vsaint1 vsaint1 commented Oct 3, 2025

  • Support for both desktop (OpenGL 3.3) and mobile/web (OpenGL ES 3.0)
  • Example main menu with settings (resolution, difficulty, volume, etc..)

Here are some examples tested on different platforms:

ui_web ui_android image

@vsaint1
Copy link
Author

vsaint1 commented Oct 3, 2025

Forgot to add

image

{

nk_glyph glyph;
memcpy(glyph, evt->text.text, NK_UTF_SIZE);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is correct, didn't crashed but i need to make some minor changes, thanks for showing this!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants