The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
Android rendering messed up (all red) on a Samsung S3 / Mali
m3xican


Joined: 07 Oct 2010
Posts: 21
Location: London, UK
Hi everyone,

I've just started a closed beta for my game based on SDL 2 (2.0.3) and one of the testers reported a very weird behaviour when running the game on a Samsung S3 (Android 4.3).

Basically every colour is turned into red as showed in the pics you can find here:
http://imgur.com/a/dvris

The most weird thing is that if he takes a screenshot the images come up with the right colours.

I did some digging on Google and found other games suffer the same bug, for example:
http://openxcom.org/forum/index.php/topic,1864.msg16802.html#msg16802


That guy was experiencing this problem on a Galaxy Note 10.1 which has a Mali-400MP4 as GPU, the same used by the S3. My game works fine on a Sony Xperia U with a Mali-400 instead. So it seems to be very specific to that particular GPU.


Any idea how to fix this?


Thanks

--
Davide Coppola

email:
website: http://www.davidecoppola.com



blog: http://blog.davidecoppola.com


[/url] [url=http://www.linkedin.com/in/davidecoppola] [url=http://www.twitter.com/vivaladav][/url]
Android rendering messed up (all red) on a Samsung S3 / Mali
gabomdq


Joined: 28 Jul 2011
Posts: 495
Location: Argentina
This is a known issue, take a look at Bugzilla for a few workarounds.

2015-09-04 12:42 GMT-03:00 Davide Coppola:
Quote:
Hi everyone,

I've just started a closed beta for my game based on SDL 2 (2.0.3) and one of the testers reported a very weird behaviour when running the game on a Samsung S3 (Android 4.3).

Basically every colour is turned into red as showed in the pics you can find here:
http://imgur.com/a/dvris

The most weird thing is that if he takes a screenshot the images come up with the right colours.

I did some digging on Google and found other games suffer the same bug, for example:
http://openxcom.org/forum/index.php/topic,1864.msg16802.html#msg16802


That guy was experiencing this problem on a Galaxy Note 10.1 which has a Mali-400MP4 as GPU, the same used by the S3. My game works fine on a Sony Xperia U with a Mali-400 instead. So it seems to be very specific to that particular GPU.


Any idea how to fix this?


Thanks

--
Davide Coppola

email:
website: http://www.davidecoppola.com



blog: http://blog.davidecoppola.com


[/url] [url=http://www.linkedin.com/in/davidecoppola] [/url]






_______________________________________________
SDL mailing list

[url=http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org]http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org






--
Gabriel.
Android rendering messed up (all red) on a Samsung S3 / Mali
m3xican


Joined: 07 Oct 2010
Posts: 21
Location: London, UK
Thank you Gabriel.

For future reference the related bug report is: https://bugzilla.libsdl.org/show_bug.cgi?id=2291


I haven't tried any workaround yet, but I will post my results here and on Bugzilla.


Cheers


--
Davide Coppola

email:
website: http://www.davidecoppola.com



blog: http://blog.davidecoppola.com


[/url] [url=http://www.linkedin.com/in/davidecoppola] [url=http://www.twitter.com/vivaladav][/url]
Android rendering messed up (all red) on a Samsung S3 / Mali
Owen Alanzo Hogarth
Guest

I had this issue on a samsung device. I was able to solve it by adding this code before my window create call.

    SDL_GetDisplayMode(0, 0, &sdpm);
    i_width = sdpm.w;
    i_height = sdpm.h;


    SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
    SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 6);
    SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);


    window = SDL_CreateWindow(title, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, i_width, i_height, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN);



You can also try 8, 8, 8 if 5,6,5 doesn't work for you.


On Sat, Sep 5, 2015 at 2:59 AM, Davide Coppola wrote:
Android rendering messed up (all red) on a Samsung S3 / Mali
Alex Szpakowski
Guest

I wonder why SDL requests a R3 G3 B2 (8-bit) system GL framebuffer by default in the first place. I’d expect SDL to default to at least 5,6,5 (16-bit) – sane systems will probably just give back 16 or 24/32 bit when 8 bit is requested, in any case.

Ryan / Sam: would you object to changing the default RGB bit sizes that SDL requests for the system GL framebuffer from 3,3,2 to 5,6,5?

Quote:
On Sep 5, 2015, at 1:52 PM, Owen Alanzo Hogarth wrote:

I had this issue on a samsung device. I was able to solve it by adding this code before my window create call.

SDL_GetDisplayMode(0, 0, &sdpm);
i_width = sdpm.w;
i_height = sdpm.h;

SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 6);
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);

window = SDL_CreateWindow(title, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, i_width, i_height, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN);

You can also try 8, 8, 8 if 5,6,5 doesn't work for you.

_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Android rendering messed up (all red) on a Samsung S3 / Mali
Raymond Jennings
Guest

I always thought that the default size of the rgb bitfields depended on system capabilities.



On Sat, Sep 5, 2015 at 12:27 PM, Alex Szpakowski wrote:
Quote:
I wonder why SDL requests a R3 G3 B2 (8-bit) system GL framebuffer by default in the first place. I’d expect SDL to default to at least 5,6,5 (16-bit) – sane systems will probably just give back 16 or 24/32 bit when 8 bit is requested, in any case.

Ryan / Sam: would you object to changing the default RGB bit sizes that SDL requests for the system GL framebuffer from 3,3,2 to 5,6,5?

Quote:
On Sep 5, 2015, at 1:52 PM, Owen Alanzo Hogarth wrote:

