Issue
I've written an application in OpenGL (not-fixed pipeline). I've ported the application to Android using NDK and there's a few problems. Everything is darker, and some objects don't show as they should.
Windows
Android

(source: vvcap.net)
- The teapot on the right is black and has some strange reflections.
- Lower half of the flying ball is black
- Everything is dark
- Water doesn't look right at all.
- Teapot with environmental has a pink color.
Did anyone have similiar problems while porting to OpenGL Es 2.0 ? I didn't change anything in the shaders or the code except texture loading format:
#ifdef _NDK
if (IsAlpha)
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, Width, Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, Bits);
else
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, Width, Height, 0, GL_RGB, GL_UNSIGNED_BYTE, Bits);
#else
if (IsAlpha)
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, Width, Height, 0, GL_BGRA, GL_UNSIGNED_BYTE, Bits);
else
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, Width, Height, 0, GL_BGR, GL_UNSIGNED_BYTE, Bits);
#endif
Thanks!
Solution
In your desktop code path you pass BGR as the format to TexImage2D, while in you Android code path, you choose RGB.
The GL has no way to know what data Bits holds and simply constructs RGBA values from the data (substituting 1.0 for the A component in case of an RGB or a BGR format.) If you don't preprocess your data to reflect the format, the GL will simply take the B component values for the R component if you lay out the data for a RGB texture.
Correct the format and you'll be fine.
Answered By - thokra

0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.