Bug 9229 - TexturedCube-1.0 does not render correctly
Summary: TexturedCube-1.0 does not render correctly
Status: VERIFIED FIXED
Alias: None
Product: Android
Classification: Xamarin
Component: Samples ()
Version: 4.8.x
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: dean.ellis
URL:
Depends on:
Blocks:
 
Reported: 2013-01-03 12:35 UTC by dean.ellis
Modified: 2014-03-27 08:29 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and 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 Links.

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.

Related Links:
Status:
VERIFIED FIXED

Description dean.ellis 2013-01-03 12:35:56 UTC
The TexturedCube-1.0 sample does not render the cube correctly. 

This is how it is currently rendered http://docs2.xamarin.com/Android/Samples/Details/TexturedCube-1.0
This is how it should be rendered http://twitpic.com/bs143o

The pixel data from the texture looks like it is in the wrong format.
Comment 1 dean.ellis 2013-01-07 08:30:41 UTC
replacing the following code in GetTextureFromBitmapResource

return pixels;

with 

return pixels.Select(x => (((x >> 24) & 0xff) << 24 | (x & 0xff) << 16 | ((x>> 8) & 0xff) << 8| ((x>> 16) & 0xff))).ToArray();

will correct the pixel data into the format that GLES is expecting.
Comment 2 dean.ellis 2013-01-14 08:34:06 UTC
A more efficient way would be 

for(int i=0; i < pixels.Length; i++) {
pixels[i] = (((pixels[i] >> 24) & 0xff) << 24 | (pixels[i] & 0xff) << 16 | ((pixels[i] >> 8) & 0xff) << 8| ((pixels[i] >> 16) & 0xff));

As it would not result in an array copy.
Comment 3 Miguel de Icaza [MSFT] 2013-05-23 15:48:31 UTC
Dean, would you mind landing the suggested change on the sample?
Comment 4 dean.ellis 2013-05-23 17:29:04 UTC
This sample just needs the same fix as the other TextureCube sample see https://bugzilla.xamarin.com/show_bug.cgi?id=10668. Its not using the android util method

Android.Opengl.GLUtils.TexImage2D

 to create the texture. This method sorts out the RGBA/BGRA stuff
automatically. The sample just needs updating.

I'll fix this up
Comment 5 dean.ellis 2013-05-24 04:51:08 UTC
PJ Applied the change when fixing the 10668 bug
Comment 6 Tajinder Singh 2014-03-27 08:29:16 UTC
I have checked this issue with the latest master builds:
XS 4.2.4(build 266)
X.Android 4.13.00004

Now Textured cube sample is rendering properly.Hence closing this issue.