Switch to using OBJECT library for main build
Allows sharing object files between the fgfs and test_suite targets, in a follow-up commit.
This commit is contained in:
parent
af329b794f
commit
33e205f123
14 changed files with 184 additions and 255 deletions
|
@ -298,7 +298,6 @@ endif (USE_DBUS)
|
|||
##############################################################################
|
||||
## Qt5 setup setup
|
||||
if (ENABLE_QT)
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
|
||||
find_package(Qt5 5.9 COMPONENTS Widgets Gui Network Qml Quick Svg)
|
||||
if (Qt5Widgets_FOUND)
|
||||
|
@ -312,6 +311,8 @@ if (ENABLE_QT)
|
|||
get_filename_component(FG_QT_ROOT_DIR ${FG_QT_BIN_DIR} DIRECTORY)
|
||||
endif()
|
||||
|
||||
set(CMAKE_AUTOMOC OFF)
|
||||
|
||||
message(STATUS "Qt GUI enabled, found Qt at: ${FG_QT_ROOT_DIR}")
|
||||
else()
|
||||
message(STATUS "Qt GUI disabled, Qt/qmake not found in PATH/CMAKE_PREFIX_PATH")
|
||||
|
@ -472,6 +473,24 @@ include_directories(${PROJECT_BINARY_DIR}/src/Include)
|
|||
include_directories(${PROJECT_BINARY_DIR}/src) # for version.h
|
||||
include_directories(${PROJECT_SOURCE_DIR}/src)
|
||||
|
||||
|
||||
#######################################################################
|
||||
|
||||
include(SetupFGFSIncludes)
|
||||
include(SetupFGFSLibraries)
|
||||
|
||||
# create an object library target to hold all our sources
|
||||
# subdirectories will append sources to this target, and we'll
|
||||
# link it into our real executable targets
|
||||
|
||||
add_library(fgfsObjects OBJECT)
|
||||
# Set up the include search paths for the object library
|
||||
setup_fgfs_libraries(fgfsObjects)
|
||||
setup_fgfs_includes(fgfsObjects)
|
||||
|
||||
########################################################################
|
||||
|
||||
|
||||
add_subdirectory(3rdparty)
|
||||
add_subdirectory(utils)
|
||||
|
||||
|
|
|
@ -6,14 +6,24 @@ macro(flightgear_component name sources)
|
|||
set_property(GLOBAL
|
||||
APPEND PROPERTY FG_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/${s}")
|
||||
set(fc "${fc}#${CMAKE_CURRENT_SOURCE_DIR}/${s}")
|
||||
|
||||
# becuase we can't require CMake 3.13, we can't use CMP0076
|
||||
# so we need to manually resolve relative paths into absolute paths
|
||||
target_sources(fgfsObjects PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/${s})
|
||||
|
||||
endforeach()
|
||||
|
||||
foreach(h ${ARGV2})
|
||||
set_property(GLOBAL
|
||||
APPEND PROPERTY FG_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/${h}")
|
||||
set(fh "${fh}#${CMAKE_CURRENT_SOURCE_DIR}/${h}")
|
||||
|
||||
# becuase we can't require CMake 3.13, we can't use CMP0076
|
||||
# so we need to manually resolve relative paths into absolute paths
|
||||
target_sources(fgfsObjects PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/${h})
|
||||
endforeach()
|
||||
|
||||
set_property(GLOBAL APPEND PROPERTY FG_GROUPS_C "${fc}@")
|
||||
set_property(GLOBAL APPEND PROPERTY FG_GROUPS_H "${fh}@")
|
||||
|
||||
endmacro()
|
||||
|
|
|
@ -9,4 +9,9 @@ function(setup_fgfs_includes target)
|
|||
# only actually needed for httpd.cxx
|
||||
target_include_directories(${target} PRIVATE ${PROJECT_SOURCE_DIR}/3rdparty/mongoose)
|
||||
|
||||
if (FG_QT_ROOT_DIR)
|
||||
# for QtPlatformHeaders
|
||||
target_include_directories(${target} PRIVATE ${FG_QT_ROOT_DIR}/include)
|
||||
endif()
|
||||
|
||||
endfunction()
|
||||
|
|
|
@ -1,9 +1,4 @@
|
|||
function(setup_fgfs_libraries target)
|
||||
get_property(FG_LIBS GLOBAL PROPERTY FG_LIBS)
|
||||
#message(STATUS "fg libs ${FG_LIBS}")
|
||||
#message(STATUS "OSG libs ${OPENSCENEGRAPH_LIBRARIES}")
|
||||
#message(STATUS "SG libs ${SIMGEAR_LIBRARIES}")
|
||||
|
||||
if(RTI_FOUND)
|
||||
set(HLA_LIBRARIES ${RTI_LDFLAGS})
|
||||
else()
|
||||
|
@ -54,9 +49,10 @@ function(setup_fgfs_libraries target)
|
|||
|
||||
target_link_libraries(${target} PLIBFont)
|
||||
|
||||
if (TARGET fglauncher)
|
||||
# FIXME : rewrite options.cxx / SetupRootDialog.hxx not
|
||||
# to require this dependency
|
||||
if (HAVE_QT)
|
||||
target_link_libraries(${target} Qt5::Core Qt5::Widgets fglauncher fgqmlui)
|
||||
set_property(TARGET ${target} PROPERTY AUTOMOC ON)
|
||||
endif()
|
||||
|
||||
if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
|
||||
|
@ -66,4 +62,8 @@ function(setup_fgfs_libraries target)
|
|||
if(${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
|
||||
target_link_libraries(${target} execinfo)
|
||||
endif()
|
||||
|
||||
if (TARGET sentry::sentry)
|
||||
target_link_libraries(${target} sentry::sentry)
|
||||
endif()
|
||||
endfunction()
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
|
||||
|
||||
# note order here affects link order, and hence linking correctness
|
||||
# on systems with a traditional ld (eg, GNU ld on Linux)
|
||||
foreach( mylibfolder
|
||||
|
|
|
@ -2,7 +2,7 @@ include(FlightGearComponent)
|
|||
|
||||
set(COMMON
|
||||
Airplane.cpp
|
||||
Atmosphere.cpp
|
||||
YASimAtmosphere.cpp
|
||||
ControlMap.cpp
|
||||
ElectricEngine.cpp
|
||||
FGFDM.cpp
|
||||
|
|
|
@ -573,13 +573,18 @@ void QQuickDrawable::drawImplementation(osg::RenderInfo& renderInfo) const
|
|||
d->quickWindow->resetOpenGLState();
|
||||
}
|
||||
|
||||
void QQuickDrawable::reload(QUrl url)
|
||||
void QQuickDrawable::reload(const QUrl& url)
|
||||
{
|
||||
d->qmlEngine->clearComponentCache();
|
||||
setSource(url);
|
||||
}
|
||||
|
||||
void QQuickDrawable::setSource(QUrl url)
|
||||
void QQuickDrawable::setSourcePath(const std::string& path)
|
||||
{
|
||||
setSource(QUrl::fromLocalFile(QString::fromStdString(path)));
|
||||
}
|
||||
|
||||
void QQuickDrawable::setSource(const QUrl& url)
|
||||
{
|
||||
if (d->rootItem)
|
||||
delete d->rootItem;
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
|
||||
#include <memory>
|
||||
#include <osg/Drawable>
|
||||
#include <QUrl>
|
||||
|
||||
#include <osgViewer/GraphicsWindow>
|
||||
|
||||
|
@ -29,6 +28,7 @@ namespace osgViewer {
|
|||
class Viewer;
|
||||
}
|
||||
|
||||
class QUrl;
|
||||
class QQuickDrawablePrivate;
|
||||
|
||||
class QQuickDrawable : public osg::Drawable
|
||||
|
@ -44,9 +44,10 @@ public:
|
|||
|
||||
void setup(osgViewer::GraphicsWindow* gw, osgViewer::Viewer* viewer);
|
||||
|
||||
void setSource(QUrl url);
|
||||
void setSourcePath(const std::string& path);
|
||||
void setSource(const QUrl& url);
|
||||
|
||||
void reload(QUrl url);
|
||||
void reload(const QUrl& url);
|
||||
|
||||
void resize(int width, int height);
|
||||
|
||||
|
|
|
@ -70,9 +70,9 @@ setup_msvc_grouping()
|
|||
|
||||
|
||||
|
||||
# All sources and headers to be built into fgfs.
|
||||
get_property(FG_SOURCES GLOBAL PROPERTY FG_SOURCES)
|
||||
get_property(FG_HEADERS GLOBAL PROPERTY FG_HEADERS)
|
||||
# # All sources and headers to be built into fgfs.
|
||||
# get_property(FG_SOURCES GLOBAL PROPERTY FG_SOURCES)
|
||||
# get_property(FG_HEADERS GLOBAL PROPERTY FG_HEADERS)
|
||||
|
||||
# important we pass WIN32 here so the console is optional. Other
|
||||
# platforms ignore this option. If a console is needed we allocate
|
||||
|
@ -82,8 +82,7 @@ add_executable(fgfs
|
|||
WIN32
|
||||
MACOSX_BUNDLE
|
||||
${MAIN_SOURCE}
|
||||
${FG_SOURCES}
|
||||
${FG_HEADERS}
|
||||
$<TARGET_OBJECTS:fgfsObjects>
|
||||
)
|
||||
|
||||
add_dependencies(fgfs buildId)
|
||||
|
@ -108,16 +107,13 @@ else()
|
|||
install(TARGETS fgfs RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
endif()
|
||||
|
||||
if (TARGET sentry::sentry)
|
||||
target_link_libraries(fgfs sentry::sentry)
|
||||
endif()
|
||||
|
||||
if(ENABLE_METAR)
|
||||
add_executable(metar metar_main.cxx)
|
||||
target_link_libraries(metar SimGearScene)
|
||||
install(TARGETS metar RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
endif()
|
||||
|
||||
# ensure run/debug paths are set automatically in Visual Studio
|
||||
if (MSVC)
|
||||
file(TO_NATIVE_PATH "${FG_QT_BIN_DIR}" _qt5_bin_dir_native)
|
||||
file(TO_NATIVE_PATH "${FINAL_MSVC_3RDPARTY_DIR}/bin" _msvc_3rdparty_bin_dir)
|
||||
|
@ -125,9 +121,4 @@ if (MSVC)
|
|||
|
||||
set_property(TARGET fgfs PROPERTY
|
||||
VS_GLOBAL_LocalDebuggerEnvironment "PATH=${_install_bin_dir};${_msvc_3rdparty_bin_dir};${_qt5_bin_dir_native}")
|
||||
endif()
|
||||
|
||||
if (FG_QT_ROOT_DIR)
|
||||
# for QtPlatformHeaders
|
||||
target_include_directories(fgfs PRIVATE ${FG_QT_ROOT_DIR}/include)
|
||||
endif()
|
||||
endif()
|
|
@ -31,10 +31,8 @@ set(HEADERS
|
|||
)
|
||||
|
||||
if (Qt5Core_FOUND)
|
||||
list(APPEND HEADERS GraphicsWindowQt5.hxx
|
||||
OSGQtAdaption.hxx)
|
||||
list(APPEND SOURCES GraphicsWindowQt5.cpp
|
||||
OSGQtAdaption.cxx)
|
||||
list(APPEND HEADERS OSGQtAdaption.hxx)
|
||||
list(APPEND SOURCES OSGQtAdaption.cxx)
|
||||
endif()
|
||||
|
||||
if (YES)
|
||||
|
|
|
@ -30,11 +30,6 @@
|
|||
#include <osgViewer/api/Cocoa/GraphicsWindowCocoa>
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_QT)
|
||||
#include "GraphicsWindowQt5.hxx"
|
||||
#endif
|
||||
|
||||
|
||||
using namespace std;
|
||||
using namespace osg;
|
||||
|
||||
|
@ -62,9 +57,6 @@ void WindowBuilder::initWindowBuilder(bool stencil)
|
|||
|
||||
WindowBuilder::WindowBuilder(bool stencil) : defaultCounter(0)
|
||||
{
|
||||
#if defined (HAVE_QT)
|
||||
usingQtGraphicsWindow = fgGetBool("/sim/rendering/graphics-window-qt", false);
|
||||
#endif
|
||||
makeDefaultTraits(stencil);
|
||||
}
|
||||
|
||||
|
@ -107,58 +99,32 @@ void WindowBuilder::makeDefaultTraits(bool stencil)
|
|||
traits->vsync = fgGetBool("/sim/rendering/vsync-enable", traits->vsync);
|
||||
|
||||
const bool wantFullscreen = fgGetBool("/sim/startup/fullscreen");
|
||||
if (usingQtGraphicsWindow) {
|
||||
#if defined(HAVE_QT)
|
||||
// fullscreen is handled by Qt natively
|
||||
// we will check and set fullscreen mode when building
|
||||
// the window instance
|
||||
auto data = new GraphicsWindowQt5::WindowData;
|
||||
data->createFullscreen = wantFullscreen;
|
||||
data->isPrimaryWindow = true;
|
||||
|
||||
#if OSG_VERSION_GREATER_THAN(3, 5, 9)
|
||||
traits->windowingSystemPreference = "FlightGearQt5";
|
||||
#endif
|
||||
traits->inheritedWindowData = data;
|
||||
traits->windowDecoration = true;
|
||||
traits->supportsResize = true;
|
||||
traits->width = fgGetInt("/sim/startup/xsize");
|
||||
traits->height = fgGetInt("/sim/startup/ysize");
|
||||
|
||||
// these are marker values to tell GraphicsWindowQt5 to use default x/y
|
||||
traits->x = std::numeric_limits<int>::max();
|
||||
traits->y = std::numeric_limits<int>::max();
|
||||
#else
|
||||
SG_LOG(SG_VIEW,SG_ALERT,"requested Qt GraphicsWindow in non-Qt build");
|
||||
#endif
|
||||
unsigned screenwidth = 0;
|
||||
unsigned screenheight = 0;
|
||||
// this is a deprecated method, should be screen-aware.
|
||||
wsi->getScreenResolution(*traits, screenwidth, screenheight);
|
||||
|
||||
// handle fullscreen manually
|
||||
traits->windowDecoration = !wantFullscreen;
|
||||
if (!traits->windowDecoration) {
|
||||
// fullscreen
|
||||
traits->supportsResize = false;
|
||||
traits->width = screenwidth;
|
||||
traits->height = screenheight;
|
||||
SG_LOG(SG_VIEW,SG_DEBUG,"Using full screen size for window: " << screenwidth << " x " << screenheight);
|
||||
} else {
|
||||
unsigned screenwidth = 0;
|
||||
unsigned screenheight = 0;
|
||||
// this is a deprecated method, should be screen-aware.
|
||||
wsi->getScreenResolution(*traits, screenwidth, screenheight);
|
||||
|
||||
// handle fullscreen manually
|
||||
traits->windowDecoration = !wantFullscreen;
|
||||
if (!traits->windowDecoration) {
|
||||
// fullscreen
|
||||
traits->supportsResize = false;
|
||||
traits->width = screenwidth;
|
||||
traits->height = screenheight;
|
||||
SG_LOG(SG_VIEW,SG_DEBUG,"Using full screen size for window: " << screenwidth << " x " << screenheight);
|
||||
} else {
|
||||
// window
|
||||
int w = fgGetInt("/sim/startup/xsize");
|
||||
int h = fgGetInt("/sim/startup/ysize");
|
||||
traits->supportsResize = true;
|
||||
traits->width = w;
|
||||
traits->height = h;
|
||||
if ((w>0)&&(h>0))
|
||||
{
|
||||
traits->x = ((unsigned)w>screenwidth) ? 0 : (screenwidth-w)/3;
|
||||
traits->y = ((unsigned)h>screenheight) ? 0 : (screenheight-h)/3;
|
||||
}
|
||||
SG_LOG(SG_VIEW,SG_DEBUG,"Using initial window size: " << w << " x " << h);
|
||||
// window
|
||||
int w = fgGetInt("/sim/startup/xsize");
|
||||
int h = fgGetInt("/sim/startup/ysize");
|
||||
traits->supportsResize = true;
|
||||
traits->width = w;
|
||||
traits->height = h;
|
||||
if ((w>0)&&(h>0))
|
||||
{
|
||||
traits->x = ((unsigned)w>screenwidth) ? 0 : (screenwidth-w)/3;
|
||||
traits->y = ((unsigned)h>screenheight) ? 0 : (screenheight-h)/3;
|
||||
}
|
||||
SG_LOG(SG_VIEW,SG_DEBUG,"Using initial window size: " << w << " x " << h);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -212,61 +178,35 @@ void WindowBuilder::setFullscreenTraits(const SGPropertyNode* winNode, GraphicsC
|
|||
bool overrideRedirect = orrNode && orrNode->getBoolValue();
|
||||
traits->overrideRedirect = overrideRedirect;
|
||||
|
||||
#if defined(HAVE_QT)
|
||||
if (usingQtGraphicsWindow) {
|
||||
auto data = new GraphicsWindowQt5::WindowData;
|
||||
data->createFullscreen = true;
|
||||
traits->inheritedWindowData = data;
|
||||
traits->windowDecoration = winNode->getBoolValue("decoration");
|
||||
} else
|
||||
#endif
|
||||
// this codepath is mandatory on non-Qt builds
|
||||
{
|
||||
traits->windowDecoration = false;
|
||||
|
||||
unsigned int width = 0;
|
||||
unsigned int height = 0;
|
||||
auto wsi = osg::GraphicsContext::getWindowingSystemInterface();
|
||||
wsi->getScreenResolution(*traits, width, height);
|
||||
traits->width = width;
|
||||
traits->height = height;
|
||||
traits->supportsResize = false;
|
||||
traits->x = 0;
|
||||
traits->y = 0;
|
||||
}
|
||||
traits->windowDecoration = false;
|
||||
|
||||
unsigned int width = 0;
|
||||
unsigned int height = 0;
|
||||
auto wsi = osg::GraphicsContext::getWindowingSystemInterface();
|
||||
wsi->getScreenResolution(*traits, width, height);
|
||||
traits->width = width;
|
||||
traits->height = height;
|
||||
traits->supportsResize = false;
|
||||
traits->x = 0;
|
||||
traits->y = 0;
|
||||
}
|
||||
|
||||
bool WindowBuilder::setWindowedTraits(const SGPropertyNode* winNode, GraphicsContext::Traits* traits)
|
||||
{
|
||||
bool customTraits = false;
|
||||
#if defined(HAVE_QT)
|
||||
if (usingQtGraphicsWindow) {
|
||||
if (winNode->hasValue("fullscreen")) {
|
||||
auto data = new GraphicsWindowQt5::WindowData;
|
||||
data->createFullscreen = false;
|
||||
traits->inheritedWindowData = data;
|
||||
customTraits = true;
|
||||
}
|
||||
customTraits |= setFromProperty(traits->windowDecoration, winNode, "decoration");
|
||||
customTraits |= setFromProperty(traits->width, winNode, "width");
|
||||
customTraits |= setFromProperty(traits->height, winNode, "height");
|
||||
} else
|
||||
#endif
|
||||
int resizable = 0;
|
||||
const SGPropertyNode* fullscreenNode = winNode->getNode("fullscreen");
|
||||
if (fullscreenNode && !fullscreenNode->getBoolValue())
|
||||
{
|
||||
int resizable = 0;
|
||||
const SGPropertyNode* fullscreenNode = winNode->getNode("fullscreen");
|
||||
if (fullscreenNode && !fullscreenNode->getBoolValue())
|
||||
{
|
||||
traits->windowDecoration = true;
|
||||
resizable = 1;
|
||||
}
|
||||
resizable |= setFromProperty(traits->windowDecoration, winNode, "decoration");
|
||||
resizable |= setFromProperty(traits->width, winNode, "width");
|
||||
resizable |= setFromProperty(traits->height, winNode, "height");
|
||||
if (resizable) {
|
||||
traits->supportsResize = true;
|
||||
customTraits = true;
|
||||
}
|
||||
traits->windowDecoration = true;
|
||||
resizable = 1;
|
||||
}
|
||||
resizable |= setFromProperty(traits->windowDecoration, winNode, "decoration");
|
||||
resizable |= setFromProperty(traits->width, winNode, "width");
|
||||
resizable |= setFromProperty(traits->height, winNode, "height");
|
||||
if (resizable) {
|
||||
traits->supportsResize = true;
|
||||
customTraits = true;
|
||||
}
|
||||
|
||||
return customTraits;
|
||||
|
@ -275,18 +215,16 @@ bool WindowBuilder::setWindowedTraits(const SGPropertyNode* winNode, GraphicsCon
|
|||
void WindowBuilder::setMacPoseAsStandaloneApp(GraphicsContext::Traits* traits)
|
||||
{
|
||||
#if defined(SG_MAC)
|
||||
if (!usingQtGraphicsWindow) {
|
||||
// this logic is unecessary if using a Qt window, since everything
|
||||
// plays together nicely
|
||||
int flags = osgViewer::GraphicsWindowCocoa::WindowData::CheckForEvents;
|
||||
|
||||
// avoid both QApplication and OSG::CocoaViewer doing single-application
|
||||
// init (Apple menu, making front process, etc)
|
||||
if (poseAsStandaloneApp) {
|
||||
flags |= osgViewer::GraphicsWindowCocoa::WindowData::PoseAsStandaloneApp;
|
||||
}
|
||||
traits->inheritedWindowData = new osgViewer::GraphicsWindowCocoa::WindowData(flags);
|
||||
// this logic is unecessary if using a Qt window, since everything
|
||||
// plays together nicely
|
||||
int flags = osgViewer::GraphicsWindowCocoa::WindowData::CheckForEvents;
|
||||
|
||||
// avoid both QApplication and OSG::CocoaViewer doing single-application
|
||||
// init (Apple menu, making front process, etc)
|
||||
if (poseAsStandaloneApp) {
|
||||
flags |= osgViewer::GraphicsWindowCocoa::WindowData::PoseAsStandaloneApp;
|
||||
}
|
||||
traits->inheritedWindowData = new osgViewer::GraphicsWindowCocoa::WindowData(flags);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -331,14 +269,6 @@ GraphicsWindow* WindowBuilder::buildWindow(const SGPropertyNode* winNode)
|
|||
bool drawGUI = false;
|
||||
traitsSet |= setFromProperty(drawGUI, winNode, "gui");
|
||||
if (traitsSet) {
|
||||
#if defined (HAVE_QT)
|
||||
if (usingQtGraphicsWindow) {
|
||||
// this assumes the user only sets the 'gui' flag on one window, not ideal
|
||||
auto data = static_cast<GraphicsWindowQt5::WindowData*>(traits->inheritedWindowData.get());
|
||||
data->isPrimaryWindow = drawGUI;
|
||||
}
|
||||
#endif
|
||||
|
||||
GraphicsContext* gc = GraphicsContext::createGraphicsContext(traits);
|
||||
if (gc) {
|
||||
GraphicsWindow* window = WindowSystemAdapter::getWSA()
|
||||
|
|
|
@ -56,12 +56,6 @@
|
|||
#include "WindowSystemAdapter.hxx"
|
||||
#include <Main/sentryIntegration.hxx>
|
||||
|
||||
#if defined(HAVE_QT)
|
||||
#include "GraphicsWindowQt5.hxx"
|
||||
#include <GUI/QtLauncher.hxx>
|
||||
#include <QCoreApplication>
|
||||
#endif
|
||||
|
||||
#if defined(SG_MAC)
|
||||
# include <GUI/CocoaHelpers.h>
|
||||
#endif
|
||||
|
@ -108,8 +102,6 @@ using namespace osg;
|
|||
|
||||
osg::ref_ptr<osgViewer::Viewer> viewer;
|
||||
|
||||
bool global_usingGraphicsWindowQt = false;
|
||||
|
||||
static void setStereoMode( const char * mode )
|
||||
{
|
||||
DisplaySettings::StereoMode stereoMode = DisplaySettings::QUAD_BUFFER;
|
||||
|
@ -421,17 +413,9 @@ void fgWarpMouse(int x, int y)
|
|||
|
||||
void fgOSInit(int* argc, char** argv)
|
||||
{
|
||||
#if defined(HAVE_QT)
|
||||
global_usingGraphicsWindowQt = fgGetBool("/sim/rendering/graphics-window-qt", false);
|
||||
if (global_usingGraphicsWindowQt) {
|
||||
SG_LOG(SG_GL, SG_INFO, "Using Qt implementation of GraphicsWindow");
|
||||
flightgear::initQtWindowingSystem();
|
||||
} else {
|
||||
// stock OSG windows are not Hi-DPI aware
|
||||
fgSetDouble("/sim/rendering/gui-pixel-ratio", 1.0);
|
||||
SG_LOG(SG_GL, SG_INFO, "Using stock OSG implementation of GraphicsWindow");
|
||||
}
|
||||
#endif
|
||||
// stock OSG windows are not Hi-DPI aware
|
||||
fgSetDouble("/sim/rendering/gui-pixel-ratio", 1.0);
|
||||
|
||||
#if defined(SG_MAC)
|
||||
cocoaRegisterTerminateHandler();
|
||||
#endif
|
||||
|
@ -472,91 +456,77 @@ void fgOSFullScreen()
|
|||
* The other windows should use fixed setup from the camera.xml file anyway. */
|
||||
osgViewer::GraphicsWindow* window = windows[0];
|
||||
|
||||
#if defined(HAVE_QT)
|
||||
if (global_usingGraphicsWindowQt) {
|
||||
const bool wasFullscreen = fgGetBool("/sim/startup/fullscreen");
|
||||
auto qtWin = static_cast<flightgear::GraphicsWindowQt5*>(window);
|
||||
qtWin->setFullscreen(!wasFullscreen);
|
||||
fgSetBool("/sim/startup/fullscreen", !wasFullscreen);
|
||||
|
||||
// FIXME tell lies here for HiDPI sizing?
|
||||
fgSetInt("/sim/startup/xsize", qtWin->getGLWindow()->width());
|
||||
fgSetInt("/sim/startup/ysize", qtWin->getGLWindow()->height());
|
||||
} else
|
||||
#endif
|
||||
osg::GraphicsContext::WindowingSystemInterface *wsi = osg::GraphicsContext::getWindowingSystemInterface();
|
||||
if (wsi == NULL)
|
||||
{
|
||||
osg::GraphicsContext::WindowingSystemInterface *wsi = osg::GraphicsContext::getWindowingSystemInterface();
|
||||
if (wsi == NULL)
|
||||
{
|
||||
SG_LOG(SG_VIEW, SG_ALERT, "ERROR: No WindowSystemInterface available. Cannot toggle window fullscreen.");
|
||||
return;
|
||||
}
|
||||
SG_LOG(SG_VIEW, SG_ALERT, "ERROR: No WindowSystemInterface available. Cannot toggle window fullscreen.");
|
||||
return;
|
||||
}
|
||||
|
||||
static int previous_x = 0;
|
||||
static int previous_y = 0;
|
||||
static int previous_width = 800;
|
||||
static int previous_height = 600;
|
||||
static int previous_x = 0;
|
||||
static int previous_y = 0;
|
||||
static int previous_width = 800;
|
||||
static int previous_height = 600;
|
||||
|
||||
unsigned int screenWidth;
|
||||
unsigned int screenHeight;
|
||||
wsi->getScreenResolution(*(window->getTraits()), screenWidth, screenHeight);
|
||||
unsigned int screenWidth;
|
||||
unsigned int screenHeight;
|
||||
wsi->getScreenResolution(*(window->getTraits()), screenWidth, screenHeight);
|
||||
|
||||
int x;
|
||||
int y;
|
||||
int width;
|
||||
int height;
|
||||
window->getWindowRectangle(x, y, width, height);
|
||||
int x;
|
||||
int y;
|
||||
int width;
|
||||
int height;
|
||||
window->getWindowRectangle(x, y, width, height);
|
||||
|
||||
/* Note: the simple "is window size == screen size" check to detect full screen state doesn't work with
|
||||
* X screen servers in Xinerama mode, since the reported screen width (or height) exceeds the maximum width
|
||||
* (or height) usable by a single window (Xserver automatically shrinks/moves the full screen window to fit a
|
||||
* single display) - so we detect full screen mode using "WindowDecoration" state instead.
|
||||
* "false" - even when a single window is display in fullscreen */
|
||||
//bool isFullScreen = x == 0 && y == 0 && width == (int)screenWidth && height == (int)screenHeight;
|
||||
bool isFullScreen = !window->getWindowDecoration();
|
||||
/* Note: the simple "is window size == screen size" check to detect full screen state doesn't work with
|
||||
* X screen servers in Xinerama mode, since the reported screen width (or height) exceeds the maximum width
|
||||
* (or height) usable by a single window (Xserver automatically shrinks/moves the full screen window to fit a
|
||||
* single display) - so we detect full screen mode using "WindowDecoration" state instead.
|
||||
* "false" - even when a single window is display in fullscreen */
|
||||
//bool isFullScreen = x == 0 && y == 0 && width == (int)screenWidth && height == (int)screenHeight;
|
||||
bool isFullScreen = !window->getWindowDecoration();
|
||||
|
||||
SG_LOG(SG_VIEW, SG_DEBUG, "Toggling fullscreen. Previous window rectangle ("
|
||||
<< x << ", " << y << ") x (" << width << ", " << height << "), fullscreen: " << isFullScreen
|
||||
<< ", number of screens: " << wsi->getNumScreens());
|
||||
if (isFullScreen)
|
||||
{
|
||||
// limit x,y coordinates and window size to screen area
|
||||
if (previous_x + previous_width > (int)screenWidth)
|
||||
previous_x = 0;
|
||||
if (previous_y + previous_height > (int)screenHeight)
|
||||
previous_y = 0;
|
||||
SG_LOG(SG_VIEW, SG_DEBUG, "Toggling fullscreen. Previous window rectangle ("
|
||||
<< x << ", " << y << ") x (" << width << ", " << height << "), fullscreen: " << isFullScreen
|
||||
<< ", number of screens: " << wsi->getNumScreens());
|
||||
if (isFullScreen)
|
||||
{
|
||||
// limit x,y coordinates and window size to screen area
|
||||
if (previous_x + previous_width > (int)screenWidth)
|
||||
previous_x = 0;
|
||||
if (previous_y + previous_height > (int)screenHeight)
|
||||
previous_y = 0;
|
||||
|
||||
// disable fullscreen mode, restore previous window size/coordinates
|
||||
x = previous_x;
|
||||
y = previous_y;
|
||||
width = previous_width;
|
||||
height = previous_height;
|
||||
}
|
||||
else
|
||||
{
|
||||
// remember previous setting
|
||||
previous_x = x;
|
||||
previous_y = y;
|
||||
previous_width = width;
|
||||
previous_height = height;
|
||||
// disable fullscreen mode, restore previous window size/coordinates
|
||||
x = previous_x;
|
||||
y = previous_y;
|
||||
width = previous_width;
|
||||
height = previous_height;
|
||||
}
|
||||
else
|
||||
{
|
||||
// remember previous setting
|
||||
previous_x = x;
|
||||
previous_y = y;
|
||||
previous_width = width;
|
||||
previous_height = height;
|
||||
|
||||
// enable fullscreen mode, set new width/height
|
||||
x = 0;
|
||||
y = 0;
|
||||
width = screenWidth;
|
||||
height = screenHeight;
|
||||
}
|
||||
// enable fullscreen mode, set new width/height
|
||||
x = 0;
|
||||
y = 0;
|
||||
width = screenWidth;
|
||||
height = screenHeight;
|
||||
}
|
||||
|
||||
// set xsize/ysize properties to adapt GUI planes
|
||||
fgSetInt("/sim/startup/xsize", width);
|
||||
fgSetInt("/sim/startup/ysize", height);
|
||||
fgSetBool("/sim/startup/fullscreen", !isFullScreen);
|
||||
// set xsize/ysize properties to adapt GUI planes
|
||||
fgSetInt("/sim/startup/xsize", width);
|
||||
fgSetInt("/sim/startup/ysize", height);
|
||||
fgSetBool("/sim/startup/fullscreen", !isFullScreen);
|
||||
|
||||
// reconfigure window
|
||||
window->setWindowDecoration(isFullScreen);
|
||||
window->setWindowRectangle(x, y, width, height);
|
||||
window->grabFocusIfPointerInWindow();
|
||||
} // of stock GraphicsWindow verison (OSG has no native fullscreen mode)
|
||||
// reconfigure window
|
||||
window->setWindowDecoration(isFullScreen);
|
||||
window->setWindowRectangle(x, y, width, height);
|
||||
window->grabFocusIfPointerInWindow();
|
||||
}
|
||||
|
||||
static void setMouseCursor(osgViewer::GraphicsWindow* gw, int cursor)
|
||||
|
|
|
@ -726,8 +726,7 @@ FGRenderer::setupView( void )
|
|||
if (!rootQMLPath.empty()) {
|
||||
_quickDrawable = new QQuickDrawable;
|
||||
_quickDrawable->setup(graphicsWindow, viewer);
|
||||
|
||||
_quickDrawable->setSource(QUrl::fromLocalFile(QString::fromStdString(rootQMLPath)));
|
||||
_quickDrawable->setSourcePath(rootQMLPath);
|
||||
|
||||
osg::Geode* qqGeode = new osg::Geode;
|
||||
qqGeode->addDrawable(_quickDrawable);
|
||||
|
|
Loading…
Add table
Reference in a new issue