From ea2e45f4e2ff9342b6bc4558db904a1c31df66a3 Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Sat, 31 Jan 2015 23:17:37 -0400 Subject: [PATCH] Renamed love.mouse.setRelative to love.mouse.setRelativeMode, removed some unused OpenGL code. --- src/modules/graphics/opengl/OpenGL.cpp | 62 -------------------------- src/modules/graphics/opengl/OpenGL.h | 10 ----- src/modules/mouse/Mouse.h | 4 +- src/modules/mouse/sdl/Mouse.cpp | 4 +- src/modules/mouse/sdl/Mouse.h | 4 +- src/modules/mouse/wrap_Mouse.cpp | 12 ++--- src/modules/mouse/wrap_Mouse.h | 4 +- src/scripts/graphics.lua | 11 +---- src/scripts/graphics.lua.h | 21 +-------- 9 files changed, 17 insertions(+), 115 deletions(-) diff --git a/src/modules/graphics/opengl/OpenGL.cpp b/src/modules/graphics/opengl/OpenGL.cpp index 85ad625a5..cc38b6c49 100644 --- a/src/modules/graphics/opengl/OpenGL.cpp +++ b/src/modules/graphics/opengl/OpenGL.cpp @@ -122,8 +122,6 @@ void OpenGL::initContext() initMaxValues(); createDefaultTexture(); - state.lastPseudoInstanceID = -1; - // Invalidate the cached matrices by setting some elements to NaN. float nan = std::numeric_limits::quiet_NaN(); state.lastProjectionMatrix.setTranslation(nan, nan); @@ -276,14 +274,6 @@ void OpenGL::prepareDraw() // love-provided uniforms. shader->checkSetScreenParams(); - // Make sure the Instance ID variable is up-to-date when - // pseudo-instancing is used. - if (state.lastPseudoInstanceID != 0 && shader->hasVertexAttrib(ATTRIB_PSEUDO_INSTANCE_ID)) - { - glVertexAttrib1f((GLuint) ATTRIB_PSEUDO_INSTANCE_ID, 0.0f); - state.lastPseudoInstanceID = 0; - } - // We need to make sure antialiased Canvases are properly resolved // before sampling from their textures in a shader. // This is kind of a big hack. :( @@ -332,58 +322,6 @@ void OpenGL::drawElements(GLenum mode, GLsizei count, GLenum type, const void *i ++stats.drawCalls; } -void OpenGL::drawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei primcount) -{ - Shader *shader = Shader::current; - - if (GLEE_ARB_draw_instanced) - glDrawArraysInstancedARB(mode, first, count, primcount); - else - { - bool shaderHasID = shader && shader->hasVertexAttrib(ATTRIB_PSEUDO_INSTANCE_ID); - - // Pseudo-instancing fallback. - for (int i = 0; i < primcount; i++) - { - if (shaderHasID) - glVertexAttrib1f((GLuint) ATTRIB_PSEUDO_INSTANCE_ID, (GLfloat) i); - - glDrawArrays(mode, first, count); - } - - if (shaderHasID) - state.lastPseudoInstanceID = primcount - 1; - } - - ++stats.drawCalls; -} - -void OpenGL::drawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount) -{ - Shader *shader = Shader::current; - - if (GLEE_ARB_draw_instanced) - glDrawElementsInstancedARB(mode, count, type, indices, primcount); - else - { - bool shaderHasID = shader && shader->hasVertexAttrib(ATTRIB_PSEUDO_INSTANCE_ID); - - // Pseudo-instancing fallback. - for (int i = 0; i < primcount; i++) - { - if (shaderHasID) - glVertexAttrib1f((GLuint) ATTRIB_PSEUDO_INSTANCE_ID, (GLfloat) i); - - glDrawElements(mode, count, type, indices); - } - - if (shaderHasID) - state.lastPseudoInstanceID = primcount - 1; - } - - ++stats.drawCalls; -} - void OpenGL::setColor(const Color &c) { glColor4ubv(&c.r); diff --git a/src/modules/graphics/opengl/OpenGL.h b/src/modules/graphics/opengl/OpenGL.h index 595c516e3..70c35cb08 100644 --- a/src/modules/graphics/opengl/OpenGL.h +++ b/src/modules/graphics/opengl/OpenGL.h @@ -171,13 +171,6 @@ public: void drawArrays(GLenum mode, GLint first, GLsizei count); void drawElements(GLenum mode, GLsizei count, GLenum type, const void *indices); - /** - * glDrawArraysInstanced and glDrawElementsInstanced with pseudo-instancing - * fallbacks. They also increment the draw-call counter (once per call). - **/ - void drawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei primcount); - void drawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); - /** * Sets the current constant color. **/ @@ -326,9 +319,6 @@ private: BlendState blend; - // The last ID value used for pseudo-instancing. - int lastPseudoInstanceID; - Matrix lastProjectionMatrix; Matrix lastTransformMatrix; diff --git a/src/modules/mouse/Mouse.h b/src/modules/mouse/Mouse.h index 86fc58291..77ebc6195 100644 --- a/src/modules/mouse/Mouse.h +++ b/src/modules/mouse/Mouse.h @@ -73,8 +73,8 @@ public: virtual bool isVisible() const = 0; virtual void setGrabbed(bool grab) = 0; virtual bool isGrabbed() const = 0; - virtual bool setRelative(bool relative) = 0; - virtual bool isRelative() const = 0; + virtual bool setRelativeMode(bool relative) = 0; + virtual bool getRelativeMode() const = 0; static bool getConstant(const char *in, Button &out); static bool getConstant(Button in, const char *&out); diff --git a/src/modules/mouse/sdl/Mouse.cpp b/src/modules/mouse/sdl/Mouse.cpp index ea296aa0f..5f912ec46 100644 --- a/src/modules/mouse/sdl/Mouse.cpp +++ b/src/modules/mouse/sdl/Mouse.cpp @@ -208,12 +208,12 @@ bool Mouse::isGrabbed() const return false; } -bool Mouse::setRelative(bool relative) +bool Mouse::setRelativeMode(bool relative) { return SDL_SetRelativeMouseMode(relative ? SDL_TRUE : SDL_FALSE) == 0; } -bool Mouse::isRelative() const +bool Mouse::getRelativeMode() const { return SDL_GetRelativeMouseMode() != SDL_FALSE; } diff --git a/src/modules/mouse/sdl/Mouse.h b/src/modules/mouse/sdl/Mouse.h index 9623cdbea..93db09440 100644 --- a/src/modules/mouse/sdl/Mouse.h +++ b/src/modules/mouse/sdl/Mouse.h @@ -64,8 +64,8 @@ public: bool isVisible() const; void setGrabbed(bool grab); bool isGrabbed() const; - bool setRelative(bool relative); - bool isRelative() const; + bool setRelativeMode(bool relative); + bool getRelativeMode() const; private: diff --git a/src/modules/mouse/wrap_Mouse.cpp b/src/modules/mouse/wrap_Mouse.cpp index 92fcbe7de..bf46149ba 100644 --- a/src/modules/mouse/wrap_Mouse.cpp +++ b/src/modules/mouse/wrap_Mouse.cpp @@ -179,16 +179,16 @@ int w_isGrabbed(lua_State *L) return 1; } -int w_setRelative(lua_State *L) +int w_setRelativeMode(lua_State *L) { bool relative = luax_toboolean(L, 1); - luax_pushboolean(L, instance()->setRelative(relative)); + luax_pushboolean(L, instance()->setRelativeMode(relative)); return 1; } -int w_isRelative(lua_State *L) +int w_getRelativeMode(lua_State *L) { - luax_pushboolean(L, instance()->isRelative()); + luax_pushboolean(L, instance()->getRelativeMode()); return 1; } @@ -210,8 +210,8 @@ static const luaL_Reg functions[] = { "getPosition", w_getPosition }, { "setGrabbed", w_setGrabbed }, { "isGrabbed", w_isGrabbed }, - { "setRelative", w_setRelative }, - { "isRelative", w_isRelative }, + { "setRelativeMode", w_setRelativeMode }, + { "getRelativeMode", w_getRelativeMode }, { 0, 0 } }; diff --git a/src/modules/mouse/wrap_Mouse.h b/src/modules/mouse/wrap_Mouse.h index 4392c741d..f08e430b3 100644 --- a/src/modules/mouse/wrap_Mouse.h +++ b/src/modules/mouse/wrap_Mouse.h @@ -45,8 +45,8 @@ int w_setVisible(lua_State *L); int w_isVisible(lua_State *L); int w_setGrabbed(lua_State *L); int w_isGrabbed(lua_State *L); -int w_setRelative(lua_State *L); -int w_isRelative(lua_State *L); +int w_setRelativeMode(lua_State *L); +int w_getRelativeMode(lua_State *L); extern "C" LOVE_EXPORT int luaopen_love_mouse(lua_State *L); } // mouse diff --git a/src/scripts/graphics.lua b/src/scripts/graphics.lua index 940feb4c0..4319d20ea 100644 --- a/src/scripts/graphics.lua +++ b/src/scripts/graphics.lua @@ -52,16 +52,7 @@ uniform vec4 love_ScreenSize;]] #define VertexColor gl_Color #define VaryingTexCoord gl_TexCoord[0] -#define VaryingColor gl_FrontColor - -// #if defined(GL_ARB_draw_instanced) -// #extension GL_ARB_draw_instanced : enable -// #define love_InstanceID gl_InstanceIDARB -// #else -// attribute float love_PseudoInstanceID; -// int love_InstanceID = int(love_PseudoInstanceID); -// #endif -]], +#define VaryingColor gl_FrontColor]], FOOTER = [[ void main() { diff --git a/src/scripts/graphics.lua.h b/src/scripts/graphics.lua.h index 1cab69723..5809b1279 100644 --- a/src/scripts/graphics.lua.h +++ b/src/scripts/graphics.lua.h @@ -134,25 +134,8 @@ const unsigned char graphics_lua[] = 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x20, 0x67, 0x6c, 0x5f, 0x54, 0x65, 0x78, 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x5b, 0x30, 0x5d, 0x0a, 0x23, 0x64, 0x65, 0x66, 0x69, 0x6e, 0x65, 0x20, 0x56, 0x61, 0x72, 0x79, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6c, - 0x6f, 0x72, 0x20, 0x67, 0x6c, 0x5f, 0x46, 0x72, 0x6f, 0x6e, 0x74, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x0a, - 0x2f, 0x2f, 0x20, 0x23, 0x69, 0x66, 0x20, 0x64, 0x65, 0x66, 0x69, 0x6e, 0x65, 0x64, 0x28, 0x47, 0x4c, 0x5f, - 0x41, 0x52, 0x42, 0x5f, 0x64, 0x72, 0x61, 0x77, 0x5f, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x64, - 0x29, 0x0a, - 0x2f, 0x2f, 0x09, 0x23, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x47, 0x4c, 0x5f, 0x41, - 0x52, 0x42, 0x5f, 0x64, 0x72, 0x61, 0x77, 0x5f, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x64, 0x20, - 0x3a, 0x20, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x0a, - 0x2f, 0x2f, 0x09, 0x23, 0x64, 0x65, 0x66, 0x69, 0x6e, 0x65, 0x20, 0x6c, 0x6f, 0x76, 0x65, 0x5f, 0x49, 0x6e, - 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x49, 0x44, 0x20, 0x67, 0x6c, 0x5f, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, - 0x63, 0x65, 0x49, 0x44, 0x41, 0x52, 0x42, 0x0a, - 0x2f, 0x2f, 0x20, 0x23, 0x65, 0x6c, 0x73, 0x65, 0x0a, - 0x2f, 0x2f, 0x09, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, - 0x20, 0x6c, 0x6f, 0x76, 0x65, 0x5f, 0x50, 0x73, 0x65, 0x75, 0x64, 0x6f, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, - 0x63, 0x65, 0x49, 0x44, 0x3b, 0x0a, - 0x2f, 0x2f, 0x09, 0x69, 0x6e, 0x74, 0x20, 0x6c, 0x6f, 0x76, 0x65, 0x5f, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, - 0x63, 0x65, 0x49, 0x44, 0x20, 0x3d, 0x20, 0x69, 0x6e, 0x74, 0x28, 0x6c, 0x6f, 0x76, 0x65, 0x5f, 0x50, 0x73, - 0x65, 0x75, 0x64, 0x6f, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x49, 0x44, 0x29, 0x3b, 0x0a, - 0x2f, 0x2f, 0x20, 0x23, 0x65, 0x6e, 0x64, 0x69, 0x66, 0x0a, - 0x5d, 0x5d, 0x2c, 0x0a, + 0x6f, 0x72, 0x20, 0x67, 0x6c, 0x5f, 0x46, 0x72, 0x6f, 0x6e, 0x74, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x5d, 0x5d, + 0x2c, 0x0a, 0x09, 0x09, 0x46, 0x4f, 0x4f, 0x54, 0x45, 0x52, 0x20, 0x3d, 0x20, 0x5b, 0x5b, 0x0a, 0x76, 0x6f, 0x69, 0x64, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x28, 0x29, 0x20, 0x7b, 0x0a, 0x09, 0x56, 0x61, 0x72, 0x79, 0x69, 0x6e, 0x67, 0x54, 0x65, 0x78, 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x20, 0x3d,