Fix: RGB values set by macro MFP_RGB on Android platforms where CPU is either running in little (seems to be the default) or big endian. #73
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Noticed all my colours were wrong on Android and other platforms worked fine.
This is a fix for RGB values set by macro MFP_RGB on Android platforms where CPU is either running in little (seems to be the default) or big endian.
"Since code runs on the little endian CPU, red color in 'rgb' would be masked as 0x000000ff, and blue color would be masked as 0x00ff0000, while if the code runs on a big endian CPU, the red color in 'rgb' would be masked as 0xff000000, and blue color would be masked as 0x0000ff00."
This is easily demonstrated by updated test: src/main/cpp/noise.c:
...
// Comment out to test appropriate colour channel
//g_buffer[i] = MFB_RGB(noise, 0, 0); // Test red channel
//g_buffer[i] = MFB_RGB(0, noise, 0); // Test green channel
//g_buffer[i] = MFB_RGB(0, 0, noise); // Test blue channel
g_buffer[i] = MFB_RGB(noise, noise, noise);
...
The uint32 value RGB values is set as blue, green then red. Tested on real devices with arm64-v8a and armeabi-v7a and on x86 emulator).
MFB_RGB works fine as-is on X11, Windows, MacOS and iOS platforms.