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

Re: Pi3D transparent background on Pi4

Sat Nov 09, 2019 8:25 am

Gavin, that error is a bit hard to pin down as it just arises at the end of the display surface creation process if it's failed! On the pi4 pi3d checks that fakeKMS has been set by looking for vc4 in /proc/modules and then uses the x11 libraries to create a GL compatible window. So those are the main things that need to be set up. ie X server started and Kms selected in raspi-config (or equivalent, not sure what happens on gentoo)

I'm really grateful that you're testing pi3d on gentoo64 (especially after the David Attenborough program) so I'm happy to help you get it working. Maybe I should set up an SD card myself! By the way, I see you're running an installed version of pi3d (which is sensible to get it working) but at the moment these X transparency changes are just in the develop branch so you would need to clone the GitHub repo (the demos all have a snippet of code at the start to pick up pi3d from local repo if present)
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d

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

Re: Pi3D transparent background on Pi4

Sat Nov 09, 2019 10:02 am

Found this in proc/modules, not sure if that helps.

Code: Select all

vc4 188416 20 - Live 0x0000000000000000
Always fun trying to get stuff working in a different OS than Buster ;)
Gentoo64 only does OpenGL on Pi4's.

This post made me notice Python can do shader code and since Tim's shadertoy woke me up to shaders I have been doing a crash course.
https://www.raspberrypi.org/forums/view ... 2&t=256132
Did not notice shaders in Pi3D before.

Toni Vuoristo's GLSL_Python is simple enough for me to understand, unlike Pi3D which in much bigger.
I keep getting surprised how much mainstream code runs on Pi's now.
If only it did OpenGL 3.3 :lol:
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

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

Re: Pi3D transparent background on Pi4

Sat Nov 09, 2019 12:29 pm

Hi, it looks like it is using fake KMS and, presumably the desktop (X11) is running as in your screen cap. Could be all sorts of things then, I would work my way through pi3d/util/DisplayOpenGL.py sticking print(x) statements until I found where it went wrong.. looks like I might have to set up a gentoo card - did you use the sakaki- image? (Downloading it now anyway)

Well GLSL_Python is simple enough but it uses pyopengl and pygame, both of which are orders of magnitude bigger then pi3d! If you did the same kind of thing in pi3d it wouldn't have any of those gl function calls. i.e.

Code: Select all

import pi3d
import time

display = pi3d.Display.create(w=800, h=600, frames_per_second=20, background=(0.0, 0.0, 0.0, 1.0))
shader = pi3d.Shader(
    vshader_source='''
#version 300 es
precision mediump float;

layout(location = 0) in vec3 vertex; /// called vertex in pi3d

void main()
{
    gl_Position = vec4(vertex, 1.0);
}''',
    fshader_source='''
#version 300 es
precision mediump float;
#define fragCoord gl_FragCoord.xy
//uniform vec2  iMouse;
//uniform float iTime; /// unif[19].z
//uniform vec2  iResolution; /// unif[19].xy
uniform vec3 unif[20];
out vec4 fragColor;
void main()
{
    vec2 iResolution = unif[19].xy;
    float iTime = unif[19][2];
    // Set origin to center of the screen
    vec2 uv = fragCoord/iResolution.xy * 2.0 - 1.0;
    // Fix aspect ratio
    uv.x *= iResolution.x / iResolution.y;
    // Time varying pixel color (Copied from ShaderToy default scene)
    vec3 color = 0.5 + 0.5 * cos(iTime + uv.xyx + vec3(0.0, 2.0, 4.0));
    fragColor = vec4(color, 1.0);
    //fragColor = vec4(1.0, 1.0, 0.5, 1.0);
}
    '''
)
cam = pi3d.Camera(is_3d=False)
plane = pi3d.Plane(camera=cam, w=display.width, h=display.height, z=1.0)
plane.set_shader(shader)
plane.unif[57:59] = [display.width, display.height] ############ unif is an array of floats used by the pi3d shaders
mykeys = pi3d.Keyboard()
mouse = pi3d.Mouse()
mouse.start()
while display.loop_running():
  mx, my = mouse.position()
  plane.unif[59] = ((2.0 * mx + my) * 0.01 + time.time()) % 1000.0
  plane.draw()
  k = mykeys.read()
  if k == 27:
    mykeys.close()
    display.destroy()
    break
