Celestia on Solaris and the X Window System

I compiled and ran Celestia v. 1.5.1 on my Solaris machine:

uname -a
SunOS i5 5.10 Generic_127111-05 sun4u sparc SUNW,Sun-Fire-V240

I am displaying the output of Celestia with X Window servers running on Mac OS X and Windows XP. But on OS X, only the very brightest stars appear. And on XP, no sunlight falls on the planets. Thank you in advance for your help.

I downloaded the source code of Celestia from
http://prdownloads.sourceforge.net/celestia/celestia-1.5.1.tar.gz?download
The Celestia README file offers four choices:

	--with-gtk
	--with-kde
	--with-gnome
	--with-glut
I decided to go with GLUT for simplicity.

Install GLUT

Since I don’t have GLUT, I began by installing it on my Solaris machine. Downloading it went smoothly:

v=glut-3.7
wget --quiet http://www.opengl.org/resources/libraries/glut/$v.tar.gz
gunzip $v.tar.gz
tar xf $v.tar
cd $v
My C and C++ compiler is
gcc -v
Reading specs from /usr/sfw/lib/gcc/sparc-sun-solaris2.10/3.4.3/specs
Configured with:
/gates/sfw10/builds/sfw10-gate/usr/src/cmd/gcc/gcc-3.4.3/configure
--prefix=/usr/sfw --with-as=/usr/sfw/bin/gas --with-gnu-as
--with-ld=/usr/ccs/bin/ld --without-gnu-ld --enable-languages=c,c++
--enable-shared
Thread model: posix
gcc version 3.4.3 (csl-sol210-3_4-branch+sol_rpath)

To get GLUT to compile, I had to make two trivial changes to the source code. I perform the changes with perl commands, which can be put into a script once and for all.

perl -i -pe 'if ($. == 9) {
	print '"'"'
#include <sys/time.h>
struct timeval {
        time_t tv_sec;	/* seconds */
        long   tv_usec;	/* and microseconds */
};
'"'"';
		}
' lib/glut/glutint.h

perl -i -pe 's:^:#include <sys/select.h>: if $. == 14;' lib/glut/glut_event.c

Following the directions in the linux/README file that came with GLUT, I performed the following mvs and lns. I also had to make two trivial changes to the Makefiles.

mv Glut.cf oldGlut.cf
mv linux/Glut.cf .
./mkmkfiles.imake
mv lib/glut/Makefile lib/glut/oldMakefile
perl -pe 's/\s*-m486//g' linux/Makefile > lib/glut/Makefile

cd lib/glut
perl -i -pe 's/ -Wl,-soname,libglut\.so\.3// if $. == 534;' Makefile
make
ln -s libglut.so.3.7 libglut.so.3
ln -s libglut.so.3.7 libglut.so

cd ../..
make

All done! GLUT is installed.

Install Celestia

Downloading Celestia went smoothly:

v=celestia-1.5.1
wget --quiet http://prdownloads.sourceforge.net/celestia/$v.tar.gz
gunzip $v.tar.gz
tar xf $v.tar
cd $v

I passed lots of arguments to ./configure, maybe more than I need right now. But I’m planning to upgrade to GTK after I get GLUT completely working.

./configure \
--quiet \
--with-glut \
--with-glut-inc=$HOME/public_html/planetarium/c/glut-3.7/include \
--without-lua \
--prefix=$HOME/public_html/planetarium/c \
--with-gl-libs=/usr/openwin/lib \
LDFLAGS='-L/usr/openwin/lib -L/opt/csw/lib' \
CPPFLAGS='-Usun' \
GTK_CFLAGS='-I /opt/csw/include/gtk-2.0/gtk -I /opt/csw/include/gtk-2.0 -I /opt/csw/include/cairo -I /opt/csw/include/glib-2.0 -I /opt/csw/lib/glib-2.0/include -I /opt/csw/include/pango-1.0 -I /opt/csw/lib/gtk-2.0/include -I /opt/csw/include/atk-1.0' \
GTK_LIBS='-L/opt/csw/lib -R/opt/csw/lib -lgtk-x11-2.0 -lglib-2.0 -lgobject-2.0'

./configure yielded an exit status of zero, indicating success.

To get Celestia to compile, I had to change two of the Makefiles.

perl -i -pe '
	s/ -lm /$& -liconv /;
	s: -L/usr/openwin/lib::;
	s:(-L) (/usr/openwin/lib):$1$2:;
	s:(-L) (/opt/csw/lib):$1$2:;
' src/celestia/Makefile

perl -i -pe '
	s: -L/usr/openwin/lib::;
	s:(-L) (/usr/openwin/lib):$1$2:;
	s:(-L) (/opt/csw/lib):$1$2:;
' src/Makefile

I also had to change four of the source code files. One problem was that the C++ data type struct tm on my machine does not have the fields tm_gtoff and tm_zone. The most common problem, however, was that the data type char is signed on my machine while GLcharARB is a typedef for unsigned char.

perl -i -pe '
	s:^://: if $. == 472 || $. == 473;
	s/^(\s*)(char\* strftime_format;)/$1const $2/ if $. == 475;
	s/^(\s*)(char\* inBuff = )/$1const $2/ if $. == 508;
	s/localt->tm_gmtoff/((localt->tm_isdst > 0 ? -4 : -5) * 60 * 60)/
		if $. == 760;
	s/localt->tm_zone/(localt->tm_isdst > 0 ? "EDT" : "EST")/ if $. == 761;
' src/celengine/astro.cpp

perl -i -pe '
s/^\s*$/extern "C" FUNCS glXGetProcAddressARB(const GLubyte *);/ if $. == 304;
' src/celengine/glext.cpp

