diff --git a/platform/macosx/love-framework.xcodeproj/project.pbxproj b/platform/macosx/love-framework.xcodeproj/project.pbxproj index a8f839e54..e0c7e9079 100644 --- a/platform/macosx/love-framework.xcodeproj/project.pbxproj +++ b/platform/macosx/love-framework.xcodeproj/project.pbxproj @@ -2032,8 +2032,12 @@ FRAMEWORK_SEARCH_PATHS = /Library/Frameworks; GCC_OPTIMIZATION_LEVEL = s; GCC_PREPROCESSOR_DEFINITIONS = LOVE_SUPPORT_GME; - GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES; + GCC_WARN_SIGN_COMPARE = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_PARAMETER = YES; GCC_WARN_UNUSED_VARIABLE = YES; HEADER_SEARCH_PATHS = ( "\"$(SRCROOT)/../../src\"", @@ -2059,8 +2063,12 @@ FRAMEWORK_SEARCH_PATHS = /Library/Frameworks; GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = LOVE_SUPPORT_GME; - GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES; + GCC_WARN_SIGN_COMPARE = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_PARAMETER = YES; GCC_WARN_UNUSED_VARIABLE = YES; HEADER_SEARCH_PATHS = ( "\"$(SRCROOT)/../../src\"", diff --git a/src/common/delay.h b/src/common/delay.h index 27d024177..db0636f73 100644 --- a/src/common/delay.h +++ b/src/common/delay.h @@ -26,6 +26,6 @@ namespace love void delay(unsigned int ms); -}; // namespace love +} // namespace love #endif // DELAY_H_ diff --git a/src/common/runtime.cpp b/src/common/runtime.cpp index 895540e1b..15e7d4e81 100644 --- a/src/common/runtime.cpp +++ b/src/common/runtime.cpp @@ -460,6 +460,7 @@ StringMap::Entry typeEntries[] = // Graphics {"Drawable", GRAPHICS_DRAWABLE_ID}, + {"DrawGable", GRAPHICS_DRAWGABLE_ID}, {"Image", GRAPHICS_IMAGE_ID}, {"Geometry", GRAPHICS_GEOMETRY_ID}, {"Font", GRAPHICS_FONT_ID}, @@ -486,9 +487,12 @@ StringMap::Entry typeEntries[] = {"World", PHYSICS_WORLD_ID}, {"Contact", PHYSICS_CONTACT_ID}, {"Body", PHYSICS_BODY_ID}, + {"Fixture", PHYSICS_FIXTURE_ID}, {"Shape", PHYSICS_SHAPE_ID}, {"CircleShape", PHYSICS_CIRCLE_SHAPE_ID}, {"PolygonShape", PHYSICS_POLYGON_SHAPE_ID}, + {"EdgeShape", PHYSICS_EDGE_SHAPE_ID}, + {"ChainShape", PHYSICS_CHAIN_SHAPE_ID}, {"Joint", PHYSICS_JOINT_ID}, {"MouseJoint", PHYSICS_MOUSE_JOINT_ID}, {"DistanceJoint", PHYSICS_DISTANCE_JOINT_ID}, @@ -496,6 +500,9 @@ StringMap::Entry typeEntries[] = {"RevoluteJoint", PHYSICS_REVOLUTE_JOINT_ID}, {"PulleyJoint", PHYSICS_PULLEY_JOINT_ID}, {"GearJoint", PHYSICS_GEAR_JOINT_ID}, + {"WeldJoint", PHYSICS_WELD_JOINT_ID}, + {"RopeJoint", PHYSICS_ROPE_JOINT_ID}, + {"WheelJoint", PHYSICS_WHEEL_JOINT_ID}, // Thread {"Thread", THREAD_THREAD_ID}, diff --git a/src/modules/graphics/Graphics.cpp b/src/modules/graphics/Graphics.cpp index 847c2a287..ee14af22b 100644 --- a/src/modules/graphics/Graphics.cpp +++ b/src/modules/graphics/Graphics.cpp @@ -59,16 +59,6 @@ bool Graphics::getConstant(BlendMode in, const char *&out) return blendModes.find(in, out); } -bool Graphics::getConstant(const char *in, ColorMode &out) -{ - return colorModes.find(in, out); -} - -bool Graphics::getConstant(ColorMode in, const char *&out) -{ - return colorModes.find(in, out); -} - bool Graphics::getConstant(const char *in, LineStyle &out) { return lineStyles.find(in, out); @@ -149,15 +139,6 @@ StringMap::Entry Graphics::blendM StringMap Graphics::blendModes(Graphics::blendModeEntries, sizeof(Graphics::blendModeEntries)); -StringMap::Entry Graphics::colorModeEntries[] = -{ - { "replace", Graphics::COLOR_REPLACE }, - { "modulate", Graphics::COLOR_MODULATE }, - { "combine", Graphics::COLOR_COMBINE }, -}; - -StringMap Graphics::colorModes(Graphics::colorModeEntries, sizeof(Graphics::colorModeEntries)); - StringMap::Entry Graphics::lineStyleEntries[] = { { "smooth", Graphics::LINE_SMOOTH }, diff --git a/src/modules/graphics/Graphics.h b/src/modules/graphics/Graphics.h index ec212ede9..b5ab4fc52 100644 --- a/src/modules/graphics/Graphics.h +++ b/src/modules/graphics/Graphics.h @@ -61,14 +61,6 @@ public: BLEND_MAX_ENUM }; - enum ColorMode - { - COLOR_MODULATE = 1, - COLOR_REPLACE, - COLOR_COMBINE, - COLOR_MAX_ENUM - }; - enum LineStyle { LINE_ROUGH = 1, @@ -129,9 +121,6 @@ public: static bool getConstant(const char *in, BlendMode &out); static bool getConstant(BlendMode in, const char *&out); - static bool getConstant(const char *in, ColorMode &out); - static bool getConstant(ColorMode in, const char *&out); - static bool getConstant(const char *in, LineStyle &out); static bool getConstant(LineStyle in, const char *&out); @@ -158,9 +147,6 @@ private: static StringMap::Entry blendModeEntries[]; static StringMap blendModes; - static StringMap::Entry colorModeEntries[]; - static StringMap colorModes; - static StringMap::Entry lineStyleEntries[]; static StringMap lineStyles; diff --git a/src/modules/graphics/opengl/Canvas.cpp b/src/modules/graphics/opengl/Canvas.cpp index f5b154d06..cb52a0e84 100644 --- a/src/modules/graphics/opengl/Canvas.cpp +++ b/src/modules/graphics/opengl/Canvas.cpp @@ -38,6 +38,8 @@ namespace opengl // none, opengl >= 3.0, extensions struct FramebufferStrategy { + virtual ~FramebufferStrategy() {} + /// create a new framebuffer, depth_stencil and texture /** * @param[out] framebuffer Framebuffer name diff --git a/src/modules/graphics/opengl/Shader.cpp b/src/modules/graphics/opengl/Shader.cpp index e4312e5ed..f5af80188 100644 --- a/src/modules/graphics/opengl/Shader.cpp +++ b/src/modules/graphics/opengl/Shader.cpp @@ -124,9 +124,9 @@ GLuint Shader::compileCode(ShaderType type, const std::string &code) { GLenum err = glGetError(); - if (err == GL_INVALID_ENUM) // invalid or unsupported shader type + if (err == GL_INVALID_ENUM) throw love::Exception("Cannot create %s shader object: %s shaders not supported.", typestr, typestr); - else // other errors should only happen between glBegin() and glEnd() + else throw love::Exception("Cannot create %s shader object.", typestr); } @@ -136,14 +136,14 @@ GLuint Shader::compileCode(ShaderType type, const std::string &code) glCompileShader(shaderid); - // Get any warnings the shader compiler may have produced + // Get any warnings the shader compiler may have produced. GLint infologlen; glGetShaderiv(shaderid, GL_INFO_LOG_LENGTH, &infologlen); GLchar *infolog = new GLchar[infologlen + 1]; glGetShaderInfoLog(shaderid, infologlen, NULL, infolog); - // Save any warnings for later querying + // Save any warnings for later querying. if (infologlen > 0) shaderWarnings[type] = infolog; @@ -164,7 +164,7 @@ GLuint Shader::compileCode(ShaderType type, const std::string &code) void Shader::createProgram(const std::vector &shaderids) { program = glCreateProgram(); - if (program == 0) // should only fail when called between glBegin() and glEnd() + if (program == 0) throw love::Exception("Cannot create shader program object."); std::vector::const_iterator it; @@ -173,8 +173,9 @@ void Shader::createProgram(const std::vector &shaderids) glLinkProgram(program); + // flag shaders for auto-deletion when the program object is deleted. for (it = shaderids.begin(); it != shaderids.end(); ++it) - glDeleteShader(*it); // flag shaders for auto-deletion when program object is deleted + glDeleteShader(*it); GLint status; glGetProgramiv(program, GL_LINK_STATUS, &status); @@ -198,6 +199,9 @@ void Shader::mapActiveUniforms() GLsizei bufsize; glGetProgramiv(program, GL_ACTIVE_UNIFORM_MAX_LENGTH, (GLint *) &bufsize); + if (bufsize <= 0) + return; + for (int i = 0; i < numuniforms; i++) { GLchar *cname = new GLchar[bufsize]; @@ -242,11 +246,13 @@ bool Shader::loadVolatile() createProgram(shaderids); + // Retreive all active uniform variables in this shader from OpenGL. mapActiveUniforms(); if (current == this) { - current = NULL; // make sure glUseProgram gets called + // make sure glUseProgram gets called. + current = NULL; attach(); } @@ -497,7 +503,7 @@ void Shader::sendMatrix(const std::string &name, int size, const GLfloat *m, int if (size < 2 || size > 4) { throw love::Exception("Invalid matrix size: %dx%d " - "(can only set 2x2, 3x3 or 4x4 matrices).", size,size); + "(can only set 2x2, 3x3 or 4x4 matrices.)", size,size); } const Uniform &u = getUniform(name); @@ -584,9 +590,13 @@ int Shader::getTextureUnit(const std::string &name) std::string Shader::getGLSLVersion() { - // GL_SHADING_LANGUAGE_VERSION may not be available in OpenGL < 2.0. - const char *tmp = (const char *) glGetString(GL_SHADING_LANGUAGE_VERSION); - if (tmp == NULL) + const char *tmp = 0; + + // GL_SHADING_LANGUAGE_VERSION isn't available in OpenGL < 2.0. + if (GL_VERSION_2_0) + tmp = (const char *) glGetString(GL_SHADING_LANGUAGE_VERSION); + + if (tmp == 0) return "0.0"; // the version string always begins with a version number of the format diff --git a/src/modules/graphics/opengl/wrap_Graphics.cpp b/src/modules/graphics/opengl/wrap_Graphics.cpp index 839c9bfe6..018fe1541 100644 --- a/src/modules/graphics/opengl/wrap_Graphics.cpp +++ b/src/modules/graphics/opengl/wrap_Graphics.cpp @@ -1594,7 +1594,7 @@ int w_shear(lua_State *L) return 0; } -int w_origin(lua_State *L) +int w_origin(lua_State * /*L*/) { instance->origin(); return 0; diff --git a/src/modules/graphics/opengl/wrap_Shader.cpp b/src/modules/graphics/opengl/wrap_Shader.cpp index 3d77f90e9..c18e0d7de 100644 --- a/src/modules/graphics/opengl/wrap_Shader.cpp +++ b/src/modules/graphics/opengl/wrap_Shader.cpp @@ -47,8 +47,8 @@ template static T *_getScalars(lua_State *L, int count, size_t &dimension) { dimension = 1; - T *values = new T[count]; + for (int i = 0; i < count; ++i) { if (lua_isnumber(L, 3 + i)) diff --git a/src/modules/image/CompressedData.cpp b/src/modules/image/CompressedData.cpp index edabe6889..2b82f19b5 100644 --- a/src/modules/image/CompressedData.cpp +++ b/src/modules/image/CompressedData.cpp @@ -95,7 +95,7 @@ CompressedData::TextureType CompressedData::getType() const void CompressedData::checkMipmapLevelExists(int miplevel) const { - if (miplevel < 0 || miplevel >= dataImages.size()) + if (miplevel < 0 || miplevel >= (int) dataImages.size()) throw love::Exception("Mipmap level %d does not exist", miplevel); } diff --git a/src/modules/image/ImageData.cpp b/src/modules/image/ImageData.cpp index 2692375b3..133b0d1e4 100644 --- a/src/modules/image/ImageData.cpp +++ b/src/modules/image/ImageData.cpp @@ -74,7 +74,7 @@ void ImageData::setPixel(int x, int y, pixel c) pixels[y*getWidth()+x] = c; } -pixel ImageData::getPixel(int x, int y) +pixel ImageData::getPixel(int x, int y) const { if (!inside(x, y)) throw love::Exception("Attempt to get out-of-range pixel!"); diff --git a/src/modules/image/ImageData.h b/src/modules/image/ImageData.h index a842ce5e8..290e4f422 100644 --- a/src/modules/image/ImageData.h +++ b/src/modules/image/ImageData.h @@ -111,7 +111,7 @@ public: * @param y The location along the y-axis. * @return The color for the given location. **/ - pixel getPixel(int x, int y); + pixel getPixel(int x, int y) const; /** * Encodes raw pixel data into a given format. diff --git a/src/modules/image/magpie/DevilHandler.cpp b/src/modules/image/magpie/DevilHandler.cpp index 06425f1b3..739fce4c1 100644 --- a/src/modules/image/magpie/DevilHandler.cpp +++ b/src/modules/image/magpie/DevilHandler.cpp @@ -56,7 +56,7 @@ void DevilHandler::quit() ilShutDown(); } -bool DevilHandler::canDecode(love::filesystem::FileData *data) +bool DevilHandler::canDecode(love::filesystem::FileData * /*data*/) { // DevIL can decode a lot of formats... return true; diff --git a/src/modules/math/MathModule.cpp b/src/modules/math/MathModule.cpp index c693519ff..837195b0c 100644 --- a/src/modules/math/MathModule.cpp +++ b/src/modules/math/MathModule.cpp @@ -20,7 +20,6 @@ // LOVE #include "MathModule.h" -#include "common/math.h" // STL #include