Actually in this last series of mods on the develop branch I've made the Shader class check what GL or GLES is being used and it tweaks the code accordingly. It doesn't do that if you pass the source in directly like this. I will ponder if that's good or bad..

PS gentoo finished downloading but I won't mess around further until tonight or tomorrow.
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d

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

Re: Pi3D transparent background on Pi4

Sun Nov 10, 2019 12:41 am

Cool more shader code, thanks :D
Found some Python GLSL Shader YT tuts last night.
But pretty much the same error, EGL_NO_SURFACE

Will try debugging via pi3d/util/DisplayOpenGL.py
VC4 Pi's and VC6 Pi need some GL/ES debug tools, I"m thinking I might need to learn Piglit.
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

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

Re: Pi3D transparent background on Pi4

Sun Nov 10, 2019 1:05 am

Had a look at this and for some reason the egl functions don't work properly around here Almost certainly the wrong kind of pointer annoying as the same code works ok other places 32 or 64 bit. The egl.h is rather opaque and the pyopengl code also pretty hard to figure - but I suppose I will have to do that.
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d

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

Re: Pi3D transparent background on Pi4

Sun Nov 10, 2019 3:26 am

I have the Mesa demos compiled
eglinfo reports stuff like this

Code: Select all

X11 platform:
EGL API version: 1.4
EGL vendor string: Mesa Project
EGL version string: 1.4
EGL client APIs: OpenGL OpenGL_ES 
last lines

Code: Select all

Device platform:
eglinfo: eglInitialize failed
but xeglgears works, so do most of the others, eglkms fails as I would expect under fkms

Code: Select all

EGL_VERSION = 1.4
drmModeGetResources failed
Have not had much trouble with OpenGL 2.1 in other languages in Gentoo64.
Lazarus/FPC and BBC Basic don't have 64bit Pi versions yet.


Looking at DisplayOpenGL.py could it be a Python issue, perhaps integer size?
Using 3.6 at the moment , but it would be compiled for aarch64.
Been so long since I used Python I forgot how print works :oops:
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

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

Re: Pi3D transparent background on Pi4

Sun Nov 10, 2019 4:03 am

Figured it out.
This pops open a pygame window.
Interesting it says my screen width is 2560, which in my dual system is both 1280 screen.
Now to swap pi3d for pygame

Code: Select all

#!/usr/bin/env python

import ctypes
import platform
import time
import sys
import pygame


def main(args):
	
    print('hello world')
	
    pygame.init()
    d = pygame.display.set_mode((0, 0),pygame.DOUBLEBUF | pygame.RESIZABLE | pygame.OPENGL)
    info = pygame.display.Info()
    
    print(info)
    time.sleep(2)
    return 0

if __name__ == '__main__':
    import sys
    sys.exit(main(sys.argv))
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

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

Re: Pi3D transparent background on Pi4

Sun Nov 10, 2019 4:17 am

Ok, just guessing now but it look like Pi4 is x11 so use this"xlib.XOpenDisplay"
need to add

Code: Select all

elif PLATFORM == PLATFORM_PI4
But pygame worked too?

bcm.bcm_host _init gave error
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

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

Re: Pi3D transparent background on Pi4

Sun Nov 10, 2019 8:31 am

Yes integer size is a likely culprit. There are a few places where a python int is fed into a c function. Also it uses ctypes.c_int in quite a few places which probably should be c_int32 or other way round! But pi3d works fine on 64b Ubuntu laptop.

libbcm isn't available in RPi4 so those calls won't do anything. So RASPBERRY_PI4 isn't needed it's just another x11 machine. On rasbian anyway. But people trying to get it working on Darwin have reported similar so there's obvious something not tried down properly. Maybe I should just switch to having pyOpenGL as a dependency!
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d

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

Re: Pi3D transparent background on Pi4

Sun Nov 10, 2019 12:34 pm

PyOpenGL and Pyglet work on Gentoo64.

I got ambitious and compiled Panda3d, which made a deb install somewhere, which is useless on Gentoo?
Only took 3+hours to compile :o
Needed something with a simple game engine.
Which Panda is not but the demos look cool

It would be nice to get P3D working, but I now have a simple way to test GLSL shaders with Python.
Most till now have been WebGL, Live or compiled GLSL shaders.

