Compare commits

...

55 Commits

Author SHA1 Message Date
curt
3b6af2f0c2 Ready for 0.3.8 release. 2005-01-18 14:34:13 +00:00
curt
5bdff41641 Require plib-1.8.4 2005-01-17 21:48:05 +00:00
ehofman
67e9d105cb Use the double precission pow() function to get Solaris compiling. 2005-01-16 08:52:22 +00:00
ehofman
f1fc99f16f Solaris fix 2005-01-15 14:24:28 +00:00
ehofman
f89e359d53 Solaris fix. 2005-01-15 14:22:56 +00:00
ehofman
77ec170a50 MingW/MSYS fix 2005-01-15 14:18:30 +00:00
ehofman
34320f5f20 Eliminate some compiler warnings about converting float to int. 2005-01-15 11:57:34 +00:00
ehofman
a26271e46e Add a make_bumpmap and a make_maxcolorwindow function, modify the make_normalmap function to maximize the color window before proceding. 2005-01-15 10:48:40 +00:00
ehofman
e2e7466250 Add support for contrast. 2005-01-14 15:52:56 +00:00
ehofman
1e24cc4643 little endian fixes. 2005-01-14 14:27:57 +00:00
ehofman
dfc23c3528 Add a make_grayscale function and call it from make_normalmap automatically, removing the need to do it make_grayscale prior to calling make_normalmap. 2005-01-14 13:36:38 +00:00
ehofman
cd11a5dc27 Fix a mistake. 2005-01-14 13:12:44 +00:00
ehofman
899734296b Add a function to calculate the normalmap from a regular texture. 2005-01-14 13:08:57 +00:00
ehofman
7a3a81c152 RGBA textures can be made monochrome also 2005-01-14 10:12:00 +00:00
ehofman
e62a4a05ac Fix a few bugs and add a make_monochrome() function 2005-01-14 10:09:21 +00:00
ehofman
463ca207ce Some small updates to the saving code. 2005-01-13 18:35:56 +00:00
ehofman
da6e1b31ea Fix a crash situation. 2005-01-13 18:05:46 +00:00
ehofman
8c783b1680 Update the code a bit more, add a function to retreive the last error string and add a function to write SGI texture fils. 2005-01-13 14:47:31 +00:00
curt
efce88ff12 - Fix a couple oops's in cloud.cxx
- In sky.cxx blend low density cloud layers (few/scattered) into nothing (but
  don't touch visibility distance) as we approach them so we can fly through
  clean.
- For high density cloud layers (broken/overcast) we do not fade the layers
  out, but we fade visibility to nearly nothing as we approach the layer.
2005-01-11 16:02:39 +00:00
curt
01608b7e18 Add a method to SGCloudLayer to set overall cloud alpha. This gives us the
capability to slowly fade a cloud layer in or out.

We use this effect in combination with lowering visibility as we approach
a cloud layer to hide the fact that it is simply a 2d textured polygon being
drawn across the sky.
2005-01-11 15:21:58 +00:00
david
a5f0e0395a Do not reduce visibility when passing through a 'few' or 'scattered'
cloud layer (i.e. <50% coverage).  This is a quick hack rather than a
proper fix, but it will at least make it possible to get above a
scattered layer VFR.
2005-01-10 23:34:52 +00:00
ehofman
0b723174fd Add support for binding a thread to a specific CPU (IRIX only at this time). 2005-01-09 10:24:54 +00:00
ehofman
5d248bf0df Frederic Bouvier:
It comes to me that the bulk of all problem reports, especially from Windows users, have it's cause in an obsolete sound driver. These messages should direct them to the right solution before complaining.
2005-01-08 11:47:19 +00:00
curt
c039ccdeb0 Updates for 0.3.8-pre2 release. 2005-01-03 19:05:32 +00:00
ehofman
d88fb32a73 Melchior FRANZ:
My recent fix for the load/save fgfs.sav feature was a bit too ambitious.
While aliases lead to abortion before, I tried to copy them properly,
although this wasn't a requirement. Unfortunately, this seems to have
worked for absolute aliases only, not for relative ones, and hence broke
several panel instruments. The attached patch backs most of the previous
patch out again, and goes a simpler route: just ignore aliases.
2004-12-23 13:32:01 +00:00
ehofman
37ac409586 Melchior FRANZ:
fgLoadFlight() loads a property file ("fgfs.sav") to a new property tree,
and then copies that over to the main tree. copyProperties() didn't know
how to handle type SGPropertyNode::ALIAS and hence threw an exception that
made fgfs abort.

The attached patch adds support for ALIAS to copyProperties(): aliased
nodes are created in the target tree if necessary, and then linked like in
the source tree. It seemed useful to add an optional argument to
props.[ch]xx/getType() that would indeed return the property type "ALIAS"
for aliased nodes, and not the type of the node that it refers to. The patch
also fixes a bug in writeNode() that caused extra lines after alias entries.

If there's resistance to the change to getType() (David?) I can easily use
isAlias(). This just makes copyProperties() a tad uglier, but I can live with
it. It's useful for scanning a tree, though, if an alias node can be treated
exactly like all other nodes, without automatic redirection.
2004-12-19 10:19:14 +00:00
ehofman
7b24e94c66 gcc 4.0 fix. 2004-12-18 10:53:54 +00:00
ehofman
e12cd2a50c Initialize volume to inaudiable at startup. 2004-12-16 13:15:13 +00:00
curt
98b2ba4fc1 More prerelease updates. 2004-12-15 16:45:57 +00:00
curt
2f0afdccc1 Prerelease updates. 2004-12-15 16:34:14 +00:00
ehofman
79734df554 Threads detection code cleanup and FreeBSD fixes. 2004-12-13 20:31:44 +00:00
ehofman
c52657fa1a This was too quick, now pthreads isn't detected on IRIX (and other platforms?) anymore. This needs some more thought. 2004-12-08 15:12:11 +00:00
ehofman
9cac8409cd FreeBSD fix. 2004-12-08 15:00:45 +00:00
ehofman
18703ce02d AIX fix 2004-12-05 09:36:49 +00:00
curt
709a166bd6 Oops, 2nd try ... 2004-12-02 15:08:54 +00:00
curt
8048e6297c Martin Spott: Revised handling of missing isnan() on earlier versions of
FreeBSD.
2004-12-02 15:00:26 +00:00
curt
fb0dded103 Fix a typo for the Mac OSX platform. 2004-12-01 17:37:43 +00:00
curt
055e969e7a Fix a dumb bug. 2004-11-21 21:46:02 +00:00
curt
f10db8a30e Fix a dumb bug for FreeBSD. 2004-11-21 21:45:35 +00:00
ehofman
c19af3525e Melchior FRANZ:
At last I've found the reason why fgfs crashed routinely for me. When I still
used KDE's artsdsp (preloads lib with OSS replacement functions) I saw
this crash only occasionally. After letting OpenAl communicate with artsd
directly (by means of ~/.openalrc setting), I got the crash always when
I left fgfs.

This bug may also have crashed fgfs when running with sound daemons other than
aRts.
2004-11-21 17:05:42 +00:00
curt
7c60ccfc35 I don't understand why FreeBSD doesn't see isnan() after including math.h
but it doesn't.  Trying the apple approach to fixing isnan results in an
infinite loop (making me wonder what happens on OSX?)  This is an alternative
approach to checking isnan() on freebsd ...
2004-11-21 03:13:54 +00:00
curt
84cba33aab FreeBSD fix. 2004-11-20 19:11:08 +00:00
ehofman
a52b1ec64f MSVC fix. 2004-11-20 12:35:28 +00:00
curt
f30c4720ae Update a few more instances of my email address. 2004-11-19 21:47:05 +00:00
curt
7fc8c02688 My old email address is no longer valid ... point to my web page. 2004-11-19 21:44:16 +00:00
curt
54a7a0d534 Ooops, fix an unintentional line wrap. 2004-11-18 19:12:17 +00:00
curt
8d73160a75 Abstract out location of gl.h, glut.h, and glu.h includes so that we can
make the Mac platform happy since they put these in a different place compared
to the rest of the world.
2004-11-18 19:10:34 +00:00
andy
ff10602c65 Make sure that timer delay values are positive-definite, otherwise
user code that wants to use zero delay to mean "next frame" will get
stuck in an infinite loop.
2004-11-17 19:37:45 +00:00
ehofman
ca50fe386d Roy Vegard Ovesen:
I've added two new debug log types for the instrumentation and systems. They
used to use the autopilot debug log, because I couldn't figure out how to
make new log types. Well, now I have figured it out.  ;-)
2004-10-24 09:29:56 +00:00
ehofman
39f3c6e41d Frederic Bouvier:
This is a patch to make display list usage optional. They are on by default.
Use --prop:/sim/rendering/use-display-list=false to use immediate mode.
There is also a change in exception handling in main.cxx and bootstrap.cxx
2004-10-17 17:06:50 +00:00
ehofman
ba1b96e518 Roy Vegard Ovesen:
I'm working on a route manager in the GPS module. So I've added a name
parameter to the waypoint class in Simgear. I use the existing ID parameter
to store the ID, for example KLAX, and the name parameter to store the name,
San Francisco Intl.
2004-10-16 12:23:53 +00:00
ehofman
ef486b2cc6 Remove the refference to fgsg 2004-10-14 13:35:11 +00:00
curt
06f3cb4f8e Fix a couple bugs in openal detection. I should actually generate a new
configure and test it, rather than testing the old configure script.
2004-10-13 20:18:35 +00:00
curt
074f5ff996 Oops, missed a part of the previous change. 2004-10-13 19:52:13 +00:00
curt
8c26f32d5f Add a sanity check for the existance of OpenAL. If not there, bail from
the configure script with an appropriate/helpful message.
2004-10-13 19:51:38 +00:00
113 changed files with 797 additions and 241 deletions

