From b6f602cd462b6c7fe5ec026090f7da691fec4d19 Mon Sep 17 00:00:00 2001 From: Fabien Piuzzi Date: Sun, 1 Jul 2012 10:00:51 +0200 Subject: [PATCH] Still can't manage to get a correct screen resolution --- src/client/cl_main.c | 9 +++++++++ src/egl/eglport.c | 21 +++++++++++++++++---- src/refresh/r_main.c | 8 +------- src/sdl/input.c | 2 +- 4 files changed, 28 insertions(+), 12 deletions(-) diff --git a/src/client/cl_main.c b/src/client/cl_main.c index 5e24b2048..9ff5534aa 100644 --- a/src/client/cl_main.c +++ b/src/client/cl_main.c @@ -27,6 +27,11 @@ #include "header/client.h" +#if defined(PI) +#include "bcm_host.h" +#endif + + void CL_ForwardToServer_f (void); void CL_Changing_f (void); void CL_Reconnect_f (void); @@ -780,6 +785,10 @@ void CL_Frame (int msec) void CL_Init (void) { +#if defined(PI) + printf("Init PI BCM system\n"); + bcm_host_init(); +#endif if (dedicated->value) return; /* nothing running on the client */ diff --git a/src/egl/eglport.c b/src/egl/eglport.c index 848364de2..2e23ebc50 100755 --- a/src/egl/eglport.c +++ b/src/egl/eglport.c @@ -53,7 +53,7 @@ int fbdev = -1; #include "GLES2/gl2.h" #include "EGL/egl.h" #include "EGL/eglext.h" - +static EGL_DISPMANX_WINDOW_T nativewindow; #endif int8_t VSync = 0; @@ -96,7 +96,12 @@ void EGL_Close() g_eglContext = NULL; g_eglDisplay = NULL; -#if defined(USE_EGL_RAW) +#if defined(PI) + /* if (nativewindow != NULL) { */ + /* free(nativewindow); */ + /* } */ + /* nativewindow = NULL; */ +#elif defined(USE_EGL_RAW) if (g_Window != NULL) { free(g_Window); } @@ -124,6 +129,7 @@ int8_t EGL_Init( void ) { int configIndex = 0; + if (FindAppropriateEGLConfigs() != 0) { printf( "EGL ERROR: Unable to configure EGL. See previous error.\n" ); @@ -258,7 +264,11 @@ int8_t ConfigureEGL(EGLConfig config) #endif /* defined(USE_EGL_SDL) */ printf( "EGL Creating Context\n" ); +#if defined(PI) + g_eglContext = peglCreateContext( g_eglDisplay, config, EGL_NO_CONTEXT, s_contextAttribs ); +#else g_eglContext = peglCreateContext( g_eglDisplay, config, NULL, s_contextAttribs ); +#endif if (g_eglContext == EGL_NO_CONTEXT) { @@ -296,7 +306,6 @@ int8_t ConfigureEGL(EGLConfig config) #endif /* defined(USE_EGL_RAW) */ #if defined(PI) - static EGL_DISPMANX_WINDOW_T nativewindow; DISPMANX_ELEMENT_HANDLE_T dispman_element; DISPMANX_DISPLAY_HANDLE_T dispman_display; @@ -319,6 +328,7 @@ int8_t ConfigureEGL(EGLConfig config) // You can hardcode the resolution here: /* display_width = 1440; */ /* display_height = 900; */ + printf("Current PI display size: %dx%d\n", display_width, display_height); dst_rect.x = 0; dst_rect.y = 0; @@ -387,7 +397,6 @@ int8_t FindAppropriateEGLConfigs( void ) EGLint ConfigAttribs[19]; #if defined(PI) - ConfigAttribs[attrib++] = EGL_RED_SIZE; ConfigAttribs[attrib++] = 8; ConfigAttribs[attrib++] = EGL_GREEN_SIZE; @@ -429,7 +438,11 @@ int8_t FindAppropriateEGLConfigs( void ) ConfigAttribs[attrib++] = EGL_NONE; #endif /* defined(PI) */ +#if defined(PI) + result = eglSaneChooseConfigBRCM( g_eglDisplay, ConfigAttribs, g_allConfigs, 1, &g_totalConfigsFound ); +#else result = peglChooseConfig( g_eglDisplay, ConfigAttribs, g_allConfigs, g_totalConfigsIn, &g_totalConfigsFound ); +#endif if (result != EGL_TRUE || g_totalConfigsFound == 0) { CheckEGLErrors( __FILE__, __LINE__ ); diff --git a/src/refresh/r_main.c b/src/refresh/r_main.c index 2340b2099..8497d1e26 100644 --- a/src/refresh/r_main.c +++ b/src/refresh/r_main.c @@ -24,10 +24,6 @@ * ======================================================================= */ -#if defined(PI) -#include "bcm_host.h" -#endif - #include "header/local.h" #define NUM_BEAM_SEGS 6 @@ -1300,9 +1296,7 @@ R_SetMode ( void ) int R_Init ( void *hinstance, void *hWnd ) { -#if defined(PI) - bcm_host_init(); -#endif + char renderer_buffer [ 1000 ]; char vendor_buffer [ 1000 ]; int err; diff --git a/src/sdl/input.c b/src/sdl/input.c index 7a0993b54..038d0bbbd 100644 --- a/src/sdl/input.c +++ b/src/sdl/input.c @@ -290,7 +290,7 @@ void IN_Update(void) IN_Update_Flag = 1; -#if defined(WIZ) || defined(CAANOO) || defined(PI) +#if defined(WIZ) || defined(CAANOO) uint32_t key; uint8_t update; uint8_t button;