GLSL and OpenGL code is pretty must the same no matter what language is used.
Libs/wrappers around those just get in the way of learning GLSL/OpenGL.
ModernGL is a wrapper, just more abstractions.

But the last few days have got me up to speed with Python and OpenGL/GLSL.
It is much better now, the last time I python it for a project was 2012 with Pygame.
Or maybe the Pi's are better than that old Pi Model A :lol:

But a few water and cloud shaders I made crash after some time.
How to test for Python or GPU memory leaks?

Good enough to prototype and test code anyway.
Time to install Thonny, been using Geany till now.
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

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

Re: Pi3D transparent background on Pi4

Mon Nov 11, 2019 3:07 pm

Gavin, There's a script in pi3d/experiments/ that I've used for finding leaks in python in the past. GPU is much harder as the python GC won't tidy it up - you just have to keep track and destroy things.

I've eliminated a few reasons why pi3d doesn't render on gentoo64 but not managed to get it to work. There aren't any egl configs that match the one requested. Namely none available have the specified SURFACE_TYPE. It asks for EGL_WINDOW_BIT mask which is a config that can create window surfaces. This is what it says is available, I've tried them all and they all give a blank window. The GL stuff seems to set up ok and reports GLES 3.0.

Code: Select all

0 - RED_SIZE=8, GREEN_SIZE=8, BLUE_SIZE=8, DEPTH_SIZE=0, ALPHA_SIZE=8, BUFFER_SIZE=32, SAMPLES=0, STENCIL_SIZE=0, SURFACE_TYPE=1, 
1 - RED_SIZE=8, GREEN_SIZE=8, BLUE_SIZE=8, DEPTH_SIZE=16, ALPHA_SIZE=8, BUFFER_SIZE=32, SAMPLES=0, STENCIL_SIZE=0, SURFACE_TYPE=1, 
2 - RED_SIZE=8, GREEN_SIZE=8, BLUE_SIZE=8, DEPTH_SIZE=24, ALPHA_SIZE=8, BUFFER_SIZE=32, SAMPLES=0, STENCIL_SIZE=0, SURFACE_TYPE=1, 
3 - RED_SIZE=8, GREEN_SIZE=8, BLUE_SIZE=8, DEPTH_SIZE=24, ALPHA_SIZE=8, BUFFER_SIZE=32, SAMPLES=0, STENCIL_SIZE=8, SURFACE_TYPE=1, 
4 - RED_SIZE=8, GREEN_SIZE=8, BLUE_SIZE=8, DEPTH_SIZE=0, ALPHA_SIZE=8, BUFFER_SIZE=32, SAMPLES=4, STENCIL_SIZE=0, SURFACE_TYPE=0, 
5 - RED_SIZE=8, GREEN_SIZE=8, BLUE_SIZE=8, DEPTH_SIZE=16, ALPHA_SIZE=8, BUFFER_SIZE=32, SAMPLES=4, STENCIL_SIZE=0, SURFACE_TYPE=0, 
6 - RED_SIZE=8, GREEN_SIZE=8, BLUE_SIZE=8, DEPTH_SIZE=24, ALPHA_SIZE=8, BUFFER_SIZE=32, SAMPLES=4, STENCIL_SIZE=0, SURFACE_TYPE=0, 
7 - RED_SIZE=8, GREEN_SIZE=8, BLUE_SIZE=8, DEPTH_SIZE=24, ALPHA_SIZE=8, BUFFER_SIZE=32, SAMPLES=4, STENCIL_SIZE=8, SURFACE_TYPE=0, 
8 - RED_SIZE=8, GREEN_SIZE=8, BLUE_SIZE=8, DEPTH_SIZE=0, ALPHA_SIZE=0, BUFFER_SIZE=24, SAMPLES=0, STENCIL_SIZE=0, SURFACE_TYPE=1, 
9 - RED_SIZE=8, GREEN_SIZE=8, BLUE_SIZE=8, DEPTH_SIZE=16, ALPHA_SIZE=0, BUFFER_SIZE=24, SAMPLES=0, STENCIL_SIZE=0, SURFACE_TYPE=1, 
10 - RED_SIZE=8, GREEN_SIZE=8, BLUE_SIZE=8, DEPTH_SIZE=24, ALPHA_SIZE=0, BUFFER_SIZE=24, SAMPLES=0, STENCIL_SIZE=0, SURFACE_TYPE=1, 
11 - RED_SIZE=8, GREEN_SIZE=8, BLUE_SIZE=8, DEPTH_SIZE=24, ALPHA_SIZE=0, BUFFER_SIZE=24, SAMPLES=0, STENCIL_SIZE=8, SURFACE_TYPE=1, 
12 - RED_SIZE=8, GREEN_SIZE=8, BLUE_SIZE=8, DEPTH_SIZE=0, ALPHA_SIZE=0, BUFFER_SIZE=24, SAMPLES=4, STENCIL_SIZE=0, SURFACE_TYPE=0, 
13 - RED_SIZE=8, GREEN_SIZE=8, BLUE_SIZE=8, DEPTH_SIZE=16, ALPHA_SIZE=0, BUFFER_SIZE=24, SAMPLES=4, STENCIL_SIZE=0, SURFACE_TYPE=0, 
14 - RED_SIZE=8, GREEN_SIZE=8, BLUE_SIZE=8, DEPTH_SIZE=24, ALPHA_SIZE=0, BUFFER_SIZE=24, SAMPLES=4, STENCIL_SIZE=0, SURFACE_TYPE=0, 
15 - RED_SIZE=8, GREEN_SIZE=8, BLUE_SIZE=8, DEPTH_SIZE=24, ALPHA_SIZE=0, BUFFER_SIZE=24, SAMPLES=4, STENCIL_SIZE=8, SURFACE_TYPE=0, 
16 - RED_SIZE=5, GREEN_SIZE=6, BLUE_SIZE=5, DEPTH_SIZE=0, ALPHA_SIZE=0, BUFFER_SIZE=16, SAMPLES=0, STENCIL_SIZE=0, SURFACE_TYPE=1, 
17 - RED_SIZE=5, GREEN_SIZE=6, BLUE_SIZE=5, DEPTH_SIZE=16, ALPHA_SIZE=0, BUFFER_SIZE=16, SAMPLES=0, STENCIL_SIZE=0, SURFACE_TYPE=1, 
18 - RED_SIZE=5, GREEN_SIZE=6, BLUE_SIZE=5, DEPTH_SIZE=24, ALPHA_SIZE=0, BUFFER_SIZE=16, SAMPLES=0, STENCIL_SIZE=0, SURFACE_TYPE=1, 
19 - RED_SIZE=5, GREEN_SIZE=6, BLUE_SIZE=5, DEPTH_SIZE=24, ALPHA_SIZE=0, BUFFER_SIZE=16, SAMPLES=0, STENCIL_SIZE=8, SURFACE_TYPE=1, 
20 - RED_SIZE=5, GREEN_SIZE=6, BLUE_SIZE=5, DEPTH_SIZE=0, ALPHA_SIZE=0, BUFFER_SIZE=16, SAMPLES=4, STENCIL_SIZE=0, SURFACE_TYPE=0, 
21 - RED_SIZE=5, GREEN_SIZE=6, BLUE_SIZE=5, DEPTH_SIZE=16, ALPHA_SIZE=0, BUFFER_SIZE=16, SAMPLES=4, STENCIL_SIZE=0, SURFACE_TYPE=0, 
22 - RED_SIZE=5, GREEN_SIZE=6, BLUE_SIZE=5, DEPTH_SIZE=24, ALPHA_SIZE=0, BUFFER_SIZE=16, SAMPLES=4, STENCIL_SIZE=0, SURFACE_TYPE=0, 
23 - RED_SIZE=5, GREEN_SIZE=6, BLUE_SIZE=5, DEPTH_SIZE=24, ALPHA_SIZE=0, BUFFER_SIZE=16, SAMPLES=4, STENCIL_SIZE=8, SURFACE_TYPE=0, 
As you can see #3 is close but should have SURFACE_TYPE & 4 > 0. The GLX window option (subject of this thread) needed to have XCreateWindow rather than XCreateSimpleWindow so maybe that's what happens behind the scenes in pygame. I would try it with pygame (which is an option in pi3d) but when I try to pip install it I get
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-51p7sa6b/pygame/
as the browser on this gentoo64 desktop seems to make the whole thing run slower and s l o w e... (aka verging on unusable) might google around that later. I would also try the GLX option but there doesn't seem to be libGLX.so.0.1 here - and no obvious way of getting it. Let you know how I get on.

