Update FGPanel:
- use OpenGL 2.0 instead of OpenGL 1.0; - port to Raspberry Pi; - remove PLib dependencies.
This commit is contained in:
parent
5b14d6e495
commit
e78b92ca27
7 changed files with 52 additions and 51 deletions
|
@ -16,7 +16,6 @@
|
||||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
# include <direct.h> // for getcwd()
|
# include <direct.h> // for getcwd()
|
||||||
#else // !_WIN32
|
#else // !_WIN32
|
||||||
|
|
|
@ -1,16 +1,6 @@
|
||||||
find_package(PNG)
|
find_package(PNG REQUIRED)
|
||||||
find_package(OpenGL)
|
find_package(OpenGL REQUIRED)
|
||||||
find_package(GLEW)
|
find_package(Freetype REQUIRED)
|
||||||
find_package(Freetype)
|
|
||||||
|
|
||||||
if ((NOT PNG_FOUND) OR (NOT OPENGL_FOUND) OR (NOT GLEW_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 "GLEW: ${GLEW_FOUND}")
|
|
||||||
message(STATUS "Freetype: ${FREETYPE_FOUND}")
|
|
||||||
return()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
find_path(BCMHOST_INCLUDE_DIR
|
find_path(BCMHOST_INCLUDE_DIR
|
||||||
NAMES bcm_host.h
|
NAMES bcm_host.h
|
||||||
|
@ -23,8 +13,7 @@ include_directories(
|
||||||
${PNG_INCLUDE_DIR}
|
${PNG_INCLUDE_DIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
if(${BCMHOST_INCLUDE_DIR} STREQUAL "BCMHOST_INCLUDE_DIR-NOTFOUND")
|
if(BCMHOST_INCLUDE_DIR)
|
||||||
else()
|
|
||||||
# CMAKE > 3.1 : target_sources(fgpanel
|
# CMAKE > 3.1 : target_sources(fgpanel
|
||||||
set(TARGET_SOURCES
|
set(TARGET_SOURCES
|
||||||
GLES_utils.cxx
|
GLES_utils.cxx
|
||||||
|
@ -78,41 +67,54 @@ add_executable(fgpanel
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(fgpanel
|
target_link_libraries(fgpanel
|
||||||
SimGearCore
|
|
||||||
${PNG_LIBRARIES}
|
${PNG_LIBRARIES}
|
||||||
|
SimGearCore
|
||||||
${FREETYPE_LIBRARIES}
|
${FREETYPE_LIBRARIES}
|
||||||
)
|
)
|
||||||
|
|
||||||
if(${BCMHOST_INCLUDE_DIR} STREQUAL "BCMHOST_INCLUDE_DIR-NOTFOUND")
|
if(BCMHOST_INCLUDE_DIR)
|
||||||
find_package(GLUT REQUIRED)
|
|
||||||
if(GLUT_FOUND)
|
|
||||||
message(STATUS "found GLUT inc ${GLUT_INCLUDE_DIR}, lib ${GLUT_LIBRARIES} ")
|
|
||||||
if (MSVC)
|
|
||||||
add_definitions( -DFREEGLUT_LIB_PRAGMAS=0 )
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
target_link_libraries(fgpanel
|
|
||||||
${OPENGL_LIBRARIES}
|
|
||||||
${GLUT_LIBRARIES}
|
|
||||||
GLEW::GLEW
|
|
||||||
)
|
|
||||||
else(GLUT_FOUND)
|
|
||||||
message(STATUS "glut NOT found, can't build fgpanel")
|
|
||||||
endif(GLUT_FOUND)
|
|
||||||
else()
|
|
||||||
message(STATUS "found Raspberry Pi")
|
message(STATUS "found Raspberry Pi")
|
||||||
|
|
||||||
target_link_libraries(fgpanel
|
|
||||||
-lGLESv2 -lEGL -lm -lbcm_host -L/opt/vc/lib
|
|
||||||
)
|
|
||||||
|
|
||||||
include_directories(
|
include_directories(
|
||||||
${BCMHOST_INCLUDE_DIR}
|
${BCMHOST_INCLUDE_DIR}
|
||||||
${BCMHOST_INCLUDE_DIR}/interface/vcos/pthreads
|
${BCMHOST_INCLUDE_DIR}/interface/vcos/pthreads
|
||||||
${BCMHOST_INCLUDE_DIR}/interface/vmcs_host/linux
|
${BCMHOST_INCLUDE_DIR}/interface/vmcs_host/linux
|
||||||
)
|
)
|
||||||
|
|
||||||
|
target_link_libraries(fgpanel
|
||||||
|
-lGLESv2 -lEGL -lm -lbcm_host -L/opt/vc/lib
|
||||||
|
)
|
||||||
|
|
||||||
add_definitions(-D_GLES2 -D_RPI)
|
add_definitions(-D_GLES2 -D_RPI)
|
||||||
|
else()
|
||||||
|
find_package(GLUT)
|
||||||
|
if(GLUT_FOUND)
|
||||||
|
|
||||||
|
find_package(GLEW)
|
||||||
|
if(GLEW_FOUND)
|
||||||
|
|
||||||
|
include_directories(
|
||||||
|
${GLEW_INCLUDE_DIRS}
|
||||||
|
)
|
||||||
|
|
||||||
|
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")
|
||||||
|
set(WITH_FGPANEL 0)
|
||||||
|
endif(GLUT_FOUND)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
install(TARGETS fgpanel RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
|
if(WITH_FGPANEL)
|
||||||
|
message(STATUS "FGPanel : ENABLED")
|
||||||
|
install(TARGETS fgpanel RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||||
|
else()
|
||||||
|
message(WARNING "FGPanel : DISABLED")
|
||||||
|
endif()
|
||||||
|
|
|
@ -94,7 +94,7 @@ FGPanel::init () {
|
||||||
"attribute vec2 a_tex_coord; \n"
|
"attribute vec2 a_tex_coord; \n"
|
||||||
"varying vec2 v_tex_coord; \n"
|
"varying vec2 v_tex_coord; \n"
|
||||||
#else
|
#else
|
||||||
"#version 330 \n"
|
"#version 130 \n"
|
||||||
"in vec4 a_position; \n"
|
"in vec4 a_position; \n"
|
||||||
"in vec2 a_tex_coord; \n"
|
"in vec2 a_tex_coord; \n"
|
||||||
"out vec2 v_tex_coord; \n"
|
"out vec2 v_tex_coord; \n"
|
||||||
|
@ -110,9 +110,8 @@ FGPanel::init () {
|
||||||
"precision mediump float; \n"
|
"precision mediump float; \n"
|
||||||
"varying vec2 v_tex_coord; \n"
|
"varying vec2 v_tex_coord; \n"
|
||||||
#else
|
#else
|
||||||
"#version 330 \n"
|
"#version 130 \n"
|
||||||
"in vec2 v_tex_coord; \n"
|
"in vec2 v_tex_coord; \n"
|
||||||
"out vec4 gl_FragColor; \n"
|
|
||||||
#endif
|
#endif
|
||||||
"uniform sampler2D u_texture; \n"
|
"uniform sampler2D u_texture; \n"
|
||||||
"void main () { \n"
|
"void main () { \n"
|
||||||
|
|
|
@ -51,8 +51,7 @@ using namespace std;
|
||||||
* redraw themselves when necessary, and will pass mouse clicks on to
|
* redraw themselves when necessary, and will pass mouse clicks on to
|
||||||
* the appropriate instruments for processing.
|
* the appropriate instruments for processing.
|
||||||
*/
|
*/
|
||||||
class FGPanel : public SGSubsystem
|
class FGPanel : public SGSubsystem {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
FGPanel (const SGPropertyNode_ptr root);
|
FGPanel (const SGPropertyNode_ptr root);
|
||||||
virtual ~FGPanel ();
|
virtual ~FGPanel ();
|
||||||
|
|
|
@ -28,8 +28,7 @@ class PropertySetter;
|
||||||
|
|
||||||
typedef vector<PropertySetter*> PropertySetterVector;
|
typedef vector<PropertySetter*> PropertySetterVector;
|
||||||
|
|
||||||
class FGPanelProtocol : public SGSubsystem
|
class FGPanelProtocol : public SGSubsystem {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
FGPanelProtocol (SGPropertyNode_ptr a_Root);
|
FGPanelProtocol (SGPropertyNode_ptr a_Root);
|
||||||
virtual ~FGPanelProtocol ();
|
virtual ~FGPanelProtocol ();
|
||||||
|
|
|
@ -38,13 +38,14 @@ FGTextLayer::Init () {
|
||||||
#ifdef _GLES2
|
#ifdef _GLES2
|
||||||
"attribute vec4 a_position; \n"
|
"attribute vec4 a_position; \n"
|
||||||
"attribute vec2 a_tex_coord; \n"
|
"attribute vec2 a_tex_coord; \n"
|
||||||
|
"varying vec2 v_tex_coord; \n"
|
||||||
#else
|
#else
|
||||||
"#version 330 \n"
|
"#version 130 \n"
|
||||||
"in vec4 a_position; \n"
|
"in vec4 a_position; \n"
|
||||||
"in vec2 a_tex_coord; \n"
|
"in vec2 a_tex_coord; \n"
|
||||||
|
"out vec2 v_tex_coord; \n"
|
||||||
#endif
|
#endif
|
||||||
"uniform mat4 u_mvp_matrix; \n"
|
"uniform mat4 u_mvp_matrix; \n"
|
||||||
"varying vec2 v_tex_coord; \n"
|
|
||||||
"void main () { \n"
|
"void main () { \n"
|
||||||
" gl_Position = u_mvp_matrix * a_position; \n"
|
" gl_Position = u_mvp_matrix * a_position; \n"
|
||||||
" v_tex_coord = a_tex_coord; \n"
|
" v_tex_coord = a_tex_coord; \n"
|
||||||
|
@ -53,8 +54,11 @@ FGTextLayer::Init () {
|
||||||
const char F_Text_Layer_Shader_Str[] =
|
const char F_Text_Layer_Shader_Str[] =
|
||||||
#ifdef _GLES2
|
#ifdef _GLES2
|
||||||
"precision mediump float; \n"
|
"precision mediump float; \n"
|
||||||
#endif
|
|
||||||
"varying vec2 v_tex_coord; \n"
|
"varying vec2 v_tex_coord; \n"
|
||||||
|
#else
|
||||||
|
"#version 130 \n"
|
||||||
|
"in vec2 v_tex_coord; \n"
|
||||||
|
#endif
|
||||||
"uniform sampler2D u_texture; \n"
|
"uniform sampler2D u_texture; \n"
|
||||||
"uniform vec4 u_color; \n"
|
"uniform vec4 u_color; \n"
|
||||||
"void main () { \n"
|
"void main () { \n"
|
||||||
|
|
|
@ -31,8 +31,7 @@
|
||||||
|
|
||||||
#include "FGPanel.hxx"
|
#include "FGPanel.hxx"
|
||||||
|
|
||||||
class FGReadablePanel : public FGPanel
|
class FGReadablePanel : public FGPanel {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
// Subsystem identification.
|
// Subsystem identification.
|
||||||
static const char* staticSubsystemClassId() { return "readable-panel"; }
|
static const char* staticSubsystemClassId() { return "readable-panel"; }
|
||||||
|
|
Loading…
Reference in a new issue