perl -i -pe '
	s/\bchar\b/GLcharARB/g if $. == 44 || $. == 348;
	s/(= )(source\[i\]\.c_str\(\))/$1 reinterpret_cast<const GLcharARB *>($2)/
		if $. == 46;

	s/(, )(name)/$1reinterpret_cast<const GLcharARB *>($2)/
		if $. == 81 || $. == 100 || $. == 127;

	s/(log)(,)/reinterpret_cast<const char *>($1)$2/ if $. == 354;
' src/celengine/glshader.cpp

perl -i -pe '
	s/(, )("[^"]*")/$1reinterpret_cast<const GLcharARB *>($2)/
		if $. == 2027
			|| $. == 2033
			|| $. == 2196
			|| $. == 2203
			|| $. == 2210
			|| $. == 2217
			|| $. == 2214
			|| $. == 2224
			|| $. == 2231
			|| $. == 2238
			|| $. == 2245;
' src/celengine/shadermanager.cpp

make install left the data files uninstalled for some reason, so I linked them in myself.

cd $v
make
make install

cd data
ln `ls | grep -v 'stars\.dat'` ../../share/celestia/data
cd ..

ln extras/*  ../share/celestia/extras
ln fonts/*   ../share/celestia/fonts
ln models/*  ../share/celestia/models
ln shaders/* ../share/celestia/shaders

ln *.cel splash.png ../share/celestia
ln textures/logo.png ../share/celestia/textures

ln textures/lores/*  ../share/celestia/textures/lores
ln textures/medres/* ../share/celestia/textures/medres
ln textures/hires/*  ../share/celestia/textures/hires

All done! Celestia is installed.

The X Window servers

The Celestia I compiled is an X Window client, so I had to launch an X Window server. I tried two of them:

  1. The X Window server X11.app (version 1.1.3 – XFree86 4.4.0) on Mac OS X (version 10.4.11). In the xterm displayed by X11.app, I logged onto my Solaris server with ssh -Y (version Sun_SSH_1.1, SSH protocols 1.5/2.0, OpenSSL 0x0090704f), and launched my Celestia.

  2. The X Window server Xming (version 6.9.0.31) on a Microsoft Windows XP Professional, version 2002, Sevice Pack 3, Pentium(R) D CPU 2.80 GHz, etc. On the XP, I logged onto my Solaris server with PuTTY (version 0.57) with X11 forwarding enabled, and launched my Celestia.

What I saw

Using X11.app on the Macintosh, only the very brightest stars appeared. Here, for example, is Orion with autoMag off and Magnitude Limit set to 9.08. You can see Rigel and just barely Betelgeuse. Where are the rest of the stars? The star labels appear when I type B, but the stars themselves are quite invisible.

Using Xming on the XP, the stars are fine. But this time, no sunlight falls on the planets. Here, for example, is Earth. You can see the atmosphere all around the planet’s limb, and if I step up the ambient light all the way I can just barely see the continents. But no sunlight falls on the Earth.

Details

Not sure what the following mean, or if they are the cause of my problems.

  1. When I ran /usr/openwin/bin/xdpyinfo -queryExtensions on my Solaris box and connected it to the X Window servers running on the Mac and XP, I got these results on the Mac and XP.

  2. When I ran glxinfo -v on my Solaris box and connected it to the X Window servers running on the Mac and XP, I got these results on the Mac (a mere 27 OpenGL Extensions) and XP (32 OpenGL Extensions). But when I ran glxinfo -v on my Mac and connected it to the X Window server running on the same machine, I got these results (a whopping 95 OpenGL Extensions). And when I ran glxinfo -v on the XP and connected it to the X Window server running on the same machine, I got these results (90 OpenGL Extensions; didn’t bother to save the rest). /usr/openwin/demo/GL/xglinfo running on Solaris connected to X Window server on Mac gives this output.

  3. I inserted a call to glGetString(GL_EXTENSIONS) into the main function of my Celestia in the file celestia-1.5.1/src/celestia/glutmain.cpp. Here are the results I got, alphabetized for your convenience, on the Mac and XP. They are exactly the same lists of words that appeared in “OpenGL Extensions” in the output of the glxinfo -v I ran on Solaris.

  4. When I downloaded the Celestia executables from http://www.shatters.net/celestia/download.html and said
    HelpOpenGL Info
    I got these results on the Mac and XP.

More details

The Mac has the following display adapter:

ATI Radeon HD 2600 Pro:

  Chipset Model:	ATI,RadeonHD2600
  Type:	Display
  Bus:	PCIe
  PCIe Lane Width:	x16
  VRAM (Total):	256 MB
  Vendor:	ATI (0x1002)
  Device ID:	0x9583
  Revision ID:	0x0000
  ROM Revision:	113-B2250F-219
  EFI Driver Version:	01.00.219
  Displays:
Color LCD:
  Display Type:	LCD
  Resolution:	1680 x 1050
  Depth:	32-bit Color
  Built-In:	Yes
  Core Image:	Hardware Accelerated
  Main Display:	Yes
  Mirror:	Off
  Online:	Yes
  Quartz Extreme:	Supported
Display Connector:
  Status:	No display connected

The XP display adapter is Radeon X600 Series, ATI Technologies, Driver Date 3/14/2005, Driver Version 6.14.10.6525.

To get Celestia to connect to the X Window server, I had to comment out the GLX_RGBA that is passed to the function glXChooseVisual in line 290 of the file glut-3.7/lib/glut/glut_win.c. I also had to comment out the GLX_RGBA from glxinfo.c.

Finally, as noted above, I had to insert the declaration

extern "C" FUNCS glXGetProcAddressARB(const GLubyte *);
into the file src/celengine/glext.cpp to get the call to glXGetProcAddressARB to compile.