瀏覽代碼

RPI: Init EGL via dispmanx.

Branimir Karadžić 11 年之前
父節點
當前提交
af8bc1fac0
共有 3 個文件被更改,包括 31 次插入4 次删除
  1. 2 0
      premake/premake4.lua
  2. 1 0
      src/bgfx.cpp
  3. 28 4
      src/glcontext_egl.cpp

+ 2 - 0
premake/premake4.lua

@@ -130,6 +130,8 @@ function exampleProject(_name, _uuid)
 			"GLESv2",
 			"GLESv2",
 			"EGL",
 			"EGL",
 			"bcm_host",
 			"bcm_host",
+			"vcos",
+			"vchiq_arm",
 			"pthread",
 			"pthread",
 		}
 		}
 
 

+ 1 - 0
src/bgfx.cpp

@@ -1369,6 +1369,7 @@ again:
 				 ||  BX_PLATFORM_EMSCRIPTEN
 				 ||  BX_PLATFORM_EMSCRIPTEN
 				 ||  BX_PLATFORM_IOS
 				 ||  BX_PLATFORM_IOS
 				 ||  BX_PLATFORM_NACL
 				 ||  BX_PLATFORM_NACL
+				 ||  BX_PLATFORM_RPI
 				 ) )
 				 ) )
 			{
 			{
 				_type = RendererType::OpenGLES;
 				_type = RendererType::OpenGLES;

+ 28 - 4
src/glcontext_egl.cpp

@@ -99,13 +99,12 @@ EGL_IMPORT
 #	include "glimports.h"
 #	include "glimports.h"
 
 
 #	if BX_PLATFORM_RPI
 #	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)
 	void x11SetDisplayWindow(::Display* _display, ::Window _window)
 	{
 	{
-		s_display = _display;
-		s_window = _window;
+		// Noop for now...
+		BX_UNUSED(_display, _window);
 	}
 	}
 #	endif // BX_PLATFORM_RPI
 #	endif // BX_PLATFORM_RPI
 
 
@@ -156,6 +155,31 @@ EGL_IMPORT
 		eglGetConfigAttrib(m_display, config, EGL_NATIVE_VISUAL_ID, &format);
 		eglGetConfigAttrib(m_display, config, EGL_NATIVE_VISUAL_ID, &format);
 		ANativeWindow_setBuffersGeometry(g_bgfxAndroidWindow, _width, _height, format);
 		ANativeWindow_setBuffersGeometry(g_bgfxAndroidWindow, _width, _height, format);
 		nwt = g_bgfxAndroidWindow;
 		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
 #	endif // BX_PLATFORM_ANDROID
 
 
 		m_surface = eglCreateWindowSurface(m_display, config, nwt, NULL);
 		m_surface = eglCreateWindowSurface(m_display, config, nwt, NULL);