Raspberry Pi and Open GL ES 2 color depth

Hello!

On Raspberry Pi 2 opengl-es2 driver renders my 32-bit textures in 16 bit, which creates ugly color stripes.
I found that Open GL ES2 doesn’t support 32 bit color by default.

Later I found the following topic:


people there say that using GL_IMG_texture_format_BGRA8888 extension allows to render in 32 bit color.

The following document shows that Raspberry Pi supports GL_EXT_texture_format_BGRA8888, and gl2ext.h declares GL_BGRA_EXT.
http://elinux.org/Raspberry_Pi_VideoCore_APIs#OpenGL_ES

However I couldn’t find anything related to that in SDL2 opengl es2 renderer code.
Are there any plans to enable this extension in SDL to support 32 bit color on Raspberry Pi?

Also, have anybody tried this extension on raspberry pi, does it really work as expected and gives real 32-bit output?

How did you run your SDL apps on Pi ? Via rasbian ??

I’m running in Raspbian on a Raspberry Pi 2. (I haven’t tried a 1 or
0.) I originally started in Wheezy, but upgraded to Jessie a month
ago. I did have to bump up the GPU memory. I think I’m at 128M now.
Jessie seems to need more than Wheezy.

I actually just made a video which included the Pi:

I’m using a pretty stock SDL program, using the 2D renderer. It’s
derived from the happy face example or test. I also got SDL_gpu
working on the Pi.

In either case, I don’t think I called any color depth APIs so
whatever the defaults are I guess.On 2/19/16, mr_tawan <mr_tawan at hotmail.com> wrote:

How did you run your SDL apps on Pi ? Via rasbian ??

https://www.raspberrypi.org/forums/viewtopic.php?t=29412&p=258474

Making changes to /boot/config.txt might help. I haven’t tried though, maybe later today I will.

Ok, so basically you have a SDL_Renderer and one or more textures. You render them using SDL_RenderCopy(), and it results in banding, right ?

Have you tried running the same code on the PC ? What does the output look like ?

Further research showed the following:

Raspberry pi (2) hardware definitely supports 32-bit color, and it’s easy to see with your own eyes:

  1. fbi shows 32-bit images properly.
    http://raspberrypi.stackexchange.com/questions/8922/how-do-i-display-images-without-starting-x11

  2. The following post on raspberry pi forums provides the source code of opengles-based image viewer, that also renders 32-bit color from jpg just fine
    https://www.raspberrypi.org/forums/viewtopic.php?f=33&t=57721

Apparently there are two possibilities - either I’m using SDL2 in a really wrong way, or SDL2 just doesn’t support 32-bit color for OpenGL ES/2 on Raspberry Pi.
My guess is the latter.
It’s pretty sad, because I really like the API model of SDL, also it’s multi-platform, covers pretty much all I need, etc.

I hope this situation will soon improve.
I’ll most likely still use SDL2 to handle input and possibly image load / TTF, but this 16 bit color limitation is too bad to keep using it as the graphics library.
:frowning:

mr_tawan wrote:

https://www.raspberrypi.org/forums/viewtopic.php?t=29412&p=258474

Making changes to /boot/config.txt might help. I haven’t tried though, maybe later today I will.

Yeah, I tried framebuffer_depth=32, with and without framebuffer_ignore_alpha set.
It makes no difference.

Eric Wing wrote:> On 2/19/16, mr_tawan <mr_tawan at hotmail.com> wrote:

I’m using a pretty stock SDL program, using the 2D renderer. It’s
derived from the happy face example or test.

Let me state the problem again:

When I create a 32bit (RGBA8888) texture SDL renders it in a 16-bit format, resulting in ugly/low color block artifacts.

mr_tawan wrote:

Ok, so basically you have a SDL_Renderer and one or more textures. You render them using SDL_RenderCopy(), and it results in banding, right ?

Have you tried running the same code on the PC ? What does the output look like ?

Here’s a simple program and image I tried on both raspberry pi and my Ubuntu box (meerkat).
Ubuntu shows as expected 32 bit color, while running it on my Raspberry pi 2 results in color degradation.

I tried out your program and reproduced your behavior. I think I also
know the solution.

Use SDL_GL_SetAttribute() before your create your window (or maybe renderer).

SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);

The Pi backend is OpenGL ES. I think the default for iOS and probably
Android were 565. So I’m not that surprised Pi would be the same.

-EricOn 2/19/16, bamirov wrote:

mr_tawan wrote:

Ok, so basically you have a SDL_Renderer and one or more textures. You
render them using SDL_RenderCopy(), and it results in banding, right ?

Have you tried running the same code on the PC ? What does the output look
like ?

Here’s a simple program and image I tried on both raspberry pi and my Ubuntu
box (meerkat).
Ubuntu shows as expected 32 bit color, while running it on my Raspberry pi 2
results in color degradation.

https://github.com/codekrolik/sdl2_texture_test