Paddy
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d

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

Re: Pi3D transparent background on Pi4

Mon Nov 11, 2019 9:03 pm

It hopefully is something simple.
I checked and "eselect python list" returns 2.7, 3.5, 3.6, 3.7.
So I have 4 versions I can try it on.
Understanding Python memory leaks has been on my to do list for 7 years.

Debugging GL stuff is a pain, which it why i went looking for a interpreted language that can do GLSL coding.
Edit, compile, run , test, debug takes longer with compiled languages.

There is some really cool shader stuff out there but I barely understand it let alone know how to port it to Pi's.
So a shader toy like example with just one file will keep me busy learning for a few years :oops:

Must have bent/broken your Gentoo?
You need to do "sudo genup" as there has been some improvements since 1.5.1 was released.
Browsers run fine on mine, will sometimes have Aurora and Chromium open with 20+ tabs and compiling.

I will see if I can use my setup to make the transparent Raspberry demo.
yikes, pi3d everywhere in it ;)


Edit libx11.so etc are in /usr/lib64/ not sure if that makes a difference, I noticed Gentoo uses the lib64 folder
Integer problem? I'm looking in pyxlib folder first

Code: Select all

#~ /*
 #~ * _XSERVER64 must ONLY be defined when compiling X server sources on
 #~ * systems where unsigned long is not 32 bits, must NOT be used in
 #~ * client or library code.
 #~ */
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

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

