Compare commits
18 Commits
v2.0.0-rc1
...
master-201
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
11479cd8c3 | ||
|
|
176e760de1 | ||
|
|
430c60ed1a | ||
|
|
dfea3623f6 | ||
|
|
b38783e4cb | ||
|
|
9382a4c21b | ||
|
|
3cd4c5566f | ||
|
|
601c0977df | ||
|
|
c56f036bab | ||
|
|
44dd50c0ef | ||
|
|
56919ae45f | ||
|
|
578af00b0d | ||
|
|
d6c0bf69b6 | ||
|
|
e8884b4ec0 | ||
|
|
5e79609955 | ||
|
|
4950c96f1c | ||
|
|
51b0cf535e | ||
|
|
4cc17a7f6e |
28
configure.ac
28
configure.ac
@@ -144,6 +144,15 @@ AC_ARG_WITH(osg_framework, [ --with-osg-framework=PREFIX Specify the prefix
|
||||
|
||||
if test "x$with_osg_framework" != "x"; then
|
||||
echo "osg framework prefix is $with_osg_framework"
|
||||
CPPFLAGS = "$CPPFLAGS -F$with-osg-framework"
|
||||
export DYLD_FRAMEWORK_PATH="$DYLD_FRAMEWORK_PATH:$with_osg_framework"
|
||||
fi
|
||||
|
||||
dnl specifying OpenAL.framework (for user provided OpenAL.framework / ALUT)
|
||||
AC_ARG_WITH(openal_framework, [ --with-openal-framework=PREFIX Speicfy the prefix path to OpenAL.framework ])
|
||||
|
||||
if test "x$with_openal_framework" != "x"; then
|
||||
echo "OpenAL framework prefix is $with_openal_framework"
|
||||
fi
|
||||
|
||||
dnl Determine an extra directories to add to include/lib search paths
|
||||
@@ -305,9 +314,18 @@ case "${host}" in
|
||||
|
||||
LIBS="$LIBS -framework IOKit -framework OpenAL"
|
||||
openal_LIBS="$LIBS"
|
||||
# not sure how to test if OpenAL exists on MacOS (does it come by default?)
|
||||
OPENAL_OK="yes"
|
||||
ALUT_OK="yes"
|
||||
ALUT_OK="no"
|
||||
|
||||
if test "x$with_openal_lib" != "x"; then
|
||||
echo "libopenal is not supported on Mac OS platform."
|
||||
openal_LIBS=""
|
||||
fi
|
||||
OPENAL_OK="yes"
|
||||
# Looking for alut.h, if found assume that it is a part of
|
||||
# the OpenAL package.
|
||||
AC_CHECK_HEADERS([OpenAL/alut.h],[ALUT_OK="yes"])
|
||||
|
||||
|
||||
dnl Thank you Christian Bauer from SheepSaver
|
||||
dnl Modified by Tatsuhiro Nishioka for accepting a given framework path
|
||||
@@ -338,6 +356,12 @@ case "${host}" in
|
||||
AS_VAR_POPDEF([ac_Framework])dnl
|
||||
])
|
||||
|
||||
dnl Check for OpenAL.framework when --with-openal-framework is specified
|
||||
dnl Of cource OpenAL.framework needs to have alut.h
|
||||
if test "x$with_openal_framework" != "x"; then
|
||||
AC_CHECK_FRAMEWORK(OpenAL, [#include <OpenAL/alut.h>], $with_openal_framework)
|
||||
fi
|
||||
|
||||
;;
|
||||
|
||||
*)
|
||||
|
||||
@@ -540,7 +540,7 @@ SGGeodesy::courseRad(const SGGeoc& from, const SGGeoc& to)
|
||||
}
|
||||
|
||||
double
|
||||
SGGeodesy::distanceM(const SGGeoc& from, const SGGeoc& to)
|
||||
SGGeodesy::distanceRad(const SGGeoc& from, const SGGeoc& to)
|
||||
{
|
||||
// d = 2*asin(sqrt((sin((lat1-lat2)/2))^2 +
|
||||
// cos(lat1)*cos(lat2)*(sin((lon1-lon2)/2))^2))
|
||||
@@ -550,5 +550,12 @@ SGGeodesy::distanceM(const SGGeoc& from, const SGGeoc& to)
|
||||
double tmp2 = sin(0.5*(from.getLongitudeRad() - to.getLongitudeRad()));
|
||||
double square = tmp1*tmp1 + cosLatFrom*cosLatTo*tmp2*tmp2;
|
||||
double s = SGMiscd::min(sqrt(SGMiscd::max(square, 0)), 1);
|
||||
return 2 * asin(s) * SG_RAD_TO_NM * SG_NM_TO_METER;
|
||||
return 2 * asin(s);
|
||||
}
|
||||
|
||||
|
||||
double
|
||||
SGGeodesy::distanceM(const SGGeoc& from, const SGGeoc& to)
|
||||
{
|
||||
return distanceRad(from, to) * SG_RAD_TO_NM * SG_NM_TO_METER;
|
||||
}
|
||||
|
||||
@@ -61,6 +61,7 @@ public:
|
||||
static void advanceRadM(const SGGeoc& geoc, double course, double distance,
|
||||
SGGeoc& result);
|
||||
static double courseRad(const SGGeoc& from, const SGGeoc& to);
|
||||
static double distanceRad(const SGGeoc& from, const SGGeoc& to);
|
||||
static double distanceM(const SGGeoc& from, const SGGeoc& to);
|
||||
};
|
||||
|
||||
|
||||
@@ -69,7 +69,6 @@ EffectMap effectMap;
|
||||
|
||||
double SGNewCloud::sprite_density = 1.0;
|
||||
|
||||
|
||||
SGNewCloud::SGNewCloud(string type,
|
||||
const SGPath &tex_path,
|
||||
string tex,
|
||||
@@ -214,7 +213,7 @@ osg::ref_ptr<EffectGeode> SGNewCloud::genCloud() {
|
||||
z = height * cos(elev) * 0.5f;
|
||||
}
|
||||
|
||||
// Determine the height and width as scaling factors on the minimum size (used to create the quad)
|
||||
// Determine the height and width as scaling factors on the minimum size (used to create the quad).
|
||||
float sprite_width = 1.0f + sg_random() * (max_sprite_width - min_sprite_width) / min_sprite_width;
|
||||
float sprite_height = 1.0f + sg_random() * (max_sprite_height - min_sprite_height) / min_sprite_height;
|
||||
|
||||
|
||||
@@ -106,6 +106,10 @@ SGMakeSign(SGMaterialLib *matlib, const string& path, const string& content)
|
||||
osg::Group* object = new osg::Group;
|
||||
object->setName(content);
|
||||
|
||||
SGMaterial *material = 0;
|
||||
Effect *lighted_state = 0;
|
||||
Effect *unlighted_state = 0;
|
||||
|
||||
// Part I: parse & measure
|
||||
for (const char *s = content.data(); *s; s++) {
|
||||
string name;
|
||||
@@ -215,31 +219,32 @@ SGMakeSign(SGMaterialLib *matlib, const string& path, const string& content)
|
||||
}
|
||||
}
|
||||
|
||||
if (newmat.size()) {
|
||||
SGMaterial *m = matlib->find(newmat);
|
||||
if (!m) {
|
||||
// log error, but keep using previous material to at least show something
|
||||
SG_LOG(SG_TERRAIN, SG_ALERT, SIGN "ignoring unknown material `" << newmat << '\'');
|
||||
} else {
|
||||
material = m;
|
||||
// set material states (lighted & unlighted)
|
||||
lighted_state = material->get_effect();
|
||||
newmat.append(".unlighted");
|
||||
|
||||
if (newmat.size() == 0 )
|
||||
continue;
|
||||
|
||||
SGMaterial *material = matlib->find(newmat);
|
||||
if (!material) {
|
||||
SG_LOG(SG_TERRAIN, SG_ALERT, SIGN "ignoring unknown material `" << newmat << '\'');
|
||||
continue;
|
||||
m = matlib->find(newmat);
|
||||
if (m) {
|
||||
unlighted_state = m->get_effect();
|
||||
} else {
|
||||
SG_LOG(SG_TERRAIN, SG_ALERT, SIGN "ignoring unknown material `" << newmat << '\'');
|
||||
unlighted_state = lighted_state;
|
||||
}
|
||||
}
|
||||
newmat.clear();
|
||||
}
|
||||
|
||||
|
||||
// set material states (lighted & unlighted)
|
||||
Effect *lighted_state = material->get_effect();
|
||||
Effect *unlighted_state;
|
||||
string u = newmat + ".unlighted";
|
||||
|
||||
SGMaterial *m = matlib->find(u);
|
||||
if (m) {
|
||||
unlighted_state = m->get_effect();
|
||||
} else {
|
||||
SG_LOG(SG_TERRAIN, SG_ALERT, SIGN "ignoring unknown material `" << u << '\'');
|
||||
unlighted_state = lighted_state;
|
||||
}
|
||||
newmat = "";
|
||||
|
||||
// This can only happen if the default material is missing.
|
||||
// Error has been already logged in the block above.
|
||||
if (!material) continue;
|
||||
|
||||
SGMaterialGlyph *glyph = material->get_glyph(name);
|
||||
if (!glyph) {
|
||||
SG_LOG( SG_TERRAIN, SG_ALERT, SIGN "unsupported glyph `" << *s << '\'');
|
||||
|
||||
@@ -69,7 +69,9 @@ SGSoundMgr::SGSoundMgr() :
|
||||
_geod_pos(SGGeod::fromCart(SGVec3d::zeros())),
|
||||
_velocity(SGVec3d::zeros()),
|
||||
_orientation(SGQuatd::zeros()),
|
||||
_bad_doppler(false)
|
||||
_bad_doppler(false),
|
||||
_renderer("unknown"),
|
||||
_vendor("unknown")
|
||||
{
|
||||
#if defined(ALUT_API_MAJOR_VERSION) && ALUT_API_MAJOR_VERSION >= 1
|
||||
if (_alut_init == 0) {
|
||||
@@ -158,10 +160,10 @@ void SGSoundMgr::init(const char *devname) {
|
||||
else break;
|
||||
}
|
||||
|
||||
string vendor = (const char *)alGetString(AL_VENDOR);
|
||||
string renderer = (const char *)alGetString(AL_RENDERER);
|
||||
if ( vendor != "OpenAL Community" ||
|
||||
(renderer != "Software" && renderer != "OpenAL Sample Implementation")
|
||||
_vendor = (const char *)alGetString(AL_VENDOR);
|
||||
_renderer = (const char *)alGetString(AL_RENDERER);
|
||||
if ( _vendor != "OpenAL Community" ||
|
||||
(_renderer != "Software" && _renderer != "OpenAL Sample Implementation")
|
||||
)
|
||||
{
|
||||
_bad_doppler = true;
|
||||
@@ -220,6 +222,9 @@ void SGSoundMgr::stop() {
|
||||
alcDestroyContext(_context);
|
||||
alcCloseDevice(_device);
|
||||
_context = NULL;
|
||||
|
||||
_renderer = "unknown";
|
||||
_vendor = "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -547,12 +552,14 @@ bool SGSoundMgr::load(string &samplepath, void **dbuf, int *fmt,
|
||||
|
||||
#if defined(ALUT_API_MAJOR_VERSION) && ALUT_API_MAJOR_VERSION >= 1
|
||||
ALfloat freqf;
|
||||
testForALError("load file");
|
||||
testForALCError("load file");
|
||||
data = alutLoadMemoryFromFile(samplepath.c_str(), &format, &size, &freqf );
|
||||
freq = (ALsizei)freqf;
|
||||
if (data == NULL) {
|
||||
int error = alutGetError();
|
||||
int error = alutGetError();
|
||||
if (data == NULL || error != ALUT_ERROR_NO_ERROR) {
|
||||
string msg = "Failed to load wav file: ";
|
||||
msg.append(alutGetErrorString(error));
|
||||
msg.append(alutGetErrorString(error));
|
||||
throw sg_io_exception(msg.c_str(), sg_location(samplepath));
|
||||
return false;
|
||||
}
|
||||
@@ -568,7 +575,18 @@ bool SGSoundMgr::load(string &samplepath, void **dbuf, int *fmt,
|
||||
ALenum error = alGetError();
|
||||
if ( error != AL_NO_ERROR ) {
|
||||
string msg = "Failed to load wav file: ";
|
||||
msg.append(alGetString(error));
|
||||
const ALchar *errorString = alGetString(error);
|
||||
if (errorString) {
|
||||
msg.append(errorString);
|
||||
} else {
|
||||
// alGetString returns NULL when an unexpected or OS specific error
|
||||
// occurs: e.g. -43 on Mac when file is not found.
|
||||
// In this case, alGetString() sets 'Invalid Enum' error, so
|
||||
// showing with the original error number is helpful.
|
||||
stringstream ss;
|
||||
ss << alGetString(alGetError()) << "(" << error << ")";
|
||||
msg.append(ss.str());
|
||||
}
|
||||
throw sg_io_exception(msg.c_str(), sg_location(samplepath));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -289,6 +289,12 @@ public:
|
||||
*/
|
||||
vector<const char*> get_available_devices();
|
||||
|
||||
/**
|
||||
* Get the current OpenAL vendor or rendering backend.
|
||||
*/
|
||||
const string& get_vendor() { return _vendor; }
|
||||
const string& get_renderer() { return _renderer; }
|
||||
|
||||
private:
|
||||
static int _alut_init;
|
||||
|
||||
@@ -321,6 +327,8 @@ private:
|
||||
vector<ALuint> _sources_in_use;
|
||||
|
||||
bool _bad_doppler;
|
||||
string _renderer;
|
||||
string _vendor;
|
||||
|
||||
bool testForALError(string s);
|
||||
bool testForALCError(string s);
|
||||
|
||||
@@ -110,10 +110,11 @@ SGSubsystemGroup::SGSubsystemGroup ()
|
||||
|
||||
SGSubsystemGroup::~SGSubsystemGroup ()
|
||||
{
|
||||
for (unsigned int i = 0; i < _members.size(); i++)
|
||||
// reverse order to prevent order dependency problems
|
||||
for (unsigned int i = _members.size(); i > 0; i--)
|
||||
{
|
||||
_members[i]->printTimingStatistics();
|
||||
delete _members[i];
|
||||
_members[i-1]->printTimingStatistics();
|
||||
delete _members[i-1];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,8 +149,9 @@ SGSubsystemGroup::bind ()
|
||||
void
|
||||
SGSubsystemGroup::unbind ()
|
||||
{
|
||||
for (unsigned int i = 0; i < _members.size(); i++)
|
||||
_members[i]->subsystem->unbind();
|
||||
// reverse order to prevent order dependency problems
|
||||
for (unsigned int i = _members.size(); i > 0; i--)
|
||||
_members[i-1]->subsystem->unbind();
|
||||
}
|
||||
|
||||
void
|
||||
@@ -381,7 +383,8 @@ SGSubsystemMgr::bind ()
|
||||
void
|
||||
SGSubsystemMgr::unbind ()
|
||||
{
|
||||
for (int i = 0; i < MAX_GROUPS; i++)
|
||||
// reverse order to prevent order dependency problems
|
||||
for (int i = MAX_GROUPS-1; i >= 0; i--)
|
||||
_groups[i].unbind();
|
||||
}
|
||||
|
||||
|
||||
@@ -1365,6 +1365,10 @@ int getEncodingIndex(const char *name)
|
||||
for (i = 0; i < sizeof(encodingNames)/sizeof(encodingNames[0]); i++)
|
||||
if (streqci(name, encodingNames[i]))
|
||||
return i;
|
||||
|
||||
if (streqci(name, "ASCII"))
|
||||
return US_ASCII_ENC;
|
||||
|
||||
return UNKNOWN_ENC;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user