]> Dogcows Code - chaz/yoink/commitdiff
initial port to win32
authorCharles McGarvey <chazmcgarvey@brokenzipper.com>
Mon, 7 Sep 2009 06:21:58 +0000 (00:21 -0600)
committerCharles McGarvey <chazmcgarvey@brokenzipper.com>
Mon, 7 Sep 2009 06:21:58 +0000 (00:21 -0600)
16 files changed:
configure.ac
src/Makefile.am
src/Moof/Camera.cc
src/Moof/Camera.hh
src/Moof/Engine.cc
src/Moof/Frustum.cc
src/Moof/Frustum.hh
src/Moof/Log.cc
src/Moof/Log.hh
src/Moof/OpenGL.cc [deleted file]
src/Moof/OpenGL.hh
src/Moof/Resource.cc
src/Moof/Settings.cc
src/Moof/Sound.cc
src/Moof/Timer.cc
src/YoinkApp.cc

index 731e421d86f9b67c58f38c347dc29d23d3e915b0..c5104297add457585353f72bdd3c8eff261c732c 100644 (file)
@@ -39,8 +39,8 @@ AC_ARG_ENABLE([debug],
                          [debug=$enableval
                           if test x$debug = xyes
                           then
                          [debug=$enableval
                           if test x$debug = xyes
                           then
-                                  CFLAGS="-Wall -Werror -gstabs+ -O0 -DDEBUG"
-                                  CXXFLAGS="-Wall -Werror -gstabs+ -O0 -DDEBUG"
+                                  CFLAGS="-O0 -DDEBUG"
+                                  CXXFLAGS="-O0 -DDEBUG"
                           else
                                   CFLAGS="-O2 -DNDEBUG"
                                   CXXFLAGS="-O2 -DNDEBUG"
                           else
                                   CFLAGS="-O2 -DNDEBUG"
                                   CXXFLAGS="-O2 -DNDEBUG"
@@ -69,6 +69,11 @@ AC_ARG_WITH([assetdir],
                        [DATADIR="$withval"],
                        [eval DATADIR="$datarootdir/yoink"])
 
                        [DATADIR="$withval"],
                        [eval DATADIR="$datarootdir/yoink"])
 
+case "${host}" in
+       *mingw32*)
+       DATADIR="data"
+esac
+
 AC_SUBST([DATADIR])
 AC_DEFINE_UNQUOTED([YOINK_DATADIR], ["$DATADIR"],
                                   [Define to path of game asset directory.])
 AC_SUBST([DATADIR])
 AC_DEFINE_UNQUOTED([YOINK_DATADIR], ["$DATADIR"],
                                   [Define to path of game asset directory.])
@@ -96,22 +101,22 @@ BOOST_BIND
 BOOST_FUNCTION
 
 AC_SEARCH_LIBS([IMG_Load], [SDL_image],,
 BOOST_FUNCTION
 
 AC_SEARCH_LIBS([IMG_Load], [SDL_image],,
-                          [AC_MSG_ERROR([libSDL_image is required])])
+                          [AC_MSG_ERROR([SDL_image is required])])
 
 AC_SEARCH_LIBS([Sound_Init], [SDL_sound],,
 
 AC_SEARCH_LIBS([Sound_Init], [SDL_sound],,
-                          [AC_MSG_ERROR([libSDL_sound is required])])
+                          [AC_MSG_ERROR([SDL_sound is required])])
 
 
-AC_SEARCH_LIBS([glBegin], [GL],,
-                          [AC_MSG_ERROR([libGL is required])])
+AC_SEARCH_LIBS([glBegin], [GL opengl32],,
+                          [AC_MSG_ERROR([OpenGL is required])])
 
 
-AC_SEARCH_LIBS([gluPerspective], [GLU],,
-                          [AC_MSG_ERROR([libGLU is required])])
+AC_SEARCH_LIBS([gluPerspective], [GLU MesaGLU glu32],,
+                          [AC_MSG_ERROR([GLU is required])])
 
 
-AC_SEARCH_LIBS([alGenBuffers], [openal],,
-                          [AC_MSG_ERROR([libopenal is required])])
+AC_SEARCH_LIBS([alGenBuffers], [openal openal32],,
+                          [AC_MSG_ERROR([OpenAL is required])])
 
 AC_SEARCH_LIBS([alutInit], [alut],,
 
 AC_SEARCH_LIBS([alutInit], [alut],,
-                          [AC_MSG_ERROR([libalut is required])])
+                          [AC_MSG_ERROR([alut is required])])
 
 AC_SEARCH_LIBS([clock_gettime], [rt],
                           [AC_DEFINE([HAVE_CLOCK_GETTIME], 1,
 
 AC_SEARCH_LIBS([clock_gettime], [rt],
                           [AC_DEFINE([HAVE_CLOCK_GETTIME], 1,
index 8b3900c21ae9abb203f5f5b11599ecede29abf63..01c521e9e789704856ae9fde7347316864064708 100644 (file)
@@ -32,7 +32,6 @@ libmoof_la_SOURCES = \
                                   Moof/Mippleton.hh \
                                   Moof/Octree.cc \
                                   Moof/Octree.hh \
                                   Moof/Mippleton.hh \
                                   Moof/Octree.cc \
                                   Moof/Octree.hh \
-                                  Moof/OpenGL.cc \
                                   Moof/OpenGL.hh \
                                   Moof/Physics.hh \
                                   Moof/Plane.cc \
                                   Moof/OpenGL.hh \
                                   Moof/Physics.hh \
                                   Moof/Plane.cc \
index 376e2c5a4ff5398ea9f1c388f23ce4cc0bbd5000..06261a1b41ba811b75a7746da669d6e5f6768531 100644 (file)
@@ -26,9 +26,8 @@
 
 *******************************************************************************/
 
 
 *******************************************************************************/
 
-#include <iostream>
-#include <Moof/Camera.hh>
-#include <Moof/OpenGL.hh>
+#include "Camera.hh"
+#include "OpenGL.hh"
 
 
 namespace Mf {
 
 
 namespace Mf {
@@ -52,11 +51,11 @@ void Camera::setProjection(const Matrix4& projection)
        projection_ = projection;
 }
 
        projection_ = projection;
 }
 
-void Camera::setProjection(Scalar fovy, Scalar aspect, Scalar near, Scalar far)
+void Camera::setProjection(Scalar fovy, Scalar aspect, Scalar abutting,
+               Scalar distant)
 {
 {
-       cml::matrix_perspective_yfov_RH(projection_, fovy, aspect, near, far,
-                       cml::z_clip_neg_one);
-
+       cml::matrix_perspective_yfov_RH(projection_, fovy, aspect, abutting,
+                       distant, cml::z_clip_neg_one);
        calculateSecondary();
 }
 
        calculateSecondary();
 }
 
@@ -80,7 +79,8 @@ void Camera::update(Scalar t, Scalar dt)
 
 void Camera::lookAt(const Vector3& point)
 {
 
 void Camera::lookAt(const Vector3& point)
 {
-       cml::quaternion_rotation_aim_at(rotation_, position_, point, Vector3(0.0, -1.0, 0.0));
+       cml::quaternion_rotation_aim_at(rotation_, position_, point,
+                       Vector3(0.0, -1.0, 0.0));
        calculateSecondary();
 }
 
        calculateSecondary();
 }
 
index 24632a53af82f88038b7d03df22a5039574a48ba..72df5db6703fcc3d90e3c25fb615ccc3c250f7d5 100644 (file)
@@ -46,7 +46,7 @@ public:
        Camera() :
                position_(0.0, 0.0, 0.0)
        {
        Camera() :
                position_(0.0, 0.0, 0.0)
        {
-               quaternion_rotation_world_y(rotation_, 0.0);
+               cml::quaternion_rotation_world_y(rotation_, 0.0);
                calculateSecondary();
        }
 
                calculateSecondary();
        }
 
index df6b35a8e92d2fece2439fe9a0499884d07f480c..27406521da79693040a6e8b7bdc9e34dd141528e 100644 (file)
@@ -53,7 +53,11 @@ public:
                        Engine* outer) :
                interface(outer)
        {
                        Engine* outer) :
                interface(outer)
        {
+#if defined(_WIN32) || defined (_WIN64) || defined(__WIN32__)
+               if (SDL_Init(SDL_INIT_EVERYTHING) != 0)
+#else
                if (SDL_Init(SDL_INIT_EVERYTHING | SDL_INIT_EVENTTHREAD) != 0)
                if (SDL_Init(SDL_INIT_EVERYTHING | SDL_INIT_EVENTTHREAD) != 0)
+#endif
                {
                        std::cerr << "sdl is complaining: " << SDL_GetError() << std::endl;
                        throw Exception(Exception::SDL_ERROR);
                {
                        std::cerr << "sdl is complaining: " << SDL_GetError() << std::endl;
                        throw Exception(Exception::SDL_ERROR);
index 4dc63400618883b95e877c2e288c724e7e0fdfe1..dddbde09110476a42324ca9fbf2d5197efa1601f 100644 (file)
@@ -50,11 +50,11 @@ void Frustum::init(const Matrix4& modelview, const Matrix4& projection)
 }
 
 void Frustum::init(const Matrix4& modelview, Scalar fovy, Scalar aspect,
 }
 
 void Frustum::init(const Matrix4& modelview, Scalar fovy, Scalar aspect,
-               Scalar near, Scalar far)
+               Scalar abutting, Scalar distant)
 {
        Matrix4 projection;
 
 {
        Matrix4 projection;
 
-       cml::matrix_perspective_yfov_RH(projection, fovy, aspect, near, far,
+       cml::matrix_perspective_yfov_RH(projection, fovy, aspect, abutting, distant,
                        cml::z_clip_neg_one);
 
        init(modelview, projection);
                        cml::z_clip_neg_one);
 
        init(modelview, projection);
index a50dc8338d0a10206bce3ebc900f93037b640e23..4154f1492cc98316ea72cd82b0c894359dac0010 100644 (file)
@@ -57,14 +57,14 @@ public:
                init(modelview, projection);
        }
        inline Frustum(const Matrix4& modelview, Scalar fovy, Scalar aspect,
                init(modelview, projection);
        }
        inline Frustum(const Matrix4& modelview, Scalar fovy, Scalar aspect,
-                       Scalar near, Scalar far)
+                       Scalar abutting, Scalar distant)
        {
        {
-               init(modelview, fovy, aspect, near, far);
+               init(modelview, fovy, aspect, abutting, distant);
        }
        
        void init(const Matrix4& modelview, const Matrix4& projection);
        }
        
        void init(const Matrix4& modelview, const Matrix4& projection);
-       void init(const Matrix4& modelview, Scalar fovy, Scalar aspect, Scalar near,
-                       Scalar far);
+       void init(const Matrix4& modelview, Scalar fovy, Scalar aspect,
+                       Scalar abutting, Scalar distant);
 
        Collision containsAabb(const Aabb& aabb) const;
        Collision containsSphere(const Sphere& sphere) const;
 
        Collision containsAabb(const Aabb& aabb) const;
        Collision containsSphere(const Sphere& sphere) const;
index ddd12bbcd5a3dbec2e7bec2ee501e577058ebc59..0639a601dba5f2edb4e64212eba3862425e8873e 100644 (file)
@@ -36,7 +36,7 @@
 namespace Mf {
 
 
 namespace Mf {
 
 
-static LogLevel logLevel_ = WARNING;
+static LogLevel logLevel_ = LOG_WARNING;
 
 inline void printLog_(int logLevel, const char* fmt, va_list args)
 {
 
 inline void printLog_(int logLevel, const char* fmt, va_list args)
 {
@@ -44,16 +44,16 @@ inline void printLog_(int logLevel, const char* fmt, va_list args)
 
        switch (logLevel)
        {
 
        switch (logLevel)
        {
-               case ERROR:
+               case LOG_ERROR:
                        fprintf(stderr, "  error: ");
                        break;
                        fprintf(stderr, "  error: ");
                        break;
-               case WARNING:
+               case LOG_WARNING:
                        fprintf(stderr, "warning: ");
                        break;
                        fprintf(stderr, "warning: ");
                        break;
-               case INFO:
+               case LOG_INFO:
                        fprintf(stderr, "   info: ");
                        break;
                        fprintf(stderr, "   info: ");
                        break;
-               case DEBUGGING:
+               case LOG_DEBUG:
                        fprintf(stderr, "  debug: ");
                        break;
        }
                        fprintf(stderr, "  debug: ");
                        break;
        }
@@ -77,7 +77,7 @@ void logError(const char* fmt, ...)
        va_list args;
        va_start(args, fmt);
 
        va_list args;
        va_start(args, fmt);
 
-       printLog_(ERROR, fmt, args);
+       printLog_(LOG_ERROR, fmt, args);
 
        va_end(args);
 }
 
        va_end(args);
 }
@@ -87,7 +87,7 @@ void logWarning(const char* fmt, ...)
        va_list args;
        va_start(args, fmt);
 
        va_list args;
        va_start(args, fmt);
 
-       printLog_(WARNING, fmt, args);
+       printLog_(LOG_WARNING, fmt, args);
 
        va_end(args);
 }
 
        va_end(args);
 }
@@ -97,7 +97,7 @@ void logInfo(const char* fmt, ...)
        va_list args;
        va_start(args, fmt);
 
        va_list args;
        va_start(args, fmt);
 
-       printLog_(INFO, fmt, args);
+       printLog_(LOG_INFO, fmt, args);
 
        va_end(args);
 }
 
        va_end(args);
 }
@@ -107,7 +107,7 @@ void logDebug(const char* fmt, ...)
        va_list args;
        va_start(args, fmt);
 
        va_list args;
        va_start(args, fmt);
 
-       printLog_(DEBUGGING, fmt, args);
+       printLog_(LOG_DEBUG, fmt, args);
 
        va_end(args);
 }
 
        va_end(args);
 }
index 3f6b6d7e45013b8360af975288d03082c6ed0d91..cdd5cd4e751e8e4374b94babbcc2be10f249f991 100644 (file)
@@ -62,13 +62,14 @@ namespace Mf {
  * @see LogLevel()
  */
 
  * @see LogLevel()
  */
 
-typedef enum {
-       NONE            = -1,           ///< Disable all logging.
-       ERROR           =  1,           ///< Log only errors.
-       WARNING         =  2,           ///< Log warnings and errors.
-       INFO            =  3,           ///< Log info, warnings, errors.
-       DEBUGGING       =  4            ///< Log all messages.
-} LogLevel;
+enum LogLevel
+{
+       LOG_NONE                = -1,           ///< Disable all logging.
+       LOG_ERROR               =  1,           ///< Log only errors.
+       LOG_WARNING             =  2,           ///< Log warnings and errors.
+       LOG_INFO                =  3,           ///< Log info, warnings, errors.
+       LOG_DEBUG               =  4            ///< Log all messages.
+};
 
 
 /**
 
 
 /**
diff --git a/src/Moof/OpenGL.cc b/src/Moof/OpenGL.cc
deleted file mode 100644 (file)
index b286b35..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-
-/*******************************************************************************
-
- Copyright (c) 2009, Charles McGarvey
- All rights reserved.
- Redistribution   and   use  in  source  and  binary  forms,  with  or  without
- modification, are permitted provided that the following conditions are met:
-   * Redistributions  of  source  code  must retain the above copyright notice,
-     this list of conditions and the following disclaimer.
-   * Redistributions  in binary form must reproduce the above copyright notice,
-     this  list of conditions and the following disclaimer in the documentation
-     and/or other materials provided with the distribution.
- THIS  SOFTWARE  IS  PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- AND  ANY  EXPRESS  OR  IMPLIED  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- DISCLAIMED.  IN  NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
- FOR  ANY  DIRECT,  INDIRECT,  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- DAMAGES  (INCLUDING,  BUT  NOT  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- SERVICES;  LOSS  OF  USE,  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- CAUSED  AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- OR  TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-*******************************************************************************/
-
-#include "OpenGL.hh"
-
-
-#if USE_DOUBLE_PRECISION
-
-void (*glGetScalarv)(GLenum, GLscalar*)(glGetDoublev);
-
-void (*glLoadMatrix)(const GLscalar*)(glLoadMatrixd);
-void (*glMultMatrix)(const GLscalar*)(glMultMatrixd);
-
-void (*glScale)(GLscalar, GLscalar, GLscalar)(glScaled);
-void (*glRotate)(GLscalar, GLscalar, GLscalar, GLscalar)(glRotated);
-void (*glTranslate)(GLscalar, GLscalar, GLscalar)(glTranslated);
-
-void (*glColor3)(GLscalar, GLscalar, GLscalar)(glColor3d);
-void (*glColor4)(GLscalar, GLscalar, GLscalar, GLscalar)(glColor4d);
-void (*glColor3v)(const GLscalar*)(glColor3dv);
-void (*glColor4v)(const GLscalar*)(glColor4dv);
-
-void (*glVertex2)(GLscalar, GLscalar)(glVertex2d);
-void (*glVertex3)(GLscalar, GLscalar, GLscalar)(glVertex3d);
-void (*glVertex4)(GLscalar, GLscalar, GLscalar, GLscalar)(glVertex4d);
-void (*glVertex2v)(const GLscalar*)(glVertex2dv);
-void (*glVertex3v)(const GLscalar*)(glVertex3dv);
-void (*glVertex4v)(const GLscalar*)(glVertex4dv);
-
-void (*glTexCoord2)(GLscalar, GLscalar)(glTexCoord2d);
-void (*glTexCoord3)(GLscalar, GLscalar, GLscalar)(glTexCoord3d);
-void (*glTexCoord4)(GLscalar, GLscalar, GLscalar, GLscalar)(glTexCoord4d);
-void (*glTexCoord2v)(const GLscalar*)(glTexCoord2dv);
-void (*glTexCoord3v)(const GLscalar*)(glTexCoord3dv);
-void (*glTexCoord4v)(const GLscalar*)(glTexCoord4dv);
-
-#else
-
-void (*glGetScalarv(GLenum, GLscalar*)(glGetFloatv);
-
-void (*glLoadMatrix)(const GLscalar*)(glLoadMatrixf);
-void (*glMultMatrix)(const GLscalar*)(glMultMatrixf);
-
-void (*glScale)(GLscalar, GLscalar, GLscalar)(glScalef);
-void (*glRotate)(GLscalar, GLscalar, GLscalar, GLscalar)(glRotatef);
-void (*glTranslate)(GLscalar, GLscalar, GLscalar)(glTranslatef);
-
-void (*glColor3)(GLscalar, GLscalar, GLscalar)(glColor3f);
-void (*glColor4)(GLscalar, GLscalar, GLscalar, GLscalar)(glColor4f);
-void (*glColor3v)(const GLscalar*)(glColor3fv);
-void (*glColor4v)(const GLscalar*)(glColor4fv);
-
-void (*glVertex2)(GLscalar, GLscalar)(glVertex2f);
-void (*glVertex3)(GLscalar, GLscalar, GLscalar)(glVertex3f);
-void (*glVertex4)(GLscalar, GLscalar, GLscalar, GLscalar)(glVertex4f);
-void (*glVertex2v)(const GLscalar*)(glVertex2fv);
-void (*glVertex3v)(const GLscalar*)(glVertex3fv);
-void (*glVertex4v)(const GLscalar*)(glVertex4fv);
-
-void (*glTexCoord2)(GLscalar, GLscalar)(glTexCoord2f);
-void (*glTexCoord3)(GLscalar, GLscalar, GLscalar)(glTexCoord3f);
-void (*glTexCoord4)(GLscalar, GLscalar, GLscalar, GLscalar)(glTexCoord4f);
-void (*glTexCoord2v)(const GLscalar*)(glTexCoord2df);
-void (*glTexCoord3v)(const GLscalar*)(glTexCoord3df);
-void (*glTexCoord4v)(const GLscalar*)(glTexCoord4df);
-
-#endif
-
-
-/** vim: set ts=4 sw=4 tw=80: *************************************************/
-
index 51c3e5f57cb3c639d3a033a6f154816fec3dfadb..0ac6612723025b65858cb6da55798b00f1127109 100644 (file)
 typedef GLdouble       GLscalar;
 #define GL_SCALAR      GL_DOUBLE
 
 typedef GLdouble       GLscalar;
 #define GL_SCALAR      GL_DOUBLE
 
+inline void glGetScalarv(GLenum a, GLscalar* b) { glGetDoublev(a, b); }
+
+inline void glLoadMatrix(const GLscalar* a) { glLoadMatrixd(a); }
+inline void glMultMatrix(const GLscalar* a) { glMultMatrixd(a); }
+
+inline void glScale(GLscalar a, GLscalar b, GLscalar c) { glScaled(a, b, c); }
+inline void glRotate(GLscalar a, GLscalar b, GLscalar c, GLscalar d) { glRotated(a, b, c, d); }
+inline void glTranslate(GLscalar a, GLscalar b, GLscalar c) { glTranslated(a, b, c); }
+
+inline void glColor3(GLscalar a, GLscalar b, GLscalar c) { glColor3d(a, b, c); }
+inline void glColor4(GLscalar a, GLscalar b, GLscalar c, GLscalar d) { glColor4d(a, b, c, d); }
+inline void glColor3v(const GLscalar *a) { glColor3dv(a); }
+inline void glColor4v(const GLscalar *a) { glColor4dv(a); }
+
+inline void glVertex2(GLscalar a, GLscalar b) { glVertex2d(a, b); }
+inline void glVertex3(GLscalar a, GLscalar b, GLscalar c) { glVertex3d(a, b, c); }
+inline void glVertex4(GLscalar a, GLscalar b, GLscalar c, GLscalar d) { glVertex4d(a, b, c, d); }
+inline void glVertex2v(const GLscalar* a) { glVertex2dv(a); }
+inline void glVertex3v(const GLscalar* a) { glVertex3dv(a); }
+inline void glVertex4v(const GLscalar* a) { glVertex4dv(a); }
+
+inline void glTexCoord2(GLscalar a, GLscalar b) { glTexCoord2d(a, b); } 
+inline void glTexCoord3(GLscalar a, GLscalar b, GLscalar c) { glTexCoord3d(a, b, c); }
+inline void glTexCoord4(GLscalar a, GLscalar b, GLscalar c, GLscalar d) { glTexCoord4d(a, b, c, d); }
+inline void glTexCoord2v(const GLscalar* a) { glTexCoord2dv(a); }
+inline void glTexCoord3v(const GLscalar* a) { glTexCoord3dv(a); }
+inline void glTexCoord4v(const GLscalar* a) { glTexCoord4dv(a); }
+
 #else
 
 typedef GLfloat                GLscalar;
 #define GL_SCALAR      GL_FLOAT
 
 #else
 
 typedef GLfloat                GLscalar;
 #define GL_SCALAR      GL_FLOAT
 
-#endif
-
+inline void glGetScalarv(GLenum a, GLscalar* b) { glGetFloatv(a, b); }
 
 
-extern void (*glGetScalarv)(GLenum, GLscalar*);
+inline void glLoadMatrix(const GLscalar* a) { glLoadMatrixf(a); }
+inline void glMultMatrix(const GLscalar* a) { glMultMatrixf(a); }
 
 
-extern void (*glLoadMatrix)(const GLscalar*);
-extern void (*glMultMatrix)(const GLscalar*);
+inline void glScale(GLscalar a, GLscalar b, GLscalar c) { glScalef(a, b, c); }
+inline void glRotate(GLscalar a, GLscalar b, GLscalar c, GLscalar d) { glRotatef(a, b, c, d); }
+inline void glTranslate(GLscalar a, GLscalar b, GLscalar c) { glTranslatef(a, b, c); }
 
 
-extern void (*glScale)(GLscalar, GLscalar, GLscalar);
-extern void (*glRotate)(GLscalar, GLscalar, GLscalar, GLscalar);
-extern void (*glTranslate)(GLscalar, GLscalar, GLscalar);
+inline void glColor3(GLscalar a, GLscalar b, GLscalar c) { glColor3f(a, b, c); }
+inline void glColor4(GLscalar a, GLscalar b, GLscalar c, GLscalar d) { glColor4f(a, b, c, d); }
+inline void glColor3v(const GLscalar *a) { glColor3fv(a); }
+inline void glColor4v(const GLscalar *a) { glColor4fv(a); }
 
 
-extern void (*glColor3)(GLscalar, GLscalar, GLscalar);
-extern void (*glColor4)(GLscalar, GLscalar, GLscalar, GLscalar);
-extern void (*glColor3v)(const GLscalar*);
-extern void (*glColor4v)(const GLscalar*);
+inline void glVertex2(GLscalar a, GLscalar b) { glVertex2f(a, b); }
+inline void glVertex3(GLscalar a, GLscalar b, GLscalar c) { glVertex3f(a, b, c); }
+inline void glVertex4(GLscalar a, GLscalar b, GLscalar c, GLscalar d) { glVertex4f(a, b, c, d); }
+inline void glVertex2v(const GLscalar* a) { glVertex2fv(a); }
+inline void glVertex3v(const GLscalar* a) { glVertex3fv(a); }
+inline void glVertex4v(const GLscalar* a) { glVertex4fv(a); }
 
 
-extern void (*glVertex2)(GLscalar, GLscalar);
-extern void (*glVertex3)(GLscalar, GLscalar, GLscalar);
-extern void (*glVertex4)(GLscalar, GLscalar, GLscalar, GLscalar);
-extern void (*glVertex2v)(const GLscalar*);
-extern void (*glVertex3v)(const GLscalar*);
-extern void (*glVertex4v)(const GLscalar*);
-
-extern void (*glTexCoord2)(GLscalar, GLscalar);
-extern void (*glTexCoord3)(GLscalar, GLscalar, GLscalar);
-extern void (*glTexCoord4)(GLscalar, GLscalar, GLscalar, GLscalar);
-extern void (*glTexCoord2v)(const GLscalar*);
-extern void (*glTexCoord3v)(const GLscalar*);
-extern void (*glTexCoord4v)(const GLscalar*);
+inline void glTexCoord2(GLscalar a, GLscalar b) { glTexCoord2f(a, b); } 
+inline void glTexCoord3(GLscalar a, GLscalar b, GLscalar c) { glTexCoord3f(a, b, c); }
+inline void glTexCoord4(GLscalar a, GLscalar b, GLscalar c, GLscalar d) { glTexCoord4f(a, b, c, d); }
+inline void glTexCoord2v(const GLscalar* a) { glTexCoord2fv(a); }
+inline void glTexCoord3v(const GLscalar* a) { glTexCoord3fv(a); }
+inline void glTexCoord4v(const GLscalar* a) { glTexCoord4fv(a); }
 
 
+#endif
 
 
 #endif // _MOOF_OPENGL_HH_
 
 
 #endif // _MOOF_OPENGL_HH_
index d958c3aa9e551cc584d9fe14fe02cf3275846041..a9ff22da9eb68c1300055fca4337bbcbf62d848e 100644 (file)
@@ -28,6 +28,9 @@
 
 #include <unistd.h>
 
 
 #include <unistd.h>
 
+#include <boost/algorithm/string.hpp>
+
+#include "Log.hh"
 #include "Resource.hh"
 
 
 #include "Resource.hh"
 
 
@@ -43,29 +46,43 @@ Resource::~Resource() {}
 
 void Resource::addSearchPath(const std::string& directory)
 {
 
 void Resource::addSearchPath(const std::string& directory)
 {
+       std::string path(directory);
+
+       ASSERT(path.length() > 0 && "empty search path string");
+
        // add a slash if there isn't one already
        // add a slash if there isn't one already
-       if (directory[directory.length() - 1] != '/')
-       {
-               searchPaths_.push_back(directory + '/');
-       }
-       else
+       if (*path.rbegin() != '/')
        {
        {
-               searchPaths_.push_back(directory);
+               path += '/';
        }
        }
+
+#if defined(__WIN32__) || defined(_WIN32) || defined(_WIN64)
+       boost::replace_all(path, "/", "\\");
+#endif
+
+       searchPaths_.push_back(path);
 }
 
 std::string Resource::getPath(const std::string& name)
 {
        std::vector<std::string>::iterator it;
 
 }
 
 std::string Resource::getPath(const std::string& name)
 {
        std::vector<std::string>::iterator it;
 
+       std::string path(name);
+
+#if defined(__WIN32__) || defined(_WIN32) || defined(_WIN64)
+       boost::replace_all(path, "/", "\\");
+#endif
+
        for (it = searchPaths_.begin(); it != searchPaths_.end(); ++it)
        {
                std::string fullPath(*it);
        for (it = searchPaths_.begin(); it != searchPaths_.end(); ++it)
        {
                std::string fullPath(*it);
-               fullPath += name;
+               fullPath += path;
+
+               logDebug("looking for resource %s at %s", name.c_str(), path.c_str());
 
 
-               // TODO this could be more portable
                if (access(fullPath.c_str(), R_OK) == 0)
                {
                if (access(fullPath.c_str(), R_OK) == 0)
                {
+                       logDebug("found resource %s at %s", name.c_str(), path.c_str());
                        return fullPath;
                }
        }
                        return fullPath;
                }
        }
index 624179ce36998c16efed54b1b75414f97c7d28b7..6883ddc4f852d3edd4191957e81529f87f155c8a 100644 (file)
@@ -32,6 +32,7 @@
 
 #include <boost/algorithm/string.hpp>
 
 
 #include <boost/algorithm/string.hpp>
 
+#include "Log.hh"
 #include "Settings.hh"
 
 
 #include "Settings.hh"
 
 
@@ -104,7 +105,7 @@ void Settings::loadFromFiles(const std::vector<std::string>& filePaths,
 
                if (home)
                {
 
                if (home)
                {
-                       boost::replace_first(path, "$HOME", home);
+                       boost::replace_all(path, "$HOME", home);
                }
 
                try
                }
 
                try
@@ -129,8 +130,8 @@ void Settings::loadFromFiles(const std::vector<std::string>& filePaths,
                }
                catch (Deserializer::Exception e)
                {
                }
                catch (Deserializer::Exception e)
                {
-                       std::cerr << "Cannot load settings from " << *it <<
-                               " because an exception was thrown: " << e.what() << std::endl;
+                       logWarning("cannot load settings from %s because an exception was"
+                                       "thrown: %s", (*it).c_str(), e.what());
                }
        }
 }
                }
        }
 }
index 368e9388bca4aee4f3665ae40b1abf1afa71f6cd..a0302fba003aaa6052e7e447f85a97d142ecd781 100644 (file)
@@ -63,6 +63,7 @@ struct Sound::Impl
                Buffer(const std::string& name) :
                        Mippleton<Buffer>(name)
                {
                Buffer(const std::string& name) :
                        Mippleton<Buffer>(name)
                {
+                       sound = 0;
                        objects[0] = 0;
                        objects[1] = 0;
                }
                        objects[0] = 0;
                        objects[1] = 0;
                }
@@ -84,7 +85,7 @@ struct Sound::Impl
 
                        if (!sound)
                        {
 
                        if (!sound)
                        {
-                               logWarning("audio not found: %s", getName().c_str());
+                               logWarning("error while loading sound %s: %s", getName().c_str(), Sound_GetError());
                                throw Exception(Exception::FILE_NOT_FOUND);
                        }
 
                                throw Exception(Exception::FILE_NOT_FOUND);
                        }
 
@@ -93,8 +94,9 @@ struct Sound::Impl
                        unsigned decoded = Sound_DecodeAll(sound);
                        if (decoded == 0)
                        {
                        unsigned decoded = Sound_DecodeAll(sound);
                        if (decoded == 0)
                        {
-                               logWarning("decoded not bytes from %s", getName().c_str());
-                               throw Exception(Exception::FILE_NOT_FOUND);
+                               logWarning("decoded no bytes from %s", getName().c_str());
+                               //throw Exception(Exception::FILE_NOT_FOUND);
+                               return;
                        }
 
                        alGenBuffers(2, objects);
                        }
 
                        alGenBuffers(2, objects);
@@ -207,6 +209,8 @@ Sound::Sound(const std::string& name) :
 
 void Sound::play()
 {
 
 void Sound::play()
 {
+       if (!impl_->buffer_->sound) return;
+
        //alSourceRewind(impl_->source_);
        alSourcePlay(impl_->source_);
        impl_->playing = true;
        //alSourceRewind(impl_->source_);
        alSourcePlay(impl_->source_);
        impl_->playing = true;
index 4eea488ad7f43d29af7280f63ea3371f2380f4b2..fb17f1d66e1ac3a89c99c95a4cec94d9412c0dde 100644 (file)
@@ -76,6 +76,22 @@ Scalar getTicks()
        return Scalar(ts.tv_sec - reference) + Scalar(ts.tv_nsec) / 1000000000.0;
 }
 
        return Scalar(ts.tv_sec - reference) + Scalar(ts.tv_nsec) / 1000000000.0;
 }
 
+void sleep(Scalar seconds, bool absolute)
+{
+       struct timespec ts;
+       int ret;
+
+       if (absolute) seconds -= getTicks();
+       ts.tv_sec = time_t(seconds);
+       ts.tv_nsec = long((seconds - Scalar(ts.tv_sec)) * 1000000000.0);
+
+       do
+       {
+               ret = nanosleep(&ts, &ts);
+       }
+       while (ret == -1 && errno == EINTR);
+}
+
 
 #else // ! HAVE_CLOCK_GETTIME
 
 
 #else // ! HAVE_CLOCK_GETTIME
 
@@ -92,26 +108,15 @@ Scalar getTicks()
        return Scalar(ms / 1000) + Scalar(ms % 1000) / 1000.0;
 }
 
        return Scalar(ms / 1000) + Scalar(ms % 1000) / 1000.0;
 }
 
-
-#endif // HAVE_CLOCK_GETTIME
-
-
 void sleep(Scalar seconds, bool absolute)
 {
 void sleep(Scalar seconds, bool absolute)
 {
-       struct timespec ts;
-       int ret;
-
        if (absolute) seconds -= getTicks();
        if (absolute) seconds -= getTicks();
-       ts.tv_sec = time_t(seconds);
-       ts.tv_nsec = long((seconds - Scalar(ts.tv_sec)) * 1000000000.0);
 
 
-       do
-       {
-               ret = nanosleep(&ts, &ts);
-       }
-       while (ret == -1 && errno == EINTR);
+       SDL_Delay(Uint32(seconds * 1000.0));
 }
 
 }
 
+#endif // HAVE_CLOCK_GETTIME
+
 
 } // namespace Mf
 
 
 } // namespace Mf
 
index d391927d02b364bc1a07c8ba170de838a03a4ad0..9ea4b373d90ec15e2a53cb5eba8c03e8155cb359 100644 (file)
@@ -465,7 +465,7 @@ int main(int argc, char* argv[])
                          PACKAGE_BUGREPORT << ">." << std::endl << std::endl;
 
 #if ! NDEBUG
                          PACKAGE_BUGREPORT << ">." << std::endl << std::endl;
 
 #if ! NDEBUG
-       Mf::setLogLevel(Mf::DEBUGGING);
+       Mf::setLogLevel(Mf::LOG_DEBUG);
 #endif
 
        int status = 0;
 #endif
 
        int status = 0;
This page took 0.041781 seconds and 4 git commands to generate.