Permalink
Browse files

Compile as C++11

  • Loading branch information...
nickg committed Jun 20, 2015
1 parent bb4dc51 commit 74f75a2ff8dd4a93ce9ea216ac4c9a4f09cc46c2
Showing with 20 additions and 19 deletions.
  1. +3 −0 config.h.in
  2. +2 −0 configure.ac
  3. +1 −1 src/Asteroid.cpp
  4. +7 −8 src/Font.cpp
  5. +7 −10 src/Platform.hpp
View
@@ -24,6 +24,9 @@
the CoreFoundation framework. */
#undef HAVE_CFPREFERENCESCOPYAPPVALUE
+/* define if the compiler supports basic C++11 syntax */
+#undef HAVE_CXX11
+
/* Define if the GNU dcgettext() function is already present or preinstalled.
*/
#undef HAVE_DCGETTEXT
View
@@ -14,6 +14,8 @@ AC_PROG_INSTALL
AC_PROG_CPP
AC_PROG_MKDIR_P
+AX_CXX_COMPILE_STDCXX_11
+
AM_GNU_GETTEXT([external])
AM_GNU_GETTEXT_VERSION([0.18.3])
View
@@ -1,6 +1,6 @@
//
// Asteroid.cpp -- Randomly generated asteroid.
-// Copyright (C) 2008-2013 Nick Gasson
+// Copyright (C) 2008-2015 Nick Gasson
//
// 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
@@ -1,6 +1,6 @@
//
// Font.cpp -- A wrapper around FreeType.
-// Copyright (C) 2006, 2011 Nick Gasson
+// Copyright (C) 2006, 2011-2015 Nick Gasson
//
// 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
@@ -195,11 +195,10 @@ void Font::SplitIntoLines(vector<string> &lines, const char* fmt, va_list ap)
void Font::Print(int x, int y, const char* fmt, ...)
{
- // Store the current matrix
glPushMatrix();
GLuint font = listBase;
- float h = height / 0.63f; // Add some space between lines
+ float h = height / 0.63f; // Add some space between lines
vector<string> lines;
va_list ap;
@@ -214,7 +213,8 @@ void Font::Print(int x, int y, const char* fmt, ...)
glListBase(font);
// Draw the text
- for (unsigned int i = 0; i < lines.size(); i++) {
+ const unsigned nlines = lines.size();
+ for (unsigned i = 0; i < nlines; i++) {
glPushMatrix();
glLoadIdentity();
glTranslatef((float)x, (float)y - h*i, 0.0f);
@@ -224,7 +224,6 @@ void Font::Print(int x, int y, const char* fmt, ...)
glPopMatrix();
}
- // Restore previous matrix
glPopMatrix();
}
@@ -239,10 +238,10 @@ int Font::GetStringWidth(const char* fmt, ...)
int maxlen = 0;
vector<string>::iterator it;
- for (it = lines.begin(); it != lines.end(); ++it) {
+ for (const string& line : lines) {
int len = 0;
- for (string::iterator ch = (*it).begin(); ch != (*it).end(); ++ch)
- len += widths[(int)*ch];
+ for (const char ch : line)
+ len += widths[static_cast<int>(ch)];
if (len > maxlen)
maxlen = len;
View
@@ -34,30 +34,30 @@
#include "SDL.h"
-#include <GL\gl.h>
-#include <GL\glu.h>
+#include <GL\gl.h>
+#include <GL\glu.h>
#ifndef M_PI
#define M_PI 3.1415926535897932384626433832795
#endif
-#include <boost/tr1/memory.hpp>
+#include <memory>
#define msleep(n) Sleep(n)
#define i18n(x) x
#define PATH_MAX 256
-// Don't have these on Windows for some reason
+// Don't have these on Windows for some reason
#ifndef GL_BGRA
#define GL_BGRA 0
#endif
#ifndef GL_BGR
#define GL_BGR 0
#endif
-// Define safe snprintf, etc. for MSCV8
+// Define safe snprintf, etc. for MSCV8
#if (_MSC_VER >= 1400)
#define USE_FOPEN_S
@@ -90,8 +90,8 @@
#include <sys/stat.h>
#include <unistd.h>
-// Probably using GCC
-#include <tr1/memory>
+// Probably using GCC or Clang
+#include <memory>
#endif /* #ifdef WIN32 */
@@ -127,9 +127,6 @@
#include <string>
using namespace std;
-#ifndef _LIBCPP_VERSION
-using namespace std::tr1;
-#endif
void RecreateScreens();
string LocateResource(const string& file);

0 comments on commit 74f75a2

Please sign in to comment.