diff --git a/src/modules/graphics/opengl/Quad.cpp b/src/modules/graphics/opengl/Quad.cpp index 0f88292b8..635b2269a 100644 --- a/src/modules/graphics/opengl/Quad.cpp +++ b/src/modules/graphics/opengl/Quad.cpp @@ -33,7 +33,7 @@ namespace graphics { namespace opengl { - Quad::Quad(const Viewport & v, int sw, int sh) + Quad::Quad(const Viewport & v, float sw, float sh) : sw(sw), sh(sh) { memset(vertices, 255, sizeof(vertex)*4); @@ -44,7 +44,7 @@ namespace opengl { } - void Quad::refresh(const Viewport & v, int sw, int sh) + void Quad::refresh(const Viewport & v, float sw, float sh) { if (!GLEE_ARB_texture_non_power_of_two) { @@ -56,20 +56,20 @@ namespace opengl vertices[0].x = 0; vertices[0].y = 0; vertices[1].x = 0; - vertices[1].y = (float)v.h; - vertices[2].x = (float)v.w; - vertices[2].y = (float)v.h; - vertices[3].x = (float)v.w; + vertices[1].y = v.h; + vertices[2].x = v.w; + vertices[2].y = v.h; + vertices[3].x = v.w; vertices[3].y = 0; - vertices[0].s = (float)v.x/(float)sw; - vertices[0].t = (float)v.y/(float)sh; - vertices[1].s = (float)v.x/(float)sw; - vertices[1].t = (float)(v.y+v.h)/(float)sh; - vertices[2].s = (float)(v.x+v.w)/(float)sw; - vertices[2].t = (float)(v.y+v.h)/(float)sh; - vertices[3].s = (float)(v.x+v.w)/(float)sw; - vertices[3].t = (float)v.y/(float)sh; + vertices[0].s = v.x/sw; + vertices[0].t = v.y/sh; + vertices[1].s = v.x/sw; + vertices[1].t = (v.y+v.h)/sh; + vertices[2].s = (v.x+v.w)/sw; + vertices[2].t = (v.y+v.h)/sh; + vertices[3].s = (v.x+v.w)/sw; + vertices[3].t = v.y/sh; } void Quad::setViewport(const Quad::Viewport & v) diff --git a/src/modules/graphics/opengl/Quad.h b/src/modules/graphics/opengl/Quad.h index 9da9fe6f6..b85c6ec39 100644 --- a/src/modules/graphics/opengl/Quad.h +++ b/src/modules/graphics/opengl/Quad.h @@ -38,7 +38,7 @@ namespace opengl struct Viewport { - int x, y, w, h; + float x, y, w, h; }; private: @@ -46,7 +46,7 @@ namespace opengl vertex vertices[4]; Viewport viewport; - int sw, sh; + float sw, sh; public: @@ -58,11 +58,11 @@ namespace opengl * @param sw Width of the source image. * @param sh Height of the source image. **/ - Quad(const Viewport & v, int sw, int sh); + Quad(const Viewport & v, float sw, float sh); virtual ~Quad(); - void refresh(const Viewport & v, int sw, int sh); + void refresh(const Viewport & v, float sw, float sh); void setViewport(const Viewport & v); Viewport getViewport() const; diff --git a/src/modules/graphics/opengl/wrap_Graphics.cpp b/src/modules/graphics/opengl/wrap_Graphics.cpp index 3187e4eab..6319835e4 100644 --- a/src/modules/graphics/opengl/wrap_Graphics.cpp +++ b/src/modules/graphics/opengl/wrap_Graphics.cpp @@ -226,12 +226,12 @@ namespace opengl int w_newQuad(lua_State * L) { - int x = luaL_checkint(L, 1); - int y = luaL_checkint(L, 2); - int w = luaL_checkint(L, 3); - int h = luaL_checkint(L, 4); - int sw = luaL_checkint(L, 5); - int sh = luaL_checkint(L, 6); + int x = luaL_checknumber(L, 1); + int y = luaL_checknumber(L, 2); + int w = luaL_checknumber(L, 3); + int h = luaL_checknumber(L, 4); + int sw = luaL_checknumber(L, 5); + int sh = luaL_checknumber(L, 6); Quad * frame = instance->newQuad(x, y, w, h, sw, sh); diff --git a/src/modules/graphics/opengl/wrap_Quad.cpp b/src/modules/graphics/opengl/wrap_Quad.cpp index 8d4075165..13f63a8d3 100644 --- a/src/modules/graphics/opengl/wrap_Quad.cpp +++ b/src/modules/graphics/opengl/wrap_Quad.cpp @@ -43,10 +43,10 @@ namespace opengl { Quad * quad = luax_checktype(L, 1, "Quad", GRAPHICS_QUAD_T); Quad::Viewport v; - v.x = luaL_checkint(L, 2); - v.y = luaL_checkint(L, 3); - v.w = luaL_checkint(L, 4); - v.h = luaL_checkint(L, 5); + v.x = luaL_checknumber(L, 2); + v.y = luaL_checknumber(L, 3); + v.w = luaL_checknumber(L, 4); + v.h = luaL_checknumber(L, 5); quad->setViewport(v); return 0; } @@ -55,10 +55,10 @@ namespace opengl { Quad * quad = luax_checktype(L, 1, "Quad", GRAPHICS_QUAD_T); Quad::Viewport v = quad->getViewport(); - lua_pushinteger(L, v.x); - lua_pushinteger(L, v.y); - lua_pushinteger(L, v.w); - lua_pushinteger(L, v.h); + lua_pushnumber(L, v.x); + lua_pushnumber(L, v.y); + lua_pushnumber(L, v.w); + lua_pushnumber(L, v.h); return 4; }