User avatar
Gavinmc42
Posts: 4191
Joined: Wed Aug 28, 2013 3:31 am

Re: Pi3D transparent background on Pi4

Sat Nov 23, 2019 1:59 am

Broke another Gentoo64 uSD.

Anyway I have Raspberry Rain working on a Raspbian Buster Pi4.
But it is not transparent, was it supposed to be?

Have not test everything but most Pi3D demos seem to work.

Edit My Python shader examples run fine too on Buster.
Which makes sense, the GPU does not care if it is talking to arm32 or arm64.
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

User avatar
paddyg
Posts: 2460
Joined: Sat Jan 28, 2012 11:57 am
Location: UK

Re: Pi3D transparent background on Pi4

Sat Nov 23, 2019 8:36 am

Getting the transparent background looks tricky http://forums.libsdl.org/viewtopic.php?p=44939 is only explicit ref I can find.

PS I've tried testing for availability of pysdl2 on init of pi3d and defaulting to that unless explicitly set use_sdl2=False That might be a nicer approach but will see how it works on all the different platforms.
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d

User avatar
Gavinmc42
Posts: 4191
Joined: Wed Aug 28, 2013 3:31 am

Re: Pi3D transparent background on Pi4

Sat Nov 23, 2019 8:52 am

glClearColor( 0.7, 0.7, 0.7, 0.7) ; // light gray bg
Interesting, I have the same line in my cloud shader code trying to do a blue sky.
I only get black. Tested on mesa 19.1.0 and 19.2.3
It might not be SDL issue, probably OpenGL?

Perhaps a mesa issue?
New versions are out, time to update.
Gentoo might get 19.3-rc?
It is going to 19.3 soon?

Rebuilding some new OS's now, my Buster is old and broken.
Looking for shader code that does not need x11 or SDL etc.
OpenGL or SDL2? Will look in the mesa demo code first.
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

User avatar
Gavinmc42
Posts: 4191
Joined: Wed Aug 28, 2013 3:31 am

Re: Pi3D transparent background on Pi4

Sun Nov 24, 2019 12:58 am

Made another Buster OS, has the new DVFS.
So used to 55C temps 43C is making me think something is wrong.
Just in time for summer downunder.

