summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2005-05-16 17:33:52 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2005-05-16 17:33:52 +0000
commite4e314d67ac1327aecad7bc2934921eec62050c8 (patch)
treea2b9b222d72dff45da774fce6d8911ab49b57571
parent18ce80c0ab33d39975ed996653942bd2a7614dc9 (diff)
downloadmana-e4e314d67ac1327aecad7bc2934921eec62050c8.tar.gz
mana-e4e314d67ac1327aecad7bc2934921eec62050c8.tar.bz2
mana-e4e314d67ac1327aecad7bc2934921eec62050c8.tar.xz
mana-e4e314d67ac1327aecad7bc2934921eec62050c8.zip
Leave out OpenGL completely when not enabled.
-rwxr-xr-xconfigure.ac28
-rw-r--r--src/Makefile.am2
-rw-r--r--src/graphics.cpp6
-rw-r--r--src/graphics.h4
-rw-r--r--src/gui/gui.cpp11
-rw-r--r--src/gui/gui.h2
-rw-r--r--src/main.cpp2
-rw-r--r--src/resources/image.h2
8 files changed, 38 insertions, 19 deletions
diff --git a/configure.ac b/configure.ac
index 2d58f52c..f2684b1f 100755
--- a/configure.ac
+++ b/configure.ac
@@ -25,18 +25,22 @@ AC_MSG_ERROR([ *** Unable to find PhysFS library (icculus.org/physfs/)]))
AC_CHECK_LIB([xml2], [xmlInitParser], ,
AC_MSG_ERROR([ *** Unable to find libxml2 library (xmlsoft.org)]))
-AC_CHECK_LIB(SDL_image, IMG_LoadPNG_RW, ,
+AC_CHECK_LIB(SDL_image, IMG_LoadPNG_RW, ,
AC_MSG_ERROR([ *** Unable to find SDL_image library with PNG support
(http://www.libsdl.org/projects/SDL_image/)]))
-AC_CHECK_LIB(SDL_mixer, Mix_OpenAudio, ,
-AC_MSG_ERROR([ *** Unable to find SDL_mixer library
+AC_CHECK_LIB(SDL_mixer, Mix_OpenAudio, ,
+AC_MSG_ERROR([ *** Unable to find SDL_mixer library
(http://www.libsdl.org/projects/SDL_mixer/)]))
# Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS([arpa/inet.h fcntl.h malloc.h netdb.h netinet/in.h stdlib.h string.h sys/socket.h unistd.h])
+# Check for guichan headers
+AC_CHECK_HEADERS([guichan.hpp], ,
+AC_MSG_ERROR([*** Library found but cannot find headers (guichan.sf.net) *** ]))
+
# Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_STDBOOL
AC_C_CONST
@@ -53,15 +57,9 @@ AC_CHECK_FUNCS([atexit floor getcwd gethostbyname memset mkdir select socket])
AM_INIT_AUTOMAKE
-dnl Check for guichan headers
-AC_CHECK_HEADERS(guichan.hpp, have_guichan_h=yes, have_guichan_h=no)
-if test "$have_guichan_h" != yes; then
- AC_MSG_ERROR([*** Library found but cannot find headers (guichan.sf.net) *** ])
-fi
-
-dnl Option to enable OpenGL
-AC_ARG_WITH(opengl,[ --with-opengl use OpenGL ] )
-if test "x$with_opengl" == "xyes"; then
+# Option to enable OpenGL
+AC_ARG_WITH(opengl,[ --with-opengl use OpenGL ] )
+if test "x$with_opengl" == "xyes"; then
with_opengl=yes
OPENGL_CFLAGS=' -DUSE_OPENGL'
OPENGL_LIBS=' -lGL -lguichan_opengl'
@@ -71,8 +69,8 @@ else
with_opengl=no
fi
-dnl FIND_PATH(programm-name, variable-name, list of directories,
-dnl if-not-found, test-parameter)
+# FIND_PATH(programm-name, variable-name, list of directories,
+# if-not-found, test-parameter)
AC_DEFUN(FIND_PATH,
[
AC_MSG_CHECKING([for $1])
@@ -160,7 +158,7 @@ docs/Makefile
AC_OUTPUT
echo
-echo Build with OpenGL........... : $with_opengl
+echo Build with OpenGL: $with_opengl
echo
echo configure comlete, not type \"make\"
echo
diff --git a/src/Makefile.am b/src/Makefile.am
index b0323c5f..75519286 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -138,5 +138,5 @@ INCLUDES = \
# the library search path.
tmw_LDFLAGS = $(all_libraries) $(LIBSDL_RPATH) -lguichan_sdl -lguichan `pkg-config --libs libxml-2.0`
tmw_CXXFLAGS = -Wall $(OPENGL_CFLAGS) $(LIBSDL_CFLAGS) `pkg-config --cflags libxml-2.0` -fno-inline
-tmw_LDADD = $(OPENGL_LIBS) $(LIBSDL_LIBS) -lguichan -lphysfs
+tmw_LDADD = $(LIBSDL_LIBS) -lguichan $(OPENGL_LIBS) -lphysfs
tmw_TARGET = tmw
diff --git a/src/graphics.cpp b/src/graphics.cpp
index 94c23704..4e43b4b5 100644
--- a/src/graphics.cpp
+++ b/src/graphics.cpp
@@ -32,6 +32,7 @@ SDL_Surface *screen;
Graphics::Graphics():
mouseCursor(NULL)
{
+#ifdef USE_OPENGL
if (useOpenGL) {
// Setup OpenGL
glViewport(0, 0, 800, 600);
@@ -41,6 +42,7 @@ Graphics::Graphics():
logger->log("Using OpenGL %s double buffering.",
(gotDoubleBuffer ? "with" : "without"));
}
+#endif
#ifdef USE_OPENGL
setTargetPlane(800, 600);
@@ -139,6 +141,7 @@ void Graphics::updateScreen()
mouseCursor->draw(screen, mouseX - 5, mouseY - 2);
}
+#ifdef USE_OPENGL
if (useOpenGL) {
glFlush();
glFinish();
@@ -148,6 +151,9 @@ void Graphics::updateScreen()
else {
SDL_Flip(screen);
}
+#else
+ SDL_Flip(screen);
+#endif
// Decrement frame counter when using framerate limiting
if (framesToDraw > 1) framesToDraw--;
diff --git a/src/graphics.h b/src/graphics.h
index e6dd6b02..78d4a3e6 100644
--- a/src/graphics.h
+++ b/src/graphics.h
@@ -25,9 +25,11 @@
#define _GRAPHICS_H
#include <guichan/sdl.hpp>
-#include <guichan/opengl.hpp>
#include <SDL.h>
+#ifdef USE_OPENGL
+#include <guichan/opengl.hpp>
#include <SDL_opengl.h>
+#endif
#include "resources/image.h"
extern SDL_Surface *screen;
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp
index 5b527904..ab818555 100644
--- a/src/gui/gui.cpp
+++ b/src/gui/gui.cpp
@@ -34,8 +34,7 @@ Graphics *guiGraphics; // Graphics driver
gcn::SDLInput *guiInput; // GUI input
WindowContainer *guiTop; // The top container
-Gui::Gui(Graphics *graphics):
- hostImageLoader(NULL)
+Gui::Gui(Graphics *graphics)
{
// Set graphics
guiGraphics = graphics;
@@ -46,13 +45,19 @@ Gui::Gui(Graphics *graphics):
setInput(guiInput);
// Set image loader
+#ifdef USE_OPENGL
if (useOpenGL) {
hostImageLoader = new gcn::SDLImageLoader();
imageLoader = new gcn::OpenGLImageLoader(hostImageLoader);
}
else {
+ hostImageLoader = NULL;
imageLoader = new gcn::SDLImageLoader();
}
+#else
+ imageLoader = new gcn::SDLImageLoader();
+#endif
+
gcn::Image::setImageLoader(imageLoader);
// Initialize top GUI widget
@@ -84,9 +89,11 @@ Gui::~Gui()
delete guiFont;
delete guiTop;
delete imageLoader;
+#ifdef USE_OPENGL
if (hostImageLoader) {
delete hostImageLoader;
}
+#endif
delete guiInput;
}
diff --git a/src/gui/gui.h b/src/gui/gui.h
index ff1f4889..35b7e21f 100644
--- a/src/gui/gui.h
+++ b/src/gui/gui.h
@@ -73,7 +73,9 @@ class Gui : public gcn::Gui, public gcn::MouseListener
private:
gcn::Gui *gui; /**< The GUI system */
+#ifdef USE_OPENGL
gcn::ImageLoader *hostImageLoader; /**< For loading images in GL */
+#endif
gcn::ImageLoader *imageLoader; /**< For loading images */
gcn::ImageFont *guiFont; /**< The global GUI font */
diff --git a/src/main.cpp b/src/main.cpp
index 505cc647..923ceb9c 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -37,7 +37,9 @@
#include <libxml/xmlversion.h>
#include <libxml/parser.h>
#include <SDL.h>
+#ifdef USE_OPENGL
#include <SDL_opengl.h>
+#endif
#include <SDL_image.h>
#ifdef __USE_UNIX98
diff --git a/src/resources/image.h b/src/resources/image.h
index c38677d8..807f0fb0 100644
--- a/src/resources/image.h
+++ b/src/resources/image.h
@@ -26,7 +26,9 @@
#include "resource.h"
#include <SDL.h>
+#ifdef USE_OPENGL
#include <SDL_opengl.h>
+#endif
#include <string>
// This flag causes image alpha channel to be preserved, otherwise masking is