View File

@@ -22,7 +22,7 @@ PROJECT_NAME = SimGear
# This could be handy for archiving the generated documentation or
# if some version control system is used.
PROJECT_NUMBER = 0.3.7
PROJECT_NUMBER = 0.3.8
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
# base path where the generated documentation will be put.

25
NEWS
View File

@@ -1,3 +1,28 @@
New in 0.3.8
* January 18, 2005
* Configure script does a sanity check for the existance of openal.
* Better pthreads detection for FreeBSD.
* Abstract out the location of gl.h, glu.h, and glut.h so we can more
easily support MacOS which puts these in an oddball location.
* Added two new debug output types for instrumentation and systems.
* Add a name parameter to the waypoint class for supporting a route
manager in the flightgear gps module.
* Make display list usage optional.
* Event manager: specifying a zero delay will force event execution in
the next frame rather than entering an infinite loop.
* gcc-4.0 fix.
* Fixes to property tree loading and saving.
* Make volume inaudible at startup.
* Solaris fixes.
* For low density cloud coverages, blend the layer to nothing as we pass
through instead of fully engulfing the aircraft in the cloud.
* Add several new capabilities to the texture management code for building
normal maps and doing some simple on-the-fly effects on textures.
* Better error message for sound problems.
* Add support for binding a thread to a specific CPU.
New in 0.3.7
* October 12, 2004

12
README.OpenAL Normal file
View File

@@ -0,0 +1,12 @@
[This file is mirrored in both the FlightGear and SimGear packages.]
You *must* have the development components of OpenAL installed on your system
to build FlightGear!" You can get a copy here:
http://www.openal.org
Build notes:
The OpenAL developers do not make "versioned" releases so we recommend that
you pull the latest version via anonymous CVS (follow the instructions at
the OpenAL web site) and build/install that.

4
Thanks
View File

@@ -90,7 +90,7 @@ David Megginson <david@megginson.com>
SimGear property manager/registry
Curt Olson <curt@flightgear.org>
Curt Olson http://www.flightgear.org/~curt/
Curt is responsible for overall project and source code management.
He has his hands in many of the areas.
@@ -175,7 +175,7 @@ NOTE:
----
THIS DOCUMENT WAS INITIALLY WRITTEN BY
Curt L. Olson <curt@flightgear.org>
Curt L. Olson <http://www.flightgear.org/~curt>
05 Jul 2000 Removed non-SimGear entries (CLO)

View File