Trying to get transparency to work while my Gentoo64 is genuping(update/upgrade).
`My OpenGl testing has been on Gentoo64, so I am installing most of those tools on Buster.

My Python shaders from Blakkis use pygame.
https://github.com/Blakkis/GLSL_Python

These don't seem to do anything

Code: Select all

glClearColor(0.0, 0.0, 0.0, 1.0)
glClear(GL_COLOR_BUFFER_BIT)
The NOFRAME option works

Code: Select all

 pygame.display.set_mode(self.resolution, DOUBLEBUF | OPENGL | NOFRAME)
Does glClearColor(0.0, 0.0, 1.0, 0.0) work on PC's?

Ouch, Rustc and Pi3drust install issues, broken my new Buster?
"Aw, snap" yikes, lots of OS breaking this week.
To be continued...
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

User avatar
paddyg
Posts: 2460
Joined: Sat Jan 28, 2012 11:57 am
Location: UK

Re: Pi3D transparent background on Pi4

Sun Nov 24, 2019 8:14 am

Gavinmc42 wrote:
Sun Nov 24, 2019 12:58 am
Does glClearColor(0.0, 0.0, 1.0, 0.0) work on PC's?
Yes, but only using the mechanism discussed at the start of this thread (glx and X extension) I've not got it working with the sdl2 branch or on Windows (can't get the sdl2 window to work at all on Windows yet)
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d

User avatar
Gavinmc42
Posts: 4191
Joined: Wed Aug 28, 2013 3:31 am

Re: Pi3D transparent background on Pi4

Sun Nov 24, 2019 8:47 am

Have not looked at how to use extensions yet.
Got my free Pascal OpenGL up and running on Buster now.
GL, GLX, GLU, GLEXT, GLUT are options for that.

Google time-
It looks like I need to use glext for Pascal to access the extensions.
https://wiki.lazarus.freepascal.org/OpenGL

There is also a web page on Free Pascal with SDL2, but I will skip that for the moment.

I guess these are the extensions? Probably accessible to that python example code too.

Code: Select all

OpenGL ES profile version string: OpenGL ES 3.0 Mesa 19.2.0-rc1
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.00
OpenGL ES profile extensions:
    GL_APPLE_texture_max_level, GL_EXT_base_instance, GL_EXT_blend_minmax, 
    GL_EXT_color_buffer_float, GL_EXT_compressed_ETC1_RGB8_sub_texture, 
    GL_EXT_discard_framebuffer, GL_EXT_draw_buffers, 
    GL_EXT_draw_elements_base_vertex, GL_EXT_float_blend, GL_EXT_frag_depth, 
    GL_EXT_map_buffer_range, GL_EXT_multi_draw_arrays, 
    GL_EXT_occlusion_query_boolean, GL_EXT_read_format_bgra, 
    GL_EXT_sRGB_write_control, GL_EXT_separate_shader_objects, 
    GL_EXT_shader_integer_mix, GL_EXT_texture_border_clamp, 
    GL_EXT_texture_format_BGRA8888, GL_EXT_texture_query_lod, 
    GL_EXT_texture_rg, GL_EXT_texture_sRGB_decode, 
    GL_EXT_texture_type_2_10_10_10_REV, GL_EXT_unpack_subimage, 
    GL_KHR_context_flush_control, GL_KHR_debug, GL_KHR_no_error, 
    GL_KHR_parallel_shader_compile, GL_KHR_texture_compression_astc_ldr, 
    GL_KHR_texture_compression_astc_sliced_3d, 
    GL_MESA_shader_integer_functions, GL_NV_draw_buffers, 
    GL_NV_fbo_color_attachments, GL_NV_read_buffer, GL_NV_read_depth, 
    GL_NV_read_depth_stencil, GL_NV_read_stencil, GL_OES_EGL_image, 
    GL_OES_EGL_image_external, GL_OES_EGL_image_external_essl3, 
    GL_OES_EGL_sync, GL_OES_compressed_ETC1_RGB8_texture, GL_OES_depth24, 
    GL_OES_depth_texture, GL_OES_depth_texture_cube_map, 
    GL_OES_draw_elements_base_vertex, GL_OES_element_index_uint, 
    GL_OES_fbo_render_mipmap, GL_OES_get_program_binary, GL_OES_mapbuffer, 
    GL_OES_packed_depth_stencil, GL_OES_required_internalformat, 
    GL_OES_rgb8_rgba8, GL_OES_standard_derivatives, GL_OES_stencil8, 
    GL_OES_surfaceless_context, GL_OES_texture_3D, 
    GL_OES_texture_border_clamp, GL_OES_texture_float, 
    GL_OES_texture_half_float, GL_OES_texture_half_float_linear, 
    GL_OES_texture_npot, GL_OES_texture_stencil8, GL_OES_vertex_array_object, 
    GL_OES_vertex_half_float
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

User avatar
paddyg
Posts: 2460
Joined: Sat Jan 28, 2012 11:57 am
Location: UK

Re: Pi3D transparent background on Pi4

Sun Nov 24, 2019 12:37 pm

The transparent background uses libGLX and an X extension libXrender. Which seems to be already available on raspbian and ubuntu but may be harder to find elsewhere.
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d

User avatar
Gavinmc42
Posts: 4191
Joined: Wed Aug 28, 2013 3:31 am

Re: Pi3D transparent background on Pi4

Tue Nov 26, 2019 8:18 am

Tried the raymarch shader code on Windows, same result, black background.
Pygame does not do transparency?
It could just be a simple mode setting?

Now have a PC to test the Pi code against.
Wish I knew what I was doing :lol:
Blakkis's minimal.py GLSL does 2000fps, that's a bit faster than the Pi4.
Tested OpenGL 3.3 and 4.6.
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

User avatar
Gavinmc42
Posts: 4191
Joined: Wed Aug 28, 2013 3:31 am

Re: Pi3D transparent background on Pi4

Thu Nov 28, 2019 11:10 am

Finally got my Gentoo64 OS's up and running with the new 1.5.2 release.
While playing with the python shader code I just grabbed a window to move it and noticed it went a bit transparent.

What is happening with the window compositing that does that?
Is it usable in the OpenGL shader code.
Attachments
Window.png
Window.png (231.53 KiB) Viewed 569 times
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

User avatar
paddyg
Posts: 2460
Joined: Sat Jan 28, 2012 11:57 am
Location: UK

Re: Pi3D transparent background on Pi4

Thu Nov 28, 2019 12:11 pm

Yes (and no, it's X11 window related rather than OpenGL). With the compositor running (it's turned off by default in raspbian buster but you can start it with ``xcompmgr``, already on in ubuntu or gentoo64) you can adjust the opacity of the X11 window. See the discussion on the first page of this thread.

In SDL2 it's very easy. The rust code I added to do it is a one line function. The xlib code is a bit messier with xatoms etc. It also probably depends on a later X extension being available, but that seems to be the case where I've tested it.
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d

User avatar
Gavinmc42
Posts: 4191
Joined: Wed Aug 28, 2013 3:31 am

Re: Pi3D transparent background on Pi4

Fri Nov 29, 2019 1:06 am

With the compositor running (it's turned off by default in raspbian buster but you can start it with ``xcompmgr``, already on in ubuntu or gentoo64)
I never even noticed it was on in Gentoo64..
I can remember when compositors first came out on Linux, slowed things down, I used to turn them off.

Too many layers, time to go headless, without x11?
Is pygame using SDL?
Need to get RustPi3D working on the new 1.5.2 Gentoo's
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

JeDy111
Posts: 26
Joined: Tue Sep 03, 2019 8:35 pm

Re: Pi3D transparent background on Pi4

Fri Dec 20, 2019 11:13 am

Hello Paddyg,

I have made intensive tests on the 'use_glx=True' option.
It seems that it discards the 'layer' option on the Pi4.

The code below specifies layer 2 for the omxplayer video and layer 10 for the Pi3D display, thus the Pi3D display should be above the video.
It is working fine on a Pi3. However on a Pi4 the Pi3D display is below the video.

Note for the test: you might need to adapt the omxplayer --win values to your screen width (800 = half the screen width in my case).

Code: Select all

#!/usr/bin/python
import subprocess, pi3d

subprocess.Popen('xcompmgr')

subprocess.Popen('omxplayer -o hdmi --layer 2 --win 200,200,800,800 /opt/vc/src/hello_pi/hello_video/test.h264'.split(' '))

DISPLAY = pi3d.Display.create(background=(0,0,0,0), use_glx=True, layer=10)
TEXTURE = pi3d.Texture('/usr/share/raspberrypi-artwork/raspberry-pi-logo-small.png')
SHADER = pi3d.Shader('uv_flat')
RaspberrySprite = pi3d.ImageSprite(texture=TEXTURE, shader=SHADER, w=1, h=1, x=0, y=0, z=3)
DISPLAY.add_sprites(RaspberrySprite)

KEYBOARD = pi3d.Keyboard()
while DISPLAY.loop_running():
  k = KEYBOARD.read()
  if k == 27:
    KEYBOARD.close()
    DISPLAY.stop()
    break

User avatar
paddyg
Posts: 2460
Joined: Sat Jan 28, 2012 11:57 am
Location: UK

Re: Pi3D transparent background on Pi4

Fri Dec 20, 2019 11:47 am

Hi, yes the 'layer' options is specifically the dispmanx layer so I wouldn't expect it to have any effect unless using the bcm drivers (aka legacy) on the RPis prior to v4. When you test your code on the RPi3 are your using fake KMS? As we discussed back on page 1/2 of this thread it would be nice to keep using dispmanx on the RPi but there doesn't seem to be a clear way of attaching the OpenGL context.

In this recent thread https://www.raspberrypi.org/forums/view ... d#p1578973 there was some discussion about using pi3d on top of omxplayer. It probably would have been possible in the past as there was an option to use omxplayer in a X11 window, but that now isn't possible. In that other thread @pescew ended up using ffplay.
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d

JeDy111
Posts: 26
Joined: Tue Sep 03, 2019 8:35 pm

Re: Pi3D transparent background on Pi4

Fri Dec 20, 2019 5:03 pm

Yes, I use Fake KMS when I run the test on the Pi3, dtoverlay=vc4-fkms-v3d
I agree keeping dispmanx would make things easier.

Thanks for your reply and the link to the other thread. I will probably follow the ffplay path.

Return to “Graphics programming”