Fix nk_font_bake_convert() for big-endian machines#758
Fix nk_font_bake_convert() for big-endian machines#758mardy wants to merge 1 commit intoImmediate-Mode-UI:masterfrom
Conversation
nuklear.h
Outdated
| *dst++ = 0xff; // r | ||
| *dst++ = 0xff; // g | ||
| *dst++ = 0xff; // b | ||
| *dst++ = *src++; // a |
There was a problem hiding this comment.
Need to have /* comments for C89.
Also, does this still work on non-big endian devices? The RGB bit order should be fine, but I am unclear.
| { | ||
| int n = 0; | ||
| nk_rune *dst; | ||
| nk_byte *dst; |
There was a problem hiding this comment.
Thanks a lot for the update. Would you mind making this change in the src destroy? We use paq.sh to combine the files, so wouldn't want to lose your changes.
There was a problem hiding this comment.
Thanks, I will do the needed changes today or tomorrow and I'll ping you back.
There was a problem hiding this comment.
I tested the changes on a little endian machine, the conversion still works.
I added the changes to the src directory as well; should I remove them from nuklear.h, or is it OK like it is now?
Fix the byte order for converting alpha images into RGBA by writing the destination byte-by-byte. The compiler should anyway be able to optimize this.
| for (n = (int)(img_width * img_height); n > 0; n--) { | ||
| *dst++ = 0xff; /* r */ | ||
| *dst++ = 0xff; /* g */ | ||
| *dst++ = 0xff; /* b */ |
There was a problem hiding this comment.
It might be faster to call memset(out_memory, 0xff, img_width * img_height) first to set the R/G/B components, particularly on architectures without unaligned memory access that wouldn't be able to optimise this to use 32-bit writes like the old version did.
|
The sdl_renderer will also need to be updated to use |
Fix the byte order for converting alpha images into RGBA by writing the destination byte-by-byte. The compiler should anyway be able to optimize this.