@@ -1,7 +1,5 @@
dnl Process this file with autoget.sh to produce a working configure
dnl script.
dnl
dnl $Id$
AC_INIT
AC_CONFIG_SRCDIR([simgear/bucket/newbucket.cxx])
@@ -10,7 +8,7 @@ dnl Require at least automake 2.52
AC_PREREQ(2.52)
dnl Initialize the automake stuff
AM_INIT_AUTOMAKE(SimGear, 0.3.7)
AM_INIT_AUTOMAKE(SimGear, 0.3.8)
dnl Specify KAI C++ compiler and flags.
dnl Borrowed with slight modification from blitz distribution.
@@ -165,33 +163,18 @@ dnl Checks for libraries.
dnl Thread related checks
AC_CHECK_HEADER(pthread.h)
AC_CHECK_LIB(pthread, pthread_exit)
if test "x$ac_cv_lib_pthread_pthread_exit" = "xyes" -a "x$ac_cv_header_pthread_h" = "xyes"; then
AC_SEARCH_LIBS(pthread_exit, [pthread c_r])
if test "x$ac_cv_header_pthread_h" = "xyes"; then
CXXFLAGS="$CXXFLAGS -D_REENTRANT"
CFLAGS="$CFLAGS -D_REENTRANT"
fi
if test "x$ac_cv_lib_pthread_pthread_exit" != "xyes" -a "x$ac_cv_header_pthread_h" = "xyes"; then
dnl FreeBSD: System has pthread.h, but -lpthread library check
dnl fails. See if we need -pthread instead of -lpthread and look
dnl for the functions in libc_r.
save_CXXFLAGS="$CXXFLAGS"
save_CFLAGS="$CFLAGS"
if test "x$ac_cv_search_pthread_exit" = "x-lc_r"; then
CXXFLAGS="-pthread $CXXFLAGS"
CFLAGS="-pthread $FLAGS"
save_LIBS=$LIBS
AC_CHECK_LIB(c_r, pthread_exit)
if test "x$ac_cv_lib_c_r_pthread_exit" != "xyes"; then
CXXFLAGS=$save_CXXFLAGS
CFLAGS=$save_CFLAGS
else
dnl This is cheating a bit. pthread_exit comes with using -pthread, not
-lpthread
ac_cv_lib_pthread_pthread_exit="yes"
fi
LIBS=$save_LIBS
fi
fi
AM_CONDITIONAL(HAVE_THREADS, test "x$ac_cv_lib_pthread_pthread_exit" = "xyes" -a "x$ac_cv_header_pthread_h" = "xyes")
AM_CONDITIONAL(HAVE_THREADS, test "x$ac_cv_header_pthread_h" = "xyes")
thread_LIBS="$LIBS"
LIBS=""
@@ -271,6 +254,7 @@ opengl_LIBS="$LIBS"
LIBS="$base_LIBS"
dnl check for OpenAL libraries
OPENAL_OK="no"
case "${host}" in
*-*-cygwin* | *-*-mingw32*)
dnl CygWin under Windoze.
@@ -278,23 +262,43 @@ case "${host}" in
AC_SEARCH_LIBS(alGenBuffers, openal32)
AC_SEARCH_LIBS(alutInit, [ openal32 ALut ] )
LIBS="$LIBS -lwinmm -ldsound -ldxguid -lole32"
openal_LIBS="$LIBS"
OPENAL_OK="$ac_cv_search_alGenBuffers"
;;
*-apple-darwin*)
dnl Mac OS X
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"
;;
*)
dnl default unix style machines
save_LIBS=$LIBS
LIBS="$LIBS $thread_LIBS"
AC_SEARCH_LIBS(alGenBuffers, openal)
OPENAL_OK="$ac_cv_search_alGenBuffers"
openal_LIBS="$LIBS"
LIBS=$save_LIBS
;;
esac
openal_LIBS="$LIBS"
if test "$OPENAL_OK" == "no"; then
echo
echo "You *must* have the openal library installed on your system to build"
echo "SimGear!"
echo
echo "Please see README.OpenAL for more details."
echo
echo "configure aborted."
exit
fi
LIBS="$base_LIBS"
AC_SUBST(base_LIBS)
@@ -325,11 +329,11 @@ if test "x$ac_cv_header_plib_ul_h" != "xyes"; then
exit
fi
AC_MSG_CHECKING([for plib 1.6.0 or newer])
AC_MSG_CHECKING([for plib 1.8.4 or newer])
AC_TRY_RUN([
#include <plib/ul.h>
#define MIN_PLIB_VERSION 160
#define MIN_PLIB_VERSION 184
int main() {
int major, minor, micro;
@@ -344,7 +348,7 @@ int main() {
],
AC_MSG_RESULT(yes),
[AC_MSG_RESULT(wrong version);
AC_MSG_ERROR([Install plib 1.6.0 or later first...])],
AC_MSG_ERROR([Install plib 1.8.4 or later first...])],
AC_MSG_RESULT(yes)
)
@@ -417,7 +421,6 @@ AC_CONFIG_FILES([ \
simgear/props/Makefile \
simgear/route/Makefile \
simgear/scene/Makefile \
simgear/scene/fgsg/Makefile \
simgear/scene/material/Makefile \
simgear/scene/model/Makefile \
simgear/scene/sky/Makefile \
@@ -456,7 +459,7 @@ else
echo "Without JPEG Factory support"
fi
if test "x$ac_cv_lib_pthread_pthread_exit" = "xyes" -a "x$ac_cv_header_pthread_h" = "xyes"; then
if test "x$ac_cv_header_pthread_h" = "xyes"; then
echo "Threads: pthread lib found."
else
echo "Threads: no threads (pthread lib not found.)"

View File

@@ -3,7 +3,7 @@
*
* Written by Curtis L. Olson, started February 1999.
*
* Copyright (C) 1999 Curtis L. Olson - curt@flightgear.org
* Copyright (C) 1999 Curtis L. Olson - http://www.flightgear.org/~curt/
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public

View File

@@ -3,7 +3,7 @@
*
* Written by Curtis L. Olson, started February 1999.
*
* Copyright (C) 1999 Curtis L. Olson - curt@flightgear.org
* Copyright (C) 1999 Curtis L. Olson - http://www.flightgear.org/~curt
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public

View File

@@ -121,7 +121,7 @@
# define STL_STRSTREAM <strstream>
# endif
# elif __GNUC__ == 3
# elif __GNUC__ >= 3
// g++-3.0.x
# define SG_EXPLICIT_FUNCTION_TMPL_ARGS
# define SG_NEED_AUTO_PTR
@@ -336,7 +336,9 @@
extern void *memmove(void *, const void *, size_t);
# endif // __cplusplus
# define SG_COMPILER_STR "Sun compiler version " SG_STRINGIZE(__SUNPRO_CC)
# if !defined( __GNUC__ )
# define SG_COMPILER_STR "Sun compiler version " SG_STRINGIZE(__SUNPRO_CC)
# endif
#endif // sun
@@ -364,6 +366,23 @@
#endif // __ICC
//
// Platform dependent gl.h and glut.h definitions
//
#ifdef __APPLE__
# define SG_GL_H <OpenGL/gl.h>
# define SG_GLU_H <OpenGL/glu.h>
# define SG_GLEXT_H <OpenGL/glext.h>
# define SG_GLUT_H <GLUT/glut.h>
#else
# define SG_GL_H <GL/gl.h>
# define SG_GLU_H <GL/glu.h>
# define SG_GLEXT_H <GL/glext.h>
# define SG_GLUT_H <GL/glut.h>
#endif
//
// No user modifiable definitions beyond here.
//

View File

@@ -2,7 +2,7 @@
//
// Written by Curtis Olson, started February 2000.
//
// Copyright (C) 2000 Curtis L. Olson - curt@flightgear.org
// Copyright (C) 2000 Curtis L. Olson - http://www.flightgear.org/~curt/
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public

View File

@@ -25,7 +25,9 @@ typedef enum {
SG_NETWORK = 0x00004000,
SG_ATC = 0x00008000,
SG_NASAL = 0x00010000,
SG_UNDEFD = 0x00020000, // For range checking
SG_INSTR = 0x00020000,
SG_SYSTEMS = 0x00040000,
SG_UNDEFD = 0x00080000, // For range checking
SG_ALL = 0xFFFFFFFF
} sgDebugClass;

View File

@@ -3,7 +3,7 @@
//
// Written by Curtis Olson, started March 2000.
//
// Copyright (C) 2000 Curtis L. Olson - curt@flightgear.org
// Copyright (C) 2000 Curtis L. Olson - http://www.flightgear.org/~curt
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public

View File

@@ -7,7 +7,7 @@
// All the core code underneath this is written by Durk Talsma. See
// the headers of all the other individual files for details.
//
// Copyright (C) 2000 Curtis L. Olson - curt@flightgear.org
// Copyright (C) 2000 Curtis L. Olson - http://www.flightgear.org/~curt
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
@@ -48,7 +48,7 @@
/** Ephemeris class
*
* Written by Durk Talsma <d.talsma@direct.a2000.nl> and Curtis Olson
* <curt@flightgear.org>
* <http://www.flightgear.org/~curt>
*
* Introduction
*

View File

@@ -2,7 +2,7 @@
//
// Written by Curtis Olson, started March 2000.
//
// Copyright (C) 2000 Curtis L. Olson - curt@flightgear.org
// Copyright (C) 2000 Curtis L. Olson - http://www.flightgear.org/~curt
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public

View File

@@ -2,7 +2,7 @@
//
// Written by Curtis Olson, started March 2000.
//
// Copyright (C) 2000 Curtis L. Olson - curt@flightgear.org
// Copyright (C) 2000 Curtis L. Olson - http://www.flightgear.org/~curt
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public

View File

@@ -2,7 +2,7 @@
//
// Written by Curtis Olson, started November 1999.
//
// Copyright (C) 1999 Curtis L. Olson - curt@flightgear.org
// Copyright (C) 1999 Curtis L. Olson - http://www.flightgear.org/~curt
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as

View File

@@ -5,7 +5,7 @@
// Written by Curtis Olson, started November 1999.
//
// Copyright (C) 1999 Curtis L. Olson - curt@flightgear.org
// Copyright (C) 1999 Curtis L. Olson - http://www.flightgear.org/~curt
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as

View File

@@ -4,7 +4,7 @@
// Shamelessly adapted from plib (plib.sourceforge.net) January 2001
//
// Original version Copyright (C) 2000 the plib team
// Local changes Copyright (C) 2000 Curtis L. Olson - curt@flightgear.org
// Local changes Copyright (C) 2000 Curtis L. Olson - http://www.flightgear.org/~curt
//
// 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

View File

@@ -4,7 +4,7 @@
// Shamelessly adapted from plib January 2001
//
// Original version Copyright (C) 2000 the plib team
// Local changes Copyright (C) 2000 Curtis L. Olson - curt@flightgear.org
// Local changes Copyright (C) 2000 Curtis L. Olson - http://www.flightgear.org/~curt
//
// 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

View File

@@ -2,7 +2,7 @@
//
// Written by Curtis Olson, started January 2000.
//
// Copyright (C) 2000 Curtis L. Olson - curt@flightgear.org
// Copyright (C) 2000 Curtis L. Olson - http://www.flightgear.org/~curt
//
// 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

View File

@@ -5,7 +5,7 @@
// Written by Curtis Olson, started January 2000.
//
// Copyright (C) 2000 Curtis L. Olson - curt@flightgear.org
// Copyright (C) 2000 Curtis L. Olson - http://www.flightgear.org/~curt
//
// 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

View File

@@ -2,7 +2,7 @@
//
// Written by Curtis Olson, started November 1999.
//
// Copyright (C) 1999 Curtis L. Olson - curt@flightgear.org
// Copyright (C) 1999 Curtis L. Olson - http://www.flightgear.org/~curt
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as

View File

@@ -4,7 +4,7 @@
// Written by Curtis Olson, started November 1999.
//
// Copyright (C) 1999 Curtis L. Olson - curt@flightgear.org
// Copyright (C) 1999 Curtis L. Olson - http://www.flightgear.org/~curt
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as

View File

@@ -2,7 +2,7 @@
//
// Written by Curtis Olson, started November 1999.
//
// Copyright (C) 1999 Curtis L. Olson - curt@flightgear.org
// Copyright (C) 1999 Curtis L. Olson - http://www.flightgear.org/~curt
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as

View File

@@ -5,7 +5,7 @@
// Written by Curtis Olson, started November 1999.
//
// Copyright (C) 1999 Curtis L. Olson - curt@flightgear.org
// Copyright (C) 1999 Curtis L. Olson - http://www.flightgear.org/~curt
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as

View File

@@ -3,7 +3,7 @@
// Written by Curtis Olson, started November 1999.
// Modified by Bernie Bright <bbright@bigpond.net.au>, May 2002.
//
// Copyright (C) 1999 Curtis L. Olson - curt@flightgear.org
// Copyright (C) 1999 Curtis L. Olson - http://www.flightgear.org/~curt
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as

View File

@@ -5,7 +5,7 @@
// Written by Curtis Olson, started November 1999.
//
// Copyright (C) 1999 Curtis L. Olson - curt@flightgear.org
// Copyright (C) 1999 Curtis L. Olson - http://www.flightgear.org/~curt
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as

View File

@@ -2,7 +2,7 @@
//
// Written by Curtis Olson, started November 1999.
//
// Copyright (C) 1999 Curtis L. Olson - curt@flightgear.org
// Copyright (C) 1999 Curtis L. Olson - http://www.flightgear.org/~curt
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as

View File

@@ -5,7 +5,7 @@
// Written by Curtis Olson, started November 2001.
//
// Copyright (C) 2001 Curtis L. Olson - curt@flightgear.org
// Copyright (C) 2001 Curtis L. Olson - http://www.flightgear.org/~curt
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as

View File

@@ -2,7 +2,7 @@
//
// Written by Curtis Olson, started July 2000.
//
// Copyright (C) 2000 Curtis L. Olson - curt@flightgear.org
// Copyright (C) 2000 Curtis L. Olson - http://www.flightgear.org/~curt
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as

View File

@@ -5,7 +5,7 @@
// Written by Curtis Olson, started July 2000.
//
// Copyright (C) 2000 Curtis L. Olson - curt@flightgear.org
// Copyright (C) 2000 Curtis L. Olson - http://www.flightgear.org/~curt
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as

View File

@@ -4,7 +4,7 @@
//
// Written by Curtis Olson, started April 1998.
//
// Copyright (C) 1998 Curtis L. Olson - curt@me.umn.edu
// Copyright (C) 1998 Curtis L. Olson - http://www.flightgear.org/~curt
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public

View File

@@ -6,7 +6,7 @@
// Written by Curtis Olson, started April 1998.
//
// Copyright (C) 1998 Curtis L. Olson - curt@me.umn.edu
// Copyright (C) 1998 Curtis L. Olson - http://www.flightgear.org/~curt
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public

View File

@@ -2,7 +2,7 @@
//
// Written by Curtis Olson, started September 1997.
//
// Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
// Copyright (C) 1997 Curtis L. Olson - http://www.flightgear.org/~curt
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public

View File

@@ -5,7 +5,7 @@
// Written by Curtis Olson, started September 1997.
//
// Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
// Copyright (C) 1997 Curtis L. Olson - http://www.flightgear.org/~curt
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public

View File

@@ -2,7 +2,7 @@
//
// Written by Curtis Olson, started September 2000.
//
// Copyright (C) 2000 Curtis L. Olson - curt@flightgear.org
// Copyright (C) 2000 Curtis L. Olson - http://www.flightgear.org/~curt
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public

View File

@@ -8,7 +8,7 @@
* Adapted from algebra3 by Jean-Francois Doue, started October 1998.
*/
// Copyright (C) 1998 Curtis L. Olson - curt@me.umn.edu
// Copyright (C) 1998 Curtis L. Olson - http://www.flightgear.org/~curt
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public

View File

@@ -2,7 +2,7 @@
//
// Written by Curtis Olson, started June 1997.
//
// Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
// Copyright (C) 1997 Curtis L. Olson - http://www.flightgear.org/~curt
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public

View File

@@ -5,7 +5,7 @@
// Written by Curtis Olson, started June 1997.
//
// Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
// Copyright (C) 1997 Curtis L. Olson - http://www.flightgear.org/~curt
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public

View File

@@ -2,7 +2,7 @@
//
// Written by Curtis Olson, started July 1997.
//
// Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
// Copyright (C) 1997 Curtis L. Olson - http://www.flightgear.org/~curt
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public

View File

@@ -5,7 +5,7 @@
// Written by Curtis Olson, started July 1997.
//
// Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
// Copyright (C) 1997 Curtis L. Olson - http://www.flightgear.org/~curt
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public

View File

@@ -5,7 +5,7 @@
// Written by Curtis Olson, started March 1999.
//
// Copyright (C) 1999 Curtis L. Olson - curt@flightgear.org
// Copyright (C) 1999 Curtis L. Olson - http://www.flightgear.org/~curt
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public

View File

@@ -2,7 +2,7 @@
//
// Written by Curtis Olson, started December 1997.
//
// Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
// Copyright (C) 1997 Curtis L. Olson - http://www.flightgear.org/~curt
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public

View File

@@ -5,7 +5,7 @@
// Written by Curtis Olson, started December 1997.
//
// Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
// Copyright (C) 1997 Curtis L. Olson - http://www.flightgear.org/~curt
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public

View File

@@ -3,7 +3,7 @@
//
// Written by Curtis L. Olson, started April 1999.
//
// Copyright (C) 1999 Curtis L. Olson - curt@flightgear.org
// Copyright (C) 1999 Curtis L. Olson - http://www.flightgear.org/~curt
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public

View File

@@ -6,7 +6,7 @@
// Written by Curtis L. Olson, started April 1999.
//
// Copyright (C) 1999 Curtis L. Olson - curt@flightgear.org
// Copyright (C) 1999 Curtis L. Olson - http://www.flightgear.org/~curt
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public

View File

@@ -2,7 +2,7 @@
//
// Written by Curtis Olson, started March 1999.
//
// Copyright (C) 1999 Curtis L. Olson - curt@flightgear.org
// Copyright (C) 1999 Curtis L. Olson - http://www.flightgear.org/~curt
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public

View File

@@ -5,7 +5,7 @@
// Written by Curtis Olson, started March 1999.
//
// Copyright (C) 1999 Curtis L. Olson - curt@flightgear.org
// Copyright (C) 1999 Curtis L. Olson - http://www.flightgear.org/~curt
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public

View File

@@ -483,7 +483,7 @@ writeNode (ostream &output, const SGPropertyNode * node,
}
// If there are children, write them next.
if (nChildren > 0 || node->isAlias()) {
if (nChildren > 0) {
doIndent(output, indent);
output << '<' << name;
writeAtts(output, node);
@@ -580,6 +580,8 @@ copyProperties (const SGPropertyNode *in, SGPropertyNode *out)
retval = false;
break;
default:
if (in->isAlias())
break;
string message = "Unknown internal SGPropertyNode type";
message += in->getType();
throw sg_error(message, "SimGear Property Reader");

View File

@@ -29,12 +29,13 @@
// Constructor
SGWayPoint::SGWayPoint( const double lon, const double lat, const double alt,
const modetype m, const string s ) {
const modetype m, const string s, const string n ) {
target_lon = lon;
target_lat = lat;
target_alt = alt;
mode = m;
id = s;
name = n;
}

View File

@@ -76,6 +76,7 @@ private:
double distance;
string id;
string name;
public:
@@ -86,10 +87,11 @@ public:
* @param alt target altitude
* @param mode type of coordinates/math to use
* @param s waypoint identifier
* @param n waypoint name
*/
SGWayPoint( const double lon = 0.0, const double lat = 0.0,
const double alt = 0.0, const modetype m = WGS84,
const string s = "" );
const string s = "", const string n = "" );
/** Destructor */
~SGWayPoint();
@@ -153,6 +155,9 @@ public:
/** @return waypoint id */
inline string get_id() const { return id; }
/** @return waypoint name */
inline string get_name() const { return name; }
};

View File

@@ -1,6 +1,6 @@
includedir = @includedir@/scene
SUBDIRS = fgsg material model sky tgdb
SUBDIRS = material model sky tgdb
# lib_LIBRARIES = libsgscene.a

View File

@@ -2,7 +2,7 @@
//
// Written by Curtis Olson, started May 1998.
//
// Copyright (C) 1998 - 2000 Curtis L. Olson - curt@flightgear.org
// Copyright (C) 1998 - 2000 Curtis L. Olson - http://www.flightgear.org/~curt
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as

View File

@@ -4,7 +4,7 @@
// Written by Curtis Olson, started May 1998.
// Overhauled by David Megginson, December 2001
//
// Copyright (C) 1998 - 2000 Curtis L. Olson - curt@flightgear.org
// Copyright (C) 1998 - 2000 Curtis L. Olson - http://www.flightgear.org/~curt
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as

View File

@@ -2,7 +2,7 @@
//
// Written by Curtis Olson, started May 1998.
//
// Copyright (C) 1998 Curtis L. Olson - curt@me.umn.edu
// Copyright (C) 1998 Curtis L. Olson - http://www.flightgear.org/~curt
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
@@ -33,12 +33,12 @@
# include <windows.h>
#endif
#include <GL/gl.h>
#include <simgear/compiler.h>
#include <simgear/constants.h>
#include <simgear/structure/exception.hxx>
#include SG_GL_H
#include <string.h>
#include STL_STRING

View File

@@ -2,7 +2,7 @@
//
// Written by Curtis Olson, started May 1998.
//
// Copyright (C) 1998 - 2000 Curtis L. Olson - curt@flightgear.org
// Copyright (C) 1998 - 2000 Curtis L. Olson - http://www.flightgear.org/~curt
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as

View File

@@ -2,7 +2,7 @@
//
// Written by David Megginson, started May 1998.
//
// Copyright (C) 1998 - 2003 Curtis L. Olson - curt@flightgear.org
// Copyright (C) 1998 - 2003 Curtis L. Olson - http://www.flightgear.org/~curt
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as

View File

@@ -2,7 +2,7 @@
//
// Written by David Megginson, December 2001
//
// Copyright (C) 1998 - 2003 Curtis L. Olson - curt@flightgear.org
// Copyright (C) 1998 - 2003 Curtis L. Olson - http://www.flightgear.org/~curt
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as

View File

@@ -3,7 +3,7 @@
// Written by Jim Wilson, David Megginson, started April 2002.
// Based largely on code by Curtis Olson and Norman Vine.
//
// Copyright (C) 2002 Curtis L. Olson - curt@flightgear.org
// Copyright (C) 2002 Curtis L. Olson - http://www.flightgear.org/~curt
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as

View File

@@ -29,7 +29,7 @@
SG_USING_STD(vector);
SG_USING_STD(set);
bool sgUseDisplayList = true;
////////////////////////////////////////////////////////////////////////
// Global state
@@ -329,7 +329,7 @@ sgLoad3DModel( const string &fg_root, const string &path,
}
#if PLIB_VERSION > 183
if ( model != 0 ) {
if ( model != 0 && sgUseDisplayList ) {
makeDList( model, ignore_branches );
}
#endif

View File

@@ -74,4 +74,9 @@ sgMakeAnimation( ssgBranch * model,
bool
sgSetModelFilter( bool filter );
/**
* Enable or disable Display list usage
*/
extern bool sgUseDisplayList;
#endif // __MODEL_HXX

View File

@@ -2,7 +2,7 @@
//
// Written by Curtis Olson, started June 2000.
//
// Copyright (C) 2000 Curtis L. Olson - curt@flightgear.org
// Copyright (C) 2000 Curtis L. Olson - http://www.flightgear.org/~curt
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -21,15 +21,13 @@
// #include <stdio.h>
#include <math.h>
#if defined (__APPLE__)
#if defined (__APPLE__)
// any C++ header file undefines isinf and isnan
// so this should be included before <iostream>
inline int (isinf)(double r) { return isinf(r); }
inline int (isnan)(double r) { return isnan(r); }
#endif
// #include STL_IOSTREAM
#include <plib/sg.h>
#include <plib/ssg.h>
@@ -47,6 +45,14 @@ inline int (isnan)(double r) { return isnan(r); }
#define isnan(x) _isnan(x)
#endif
#if defined (__FreeBSD__)
# if __FreeBSD_version < 500000
extern "C" {
inline int isnan(double r) { return !(r <= 0 || r >= 0); }
}
# endif
#endif
static ssgStateSelector *layer_states[SGCloudLayer::SG_MAX_CLOUD_COVERAGES];
static bool state_initialized = false;
@@ -191,9 +197,12 @@ generateNormalizationCubeMap()
// Constructor
SGCloudLayer::SGCloudLayer( const string &tex_path ) :
vertices(0),
indices(0),
layer_root(new ssgRoot),
layer_transform(new ssgTransform),
state_sel(0),
cloud_alpha(1.0),
texture_path(tex_path),
layer_span(0.0),
layer_asl(0.0),
@@ -204,9 +213,7 @@ SGCloudLayer::SGCloudLayer( const string &tex_path ) :
speed(0.0),
direction(0.0),
last_lon(0.0),
last_lat(0.0),
vertices(0),
indices(0)
last_lat(0.0)
{
cl[0] = cl[1] = cl[2] = cl[3] = NULL;
vl[0] = vl[1] = vl[2] = vl[3] = NULL;
@@ -489,7 +496,7 @@ SGCloudLayer::rebuild()
cos( j * half_angle ),
-sin( j * half_angle ) );
sgVectorProductVec3( v1.normal, v1.tTangent, v1.sTangent );
sgSetVec4( v1.color, 1.0f, 1.0f, 1.0f, (i == 0) ? 0.0f : 0.15f );
sgSetVec4( v1.color, 1.0f, 1.0f, 1.0f, (i == 0) ? 0.0f : cloud_alpha * 0.15f );
}
}
/*
@@ -624,17 +631,33 @@ bool SGCloudLayer::repaint( sgVec3 fog_color ) {
float *color;
for ( int i = 0; i < 4; i++ ) {
for ( int j = 0; j < 10; ++j ) {
color = cl[i]->get( j );
color = cl[i]->get( 0 );
sgCopyVec3( color, fog_color );
color[3] = (i == 0) ? 0.0f : cloud_alpha * 0.15f;
for ( int j = 0; j < 4; ++j ) {
color = cl[i]->get( (2*j) + 1 );
sgCopyVec3( color, fog_color );
color[3] =
((j == 0) || (i == 3)) ?
((j == 0) && (i == 3)) ? 0.0f : cloud_alpha * 0.15f : cloud_alpha;
color = cl[i]->get( (2*j) + 2 );
sgCopyVec3( color, fog_color );
color[3] =
((j == 3) || (i == 0)) ?
((j == 3) && (i == 0)) ? 0.0f : cloud_alpha * 0.15f : cloud_alpha;
}
color = cl[i]->get( 9 );
sgCopyVec3( color, fog_color );
color[3] = (i == 3) ? 0.0f : cloud_alpha * 0.15f;
}
}
return true;
}
// reposition the cloud layer at the specified origin and orientation
// lon specifies a rotation about the Z axis
// lat specifies a rotation about the new Y axis

View File

@@ -5,7 +5,7 @@
// Written by Curtis Olson, started June 2000.
//
// Copyright (C) 2000 Curtis L. Olson - curt@flightgear.org
// Copyright (C) 2000 Curtis L. Olson - http://www.flightgear.org/~curt
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
@@ -143,6 +143,18 @@ public:
/** get the cloud movement speed */
inline float getSpeed() { return speed; }
/**
* set the alpha component of the cloud base color. Normally this
* should be 1.0, but you can set it anywhere in the range of 0.0
* to 1.0 to fade a cloud layer in or out.
* @param alpha cloud alpha value (0.0 to 1.0)
*/
inline void setAlpha( float alpha ) {
if ( alpha < 0.0 ) { alpha = 0.0; }
if ( alpha > 1.0 ) { alpha = 1.0; }
cloud_alpha = alpha;
}
/** build the cloud object */
void rebuild();
@@ -191,6 +203,8 @@ private:
ssgLeaf *layer[4];
ssgStateSelector *state_sel;
float cloud_alpha; // 1.0 = drawn fully, 0.0 faded out completely
ssgColourArray *cl[4];
ssgVertexArray *vl[4];
ssgTexCoordArray *tl[4];

View File

@@ -33,9 +33,12 @@
# include <windows.h>
#endif
#include <GL/glu.h>
#include <plib/ul.h>
#include <simgear/compiler.h>
#include SG_GLU_H
#include "SkyCloud.hpp"
#include "SkyRenderableInstance.hpp"
#include "SkyContext.hpp"

View File

@@ -36,7 +36,9 @@
#include <map>
#include <GL/gl.h>
#include <simgear/compiler.h>
#include SG_GL_H
#include "SkyUtil.hpp"
#include "SkySingleton.hpp"

View File

@@ -28,7 +28,9 @@
# include <windows.h>
#endif
#include <GL/glu.h>
#include <simgear/compiler.h>
#include SG_GLU_H
#include "glut_shapes.h"

View File

@@ -33,7 +33,9 @@
# include <windows.h>
#endif
#include <GL/gl.h>
#include <simgear/compiler.h>
#include SG_GL_H
#include "vec4f.hpp"
#include "SkyUtil.hpp"

View File

@@ -29,7 +29,9 @@
# include <windows.h>
#endif
#include <GL/gl.h>
#include <simgear/compiler.h>
#include SG_GL_H
#include "SkyMinMaxBox.hpp"
#include "camutils.hpp"

View File

@@ -28,7 +28,9 @@
# include <windows.h>
#endif
#include <GL/glu.h>
#include <simgear/compiler.h>
#include SG_GLU_H
#include "SkyUtil.hpp"
#include "SkyCloud.hpp"

View File

@@ -30,7 +30,9 @@
# include <windows.h>
#endif
#include <GL/gl.h>
#include <simgear/compiler.h>
#include SG_GL_H
#include "SkyRenderableInstanceGroup.hpp"
#include "SkySceneManager.hpp"

View File

@@ -33,7 +33,9 @@
# include <windows.h>
#endif
#include <GL/gl.h>
#include <simgear/compiler.h>
#include SG_GL_H
#define __glext_h_
#define __GLEXT_H_

View File

@@ -30,7 +30,9 @@
# include <windows.h>
#endif
#include <GL/glu.h>
#include <simgear/compiler.h>
#include SG_GLU_H
#include "SkyTextureManager.hpp"
#include "SkyContext.hpp"

View File

@@ -48,10 +48,13 @@ OpenGL(TM) is a trademark of Silicon Graphics, Inc.
# include <simgear_config.h>
#endif
#include <math.h>
#include <simgear/compiler.h>
#include "glut_shapes.h"
#include <math.h>
#include <GL/glu.h>
#include SG_GLU_H
/* Some <math.h> files do not define M_PI... */
@@ -509,7 +512,7 @@ static GLfloat idata[12][3] =
{-Z, -X, 0}
};
static int index[20][3] =
static int iindex[20][3] =
{
{0, 4, 1},
{0, 9, 4},
@@ -539,7 +542,7 @@ icosahedron(GLenum shadeType)
int i;
for (i = 19; i >= 0; i--) {
drawtriangle(i, idata, index, shadeType);
drawtriangle(i, idata, iindex, shadeType);
}
}

View File

@@ -14,7 +14,9 @@
# include <windows.h>
#endif
#include <GL/gl.h>
#include <simgear/compiler.h>
#include SG_GL_H
#ifdef __cplusplus
extern "C" {

View File

@@ -3,7 +3,7 @@
// Written by Curtis Olson, started December 1997.
// SSG-ified by Curtis Olson, February 2000.
//
// Copyright (C) 1997-2000 Curtis L. Olson - curt@flightgear.org
// Copyright (C) 1997-2000 Curtis L. Olson - http://www.flightgear.org/~curt
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
@@ -33,7 +33,9 @@
#include <math.h>
#include <GL/gl.h>
#include <simgear/compiler.h>
#include SG_GL_H
#include <plib/sg.h>

View File

@@ -3,7 +3,7 @@
// Written by Curtis Olson, started December 1997.
// SSG-ified by Curtis Olson, February 2000.
//
// Copyright (C) 1997-2000 Curtis L. Olson - curt@flightgear.org
// Copyright (C) 1997-2000 Curtis L. Olson - http://www.flightgear.org/~curt
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public

View File

@@ -3,7 +3,7 @@
// Written by Curtis Olson, started December 1997.
// SSG-ified by Curtis Olson, February 2000.
//
// Copyright (C) 1997-2000 Curtis L. Olson - curt@flightgear.org
// Copyright (C) 1997-2000 Curtis L. Olson - http://www.flightgear.org/~curt
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
@@ -171,34 +171,34 @@ bool SGSky::reposition( SGSkyState &st, double dt )
void SGSky::preDraw( float alt, float fog_exp2_density ) {
ssgCullAndDraw( pre_root );
// if we are closer than this to a cloud layer, don't draw clouds
// if we are closer than this to a cloud layer, don't draw clouds
static const float slop = 5.0;
int i;
// check where we are relative to the cloud layers
in_cloud = -1;
for ( i = 0; i < (int)cloud_layers.size(); ++i ) {
float asl = cloud_layers[i]->getElevation_m();
float thickness = cloud_layers[i]->getThickness_m();
float asl = cloud_layers[i]->getElevation_m();
float thickness = cloud_layers[i]->getThickness_m();
if ( alt < asl - slop ) {
// below cloud layer
} else if ( alt < asl + thickness + slop ) {
// in cloud layer
if ( alt < asl - slop ) {
// below cloud layer
} else if ( alt < asl + thickness + slop ) {
// in cloud layer
// bail now and don't draw any clouds
in_cloud = i;
} else {
// above cloud layer
}
// bail now and don't draw any clouds
in_cloud = i;
} else {
// above cloud layer
}
}
// determine rendering order
cur_layer_pos = 0;
while ( cur_layer_pos < (int)cloud_layers.size() &&
alt > cloud_layers[cur_layer_pos]->getElevation_m())
alt > cloud_layers[cur_layer_pos]->getElevation_m() )
{
++cur_layer_pos;
++cur_layer_pos;
}
// FIXME: This should not be needed, but at this time (08/15/2003)
@@ -267,7 +267,7 @@ void SGSky::modify_vis( float alt, float time_factor ) {
double ratio = 1.0;
if ( cloud_layers[i]->getCoverage() == SGCloudLayer::SG_CLOUD_CLEAR ) {
// clear layer
// less than 50% coverage -- assume we're in the clear for now
ratio = 1.0;
} else if ( alt < asl - transition ) {
// below cloud layer
@@ -286,9 +286,35 @@ void SGSky::modify_vis( float alt, float time_factor ) {
ratio = 1.0;
}
// accumulate effects from multiple cloud layers
effvis *= ratio;
if ( cloud_layers[i]->getCoverage() == SGCloudLayer::SG_CLOUD_CLEAR ) {
// do nothing, clear layers aren't drawn, don't affect
// visibility andn dont' need to be faded in or out.
} else if ( (cloud_layers[i]->getCoverage() ==
SGCloudLayer::SG_CLOUD_FEW)
|| (cloud_layers[i]->getCoverage() ==
SGCloudLayer::SG_CLOUD_SCATTERED) )
{
// set the alpha fade value for the cloud layer. For less
// dense cloud layers we fade the layer to nothing as we
// approach it because we stay clear visibility-wise as we
// pass through it.
float temp = ratio * 2.0;
if ( temp > 1.0 ) { temp = 1.0; }
cloud_layers[i]->setAlpha( temp );
// don't touch visibility
} else {
// maintain full alpha for denser cloud layer types.
// Let's set the value explicitly in case someone changed
// the layer type.
cloud_layers[i]->setAlpha( 1.0 );
// lower visibility as we approach the cloud layer.
// accumulate effects from multiple cloud layers
effvis *= ratio;
}
#if 0
if ( ratio < 1.0 ) {
if ( ! in_puff ) {
// calc chance of entering cloud puff
@@ -345,12 +371,14 @@ void SGSky::modify_vis( float alt, float time_factor ) {
in_puff = false;
}
}
// never let visibility drop below 25 meters
if ( effvis <= 25.0 ) {
effvis = 25.0;
}
}
#endif
// never let visibility drop below 25 meters
if ( effvis <= 25.0 ) {
effvis = 25.0;
}
} // for
effective_visibility = effvis;

View File

@@ -6,7 +6,7 @@
// Written by Curtis Olson, started December 1997.
// SSG-ified by Curtis Olson, February 2000.
//
// Copyright (C) 1997-2000 Curtis L. Olson - curt@flightgear.org
// Copyright (C) 1997-2000 Curtis L. Olson - http://www.flightgear.org/~curt
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public

View File

@@ -2,7 +2,7 @@
//
// Written by Curtis Olson, started July 2001.
//
// Copyright (C) 2001 Curtis L. Olson - curt@flightgear.org
// Copyright (C) 2001 Curtis L. Olson - http://www.flightgear.org/~curt
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as

View File

@@ -2,7 +2,7 @@
//
// Written by Curtis Olson, started July 2001.
//
// Copyright (C) 2001 Curtis L. Olson - curt@flightgear.org
// Copyright (C) 2001 Curtis L. Olson - http://www.flightgear.org/~curt
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as

View File

@@ -2,7 +2,7 @@
//
// Written by Curtis Olson, started October 1997.
//
// Copyright (C) 1997 - 2003 Curtis L. Olson - curt@flightgear.org
// Copyright (C) 1997 - 2003 Curtis L. Olson - http://www.flightgear.org/~curt
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as

View File

@@ -2,7 +2,7 @@
//
// Written by Curtis Olson, started October 1997.
//
// Copyright (C) 1997 - 2003 Curtis L. Olson - curt@flightgear.org
// Copyright (C) 1997 - 2003 Curtis L. Olson - http://www.flightgear.org/~curt
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as

View File

@@ -3,7 +3,7 @@
//
// Written by Curtis Olson, started October 1997.
//
// Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
// Copyright (C) 1997 Curtis L. Olson - http://www.flightgear.org/~curt
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as

View File

@@ -3,7 +3,7 @@
//
// Written by Curtis Olson, started October 1997.
//
// Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
// Copyright (C) 1997 Curtis L. Olson - http://www.flightgear.org/~curt
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as

View File

@@ -2,7 +2,7 @@
//
// Written by Curtis Olson, started March 2002.
//
// Copyright (C) 2002 Curtis L. Olson - curt@flightgear.org
// Copyright (C) 2002 Curtis L. Olson - http://www.flightgear.org/~curt
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as

View File

@@ -2,7 +2,7 @@
//
// Written by Curtis Olson, started March 2002.
//
// Copyright (C) 2002 Curtis L. Olson - curt@flightgear.org
// Copyright (C) 2002 Curtis L. Olson - http://www.flightgear.org/~curt
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as

View File

@@ -3,7 +3,7 @@
//
// Written by David Megginson, started December 2001.
//
// Copyright (C) 2001 - 2003 Curtis L. Olson - curt@flightgear.org
// Copyright (C) 2001 - 2003 Curtis L. Olson - http://www.flightgear.org/~curt
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as

View File

@@ -3,7 +3,7 @@
//
// Written by David Megginson, started December 2001.
//
// Copyright (C) 2001 - 2003 Curtis L. Olson - curt@flightgear.org
// Copyright (C) 2001 - 2003 Curtis L. Olson - http://www.flightgear.org/~curt
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as

View File

@@ -2,7 +2,7 @@
//
// Written by Curtis Olson, started December 2003.
//
// Copyright (C) 2003 Curtis L. Olson - curt@flightgear.org
// Copyright (C) 2003 Curtis L. Olson - http://www.flightgear.org/~curt
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as

View File

@@ -15,7 +15,9 @@
#include <limits.h>
#include <string.h> // memcpy()
#include <GL/gl.h>
#include <simgear/compiler.h>
#include SG_GL_H
#include "GLBitmaps.h"

View File

@@ -113,7 +113,11 @@ void *SGGetGLProcAddress(const char *func) {
if (libHandle != NULL) {
fptr = dlsym(libHandle, func);
#if defined (__FreeBSD__)
const char *error = dlerror();
#else
char *error = dlerror();
#endif
if (error)
SG_LOG(SG_GENERAL, SG_INFO, error);
}

View File

@@ -36,7 +36,9 @@
# include <dlfcn.h>
#endif
#include <GL/gl.h>
#include <simgear/compiler.h>
#include SG_GL_H
#if defined(__cplusplus)

View File

@@ -36,7 +36,9 @@
#include <stdlib.h>
#include <limits.h>
#include <GL/gl.h>
#include <simgear/compiler.h>
#include SG_GL_H
#include "screen-dump.hxx"

View File

@@ -22,8 +22,9 @@
//
// $Id$
#include <simgear/compiler.h>
#include <GL/gl.h>
#include SG_GL_H
/**
* Dump the screen buffer to a ppm file.

View File

@@ -12,24 +12,37 @@
*/
#include <simgear/compiler.h>
#ifdef WIN32
# include <windows.h>
#endif
#include <GL/glu.h>
#include SG_GLU_H
#include <math.h>
#include <zlib.h>
#include "texture.hxx"
#include "colours.h"
const char *FILE_OPEN_ERROR = "Unable to open file.";
const char *WRONG_COUNT = "Unsupported number of color channels.";
const char *NO_TEXTURE = "No texture data resident.";
const char *OUT_OF_MEMORY = "Out of memory.";
SGTexture::SGTexture()
: texture_id(0),
texture_data(0),
num_colors(3)
num_colors(3),
file(0)
{
}
SGTexture::SGTexture(unsigned int width, unsigned int height)
: texture_id(0)
: texture_id(0),
errstr("")
{
texture_data = new GLubyte[ width * height * 3 ];
}
@@ -124,12 +137,7 @@ SGTexture::prepare(unsigned int width, unsigned int height) {
// Resize the OpenGL window to the size of our dynamic texture
resize(texture_width, texture_height);
// Clear the contents of the screen buffer to blue
glClearColor(0.0, 0.0, 1.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Turn off texturing (don't want the torus to be texture);
glDisable(GL_TEXTURE_2D);
glClearColor(0.0, 0.0, 0.0, 1.0);
}
/**
@@ -179,6 +187,7 @@ SGTexture::read_alpha_texture(const char *name)
image = ImageOpen(name);
if(!image) {
errstr = FILE_OPEN_ERROR;
return;
}
@@ -189,13 +198,16 @@ SGTexture::read_alpha_texture(const char *name)
if (image->zsize != 1) {
ImageClose(image);
errstr = WRONG_COUNT;
return;
}
texture_data = new GLubyte[ image->xsize * image->ysize ];
num_colors = 1;
if (!texture_data)
if (!texture_data) {
errstr = NO_TEXTURE;
return;
}
lptr = texture_data;
for(y=0; y<image->ysize; y++) {
@@ -217,13 +229,16 @@ SGTexture::read_rgb_texture(const char *name)
delete texture_data;
image = ImageOpen(name);
if(!image)
if(!image) {
errstr = FILE_OPEN_ERROR;
return;
}
texture_width = image->xsize;
texture_height = image->ysize;
if (image->zsize != 3 && image->zsize != 4) {
ImageClose(image);
errstr = WRONG_COUNT;
return;
}
@@ -239,6 +254,7 @@ SGTexture::read_rgb_texture(const char *name)
delete gbuf;
delete bbuf;
delete abuf;
errstr = OUT_OF_MEMORY;
return;
}
@@ -281,13 +297,16 @@ SGTexture::read_rgba_texture(const char *name)
delete texture_data;
image = ImageOpen(name);
if(!image)
if(!image) {
errstr = FILE_OPEN_ERROR;
return;
}
texture_width = image->xsize;
texture_height = image->ysize;
if (image->zsize != 3 && image->zsize != 4) {
ImageClose(image);
errstr = WRONG_COUNT;
return;
}
@@ -303,6 +322,7 @@ SGTexture::read_rgba_texture(const char *name)
delete gbuf;
delete bbuf;
delete abuf;
errstr = OUT_OF_MEMORY;
return;
}
@@ -344,15 +364,19 @@ SGTexture::read_raw_texture(const char *name)
image = RawImageOpen(name);
if(!image)
if(!image) {
errstr = FILE_OPEN_ERROR;
return;
}
texture_width = 256;
texture_height = 256;
texture_data = new GLubyte[ 256 * 256 * 3 ];
if(!texture_data)
if(!texture_data) {
errstr = OUT_OF_MEMORY;
return;
}
ptr = texture_data;
for(y=0; y<256; y++) {
@@ -376,15 +400,19 @@ SGTexture::read_r8_texture(const char *name)
//it wouldn't make sense to write a new function ...
image = RawImageOpen(name);
if(!image)
if(!image) {
errstr = FILE_OPEN_ERROR;
return;
}
texture_width = 256;
texture_height = 256;
texture_data = new GLubyte [ 256 * 256 * 3 ];
if(!texture_data)
if(!texture_data) {
errstr = OUT_OF_MEMORY;
return;
}
ptr = texture_data;
for(xy=0; xy<(256*256); xy++) {
@@ -402,30 +430,49 @@ SGTexture::read_r8_texture(const char *name)
void
SGTexture::set_pixel(GLuint x, GLuint y, sgVec3 &c)
{
if (!texture_data)
return;
SGTexture::write_texture(const char *name) {
SGTexture::ImageRec *image = ImageWriteOpen(name);
unsigned int pos = (x + y*texture_width)*3;
texture_data[pos] = (unsigned char)(c[0] * 256);
texture_data[pos+1] = (unsigned char)(c[1] * 256);
texture_data[pos+2] = (unsigned char)(c[2] * 256);
for (int c=0; c<num_colors; c++) {
GLubyte *ptr = texture_data + c;
for (int y=0; y<texture_height; y++) {
for (int x=0; x<texture_width; x++) {
image->tmp[x]=*ptr;
ptr = ptr + num_colors;
}
fwrite(image->tmp, 1, texture_width, file);
}
}
ImageClose(image);
}
float *
void
SGTexture::set_pixel(GLuint x, GLuint y, GLubyte *c)
{
if (!texture_data) {
errstr = NO_TEXTURE;
return;
}
unsigned int pos = (x + y*texture_width) * num_colors;
memcpy(texture_data+pos, c, num_colors);
}
GLubyte *
SGTexture::get_pixel(GLuint x, GLuint y)
{
static sgVec3 c;
static GLubyte c[4] = {0, 0, 0, 0};
sgSetVec3(c, 0, 0, 0);
if (!texture_data)
if (!texture_data) {
errstr = NO_TEXTURE;
return c;
}
unsigned int pos = (x + y*texture_width)*3;
sgSetVec3(c, texture_data[pos], texture_data[pos+1], texture_data[pos+2]);
unsigned int pos = (x + y*texture_width)*num_colors;
memcpy(c, texture_data + pos, num_colors);
return c;
}
@@ -450,11 +497,13 @@ SGTexture::ImageOpen(const char *fileName)
}
image = new SGTexture::ImageRec;
memset(image, 0, sizeof(SGTexture::ImageRec));
if (image == 0) {
// fprintf(stderr, "Out of memory!\n");
errstr = OUT_OF_MEMORY;
return 0;
}
if ((image->file = gzopen(fileName, "rb")) == 0) {
errstr = FILE_OPEN_ERROR;
return 0;
}
@@ -466,7 +515,7 @@ SGTexture::ImageOpen(const char *fileName)
image->tmp = new GLubyte[ image->xsize * 256 ];
if (image->tmp == 0) {
// fprintf(stderr, "\nOut of memory!\n");
errstr = OUT_OF_MEMORY;
return 0;
}
@@ -475,7 +524,7 @@ SGTexture::ImageOpen(const char *fileName)
image->rowStart = new unsigned[x];
image->rowSize = new int[x];
if (image->rowStart == 0 || image->rowSize == 0) {
// fprintf(stderr, "\nOut of memory!\n");
errstr = OUT_OF_MEMORY;
return 0;
}
image->rleEnd = 512 + (2 * x);
@@ -493,12 +542,12 @@ SGTexture::ImageOpen(const char *fileName)
void
SGTexture::ImageClose(SGTexture::ImageRec *image) {
gzclose(image->file);
if (image->file) gzclose(image->file);
if (file) fclose(file);
delete image->tmp;
delete image;
}
SGTexture::ImageRec *
SGTexture::RawImageOpen(const char *fileName)
{
@@ -518,11 +567,13 @@ SGTexture::RawImageOpen(const char *fileName)
}
image = new SGTexture::ImageRec;
memset(image, 0, sizeof(SGTexture::ImageRec));
if (image == 0) {
// fprintf(stderr, "Out of memory!\n");
errstr = OUT_OF_MEMORY;
return 0;
}
if ((image->file = gzopen(fileName, "rb")) == 0) {
errstr = FILE_OPEN_ERROR;
return 0;
}
@@ -537,13 +588,84 @@ SGTexture::RawImageOpen(const char *fileName)
image->tmp = new GLubyte;
if (image->tmp == 0) {
// fprintf(stderr, "\nOut of memory!\n");
errstr = OUT_OF_MEMORY;
return 0;
}
return image;
}
SGTexture::ImageRec *
SGTexture::ImageWriteOpen(const char *fileName)
{
union {
int testWord;
char testByte[4];
} endianTest;
ImageRec* image;
int swapFlag;
int x;
endianTest.testWord = 1;
if (endianTest.testByte[0] == 1) {
swapFlag = 1;
} else {
swapFlag = 0;
}
image = new SGTexture::ImageRec;
memset(image, 0, sizeof(SGTexture::ImageRec));
if (image == 0) {
errstr = OUT_OF_MEMORY;
return 0;
}
if ((file = fopen(fileName, "wb")) == 0) {
errstr = FILE_OPEN_ERROR;
return 0;
}
image->imagic = 474;
image->type = 0x0001;
image->dim = (num_colors > 1) ? 3 : 2;
image->xsize = texture_width;
image->ysize = texture_height;
image->zsize = num_colors;
if (swapFlag) {
ConvertShort(&image->imagic, 6);
}
fwrite(image, 1, 12, file);
fseek(file, 512, SEEK_SET);
image->tmp = new GLubyte[ image->xsize * 256 ];
if (image->tmp == 0) {
errstr = OUT_OF_MEMORY;
return 0;
}
if ((image->type & 0xFF00) == 0x0100) {
x = image->ysize * image->zsize * (int) sizeof(unsigned);
image->rowStart = new unsigned[x];
image->rowSize = new int[x];
if (image->rowStart == 0 || image->rowSize == 0) {
errstr = OUT_OF_MEMORY;
return 0;
}
image->rleEnd = 512 + (2 * x);
fseek(file, 512, SEEK_SET);
fread(image->rowStart, 1, x, file);
fread(image->rowSize, 1, x, file);
if (swapFlag) {
ConvertUint(image->rowStart, x/(int) sizeof(unsigned));
ConvertUint((unsigned *)image->rowSize, x/(int) sizeof(int));
}
}
return image;
}
void
SGTexture::ImageGetRow(SGTexture::ImageRec *image, GLubyte *buf, int y, int z) {
GLubyte *iPtr, *oPtr, pixel;
@@ -560,6 +682,7 @@ SGTexture::ImageGetRow(SGTexture::ImageRec *image, GLubyte *buf, int y, int z) {
pixel = *iPtr++;
count = (int)(pixel & 0x7F);
if (!count) {
errstr = WRONG_COUNT;
return;
}
if (pixel & 0x80) {
@@ -580,6 +703,44 @@ SGTexture::ImageGetRow(SGTexture::ImageRec *image, GLubyte *buf, int y, int z) {
}
}
void
SGTexture::ImagePutRow(SGTexture::ImageRec *image, GLubyte *buf, int y, int z) {
GLubyte *iPtr, *oPtr, pixel;
int count;
if ((image->type & 0xFF00) == 0x0100) {
fseek(file, (long) image->rowStart[y+z*image->ysize], SEEK_SET);
fread( image->tmp, 1, (unsigned int)image->rowSize[y+z*image->ysize],
file);
iPtr = image->tmp;
oPtr = buf;
for (;;) {
pixel = *iPtr++;
count = (int)(pixel & 0x7F);
if (!count) {
errstr = WRONG_COUNT;
return;
}
if (pixel & 0x80) {
while (count--) {
*oPtr++ = *iPtr++;
}
} else {
pixel = *iPtr++;
while (count--) {
*oPtr++ = pixel;
}
}
}
} else {
fseek(file, 512+(y*image->xsize)+(z*image->xsize*image->ysize),
SEEK_SET);
fread(buf, 1, image->xsize, file);
}
}
void
SGTexture::rgbtorgb(GLubyte *r, GLubyte *g, GLubyte *b, GLubyte *l, int n) {
while(n--) {
@@ -632,3 +793,175 @@ SGTexture::ConvertUint(unsigned *array, unsigned int length) {
}
}
void
SGTexture::make_monochrome(float contrast, GLubyte r, GLubyte g, GLubyte b) {
if (num_colors >= 3)
return;
GLubyte ap[3];
for (int y=0; y<texture_height; y++)
for (int x=0; x<texture_width; x++)
{
GLubyte *rgb = get_pixel(x,y);
GLubyte avg = (rgb[0] + rgb[1] + rgb[2]) / 3;
if (contrast != 1.0) {
float pixcol = -1.0 + (avg/128);
avg = 128 + int(128*pow(pixcol, contrast));
}
ap[0] = avg*r/255;
ap[1] = avg*g/255;
ap[2] = avg*b/255;
set_pixel(x,y,ap);
}
}
void
SGTexture::make_grayscale(float contrast) {
if (num_colors < 3)
return;
int colors = (num_colors == 3) ? 1 : 2;
GLubyte *map = (GLubyte *)malloc (texture_width * texture_height * colors);
for (int y=0; y<texture_height; y++)
for (int x=0; x<texture_width; x++)
{
GLubyte *rgb = get_pixel(x,y);
GLubyte avg = (rgb[0] + rgb[1] + rgb[2]) / 3;
if (contrast != 1.0) {
float pixcol = -1.0 + (avg/128);
avg = 128 + int(128*pow(pixcol, contrast));
}
int pos = (x + y*texture_width)*colors;
map[pos] = avg;
if (colors > 1)
map[pos+1] = rgb[3];
}
free (texture_data);
texture_data = map;
num_colors = colors;
}
void
SGTexture::make_maxcolorwindow() {
GLubyte minmaxc[2] = {255, 0};
unsigned int pos = 0;
unsigned int max = num_colors;
if (num_colors == 2) max = 1;
if (num_colors == 4) max = 3;
while (pos < texture_width * texture_height * num_colors) {
for (int i=0; i < max; i++) {
GLubyte c = texture_data[pos+i];
if (c < minmaxc[0]) minmaxc[0] = c;
if (c > minmaxc[1]) minmaxc[1] = c;
}
pos += num_colors;
}
GLubyte offs = minmaxc[0];
float factor = 255.0 / float(minmaxc[1] - minmaxc[0]);
// printf("Min: %i, Max: %i, Factor: %f\n", offs, minmaxc[1], factor);
pos = 0;
while (pos < texture_width * texture_height * num_colors) {
for (int i=0; i < max; i++) {
texture_data[pos+i] -= offs;
texture_data[pos+i] = int(factor * texture_data[pos+i]);
}
pos += num_colors;
}
}
void
SGTexture::make_normalmap(float brightness, float contrast) {
make_grayscale(contrast);
make_maxcolorwindow();
int colors = (num_colors == 1) ? 3 : 4;
bool alpha = (colors > 3);
int tsize = texture_width * texture_height * colors;
GLubyte *map = (GLubyte *)malloc (tsize);
int mpos = 0, dpos = 0;
for (int y=0; y<texture_height; y++) {
int ytw = y*texture_width;
for (int x=0; x<texture_width; x++)
{
int xp1 = (x < (texture_width-1)) ? x+1 : 0;
int yp1 = (y < (texture_height-1)) ? y+1 : 0;
int posxp1 = (xp1 + ytw)*num_colors;
int posyp1 = (x + yp1*texture_width)*num_colors;
GLubyte c = texture_data[dpos];
GLubyte cx1 = texture_data[posxp1];
GLubyte cy1 = texture_data[posyp1];
if (alpha) {
GLubyte a = texture_data[dpos+1];
GLubyte ax1 = texture_data[posxp1+1];
GLubyte ay1 = texture_data[posyp1+1];
c = (c + a)/2;
cx1 = (cx1 + ax1)/2;
cy1 = (cy1 + ay1)/2;
map[mpos+3] = a;
}
map[mpos+0] = (128+(cx1-c)/2);
map[mpos+1] = (128+(cy1-c)/2);
map[mpos+2] = 127+int(brightness*128); // 255-c/2;
mpos += colors;
dpos += num_colors;
}
}
free (texture_data);
texture_data = map;
num_colors = colors;
}
void
SGTexture::make_bumpmap(float brightness, float contrast) {
make_grayscale(contrast);
int colors = (num_colors == 1) ? 1 : 2;
GLubyte *map = (GLubyte *)malloc (texture_width * texture_height * colors);
for (int y=0; y<texture_height; y++)
for (int x=0; x<texture_width; x++)
{
int mpos = (x + y*texture_width)*colors;
int dpos = (x + y*texture_width)*num_colors;
int xp1 = (x < (texture_width-1)) ? x+1 : 0;
int yp1 = (y < (texture_height-1)) ? y+1 : 0;
int posxp1 = (xp1 + y*texture_width)*num_colors;
int posyp1 = (x + yp1*texture_width)*num_colors;
map[mpos] = (127 - ((texture_data[dpos]-texture_data[posxp1]) -
((texture_data[dpos]-texture_data[posyp1]))/4))/2;
if (colors > 1)
map[mpos+1] = texture_data[dpos+1];
}
free (texture_data);
texture_data = map;
num_colors = colors;
}

View File

@@ -1,4 +1,4 @@
/**
/*
* \file texture.hxx
* Texture manipulation routines
*
@@ -13,7 +13,8 @@
#ifndef __SG_TEXTURE_HXX
#define __SG_TEXTURE_HXX 1
#include <GL/gl.h>
#include <simgear/compiler.h>
#include SG_GL_H
#include <zlib.h>
#include <plib/sg.h>
@@ -35,8 +36,11 @@ private:
void resize(unsigned int width = 256, unsigned int height = 256);
const char *errstr;
protected:
FILE *file;
typedef struct _ImageRec {
unsigned short imagic;
unsigned short type;
@@ -60,9 +64,11 @@ protected:
GLubyte *l, int n);
ImageRec *ImageOpen(const char *fileName);
ImageRec *ImageWriteOpen(const char *fileName);
ImageRec *RawImageOpen(const char *fileName);
void ImageClose(ImageRec *image);
void ImageGetRow(ImageRec *image, GLubyte *buf, int y, int z);
void ImagePutRow(ImageRec *image, GLubyte *buf, int y, int z);
inline void free_id() {
#ifdef GL_VERSION_1_1
@@ -86,15 +92,18 @@ public:
void read_rgba_texture(const char *name);
void read_raw_texture(const char *name);
void read_r8_texture(const char *name);
void write_texture(const char *name);
inline bool usable() { return (texture_id > 0) ? true : false; }
inline GLuint id() { return texture_id; }
inline GLubyte *texture() { return texture_data; }
inline void set_data(GLubyte *data) { texture_data = data; }
// inline void set_colors(int c) { num_colors = c; }
inline int width() { return texture_width; }
inline int height() { return texture_height; }
inline int colors() { return num_colors; }
// dynamic texture functions.
// everything drawn to the OpenGL screen after prepare is
@@ -104,8 +113,8 @@ public:
void finish(unsigned int width, unsigned int height);
// texture pixel manipulation functions.
void set_pixel(GLuint x, GLuint y, sgVec3 &c);
float *get_pixel(GLuint x, GLuint y);
void set_pixel(GLuint x, GLuint y, GLubyte *c);
GLubyte *get_pixel(GLuint x, GLuint y);
void bind();
inline void select(bool keep_data = false) {
@@ -127,6 +136,16 @@ public:
glAreTexturesResident(1, &texture_id, &is_res);
return is_res != 0;
}
inline const char *err_str() { return errstr; }
inline void clear_err_str() { errstr = ""; }
void make_maxcolorwindow();
void make_grayscale(float contrast = 1.0);
void make_monochrome(float contrast = 1.0,
GLubyte r=255, GLubyte g=255, GLubyte b=255);
void make_normalmap(float brightness = 1.0, float contrast = 1.0);
void make_bumpmap(float brightness = 1.0, float contrast = 1.0);
};
#endif

View File

@@ -2,8 +2,13 @@
/*
* $Log$
* Revision 1.1 2002/09/07 02:58:19 curt
* Initial revision
* Revision 1.2 2004/11/18 19:10:34 curt
* Abstract out location of gl.h, glut.h, and glu.h includes so that we can
* make the Mac platform happy since they put these in a different place compared
* to the rest of the world.
*
* Revision 1.1.1.1 2002/09/07 02:58:19 curt
* Initial revsion of Simgear-0.3.0
*
* Revision 1.3 2001/07/30 20:34:21 curt
* Various MSVC fixes.
@@ -62,8 +67,9 @@
#ifdef WIN32
#include <windows.h>
#endif
#include <GL/gl.h>
#include <GL/glu.h>
#include SG_GLU_H
#include <plib/ssg.h>
#include "tr.h"

View File

@@ -2,8 +2,13 @@
/*
* $Log$
* Revision 1.1 2002/09/07 02:58:19 curt
* Initial revision
* Revision 1.2 2004/11/18 19:10:34 curt
* Abstract out location of gl.h, glut.h, and glu.h includes so that we can
* make the Mac platform happy since they put these in a different place compared
* to the rest of the world.
*
* Revision 1.1.1.1 2002/09/07 02:58:19 curt
* Initial revsion of Simgear-0.3.0
*
* Revision 1.1 2001/06/26 15:19:39 curt
* Added tr.cxx / tr.h, Brian Paul's LGPL'd tiled rendering support libs for
@@ -75,8 +80,9 @@
#ifndef TR_H
#define TR_H
#include <simgear/compiler.h>
#include <GL/gl.h>
#include SG_GL_H
//#ifdef __cplusplus

View File

@@ -2,7 +2,7 @@
//
// Written by Curtis Olson, started November 1998.
//
// Copyright (C) 1998 Curtis L. Olson - curt@flightgear.org
// Copyright (C) 1998 Curtis L. Olson - http://www.flightgear.org/~curt
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
@@ -129,7 +129,7 @@ bool SGSerialPort::open_port(const string& device) {
// config.c_cflag |= CLOCAL;
#if ! defined( sgi )
#if !defined( sgi ) && !defined(_AIX)
// disable hardware flow control
config.c_cflag &= ~(CRTSCTS);
#endif
@@ -234,11 +234,11 @@ bool SGSerialPort::set_baud(int baud) {
speed = B19200;
} else if ( baud == 38400 ) {
speed = B38400;
#if defined( linux ) || defined( __FreeBSD__ )
} else if ( baud == 57600 ) {
speed = B57600;
} else if ( baud == 115200 ) {
speed = B115200;
#if defined( linux ) || defined( __FreeBSD__ )
} else if ( baud == 230400 ) {
speed = B230400;
#endif

View File

@@ -5,7 +5,7 @@
// Written by Curtis Olson, started November 1998.
//
// Copyright (C) 1998 Curtis L. Olson - curt@flightgear.org
// Copyright (C) 1998 Curtis L. Olson - http://www.flightgear.org/~curt
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public

View File

@@ -2,7 +2,7 @@
//
// Written by Curtis Olson, started April 2004.
//
// Copyright (C) 2004 Curtis L. Olson - curt@flightgear.org
// Copyright (C) 2004 Curtis L. Olson - http://www.flightgear.org/~curt
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
@@ -123,7 +123,7 @@ SGSoundSample::SGSoundSample( const char *path, const char *file,
// Bind buffer with a source.
alGenSources(1, &source);
if (alGetError() != AL_NO_ERROR) {
throw sg_exception("Failed to gen source.");
throw sg_exception("Failed to gen source.\nPlease update your sound driver and try again.");
}
alSourcei( source, AL_BUFFER, buffer );
@@ -193,7 +193,7 @@ SGSoundSample::SGSoundSample( unsigned char *_data, int len, int _freq,
// Bind buffer with a source.
alGenSources(1, &source);
if (alGetError() != AL_NO_ERROR) {
throw sg_exception("Failed to gen source.");
throw sg_exception("Failed to gen source.\nPlease update your sound driver and try again.");
}
alSourcei( source, AL_BUFFER, buffer );

Some files were not shown because too many files have changed in this diff Show More