Changes to get FlightGear (well, the src directory at least) to
configure and compile out-of-the-box on a MinGW target: Use -lSDL instead of -lglut32 on windows builds when --enable-sdl is set. Link against alut.dll in addition to openal32.dll. Replace BSD bcopy() with ANSI C memmove() in a few places. This is simpler than trying to abstract it out as a platform dependency in a header file; bcopy() has never been standard. The ENABLE_THREADS handling has changed to be set to 0 when threads are not in use. This breaks expressions like #ifdef ENABLE_THREADS. Replace with a slightly more complicated expression. It might have been better to fix the configure.ac script, but I didn't know how and this whole setting is likely to go away soon anyway. The MinGW C runtime actually does include snprintf, so only MSVC builds (and not all WIN32 ones) need _snprintf in JSBSim/FGState.cpp Building on a platform with no glut at all exposed some spots where plib/pu.h was being included without a toolkit setting (it defaults to glut). Include fg_os.hxx first. And when still using glut, glut.h has a bizarre dependency on a _WCHAR_T_DEFINED symbol. It it's not defined, it tries to redefine (!!) wchar_t to disasterous effect.
This commit is contained in:
parent
d2adabe676
commit
7ceb85d454
14 changed files with 37 additions and 28 deletions
13
configure.ac
13
configure.ac
|
@ -73,7 +73,7 @@ dnl Thread related checks
|
|||
# defaults to yes
|
||||
with_threads=yes
|
||||
AC_ARG_WITH(threads, [ --with-threads Include tile loading threads [default=yes]])
|
||||
if test "x$with_threads" = "xno"; then
|
||||
if test "x$with_threads" != "xyes"; then
|
||||
AC_DEFINE([ENABLE_THREADS], 0, [Define to enable threaded tile paging])
|
||||
else
|
||||
AC_DEFINE([ENABLE_THREADS], 1, [Define to enable threaded tile paging])
|
||||
|
@ -252,8 +252,13 @@ case "${host}" in
|
|||
AC_DEFINE([WIN32], 1, [Define for Win32 platforms])
|
||||
AC_DEFINE([NOMINMAX], 1, [Define for Win32 platforms])
|
||||
|
||||
LIBS="$LIBS -lglut32 -lglu32 -lopengl32"
|
||||
LIBS="$LIBS -luser32 -lgdi32"
|
||||
if test "x$enable_sdl" = "xyes"; then
|
||||
AC_SEARCH_LIBS(SDL_Init, SDL)
|
||||
else
|
||||
LIBS="$LIBS -lglut32"
|
||||
fi
|
||||
|
||||
LIBS="$LIBS -lglu32 -lopengl32 -luser32 -lgdi32"
|
||||
|
||||
dnl add -lwsock32 for mingwin
|
||||
case "${host}" in
|
||||
|
@ -319,7 +324,7 @@ case "${host}" in
|
|||
*-*-cygwin* | *-*-mingw32*)
|
||||
dnl CygWin under Windoze.
|
||||
|
||||
LIBS="$LIBS -lopenal32 -lwinmm -ldsound -ldxguid -lole32"
|
||||
LIBS="$LIBS -lalut -lopenal32 -lwinmm -ldsound -ldxguid -lole32"
|
||||
;;
|
||||
|
||||
*-apple-darwin*)
|
||||
|
|
|
@ -2272,7 +2272,7 @@ string FGTower::GenText(const string& m, int c) {
|
|||
int check = 0; // If mes gets overflowed the while loop can go infinite
|
||||
while ( strchr(&mes[0], crej) != NULL ) { // ie. loop until no more occurances of crej ('@') found
|
||||
pos = strchr( &mes[0], crej );
|
||||
bcopy(pos, &tag[0], 3);
|
||||
memmove(&tag[0], pos, 3);
|
||||
tag[3] = '\0';
|
||||
int i;
|
||||
len = 0;
|
||||
|
|
|
@ -174,7 +174,7 @@ string FGTransmissionList::gen_text(const atc_type &station, const TransCode cod
|
|||
int check = 0; // If mes gets overflowed the while loop can go infinite
|
||||
while ( strchr(&mes[0], crej) != NULL ) { // ie. loop until no more occurances of crej ('@') found
|
||||
pos = strchr( &mes[0], crej );
|
||||
bcopy(pos, &tag[0], 3);
|
||||
memmove(&tag[0], pos, 3);
|
||||
tag[3] = '\0';
|
||||
int i;
|
||||
len = 0;
|
||||
|
|
|
@ -325,7 +325,7 @@ FGMetarEnvironmentCtrl::FGMetarEnvironmentCtrl ()
|
|||
proxy_port( fgGetNode("/sim/presets/proxy/port", true) ),
|
||||
proxy_auth( fgGetNode("/sim/presets/proxy/authentication", true) )
|
||||
{
|
||||
#ifdef ENABLE_THREADS
|
||||
#if defined(ENABLE_THREADS) && ENABLE_THREADS
|
||||
thread = new MetarThread(this);
|
||||
thread->start();
|
||||
#endif // ENABLE_THREADS
|
||||
|
@ -333,7 +333,7 @@ FGMetarEnvironmentCtrl::FGMetarEnvironmentCtrl ()
|
|||
|
||||
FGMetarEnvironmentCtrl::~FGMetarEnvironmentCtrl ()
|
||||
{
|
||||
#ifdef ENABLE_THREADS
|
||||
#if defined(ENABLE_THREADS) && ENABLE_THREADS
|
||||
thread->cancel();
|
||||
thread->join();
|
||||
#endif // ENABLE_THREADS
|
||||
|
@ -461,7 +461,7 @@ FGMetarEnvironmentCtrl::update(double delta_time_sec)
|
|||
}
|
||||
}
|
||||
|
||||
#ifndef ENABLE_THREADS
|
||||
#if defined(ENABLE_THREADS) && ENABLE_THREADS
|
||||
// No loader thread running so manually fetch the data
|
||||
string id = "";
|
||||
while ( !request_queue.empty() ) {
|
||||
|
@ -643,7 +643,7 @@ FGMetarEnvironmentCtrl::update_metar_properties( SGMetar *m )
|
|||
}
|
||||
|
||||
|
||||
#ifdef ENABLE_THREADS
|
||||
#if defined(ENABLE_THREADS) && ENABLE_THREADS
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include <simgear/structure/subsystem_mgr.hxx>
|
||||
#include <simgear/environment/metar.hxx>
|
||||
|
||||
#ifdef ENABLE_THREADS
|
||||
#if defined(ENABLE_THREADS) && ENABLE_THREADS
|
||||
# include <simgear/threads/SGThread.hxx>
|
||||
# include <simgear/threads/SGQueue.hxx>
|
||||
#endif
|
||||
|
@ -183,7 +183,7 @@ private:
|
|||
|
||||
private:
|
||||
|
||||
#ifdef ENABLE_THREADS
|
||||
#if defined(ENABLE_THREADS) && ENABLE_THREADS
|
||||
/**
|
||||
* FIFO queue which holds a pointer to the fetched metar data.
|
||||
*/
|
||||
|
@ -205,7 +205,7 @@ private:
|
|||
queue < FGMetarResult > result_queue;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_THREADS
|
||||
#if defined(ENABLE_THREADS) && ENABLE_THREADS
|
||||
/**
|
||||
* This class represents the thread of execution responsible for
|
||||
* fetching the metar data.
|
||||
|
|
|
@ -47,7 +47,7 @@ INCLUDES
|
|||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifdef _MSC_VER
|
||||
#define snprintf _snprintf
|
||||
#endif
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
#include <string.h>
|
||||
#include <iostream>
|
||||
|
||||
#include <Main/fg_os.hxx> // To set toolkit for pu.h
|
||||
#include <plib/pu.h>
|
||||
#include <simgear/debug/logstream.hxx>
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <Main/fg_os.hxx>
|
||||
#include <plib/pu.h>
|
||||
|
||||
#include <simgear/compiler.h> // for SG_USING_STD
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <Main/fg_os.hxx> // To set toolkit for pu.h
|
||||
#include <plib/pu.h>
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
// The mac puts this in a weird location (GLUT/glut.h), so the
|
||||
// configure script detects the location and defines it as a macro.
|
||||
#define _WCHAR_T_DEFINED 1 // Glut needs this, or else it tries to
|
||||
// redefine it
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
# include FG_GLUT_H
|
||||
|
|
|
@ -40,7 +40,7 @@ extern ssgBranch *ground;
|
|||
*/
|
||||
FGTileLoader::FGTileLoader()
|
||||
{
|
||||
#ifdef ENABLE_THREADS
|
||||
#if defined(ENABLE_THREADS) && ENABLE_THREADS
|
||||
// Create and start the loader threads.
|
||||
for (int i = 0; i < MAX_THREADS; ++i)
|
||||
{
|
||||
|
@ -55,7 +55,7 @@ FGTileLoader::FGTileLoader()
|
|||
*/
|
||||
FGTileLoader::~FGTileLoader()
|
||||
{
|
||||
#ifdef ENABLE_THREADS
|
||||
#if defined(ENABLE_THREADS) && ENABLE_THREADS
|
||||
// Wake up its time to die.
|
||||
// queue_cond.broadcast();
|
||||
|
||||
|
@ -125,7 +125,7 @@ void
|
|||
FGTileLoader::update()
|
||||
{
|
||||
|
||||
#ifdef ENABLE_THREADS
|
||||
#if defined(ENABLE_THREADS) && ENABLE_THREADS
|
||||
// send a signal to the pager thread that it is allowed to load
|
||||
// another tile
|
||||
mutex.lock();
|
||||
|
@ -159,7 +159,7 @@ FGTileLoader::update()
|
|||
}
|
||||
|
||||
|
||||
#ifdef ENABLE_THREADS
|
||||
#if defined(ENABLE_THREADS) && ENABLE_THREADS
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include <simgear/bucket/newbucket.hxx>
|
||||
#include <simgear/misc/sg_path.hxx>
|
||||
|
||||
#ifdef ENABLE_THREADS
|
||||
#if defined(ENABLE_THREADS) && ENABLE_THREADS
|
||||
# include <simgear/threads/SGThread.hxx>
|
||||
# include <simgear/threads/SGQueue.hxx>
|
||||
#else
|
||||
|
@ -97,7 +97,7 @@ private:
|
|||
|
||||
private:
|
||||
|
||||
#ifdef ENABLE_THREADS
|
||||
#if defined(ENABLE_THREADS) && ENABLE_THREADS
|
||||
/**
|
||||
* FIFO queue of tiles to load from data files.
|
||||
*/
|
||||
|
@ -113,7 +113,7 @@ private:
|
|||
*/
|
||||
string tile_path;
|
||||
|
||||
#ifdef ENABLE_THREADS
|
||||
#if defined(ENABLE_THREADS) && ENABLE_THREADS
|
||||
/**
|
||||
* Maximum number of threads to create for loading tiles.
|
||||
*/
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
|
||||
#define TEST_LAST_HIT_CACHE
|
||||
|
||||
#ifdef ENABLE_THREADS
|
||||
#if defined(ENABLE_THREADS) && ENABLE_THREADS
|
||||
SGLockedQueue<FGTileEntry *> FGTileMgr::attach_queue;
|
||||
SGLockedQueue<FGDeferredModel *> FGTileMgr::model_queue;
|
||||
#else
|
||||
|
@ -90,7 +90,7 @@ int FGTileMgr::init() {
|
|||
}
|
||||
|
||||
while ( ! model_queue.empty() ) {
|
||||
#ifdef ENABLE_THREADS
|
||||
#if defined(ENABLE_THREADS) && ENABLE_THREADS
|
||||
FGDeferredModel* dm = model_queue.pop();
|
||||
#else
|
||||
FGDeferredModel* dm = model_queue.front();
|
||||
|
@ -275,7 +275,7 @@ void FGTileMgr::update_queues()
|
|||
if ( !model_queue.empty() ) {
|
||||
// cout << "loading next model ..." << endl;
|
||||
// load the next tile in the queue
|
||||
#ifdef ENABLE_THREADS
|
||||
#if defined(ENABLE_THREADS) && ENABLE_THREADS
|
||||
FGDeferredModel* dm = model_queue.pop();
|
||||
#else
|
||||
FGDeferredModel* dm = model_queue.front();
|
||||
|
@ -314,7 +314,7 @@ void FGTileMgr::update_queues()
|
|||
}
|
||||
|
||||
if ( !attach_queue.empty() ) {
|
||||
#ifdef ENABLE_THREADS
|
||||
#if defined(ENABLE_THREADS) && ENABLE_THREADS
|
||||
FGTileEntry* e = attach_queue.pop();
|
||||
#else
|
||||
FGTileEntry* e = attach_queue.front();
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
#include <plib/ssg.h>
|
||||
|
||||
#include <simgear/bucket/newbucket.hxx>
|
||||
#ifdef ENABLE_THREADS
|
||||
#if defined(ENABLE_THREADS) && ENABLE_THREADS
|
||||
# include <simgear/threads/SGQueue.hxx>
|
||||
#endif // ENABLE_THREADS
|
||||
|
||||
|
@ -119,7 +119,7 @@ private:
|
|||
* model_queue is the set of models that need to be loaded by the
|
||||
* primary render thread.
|
||||
*/
|
||||
#ifdef ENABLE_THREADS
|
||||
#if defined(ENABLE_THREADS) && ENABLE_THREADS
|
||||
static SGLockedQueue<FGTileEntry *> attach_queue;
|
||||
static SGLockedQueue<FGDeferredModel *> model_queue;
|
||||
#else
|
||||
|
|
Loading…
Add table
Reference in a new issue