Code: Select all
vc4 188416 20 - Live 0x0000000000000000
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
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
Code: Select all
Device platform:
eglinfo: eglInitialize failed
Code: Select all
EGL_VERSION = 1.4
drmModeGetResources failed
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))
Code: Select all
elif PLATFORM == PLATFORM_PI4
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,
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.
#~ */
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("")
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
Correct, as the vpu is still in charge of composition.
We have the basics working for dpi displays, but it's still missing hdmi and some configuration around pixel valve assignment.I don't think kms mode is bug free yet on Pi4's.
I'm not sure I'd claim they were close, but have vaguely similar uses.Dispmanx is very close to EGL
Whoops noobie mistake, kernel is not OS.There isn't a 64bit Raspbian, only a 64bit kernel that you can run underneath the 32bit userspace.
So is EGL used in VC6 OpenGL or dispmanx used instead?Dispmanx is very close to EGL
I'm not sure I'd claim they were close, but have vaguely similar uses.
https://www.khronos.org/egl/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
For Pi4 the "underlying native platform window system" is either OpenGL, or DRM/KMS.EGL™ is an interface between Khronos rendering APIs such as OpenGL ES or OpenVG and the underlying native platform window system.
Code: Select all
display.set_opacity(0.9);
Code: Select all
git checkout sdl2
Code: Select all
display = pi3d.Display.create(..., use_sdl2=True)
There will be a new 1.5.2 release of Gentoo64 any day.sudo pip install --user pysdl2
Collecting pysdl2
Segmentation fault