TestSuite: Helper functions for setting up a dummy renderer and FGScenery.
This commit is contained in:
parent
3c9d3590d4
commit
112d64f828
3 changed files with 82 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
||||||
set(TESTSUITE_SOURCES
|
set(TESTSUITE_SOURCES
|
||||||
${TESTSUITE_SOURCES}
|
${TESTSUITE_SOURCES}
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/globals.cxx
|
${CMAKE_CURRENT_SOURCE_DIR}/globals.cxx
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/scene_graph.cxx
|
||||||
PARENT_SCOPE
|
PARENT_SCOPE
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -8,5 +9,6 @@ set(TESTSUITE_SOURCES
|
||||||
set(TESTSUITE_HEADERS
|
set(TESTSUITE_HEADERS
|
||||||
${TESTSUITE_HEADERS}
|
${TESTSUITE_HEADERS}
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/globals.hxx
|
${CMAKE_CURRENT_SOURCE_DIR}/globals.hxx
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/scene_graph.hxx
|
||||||
PARENT_SCOPE
|
PARENT_SCOPE
|
||||||
)
|
)
|
||||||
|
|
52
test_suite/helpers/scene_graph.cxx
Normal file
52
test_suite/helpers/scene_graph.cxx
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2018 Edward d'Auvergne
|
||||||
|
*
|
||||||
|
* This file is part of the program FlightGear.
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "scene_graph.hxx"
|
||||||
|
|
||||||
|
#include <Main/fg_props.hxx>
|
||||||
|
#include <Main/globals.hxx>
|
||||||
|
#include <Scenery/scenery.hxx>
|
||||||
|
#include <Viewer/renderer.hxx>
|
||||||
|
#include <Viewer/FGEventHandler.hxx>
|
||||||
|
|
||||||
|
|
||||||
|
namespace fgtest
|
||||||
|
{
|
||||||
|
|
||||||
|
void initScenery()
|
||||||
|
{
|
||||||
|
// Read the global defaults from $FG_ROOT/defaults.xml (needed by the renderer).
|
||||||
|
SGPath defaultsXML = globals->get_fg_root() / "defaults.xml";
|
||||||
|
if (!defaultsXML.exists())
|
||||||
|
SG_LOG(SG_GENERAL, SG_ALERT, "Cannot read the global defaults from \"" << defaultsXML.utf8Str() << "\".");
|
||||||
|
fgLoadProps("defaults.xml", globals->get_props());
|
||||||
|
|
||||||
|
// Set up the renderer.
|
||||||
|
osg::ref_ptr<osgViewer::Viewer> viewer = new osgViewer::Viewer;
|
||||||
|
FGRenderer* render = globals->get_renderer();
|
||||||
|
render->init();
|
||||||
|
render->setViewer(viewer.get());
|
||||||
|
|
||||||
|
// Start up the scenery subsystem.
|
||||||
|
globals->add_new_subsystem<FGScenery>(SGSubsystemMgr::DISPLAY);
|
||||||
|
globals->get_scenery()->init();
|
||||||
|
globals->get_scenery()->bind();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // of namespace fgtest
|
28
test_suite/helpers/scene_graph.hxx
Normal file
28
test_suite/helpers/scene_graph.hxx
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2018 Edward d'Auvergne
|
||||||
|
*
|
||||||
|
* This file is part of the program FlightGear.
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef FG_TEST_SCENE_GRAPH_HXX
|
||||||
|
#define FG_TEST_SCENE_GRAPH_HXX
|
||||||
|
|
||||||
|
namespace fgtest
|
||||||
|
{
|
||||||
|
void initScenery();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // FG_TEST_SCENE_GRAPH_HXX
|
Loading…
Add table
Reference in a new issue