1 /** 2 * Copyright (c) 2006-2012 LOVE Development Team 3 * 4 * This software is provided 'as-is', without any express or implied 5 * warranty. In no event will the authors be held liable for any damages 6 * arising from the use of this software. 7 * 8 * Permission is granted to anyone to use this software for any purpose, 9 * including commercial applications, and to alter it and redistribute it 10 * freely, subject to the following restrictions: 11 * 12 * 1. The origin of this software must not be misrepresented; you must not 13 * claim that you wrote the original software. If you use this software 14 * in a product, an acknowledgment in the product documentation would be 15 * appreciated but is not required. 16 * 2. Altered source versions must be plainly marked as such, and must not be 17 * misrepresented as being the original software. 18 * 3. This notice may not be removed or altered from any source distribution. 19 **/ 20 21 // LOVE 22 #include "wrap_Quad.h" 23 24 namespace love 25 { 26 namespace graphics 27 { 28 namespace opengl 29 { luax_checkframe(lua_State * L,int idx)30 Quad * luax_checkframe(lua_State * L, int idx) 31 { 32 return luax_checktype<Quad>(L, idx, "Quad", GRAPHICS_QUAD_T); 33 } 34 w_Quad_flip(lua_State * L)35 int w_Quad_flip(lua_State *L) 36 { 37 Quad * quad = luax_checktype<Quad>(L, 1, "Quad", GRAPHICS_QUAD_T); 38 quad->flip(luax_toboolean(L, 2), luax_toboolean(L, 3)); 39 return 0; 40 } 41 w_Quad_setViewport(lua_State * L)42 int w_Quad_setViewport(lua_State * L) 43 { 44 Quad * quad = luax_checktype<Quad>(L, 1, "Quad", GRAPHICS_QUAD_T); 45 Quad::Viewport v; 46 v.x = (float) luaL_checknumber(L, 2); 47 v.y = (float) luaL_checknumber(L, 3); 48 v.w = (float) luaL_checknumber(L, 4); 49 v.h = (float) luaL_checknumber(L, 5); 50 quad->setViewport(v); 51 return 0; 52 } 53 w_Quad_getViewport(lua_State * L)54 int w_Quad_getViewport(lua_State * L) 55 { 56 Quad * quad = luax_checktype<Quad>(L, 1, "Quad", GRAPHICS_QUAD_T); 57 Quad::Viewport v = quad->getViewport(); 58 lua_pushnumber(L, v.x); 59 lua_pushnumber(L, v.y); 60 lua_pushnumber(L, v.w); 61 lua_pushnumber(L, v.h); 62 return 4; 63 } 64 65 static const luaL_Reg w_Quad_functions[] = { 66 { "flip", w_Quad_flip }, 67 { "setViewport", w_Quad_setViewport }, 68 { "getViewport", w_Quad_getViewport }, 69 { 0, 0 } 70 }; 71 luaopen_frame(lua_State * L)72 extern "C" int luaopen_frame(lua_State * L) 73 { 74 return luax_register_type(L, "Quad", w_Quad_functions); 75 } 76 77 } // opengl 78 } // graphics 79 } // love 80