From d0fd02fa8dba2bec2ad805ad2fe3e099b520a2d9 Mon Sep 17 00:00:00 2001 From: James Turner <zakalawe@mac.com> Date: Wed, 1 Apr 2020 21:01:07 +0100 Subject: [PATCH] FGPanel: update for Raspbian 10 --- utils/fgpanel/CMakeLists.txt | 106 ++++++++++++++++----------- utils/fgpanel/FGPanel.cxx | 6 +- utils/fgpanel/FGPanelApplication.cxx | 1 - utils/fgpanel/FGTextLayer.cxx | 6 +- utils/fgpanel/README.RPi | 19 ++++- 5 files changed, 88 insertions(+), 50 deletions(-) diff --git a/utils/fgpanel/CMakeLists.txt b/utils/fgpanel/CMakeLists.txt index b1dde3a63..33d093ef8 100644 --- a/utils/fgpanel/CMakeLists.txt +++ b/utils/fgpanel/CMakeLists.txt @@ -1,6 +1,14 @@ -find_package(PNG REQUIRED) -find_package(OpenGL REQUIRED) -find_package(Freetype REQUIRED) +find_package(PNG) +find_package(OpenGL) +find_package(Freetype) + +if((NOT PNG_FOUND) OR (NOT OPENGL_FOUND) OR (NOT FREETYPE_FOUND)) + message(WARNING "FGPanel enabled, but some dependencies are missing") + message(STATUS "libPNG: ${PNG_FOUND}") + message(STATUS "OpenGL: ${OPENGL_FOUND}") + message(STATUS "Freetype: ${FREETYPE_FOUND}") + return() +endif() find_path(BCMHOST_INCLUDE_DIR NAMES bcm_host.h @@ -13,15 +21,7 @@ include_directories( ${PNG_INCLUDE_DIR} ) -if(BCMHOST_INCLUDE_DIR) - # CMAKE > 3.1 : target_sources(fgpanel - set(TARGET_SOURCES - GLES_utils.cxx - GLES_utils.hxx - ) -endif() - -add_executable(fgpanel +set(TARGET_SOURCES main.cxx ApplicationProperties.hxx ApplicationProperties.cxx @@ -63,58 +63,82 @@ add_executable(fgpanel panel_io.hxx GL_utils.cxx GL_utils.hxx - ${TARGET_SOURCES} ) +add_executable(fgpanel ${TARGET_SOURCES}) + target_link_libraries(fgpanel - ${PNG_LIBRARIES} SimGearCore + ${PNG_LIBRARIES} ${FREETYPE_LIBRARIES} ) if(BCMHOST_INCLUDE_DIR) message(STATUS "found Raspberry Pi") - include_directories( + add_executable(fgpanel-egl ${TARGET_SOURCES} + GLES_utils.cxx + GLES_utils.hxx + ) + target_include_directories(fgpanel-egl PUBLIC ${BCMHOST_INCLUDE_DIR} ${BCMHOST_INCLUDE_DIR}/interface/vcos/pthreads ${BCMHOST_INCLUDE_DIR}/interface/vmcs_host/linux ) - target_link_libraries(fgpanel - -lGLESv2 -lEGL -lm -lbcm_host -L/opt/vc/lib + target_link_libraries(fgpanel-egl + SimGearCore + ${PNG_LIBRARIES} + ${FREETYPE_LIBRARIES} + -lbrcmGLESv2 -lbrcmEGL -lm -lbcm_host -L/opt/vc/lib ) - add_definitions(-D_GLES2 -D_RPI) -else() - find_package(GLUT) - if(GLUT_FOUND) + target_compile_definitions(fgpanel-egl PUBLIC + -D_GLES2 -D_RPI + ) + target_compile_definitions(fgpanel PUBLIC + -D_RPI + ) + message(STATUS "FGPanel (Raspberry Pi) : ENABLED") + install(TARGETS fgpanel-egl RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) +else(BCMHOST_INCLUDE_DIR) + message(STATUS "FGPanel (Raspberry Pi) : DISABLED") +endif(BCMHOST_INCLUDE_DIR) - find_package(GLEW) - if(GLEW_FOUND) +find_package(GLUT) +if(GLUT_FOUND) + message(STATUS "found GLUT inc ${GLUT_INCLUDE_DIR}, lib ${GLUT_LIBRARIES}") + if(MSVC) + target_compile_definitions(fgpanel PUBLIC + -DFREEGLUT_LIB_PRAGMAS=0 + ) + endif(MSVC) - include_directories( - ${GLEW_INCLUDE_DIRS} - ) + find_package(GLEW) + if(GLEW_FOUND) + message(STATUS "found GLEW inc ${GLEW_INCLUDE_DIR}, lib ${GLEW_LIBRARIES}") - target_link_libraries(fgpanel - ${GLUT_LIBRARIES} - ${GLEW_LIBRARIES} - ${OPENGL_LIBRARIES} - ) - else(GLEW_FOUND) - message(WARNING "GLEW NOT found, can't build FGPanel") - set(WITH_FGPANEL 0) - endif(GLEW_FOUND) - else(GLUT_FOUND) - message(WARNING "GLUT NOT found, can't build FGPanel") + target_include_directories(fgpanel PUBLIC + ${GLEW_INCLUDE_DIRS} + ) + + target_link_libraries(fgpanel + ${OPENGL_LIBRARIES} + ${GLUT_LIBRARIES} + ${GLEW_LIBRARIES} + ) + else(GLEW_FOUND) + message(WARNING "GLEW NOT found, can't build FGPanel") set(WITH_FGPANEL 0) - endif(GLUT_FOUND) -endif() + endif(GLEW_FOUND) +else(GLUT_FOUND) + message(WARNING "GLUT NOT found, can't build FGPanel") + set(WITH_FGPANEL 0) +endif(GLUT_FOUND) if(WITH_FGPANEL) message(STATUS "FGPanel : ENABLED") install(TARGETS fgpanel RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) -else() +else(WITH_FGPANEL) message(WARNING "FGPanel : DISABLED") -endif() +endif(WITH_FGPANEL) diff --git a/utils/fgpanel/FGPanel.cxx b/utils/fgpanel/FGPanel.cxx index 944395f3b..3ca58ea34 100644 --- a/utils/fgpanel/FGPanel.cxx +++ b/utils/fgpanel/FGPanel.cxx @@ -89,7 +89,8 @@ void FGPanel::init () { // Textured Layer Shaders const char V_Textured_Layer_Shader_Str[] = -#ifdef _GLES2 +#ifdef _RPI + "#version 100 \n" "attribute vec4 a_position; \n" "attribute vec2 a_tex_coord; \n" "varying vec2 v_tex_coord; \n" @@ -106,7 +107,8 @@ FGPanel::init () { "} \n"; const char F_Textured_Layer_Shader_Str[] = -#ifdef _GLES2 +#ifdef _RPI + "#version 100 \n" "precision mediump float; \n" "varying vec2 v_tex_coord; \n" #else diff --git a/utils/fgpanel/FGPanelApplication.cxx b/utils/fgpanel/FGPanelApplication.cxx index 6073ebbbe..d8ff4727e 100644 --- a/utils/fgpanel/FGPanelApplication.cxx +++ b/utils/fgpanel/FGPanelApplication.cxx @@ -36,7 +36,6 @@ #include <GLUT/glut.h> #elif defined (_GLES2) #include <GLES2/gl2.h> -#include "GLES_utils.hxx" #else #include <GL/glew.h> // Must be included before <GL/gl.h> #include <GL/gl.h> diff --git a/utils/fgpanel/FGTextLayer.cxx b/utils/fgpanel/FGTextLayer.cxx index 5dddbc5b0..caf50bd1f 100644 --- a/utils/fgpanel/FGTextLayer.cxx +++ b/utils/fgpanel/FGTextLayer.cxx @@ -35,7 +35,8 @@ GLint FGTextLayer::Text_Layer_Color_Loc (0); bool FGTextLayer::Init () { const char V_Text_Layer_Shader_Str[] = -#ifdef _GLES2 +#ifdef _RPI + "#version 100 \n" "attribute vec4 a_position; \n" "attribute vec2 a_tex_coord; \n" "varying vec2 v_tex_coord; \n" @@ -52,7 +53,8 @@ FGTextLayer::Init () { "} \n"; const char F_Text_Layer_Shader_Str[] = -#ifdef _GLES2 +#ifdef _RPI + "#version 100 \n" "precision mediump float; \n" "varying vec2 v_tex_coord; \n" #else diff --git a/utils/fgpanel/README.RPi b/utils/fgpanel/README.RPi index ac56fc14b..6d3f6dd3a 100644 --- a/utils/fgpanel/README.RPi +++ b/utils/fgpanel/README.RPi @@ -15,10 +15,10 @@ INSTALLATION The source code of FGPanel can easily be adapted to other embedded devices supporting OpenGL ES 2.0. 3. Build FGPanel only (don't build all components on the Raspberry Pi as this will take ages!!!): - make -- fgpanel + make -- fgpanel-egl fgpanel -USAGE -===== +USAGE (fgpanel-egl) +=================== 1. Increase the amount of GPU memory by editing the /boot/config.txt file. Add the following line (this is for Raspberry Pi model 1B with 512 Mb of memory): @@ -30,10 +30,21 @@ USAGE 3. Stop X server. FGPanel runs in the console (Linux framebuffer). 4. Start FGPanel as usual but as ROOT or use the 'sudo' command (see README): - sudo -- utils/fgpanel/fgpanel --fg-root=/path/to/fg/data --panel=Aircraft/MyAircraft/Panels/MyPanel.xml + sudo -- utils/fgpanel/fgpanel-egl --fg-root=/path/to/fg/data --panel=Aircraft/MyAircraft/Panels/MyPanel.xml ROOT privileges are required to access the GPU of the Raspberry Pi. +USAGE (fgpanel) +=================== + +1. Activate the Full KMS driver on the Raspberry Pi using the raspi-config program: + Advanced Options -> GL Driver -> Full KMS + +2. Reboot. The Full KMS driver should be activated. + +3. When X server is running, start FGPanel as usual (see README): + utils/fgpanel/fgpanel --fg-root=/path/to/fg/data --panel=Aircraft/MyAircraft/Panels/MyPanel.xml + FEATURES ========