Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
Developer Community or GitHub with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
Nobody caught this until one intrepid forum user!
"The sample app swaps Red and Blue channels on the loaded textures, which you can clearly see by comparing the textures rendered in the emulator to the files in Resources.
I narrowed it down to the following line: GL.TexImage2D (All.Texture2D, 0, (int)All.Rgba, w, h, 0, All.Rgba, All.UnsignedByte, pixels);
I tried fixing it by changing All.Rgba to All.GbraExt but it didn't help and the loaded texture appeared all white. I finally managed to fix it by replacing the line with GLUtils.TexImage2D((int)All.Texture2D, 0, bitmap, 0); but I don't want to use the GLUtils class.
Is there a way to fix it without changing the original code much?"
When investigating... by golly he's right! The texture is actually blue and the rendered texture is red. You can see that this has slipped by for a long time. The screenshots taken that show the expected behavior are clearly red.
Example screenshot: https://github.com/xamarin/monodroid-samples/blob/master/TexturedCube/Screenshots/TexturedCube2.png
Example texture: https://github.com/xamarin/monodroid-samples/blob/master/TexturedCube/Resources/drawable-nodpi/f_spot.png
PJ, question: is this a bug in the code/sample, or a bug in our libraries that are causing this?
It was not clear from your research.
This may need some eyes from Dean or Dominique. As far as I can tell, we could get the right colors if we could set All.Bgra instead of of All.Rgba.
That being said, oftentimes you need BGR for .bmp files and RGB for .png files, so I'm not sure why the channels are flipped for this png.
All applicable values for TexImage2d's internalformat and format seem to result in either the existing behavior or a white/grey cube.
This is a bug in the sample. Its not using the android util method
to create the texture. This method sorts out the RGBA/BGRA stuff automatically. The sample just needs updating.
Oh ok, if that's the proper way to do it that works. Figured we wanted to get the Gl.TexImage2d call working correctly.
Fixed in monodroid-samples/master 522849f