Re: Pi3D transparent background on Pi4

Mon Nov 11, 2019 9:22 pm

Just a thought, have you tried on 64bit Raspbian Buster?
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

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

Re: Pi3D transparent background on Pi4

Mon Nov 11, 2019 11:13 pm

Hi, didn't know there was a 64bit raspbian. I might give that a go. When I try running the same code (as below) on the normal raspbian it gives me 32 different configs approximately matching the list I posted before (from gentoo) but with the SURFACE_TYPE mask including WINDOW_BIT and PIXMAP_BIT (i.e. values of 5, 6 and 7 rather than 0 and 1) This does seem odd as it isn't depending on anything else (X, SDL2, GL etc) as far as I can see.

The fact that all the X, GLES and EGL library function seem to produce meaningful results (the X window pops up and can be resized, return mouse and key events etc - it just doesn't get anything rendered to it) make me think that it isn't a pointer or int size issue but related to the EGL config results.

Finding and loading shared libraries is quite easy in python using the ctypes.util.find_library() and ctypes.CDLL() functions as in the code below.

Code: Select all

from ctypes import (c_int, byref, Structure, CDLL, POINTER)
from ctypes.util import find_library

egl_name = find_library("EGL")
egl = CDLL(egl_name)

EGL_BUFFER_SIZE = 0x3020
EGL_ALPHA_SIZE = 0x3021
EGL_BLUE_SIZE = 0x3022
EGL_GREEN_SIZE = 0x3023
EGL_RED_SIZE = 0x3024
EGL_DEPTH_SIZE = 0x3025
EGL_STENCIL_SIZE = 0x3026
EGL_SAMPLES = 0x3031
EGL_SURFACE_TYPE = 0x3033
EGL_DEFAULT_DISPLAY = 0

EGLint = c_int

class _EGLDisplay(Structure): ###### EDIT needs this definition to work on gentoo64 is that significant (not needed on laptop 64)
    __slots__ = [
    ]
_EGLDisplay._fields_ = [
    ('_opaque_struct', EGLint)
]
EGLDisplay = POINTER(_EGLDisplay) #######

class _EGLConfig(Structure):
    __slots__ = [
    ]
_EGLConfig._fields_ = [
    ('_opaque_struct', EGLint)
]
EGLConfig = POINTER(_EGLConfig)

egl.eglGetDisplay.restype = EGLDisplay ####### EDIT needs this on gentoo64

display = egl.eglGetDisplay(EGL_DEFAULT_DISPLAY)
r = egl.eglInitialize(display, None, None)
attrib_dict = {EGL_RED_SIZE:"RED_SIZE",
			   EGL_GREEN_SIZE:"GREEN_SIZE",
			   EGL_BLUE_SIZE:"BLUE_SIZE",
			   EGL_DEPTH_SIZE:"DEPTH_SIZE",
			   EGL_ALPHA_SIZE:"ALPHA_SIZE",
			   EGL_BUFFER_SIZE:"BUFFER_SIZE",
			   EGL_SAMPLES:"SAMPLES",
			   EGL_STENCIL_SIZE:"STENCIL_SIZE",
			   EGL_SURFACE_TYPE:"SURFACE_TYPE"}
numconfig = EGLint(0)
poss_configs = (EGLConfig * 50)(*(EGLConfig() for _ in range(50)))
r = egl.eglGetConfigs(display, byref(poss_configs), EGLint(len(poss_configs)), byref(numconfig))
attr_val = EGLint()
for i in range(numconfig.value):
  print(i, "- ", end="")
  for attr in attrib_dict:
    r = egl.eglGetConfigAttrib(display, poss_configs[i], attr, byref(attr_val))
    print("{}={}, ".format(attrib_dict[attr], attr_val.value), end="")
  print("")
PS, just checked and libSDL2.0.so is on. So maybe I should use that. If pygame with pyopengl works on gentoo that might be a possibility. If it works then I might boil the pi3d pygame option down to SLD instead. Hmm...
PPS just started genup: predicting 12,000 seconds! I will leave it till the morning.
Last edited by paddyg on Tue Nov 12, 2019 11:20 am, edited 1 time in total.
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d

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

Re: Pi3D transparent background on Pi4

Tue Nov 12, 2019 1:59 am

Add "arm_64bit=1" to config.txt
https://www.raspberrypi.org/forums/view ... 9&t=250730

SDL2 works in Gentoo as well.
The Pi4 and Gentoo64 has been so mainstream I have not had to change much example code to get it to work.
Still looking for a nice 64bit OS with Wayland instead of x11 to test OpenGL in that.

Getting Pi3D to work in Gentoo opens it up to other OS's.
Ubuntu is coming along.
The Pi4 with 64bit OS's are going to be popular once the bugs are worked out.
But getting code that works in many OS's is harder than just doing a Debian version.
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

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

Re: Pi3D transparent background on Pi4

Tue Nov 12, 2019 2:06 am

I did notice dispmanx is still used in fkms mode.
I don't think kms mode is bug free yet on Pi4's.
Dispmanx is very close to EGL?

Code: Select all

vcgencmd dispmanx_list
display:2 format:XRGB8888 transform:0 layer:-127 2560x1024 src:0,0,1280,1024 dst:0,0,1280,1024 cost:801 lbm:0 
display:7 format:XRGB8888 transform:0 layer:-127 2560x1024 src:1280,0,1280,1024 dst:0,0,1280,1024 cost:801 lbm:0 
display:7 format:ARGB8888 transform:0 layer:1 64x64 src:0,0,64,64 dst:472,586,64,64 cost:125 lbm:0 
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 7416
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Pi3D transparent background on Pi4

Tue Nov 12, 2019 7:44 am

There isn't a 64bit Raspbian, only a 64bit kernel that you can run underneath the 32bit userspace.
Debian supports 64bit ARM, but you may have to jump through a couple of hoops to get it running on a Pi. eg Raspbian is running a more recent version of mesa than Debian.
Gavinmc42 wrote:
Tue Nov 12, 2019 2:06 am
I did notice dispmanx is still used in fkms mode.
Correct, as the vpu is still in charge of composition.
I don't think kms mode is bug free yet on Pi4's.
We have the basics working for dpi displays, but it's still missing hdmi and some configuration around pixel valve assignment.
Dispmanx is very close to EGL
I'm not sure I'd claim they were close, but have vaguely similar uses.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

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

Re: Pi3D transparent background on Pi4

Tue Nov 12, 2019 9:50 am

There isn't a 64bit Raspbian, only a 64bit kernel that you can run underneath the 32bit userspace.
Whoops noobie mistake, kernel is not OS.
Raspbian python will still be 32bit?
But Python3 int is same as long int from Python2?
Ok, I'm clueless now.
Dispmanx is very close to EGL

I'm not sure I'd claim they were close, but have vaguely similar uses.
So is EGL used in VC6 OpenGL or dispmanx used instead?
Those layers confuse me.
Hard to believe someone understands that V3D drm code, not sure where EGL fits in that lot.
But if dispmanx is being used for compositing were is that happening?
In drm/vc4? Still clueless :oops:
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 7416
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Pi3D transparent background on Pi4

Tue Nov 12, 2019 12:12 pm

So is EGL used in VC6 OpenGL or dispmanx used instead?
Those layers confuse me.
Hard to believe someone understands that V3D drm code, not sure where EGL fits in that lot.
But if dispmanx is being used for compositing were is that happening?
In drm/vc4? Still clueless :oops:
https://www.khronos.org/egl/
EGL™ is an interface between Khronos rendering APIs such as OpenGL ES or OpenVG and the underlying native platform window system.
For Pi4 the "underlying native platform window system" is either OpenGL, or DRM/KMS.

The FKMS implementation of DRM/KMS sits on top of DispmanX. Going direct to DispmanX should be avoided unless absolutely necessary - DRM/KMS is the Linux standard API, and we are moving slowly but surely towards the standard APIs.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

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

Re: Pi3D transparent background on Pi4

Tue Nov 12, 2019 12:30 pm

Just tried https://github.com/paddywwoof/rust_pi3d on gentoo64 and it seems to render fine. The Rust version uses SDL2 so that looks to be the simplest option - to crank pi3d over to SDL. That will probably be a fairly major mod (though non-breaking as far as I can possibly make it) so it might be v3.0 in a few weeks. In the mean time I will probably put the glx, transparent window as v2.33

Playing with shaders in rust_pi3d wouldn't be too bad, it only takes 10s to recompile a shader change on gentoo64 RPi4 but pi3d has now got a slightly odd convention that has moved beyond the scanty documentation on github. Basically it checks what version of GL or GLES is running (GL2, GLES2 or GLES3) and modifies the shader code accordingly see here
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d

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

Re: Pi3D transparent background on Pi4

Wed Nov 13, 2019 2:42 am

37fps pretty good for the Rust game demo :D
I sometimes have trouble with cargo but that was painless.

Can you do a version of that single file python vert/frag GLSL shader example in Rust?
Want to check to see if the crashes are python or GLSL related.

Cool, even the radar works in the ship_demo, 57fps
Forest_walk is 60fps
Compile times are not too bad.

I was able to get a few more fps using medium and low precision without a noticeable difference from high.
In water and cloud shaders with perlin noise and fbm it does not seem to matter about precision.

Rust Pi3D seems ok for the short time I played with it.
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

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

Re: Pi3D transparent background on Pi4

Wed Nov 13, 2019 3:19 pm

Gavin, I was going to say no - the direct entry of shader code as strings hasn't been added to rust_pi3d... But when I looked it seemed I had left the functions public to do just that. So I just copy pasted from my earlier pi3d example and it worked straight off. On this gentoo64 pi the raymarch is a bit hesitant, but not so bad (and not significantly better if number of steps is reduced etc to coarsen the render)

As you got the other examples to work (kudos! There's not much help on the gitub readme) you should be able to just pull latest, cd pi3d then
cargo run --example shader_in_src --release
I had previously added a Display function to change window opacity so that's also demod in this example.

Paddy

PS just also found my previous look at using SDL2 for the window, mouse, key stuff when I was trying to get pi3d (python version) working on RPi4. This also seems to work on gentoo64 so it probably won't be such a job making pi3d use SDL2. I then need to decide what to keep in and what to discard: tk, pygame, bcm xlib, glx, sdl2. Too many acronyms all doing the sameish kind of thing. I suppose replacing pygame and xlib with sdl2 is logical.
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d

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

Re: Pi3D transparent background on Pi4

Thu Nov 14, 2019 1:40 am

Had trouble with this line

Code: Select all

display.set_opacity(0.9);
Probably need to update the rest of the code/library, I used my existing version
But once commented out it compiled and worked.
Ok, display.rs has changed

Yep raymarching is slow., but still cool.
Thanks Paddy- now have Rust shader code to have fun with.

Pygame is a bit dated, Pyglet seems more up to date.
SDL2 seems to have wide acceptance and works in many languages.
Not sure what the Rust equivalents would be.

I like OpenGLUT myself, but that's probably because I find the primitives like solid/wireframe sphere useful.
There is no OpenGLUT type lib for OpenGLES :(
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

Return to “Graphics programming”