I had this issue on a samsung device. I was able to solve it by adding this code before my window create call.

     SDL_GetDisplayMode(0, 0, &sdpm);
     i_width = sdpm.w;
     i_height = sdpm.h;

     SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
     SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 6);
     SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);

     window = SDL_CreateWindow(title, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, i_width, i_height, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN);

You can also try 8, 8, 8 if 5,6,5 doesn't work for you.

_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Android rendering messed up (all red) on a Samsung S3 / Mali
Alex Szpakowski
Guest

SDL requests an R3G3B2-sized color framebuffer by default: https://hg.libsdl.org/SDL/file/6d6a972746b3/src/video/SDL_video.c#l2669

But systems are allowed to actually use larger sizes than what was requested (and they definitely do in practice.) The 3-3-2 request just seems to screw up colors on some Android devices.
Quote:
On Sep 5, 2015, at 4:31 PM, Raymond Jennings wrote:
I always thought that the default size of the rgb bitfields depended on system capabilities.

Android rendering messed up (all red) on a Samsung S3 / Mali
m3xican


Joined: 07 Oct 2010
Posts: 21
Location: London, UK
I confirm that calling SDL_GL_SetAttribute for the 3 colour channels fixed the problem.

This was happening on a Samsung S3 running Android 4.3, but not on one running Android 4.4.


As Alex suggested, I agree it would be sensible to set the default values to 565.


On 5 September 2015 at 20:38, Alex Szpakowski wrote:
Quote:
SDL requests an R3G3B2-sized color framebuffer by default: https://hg.libsdl.org/SDL/file/6d6a972746b3/src/video/SDL_video.c#l2669


But systems are allowed to actually use larger sizes than what was requested (and they definitely do in practice.) The 3-3-2 request just seems to screw up colors on some Android devices.

Quote:
On Sep 5, 2015, at 4:31 PM, Raymond Jennings wrote:

I always thought that the default size of the rgb bitfields depended on system capabilities.





_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org





--
Davide Coppola

email:
website: http://www.davidecoppola.com



blog: http://blog.davidecoppola.com


[/url] [url=http://www.linkedin.com/in/davidecoppola] [url=http://www.twitter.com/vivaladav][/url]
Android rendering messed up (all red) on a Samsung S3 / Mali
Raymond Jennings
Guest

I'd rather set the default values based on underlying hardware capabilities.

On my system for example the preferred format is 8888 Smile


On Mon, Sep 7, 2015 at 9:44 AM, Davide Coppola wrote:
Quote:
I confirm that calling SDL_GL_SetAttribute for the 3 colour channels fixed the problem.

This was happening on a Samsung S3 running Android 4.3, but not on one running Android 4.4.


As Alex suggested, I agree it would be sensible to set the default values to 565.


On 5 September 2015 at 20:38, Alex Szpakowski wrote:


Quote:
SDL requests an R3G3B2-sized color framebuffer by default: https://hg.libsdl.org/SDL/file/6d6a972746b3/src/video/SDL_video.c#l2669


But systems are allowed to actually use larger sizes than what was requested (and they definitely do in practice.) The 3-3-2 request just seems to screw up colors on some Android devices.

Quote:
On Sep 5, 2015, at 4:31 PM, Raymond Jennings wrote:

I always thought that the default size of the rgb bitfields depended on system capabilities.







_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org





--
Davide Coppola

email:
website: http://www.davidecoppola.com



blog: http://blog.davidecoppola.com


[/url] [url=http://www.linkedin.com/in/davidecoppola] [/url]





_______________________________________________
SDL mailing list

[url=http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org]http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


Android rendering messed up (all red) on a Samsung S3 / Mali
m3xican


Joined: 07 Oct 2010
Posts: 21
Location: London, UK
yes, that would be definitely better!

I didn't look at the code though and I was assuming the default values were used when the proper capabilities are not recognized or properly handled by SDL (as it seems to happen for this, still unfixed, bug).


On 7 September 2015 at 17:47, Raymond Jennings wrote:
Quote:
I'd rather set the default values based on underlying hardware capabilities.

On my system for example the preferred format is 8888 Smile


On Mon, Sep 7, 2015 at 9:44 AM, Davide Coppola wrote:
Quote:
I confirm that calling SDL_GL_SetAttribute for the 3 colour channels fixed the problem.

This was happening on a Samsung S3 running Android 4.3, but not on one running Android 4.4.


As Alex suggested, I agree it would be sensible to set the default values to 565.


On 5 September 2015 at 20:38, Alex Szpakowski wrote:


Quote:
SDL requests an R3G3B2-sized color framebuffer by default: https://hg.libsdl.org/SDL/file/6d6a972746b3/src/video/SDL_video.c#l2669


But systems are allowed to actually use larger sizes than what was requested (and they definitely do in practice.) The 3-3-2 request just seems to screw up colors on some Android devices.

Quote:
On Sep 5, 2015, at 4:31 PM, Raymond Jennings wrote:

I always thought that the default size of the rgb bitfields depended on system capabilities.







_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org





--
Davide Coppola

email:
website: http://www.davidecoppola.com



blog: http://blog.davidecoppola.com


[/url] [url=http://www.linkedin.com/in/davidecoppola] [/url]





_______________________________________________
SDL mailing list

[url=http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org]http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org








_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org





--
Davide Coppola

email:
website: http://www.davidecoppola.com



blog: http://blog.davidecoppola.com


[/url] [url=http://www.linkedin.com/in/davidecoppola] [url=http://www.twitter.com/vivaladav][/url]