Added PNG support for UNIX.
parent
5106609418
commit
64753fe426
|
@ -30,6 +30,9 @@
|
||||||
/* Define if you have the jpeg library (-ljpeg). */
|
/* Define if you have the jpeg library (-ljpeg). */
|
||||||
#undef HAVE_LIBJPEG
|
#undef HAVE_LIBJPEG
|
||||||
|
|
||||||
|
/* Define if you have the png library (-lpng). */
|
||||||
|
#undef HAVE_LIBPNG
|
||||||
|
|
||||||
/* Name of package */
|
/* Name of package */
|
||||||
#undef PACKAGE
|
#undef PACKAGE
|
||||||
|
|
||||||
|
|
|
@ -2509,16 +2509,64 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
echo $ac_n "checking for png_create_info_struct in -lpng""... $ac_c" 1>&6
|
||||||
|
echo "configure:2514: checking for png_create_info_struct in -lpng" >&5
|
||||||
|
ac_lib_var=`echo png'_'png_create_info_struct | sed 'y%./+-%__p_%'`
|
||||||
|
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
|
||||||
|
echo $ac_n "(cached) $ac_c" 1>&6
|
||||||
|
else
|
||||||
|
ac_save_LIBS="$LIBS"
|
||||||
|
LIBS="-lpng $LIBS"
|
||||||
|
cat > conftest.$ac_ext <<EOF
|
||||||
|
#line 2522 "configure"
|
||||||
|
#include "confdefs.h"
|
||||||
|
/* Override any gcc2 internal prototype to avoid an error. */
|
||||||
|
/* We use char because int might match the return type of a gcc2
|
||||||
|
builtin and then its argument prototype would still apply. */
|
||||||
|
char png_create_info_struct();
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
png_create_info_struct()
|
||||||
|
; return 0; }
|
||||||
|
EOF
|
||||||
|
if { (eval echo configure:2533: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
|
||||||
|
rm -rf conftest*
|
||||||
|
eval "ac_cv_lib_$ac_lib_var=yes"
|
||||||
|
else
|
||||||
|
echo "configure: failed program was:" >&5
|
||||||
|
cat conftest.$ac_ext >&5
|
||||||
|
rm -rf conftest*
|
||||||
|
eval "ac_cv_lib_$ac_lib_var=no"
|
||||||
|
fi
|
||||||
|
rm -f conftest*
|
||||||
|
LIBS="$ac_save_LIBS"
|
||||||
|
|
||||||
|
fi
|
||||||
|
if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
|
||||||
|
echo "$ac_t""yes" 1>&6
|
||||||
|
ac_tr_lib=HAVE_LIB`echo png | sed -e 's/[^a-zA-Z0-9_]/_/g' \
|
||||||
|
-e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
|
||||||
|
cat >> confdefs.h <<EOF
|
||||||
|
#define $ac_tr_lib 1
|
||||||
|
EOF
|
||||||
|
|
||||||
|
LIBS="-lpng $LIBS"
|
||||||
|
|
||||||
|
else
|
||||||
|
echo "$ac_t""no" 1>&6
|
||||||
|
{ echo "configure: error: png library not found" 1>&2; exit 1; }
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
|
echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
|
||||||
echo "configure:2517: checking for ANSI C header files" >&5
|
echo "configure:2565: checking for ANSI C header files" >&5
|
||||||
if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
|
if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
|
||||||
echo $ac_n "(cached) $ac_c" 1>&6
|
echo $ac_n "(cached) $ac_c" 1>&6
|
||||||
else
|
else
|
||||||
cat > conftest.$ac_ext <<EOF
|
cat > conftest.$ac_ext <<EOF
|
||||||
#line 2522 "configure"
|
#line 2570 "configure"
|
||||||
#include "confdefs.h"
|
#include "confdefs.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
@ -2526,7 +2574,7 @@ else
|
||||||
#include <float.h>
|
#include <float.h>
|
||||||
EOF
|
EOF
|
||||||
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
|
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
|
||||||
{ (eval echo configure:2530: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
|
{ (eval echo configure:2578: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
|
||||||
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
|
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
|
||||||
if test -z "$ac_err"; then
|
if test -z "$ac_err"; then
|
||||||
rm -rf conftest*
|
rm -rf conftest*
|
||||||
|
@ -2543,7 +2591,7 @@ rm -f conftest*
|
||||||
if test $ac_cv_header_stdc = yes; then
|
if test $ac_cv_header_stdc = yes; then
|
||||||
# SunOS 4.x string.h does not declare mem*, contrary to ANSI.
|
# SunOS 4.x string.h does not declare mem*, contrary to ANSI.
|
||||||
cat > conftest.$ac_ext <<EOF
|
cat > conftest.$ac_ext <<EOF
|
||||||
#line 2547 "configure"
|
#line 2595 "configure"
|
||||||
#include "confdefs.h"
|
#include "confdefs.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
EOF
|
EOF
|
||||||
|
@ -2561,7 +2609,7 @@ fi
|
||||||
if test $ac_cv_header_stdc = yes; then
|
if test $ac_cv_header_stdc = yes; then
|
||||||
# ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
|
# ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
|
||||||
cat > conftest.$ac_ext <<EOF
|
cat > conftest.$ac_ext <<EOF
|
||||||
#line 2565 "configure"
|
#line 2613 "configure"
|
||||||
#include "confdefs.h"
|
#include "confdefs.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
EOF
|
EOF
|
||||||
|
@ -2582,7 +2630,7 @@ if test "$cross_compiling" = yes; then
|
||||||
:
|
:
|
||||||
else
|
else
|
||||||
cat > conftest.$ac_ext <<EOF
|
cat > conftest.$ac_ext <<EOF
|
||||||
#line 2586 "configure"
|
#line 2634 "configure"
|
||||||
#include "confdefs.h"
|
#include "confdefs.h"
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
|
#define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
|
||||||
|
@ -2593,7 +2641,7 @@ if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
|
||||||
exit (0); }
|
exit (0); }
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
if { (eval echo configure:2597: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
|
if { (eval echo configure:2645: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
|
||||||
then
|
then
|
||||||
:
|
:
|
||||||
else
|
else
|
||||||
|
@ -2621,17 +2669,17 @@ for ac_hdr in GL/gl.h GL/glut.h
|
||||||
do
|
do
|
||||||
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
|
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
|
||||||
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
|
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
|
||||||
echo "configure:2625: checking for $ac_hdr" >&5
|
echo "configure:2673: checking for $ac_hdr" >&5
|
||||||
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
|
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
|
||||||
echo $ac_n "(cached) $ac_c" 1>&6
|
echo $ac_n "(cached) $ac_c" 1>&6
|
||||||
else
|
else
|
||||||
cat > conftest.$ac_ext <<EOF
|
cat > conftest.$ac_ext <<EOF
|
||||||
#line 2630 "configure"
|
#line 2678 "configure"
|
||||||
#include "confdefs.h"
|
#include "confdefs.h"
|
||||||
#include <$ac_hdr>
|
#include <$ac_hdr>
|
||||||
EOF
|
EOF
|
||||||
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
|
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
|
||||||
{ (eval echo configure:2635: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
|
{ (eval echo configure:2683: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
|
||||||
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
|
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
|
||||||
if test -z "$ac_err"; then
|
if test -z "$ac_err"; then
|
||||||
rm -rf conftest*
|
rm -rf conftest*
|
||||||
|
@ -3044,10 +3092,7 @@ test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1
|
||||||
echo "$ac_t""" 1>&6
|
echo "$ac_t""" 1>&6
|
||||||
echo "$ac_t""" 1>&6
|
echo "$ac_t""" 1>&6
|
||||||
echo "$ac_t""********************************************************************" 1>&6
|
echo "$ac_t""********************************************************************" 1>&6
|
||||||
echo "$ac_t""*** Before compiling Celestia take a look at the configuration " 1>&6
|
echo "$ac_t""*** Celestia configuration complete." 1>&6
|
||||||
echo "$ac_t""*** file in the conf directory. Default configuration file is tuned " 1>&6
|
|
||||||
echo "$ac_t""*** for a GeForce card so if you own a less powerful card you'll " 1>&6
|
|
||||||
echo "$ac_t""*** have to edit that file and read carefully " 1>&6
|
|
||||||
echo "$ac_t""********************************************************************" 1>&6
|
echo "$ac_t""********************************************************************" 1>&6
|
||||||
echo "$ac_t""" 1>&6
|
echo "$ac_t""" 1>&6
|
||||||
echo "$ac_t""" 1>&6
|
echo "$ac_t""" 1>&6
|
||||||
|
|
|
@ -71,6 +71,9 @@ dnl Check for JPEG library.
|
||||||
AC_CHECK_LIB(jpeg, jpeg_start_decompress,,
|
AC_CHECK_LIB(jpeg, jpeg_start_decompress,,
|
||||||
AC_MSG_ERROR(jpeg library not found))
|
AC_MSG_ERROR(jpeg library not found))
|
||||||
|
|
||||||
|
dnl Check for PNG library.
|
||||||
|
AC_CHECK_LIB(png, png_create_info_struct,,
|
||||||
|
AC_MSG_ERROR(png library not found))
|
||||||
|
|
||||||
|
|
||||||
dnl Checks for header files.
|
dnl Checks for header files.
|
||||||
|
@ -91,10 +94,7 @@ AC_OUTPUT( Makefile \
|
||||||
AC_MSG_RESULT()
|
AC_MSG_RESULT()
|
||||||
AC_MSG_RESULT()
|
AC_MSG_RESULT()
|
||||||
AC_MSG_RESULT(********************************************************************)
|
AC_MSG_RESULT(********************************************************************)
|
||||||
AC_MSG_RESULT(*** Before compiling Celestia take a look at the configuration )
|
AC_MSG_RESULT(*** Celestia configuration complete.)
|
||||||
AC_MSG_RESULT(*** file in the conf directory. Default configuration file is tuned )
|
|
||||||
AC_MSG_RESULT(*** for a GeForce card so if you own a less powerful card you'll )
|
|
||||||
AC_MSG_RESULT(*** have to edit that file and read carefully )
|
|
||||||
AC_MSG_RESULT(********************************************************************)
|
AC_MSG_RESULT(********************************************************************)
|
||||||
AC_MSG_RESULT()
|
AC_MSG_RESULT()
|
||||||
AC_MSG_RESULT()
|
AC_MSG_RESULT()
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#define PNG_SUPPORT
|
#define PNG_SUPPORT
|
||||||
#else
|
#else
|
||||||
#define IJG_JPEG_SUPPORT
|
#define IJG_JPEG_SUPPORT
|
||||||
|
#define PNG_SUPPORT
|
||||||
#endif // _WIN32
|
#endif // _WIN32
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
@ -24,16 +25,31 @@
|
||||||
#include "ijl.h"
|
#include "ijl.h"
|
||||||
#endif
|
#endif
|
||||||
#ifdef IJG_JPEG_SUPPORT
|
#ifdef IJG_JPEG_SUPPORT
|
||||||
|
#ifndef PNG_SUPPORT
|
||||||
#include "setjmp.h"
|
#include "setjmp.h"
|
||||||
|
#endif // PNG_SUPPORT
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include <jpeglib.h>
|
#include <jpeglib.h>
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_SUPPORT
|
#ifdef PNG_SUPPORT
|
||||||
#include "setjmp.h"
|
|
||||||
#include "png.h"
|
#include "png.h"
|
||||||
|
|
||||||
|
// Define png_jmpbuf() in case we are using a pre-1.0.6 version of libpng
|
||||||
|
#ifndef png_jmpbuf
|
||||||
|
#define png_jmpbuf(png_ptr) png_ptr->jmpbuf
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Define various expansion transformations for old versions of libpng
|
||||||
|
#if PNG_LIBPNG_VER < 10004
|
||||||
|
#define png_set_palette_to_rgb(p) png_set_expand(p)
|
||||||
|
#define png_set_gray_1_2_4_to_8(p) png_set_expand(p)
|
||||||
|
#define png_set_tRNS_to_alpha(p) png_set_expand(p)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // PNG_SUPPORT
|
||||||
|
|
||||||
#include "celestia.h"
|
#include "celestia.h"
|
||||||
#include "vecmath.h"
|
#include "vecmath.h"
|
||||||
#include "filetype.h"
|
#include "filetype.h"
|
||||||
|
@ -712,13 +728,19 @@ CTexture* CreatePNGTexture(const string& filename)
|
||||||
|
|
||||||
// TODO: consider using paletted textures if they're available
|
// TODO: consider using paletted textures if they're available
|
||||||
if (color_type == PNG_COLOR_TYPE_PALETTE)
|
if (color_type == PNG_COLOR_TYPE_PALETTE)
|
||||||
|
{
|
||||||
png_set_palette_to_rgb(png_ptr);
|
png_set_palette_to_rgb(png_ptr);
|
||||||
|
}
|
||||||
|
|
||||||
if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8)
|
if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8)
|
||||||
|
{
|
||||||
png_set_gray_1_2_4_to_8(png_ptr);
|
png_set_gray_1_2_4_to_8(png_ptr);
|
||||||
|
}
|
||||||
|
|
||||||
if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))
|
if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))
|
||||||
|
{
|
||||||
png_set_tRNS_to_alpha(png_ptr);
|
png_set_tRNS_to_alpha(png_ptr);
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: consider passing textures with < 8 bits/component to
|
// TODO: consider passing textures with < 8 bits/component to
|
||||||
// GL without expanding
|
// GL without expanding
|
||||||
|
|
Loading…
Reference in New Issue