luca-piccioni / OpenGL.Net

Modern OpenGL bindings for C#.
MIT License
570 stars 109 forks source link

Raspberry PI VideoCore IV API Support #24

Closed luca-piccioni closed 7 years ago

luca-piccioni commented 7 years ago

Current head revision is able to run on Raspberry PI 2 without X server running. It uses the BCM VideoCore IV API to create a window onto the connected LCD, and instantiate GLES2 context properly without errors.

However, no presentation is visible screen, but the glClear operation is executed correctly. This need more investigation.

Here is a dump of the output of the sample application. No errors are generated and it seems that data is marshalled correctly. I tried to follow the RPi sample application found in /opt/vc/src, but I cannot guarantee the call orders.

    mono HelloTriangle.VideoCore.exe
// Querying EGL from libEGL.so
// EGL availability: True
// Querying BCM VideoCore from libbcm_host.so
// BCM VideoCore availability: True
bcm_host_init()
eglGetDisplay(0x00000000) = 00000001
eglInitialize(0x00000001, { null }, { null }) = True
eglGetError() = 12288
eglQueryString(0x00000001, 12372) = 1.4
eglGetError() = 12288
eglQueryString(0x00000001, 12371) = Broadcom
eglGetError() = 12288
eglQueryString(0x00000001, 12429) = OpenGL_ES OpenVG
eglGetError() = 12288
eglTerminate(0x00000001) = True
eglGetError() = 12288
// Creating VideoCore native window
graphics_get_display_size(0, 1920, 1080) = 0
vc_dispmanx_display_open(0) = 268435520
vc_dispmanx_update_start(0) = 1359443983
vc_dispmanx_element_add(1359443983, 268435520, 0, VC_RECT_T={ x=0 y=0 w=1920 h=1080 }, 0, VC_RECT_T={ x=0 y=0 w=125829120 h=70778880 }, 0, 0, 0, DISPMANX_STEREOSCOPIC_NONE) = 536893440
vc_dispmanx_update_submit_sync(1359443983) = 0
// VideoIV Native Window is 0x766170D0
// OpenGL.Net is initializing
eglGetDisplay(0x00000000) = 00000001
eglInitialize(0x00000001, {1}, {4}) = True
eglGetError() = 12288
eglChooseConfig(0x00000001, {12352,4,12339,1,12324,8,12323,8,12322,8,12344}, {8,26,6,4,2,16,14,12}, 8, {8}) = True
eglGetError() = 12288
eglCreatePbufferSurface(0x00000001, 0x00000008, {12375,1,12374,1,12344}) = 00000001
eglGetError() = 12288
eglChooseConfig(0x00000001, {12352,4,12339,5,12324,8,12323,8,12322,8,12344}, {8,26,6,4,2,16,14,12}, 8, {8}) = True
eglGetError() = 12288
eglBindAPI(12448) = True
eglGetError() = 12288
eglCreateContext(0x00000001, 0x00000008, 0x00000000, {12440,2,12344}) = 00000001
eglGetError() = 12288
eglQueryContext(0x00000001, 0x00000001, 12439, {12448}) = True
eglGetError() = 12288
eglBindAPI(12448) = True
eglGetError() = 12288
eglMakeCurrent(0x00000001, 0x00000001, 0x00000001, 0x00000001) = True
eglGetError() = 12288
eglGetCurrentContext() = 00000001
eglGetError() = 12288
glGetString(Version) = OpenGL ES 2.0
glGetError() = NoError
glGetString(Version) = OpenGL ES 2.0
glGetError() = NoError
glGetString(ShadingLanguageVersion) = OpenGL ES GLSL ES 1.00
glGetError() = NoError
glGetString(Vendor) = Broadcom
glGetError() = NoError
glGetString(Renderer) = VideoCore IV HW
glGetError() = NoError
// Query GL extensions.
glGetString(Version) = OpenGL ES 2.0
glGetError() = NoError
glGetString(Extensions) = GL_OES_compressed_ETC1_RGB8_texture GL_OES_compressed_paletted_texture GL_OES_texture_npot GL_OES_depth24 GL_OES_vertex_half_float GL_OES_EGL_image GL_OES_EGL_image_external GL_EXT_discard_framebuffer GL_OES_rgb8_rgba8 GL_OES_depth32 GL_OES_mapbuffer GL_EXT_texture_format_BGRA8888 GL_APPLE_rgb_422 GL_EXT_debug_marker
glGetError() = NoError
// Query OpenGL implementation limits.
glGetIntegerv(0x0D33, 2048)
glGetError() = NoError
glGetIntegerv(0x0D3A, {2048,2048})
glGetError() = NoError
glGetFloatv(0x846E, {0,256})
glGetError() = NoError
glGetIntegerv(0x851C, 2048)
glGetError() = NoError
glGetIntegerv(0x8B4D, 8)
glGetError() = NoError
glGetIntegerv(0x8872, 8)
glGetError() = NoError
glGetIntegerv(0x8869, 8)
glGetError() = NoError
glGetIntegerv(0x8B4C, 8)
glGetError() = NoError
glGetIntegerv(0x84E8, 2048)
glGetError() = NoError
// Query EGL extensions.
eglQueryString(0x00000001, 12373) = EGL_KHR_image EGL_KHR_image_base EGL_KHR_image_pixmap EGL_KHR_vg_parent_image EGL_KHR_gl_texture_2D_image EGL_KHR_gl_texture_cubemap_image EGL_KHR_lock_surface
eglGetError() = 12288
eglMakeCurrent(0x00000001, 0x00000000, 0x00000000, 0x00000000) = True
eglGetError() = 12288
eglDestroyContext(0x00000001, 0x00000001) = True
eglGetError() = 12288
eglDestroySurface(0x00000001, 0x00000001) = True
eglGetError() = 12288
eglTerminate(0x00000001) = True
eglGetError() = 12288
// OpenGL.Net has been initialized
eglGetDisplay(0x00000000) = 00000001
eglInitialize(0x00000001, {1}, {4}) = True
eglGetError() = 12288
eglChooseConfig(0x00000001, {12352,4,12339,4,12324,8,12323,8,12322,8,12321,8,12344}, {7,25,5,3,1,15,13,11}, 8, {8}) = True
eglGetError() = 12288
eglBindAPI(12448) = True
eglGetError() = 12288
eglCreateContext(0x00000001, 0x00000007, 0x00000000, {12440,2,12344}) = 00000001
eglGetError() = 12288
eglCreateWindowSurface(0x00000001, 0x00000007, 0x766170D0, {12344}) = 00000001
eglGetError() = 12288
eglQueryContext(0x00000001, 0x00000001, 12439, {12448}) = True
eglGetError() = 12288
eglBindAPI(12448) = True
eglGetError() = 12288
eglMakeCurrent(0x00000001, 0x00000001, 0x00000001, 0x00000001) = True
eglGetError() = 12288
eglGetCurrentContext() = 00000001
eglGetError() = 12288
glGetString(Version) = OpenGL ES 2.0
glGetError() = NoError
glViewport(0, 0, 1920, 1080)
glGetError() = NoError
glClearColor(1, 0, 0, 0)
glGetError() = NoError
glClear(ColorBufferBit)
glGetError() = NoError
glFlush()
glGetError() = NoError
eglSwapBuffers(0x00000001, 0x00000001) = True
eglGetError() = 12288
luca-piccioni commented 7 years ago

Solved by turning glClearColor(1, 0, 0, 0) into glClearColor(1, 0, 0, 1). Sigh.