From af8bc1fac0c429a01af2328f7f2613fe7079f1ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Sun, 24 Aug 2014 20:39:35 -0700 Subject: [PATCH] RPI: Init EGL via dispmanx. --- premake/premake4.lua | 2 ++ src/bgfx.cpp | 1 + src/glcontext_egl.cpp | 32 ++++++++++++++++++++++++++++---- 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/premake/premake4.lua b/premake/premake4.lua index 592936c6..4944ec0d 100644 --- a/premake/premake4.lua +++ b/premake/premake4.lua @@ -130,6 +130,8 @@ function exampleProject(_name, _uuid) "GLESv2", "EGL", "bcm_host", + "vcos", + "vchiq_arm", "pthread", } diff --git a/src/bgfx.cpp b/src/bgfx.cpp index dddadf09..79668ee2 100644 --- a/src/bgfx.cpp +++ b/src/bgfx.cpp @@ -1369,6 +1369,7 @@ again: || BX_PLATFORM_EMSCRIPTEN || BX_PLATFORM_IOS || BX_PLATFORM_NACL + || BX_PLATFORM_RPI ) ) { _type = RendererType::OpenGLES; diff --git a/src/glcontext_egl.cpp b/src/glcontext_egl.cpp index b22612a1..9cbeec07 100644 --- a/src/glcontext_egl.cpp +++ b/src/glcontext_egl.cpp @@ -99,13 +99,12 @@ EGL_IMPORT # include "glimports.h" # if BX_PLATFORM_RPI - static ::Display* s_display; - static ::Window s_window; + static EGL_DISPMANX_WINDOW_T s_dispmanWindow; void x11SetDisplayWindow(::Display* _display, ::Window _window) { - s_display = _display; - s_window = _window; + // Noop for now... + BX_UNUSED(_display, _window); } # endif // BX_PLATFORM_RPI @@ -156,6 +155,31 @@ EGL_IMPORT eglGetConfigAttrib(m_display, config, EGL_NATIVE_VISUAL_ID, &format); ANativeWindow_setBuffersGeometry(g_bgfxAndroidWindow, _width, _height, format); nwt = g_bgfxAndroidWindow; +# elif BX_PLATFORM_RPI + DISPMANX_DISPLAY_HANDLE_T dispmanDisplay = vc_dispmanx_display_open(0); + DISPMANX_UPDATE_HANDLE_T dispmanUpdate = vc_dispmanx_update_start(0); + + VC_RECT_T dstRect = { 0, 0, _width, _height }; + VC_RECT_T srcRect = { 0, 0, _width << 16, _height << 16 }; + + DISPMANX_ELEMENT_HANDLE_T dispmanElement = vc_dispmanx_element_add(dispmanUpdate + , dispmanDisplay + , 0 + , &dstRect + , 0 + , &srcRect + , DISPMANX_PROTECTION_NONE + , NULL + , NULL + , DISPMANX_NO_ROTATE + ); + + s_dispmanWindow.element = dispmanElement; + s_dispmanWindow.width = _width; + s_dispmanWindow.height = _height; + nwt = &s_dispmanWindow; + + vc_dispmanx_update_submit_sync(dispmanUpdate); # endif // BX_PLATFORM_ANDROID m_surface = eglCreateWindowSurface(m_display, config, nwt, NULL);