diff --git a/platform/msvc2008/common/common.vcproj b/platform/msvc2008/common/common.vcproj
index 506f39875..7f0394a54 100644
--- a/platform/msvc2008/common/common.vcproj
+++ b/platform/msvc2008/common/common.vcproj
@@ -42,7 +42,7 @@
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../include"
- PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
+ PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
diff --git a/platform/msvc2008/graphics/graphics.vcproj b/platform/msvc2008/graphics/graphics.vcproj
index bc98946a0..f5edfdd0e 100644
--- a/platform/msvc2008/graphics/graphics.vcproj
+++ b/platform/msvc2008/graphics/graphics.vcproj
@@ -188,22 +188,6 @@
RelativePath="..\..\..\src\modules\graphics\opengl\Font.h"
>
-
-
-
-
-
-
-
@@ -285,6 +269,14 @@
RelativePath="..\..\..\src\modules\graphics\opengl\ImageFont.h"
>
+
+
+
+
@@ -333,22 +325,6 @@
RelativePath="..\..\..\src\modules\graphics\opengl\wrap_Font.h"
>
-
-
-
-
-
-
-
@@ -397,6 +373,14 @@
RelativePath="..\..\..\src\modules\graphics\opengl\wrap_Image.h"
>
+
+
+
+
diff --git a/platform/msvc2008/love.vcproj b/platform/msvc2008/love.vcproj
index 78422d9cd..b406fa9e3 100644
--- a/platform/msvc2008/love.vcproj
+++ b/platform/msvc2008/love.vcproj
@@ -821,30 +821,6 @@
RelativePath="..\..\src\modules\graphics\opengl\Font.h"
>
-
-
-
-
-
-
-
-
-
-
@@ -949,6 +925,14 @@
RelativePath="..\..\src\modules\graphics\opengl\ImageFont.h"
>
+
+
+
+
@@ -1005,30 +989,6 @@
RelativePath="..\..\src\modules\graphics\opengl\wrap_Font.h"
>
-
-
-
-
-
-
-
-
-
-
@@ -1085,6 +1045,14 @@
RelativePath="..\..\src\modules\graphics\opengl\wrap_Image.h"
>
+
+
+
+
diff --git a/src/common/Matrix.cpp b/src/common/Matrix.cpp
index 97ecaf835..3cc09046f 100644
--- a/src/common/Matrix.cpp
+++ b/src/common/Matrix.cpp
@@ -156,7 +156,7 @@ namespace love
// | e2 e6 e10 e14 |
// | e3 e7 e11 e15 |
- void Matrix::transform(vertex * dst, const vertex * src, int size)
+ void Matrix::transform(vertex * dst, const vertex * src, int size) const
{
for(int i = 0;i
+#include
#include
+#include
namespace love
{
diff --git a/src/modules/graphics/opengl/Graphics.cpp b/src/modules/graphics/opengl/Graphics.cpp
index ab21b2c33..35270dd07 100644
--- a/src/modules/graphics/opengl/Graphics.cpp
+++ b/src/modules/graphics/opengl/Graphics.cpp
@@ -395,9 +395,14 @@ namespace opengl
return image;
}
- Frame * Graphics::newFrame(int x, int y, int w, int h, int sw, int sh)
+ Quad * Graphics::newQuad(int x, int y, int w, int h, int sw, int sh)
{
- return new Frame(x, y, w, h, sw, sh);
+ Quad::Viewport v;
+ v.x = x;
+ v.y = y;
+ v.w = w;
+ v.h = h;
+ return new Quad(v, sw, sh);
}
Font * Graphics::newFont(Data * data, int size)
diff --git a/src/modules/graphics/opengl/Graphics.h b/src/modules/graphics/opengl/Graphics.h
index 4696b750c..279085d70 100644
--- a/src/modules/graphics/opengl/Graphics.h
+++ b/src/modules/graphics/opengl/Graphics.h
@@ -36,7 +36,7 @@
#include "Image.h"
#include "TrueTypeFont.h"
#include "ImageFont.h"
-#include "Frame.h"
+#include "Quad.h"
#include "SpriteBatch.h"
namespace love
@@ -239,7 +239,7 @@ namespace opengl
/**
* Creates a Frame
**/
- Frame * newFrame(int x, int y, int w, int h, int sw, int sh);
+ Quad * newQuad(int x, int y, int w, int h, int sw, int sh);
/**
* Creates a Font object.
diff --git a/src/modules/graphics/opengl/Image.cpp b/src/modules/graphics/opengl/Image.cpp
index 82f1f4857..8366d681d 100644
--- a/src/modules/graphics/opengl/Image.cpp
+++ b/src/modules/graphics/opengl/Image.cpp
@@ -110,21 +110,11 @@ namespace opengl
t.setTransformation(x, y, angle, sx, sy, ox, oy);
drawv(t, vertices);
}
-
- void Image::draws(float x, float y, float angle, float sx, float sy, float ox, float oy, float rx, float ry, float rw, float rh) const
+
+ void Image::drawq(Quad * quad, float x, float y, float angle, float sx, float sy, float ox, float oy) const
{
static Matrix t;
- static vertex cache[4];
-
- getRectangleVertices((int)rx, (int)ry, (int)rw, (int)rh, cache);
- t.setTransformation(x, y, angle, sx, sy, ox, oy);
- drawv(t, cache);
- }
-
- void Image::drawf(float x, float y, float angle, float sx, float sy, float ox, float oy, Frame * frame) const
- {
- static Matrix t;
- const vertex * v = frame->getVertices();
+ const vertex * v = quad->getVertices();
t.setTransformation(x, y, angle, sx, sy, ox, oy);
drawv(t, v);
diff --git a/src/modules/graphics/opengl/Image.h b/src/modules/graphics/opengl/Image.h
index e28f6f2c5..bf5cf43b8 100644
--- a/src/modules/graphics/opengl/Image.h
+++ b/src/modules/graphics/opengl/Image.h
@@ -22,13 +22,12 @@
#define LOVE_GRAPHICS_OPENGL_IMAGE_H
// LOVE
-#include
-#include
-#include
-#include
-#include "Frame.h"
#include
#include
+#include
+#include
+#include
+#include "Quad.h"
// OpenGL
#include "GLee.h"
@@ -105,23 +104,12 @@ namespace opengl
void draw(float x, float y, float angle, float sx, float sy, float ox, float oy) const;
/**
- * This function draws a section of the image.
- *
- * @copydetails Drawable::draw()
- * @param rx The upper-left corner of the source rectangle along the x-axis.
- * @param ry The upper-left corner of the source rectangle along the y-axis.
- * @param rw The width of the source rectangle.
- * @param rw The height of the source rectangle.
- **/
- void draws(float x, float y, float angle, float sx, float sy, float ox, float oy, float rx, float ry, float rw, float rh) const;
-
- /**
- * This function draws a section of the image using a Frame object.
+ * This function draws a section of the image using a Quad object.
*
* @copydetails Image::draws()
* @param frame Represents the region of the Image to draw.
**/
- void drawf(float x, float y, float angle, float sx, float sy, float ox, float oy, Frame * frame) const;
+ void drawq(Quad * quad, float x, float y, float angle, float sx, float sy, float ox, float oy) const;
/**
* Sets the filter mode.
diff --git a/src/modules/graphics/opengl/Frame.cpp b/src/modules/graphics/opengl/Quad.cpp
similarity index 62%
rename from src/modules/graphics/opengl/Frame.cpp
rename to src/modules/graphics/opengl/Quad.cpp
index 439c4c339..e6c71b825 100644
--- a/src/modules/graphics/opengl/Frame.cpp
+++ b/src/modules/graphics/opengl/Quad.cpp
@@ -18,7 +18,7 @@
* 3. This notice may not be removed or altered from any source distribution.
**/
-#include "Frame.h"
+#include "Quad.h"
#include
// STD
@@ -30,26 +30,51 @@ namespace graphics
{
namespace opengl
{
- Frame::Frame(int x, int y, int w, int h, int sw, int sh)
+ Quad::Quad(const Viewport & v, int sw, int sh)
+ : sw(sw), sh(sh)
{
memset(vertices, 255, sizeof(vertex)*4);
-
- vertices[0].x = 0; vertices[0].y = 0;
- vertices[1].x = 0; vertices[1].y = (float)h;
- vertices[2].x = (float)w; vertices[2].y = (float)h;
- vertices[3].x = (float)w; vertices[3].y = 0;
-
- vertices[0].s = (float)x/(float)sw; vertices[0].t = (float)y/(float)sh;
- vertices[1].s = (float)x/(float)sw; vertices[1].t = (float)(y+h)/(float)sh;
- vertices[2].s = (float)(x+w)/(float)sw; vertices[2].t = (float)(y+h)/(float)sh;
- vertices[3].s = (float)(x+w)/(float)sw; vertices[3].t = (float)y/(float)sh;
+ refresh(v, sw, sh);
}
- Frame::~Frame()
+ Quad::~Quad()
{
}
+
+ void Quad::refresh(const Viewport & v, int sw, int sh)
+ {
+ viewport = v;
+
+ 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[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;
+ }
+
+ void Quad::setViewport(const Quad::Viewport & v)
+ {
+ refresh(v, sw, sh);
+ }
+
+ Quad::Viewport Quad::getViewport() const
+ {
+ return viewport;
+ }
- void Frame::flip(bool x, bool y)
+ void Quad::flip(bool x, bool y)
{
vertex temp[4];
if (x)
@@ -70,7 +95,7 @@ namespace opengl
}
}
- const vertex * Frame::getVertices() const
+ const vertex * Quad::getVertices() const
{
return vertices;
}
diff --git a/src/modules/graphics/opengl/Frame.h b/src/modules/graphics/opengl/Quad.h
similarity index 56%
rename from src/modules/graphics/opengl/Frame.h
rename to src/modules/graphics/opengl/Quad.h
index f30b15539..1cec23db6 100644
--- a/src/modules/graphics/opengl/Frame.h
+++ b/src/modules/graphics/opengl/Quad.h
@@ -18,8 +18,8 @@
* 3. This notice may not be removed or altered from any source distribution.
**/
-#ifndef LOVE_GRAPHICS_OPENGL_FRAME_H
-#define LOVE_GRAPHICS_OPENGL_FRAME_H
+#ifndef LOVE_GRAPHICS_OPENGL_QUAD_H
+#define LOVE_GRAPHICS_OPENGL_QUAD_H
// LOVE
#include
@@ -32,37 +32,50 @@ namespace graphics
{
namespace opengl
{
- class Frame : public Object
+ class Quad : public Object
{
- private:
- vertex vertices[4];
- public:
+ public:
- /**
- * Creates a new Frame of size (w,h), using (x,y) as the top-left
- * anchor point in the source image. The size of the source image is
- * is specified by (sw,sh).
- *
- * @param x Frame source position along the x-axis.
- * @param y Frame source position along the y-axis.
- * @param w Frame width.
- * @param h Frame width.
- * @param sw Width of the source image.
- * @param sh Height of the source image.
- **/
- Frame(int x, int y, int w, int h, int sw, int sh);
+ struct Viewport
+ {
+ int x, y, w, h;
+ };
- virtual ~Frame();
+ private:
- void flip(bool x, bool y);
+ vertex vertices[4];
- /**
- * Gets a pointer to the vertices.
- **/
- const vertex * getVertices() const;
+ Viewport viewport;
+ int sw, sh;
+
+ public:
+
+ /**
+ * Creates a new Quad of size (w,h), using (x,y) as the top-left
+ * anchor point in the source image. The size of the source image is
+ * is specified by (sw,sh).
+ *
+ * @param sw Width of the source image.
+ * @param sh Height of the source image.
+ **/
+ Quad(const Viewport & v, int sw, int sh);
+
+ virtual ~Quad();
+
+ void refresh(const Viewport & v, int sw, int sh);
+
+ void setViewport(const Viewport & v);
+ Viewport getViewport() const;
+
+ void flip(bool x, bool y);
+
+ /**
+ * Gets a pointer to the vertices.
+ **/
+ const vertex * getVertices() const;
};
} // opengl
} // graphics
} // love
-#endif // LOVE_GRAPHICS_OPENGL_FRAME_H
+#endif // LOVE_GRAPHICS_OPENGL_QUAD_H
diff --git a/src/modules/graphics/opengl/SpriteBatch.cpp b/src/modules/graphics/opengl/SpriteBatch.cpp
index 59f2df9d3..83f65c6c4 100644
--- a/src/modules/graphics/opengl/SpriteBatch.cpp
+++ b/src/modules/graphics/opengl/SpriteBatch.cpp
@@ -25,6 +25,7 @@
// LOVE
#include "Image.h"
+#include "Quad.h"
namespace love
{
@@ -88,6 +89,7 @@ namespace opengl
// Get a pointer to the correct insertion position.
vertex * v = vertices + next*4;
+ // Needed for texture coordinates.
memcpy(v, image->getVertices(), sizeof(vertex)*4);
// Transform.
@@ -95,18 +97,30 @@ namespace opengl
t.setTransformation(x, y, a, sx, sy, ox, oy);
t.transform(v, v, 4);
- if(lockp != 0)
- {
- // Copy into mapped memory if buffer is locked.
- memcpy(lockp + (next*4), v, sizeof(vertex)*4);
- }
- else
- {
- // ... use glBufferSubData otherwise.
- glBindBuffer(GL_ARRAY_BUFFER, vbo[0]);
- glBufferSubData(GL_ARRAY_BUFFER, (next*4)*sizeof(vertex), sizeof(vertex)*4, v);
- glBindBuffer(GL_ARRAY_BUFFER, 0);
- }
+ addv(t, v);
+
+ // Increment counter.
+ next++;
+ }
+ }
+
+ void SpriteBatch::addq(Quad * quad, float x, float y, float a, float sx, float sy, float ox, float oy)
+ {
+ // Only do this if there's a free slot.
+ if(next < size)
+ {
+ // Get a pointer to the correct insertion position.
+ vertex * v = vertices + next*4;
+
+ // Needed for colors.
+ memcpy(v, quad->getVertices(), sizeof(vertex)*4);
+
+ // Transform.
+ Matrix t;
+ t.setTransformation(x, y, a, sx, sy, ox, oy);
+ t.transform(v, quad->getVertices(), 4);
+
+ addv(t, v);
// Increment counter.
next++;
@@ -169,6 +183,28 @@ namespace opengl
glPopMatrix();
}
+ void SpriteBatch::addv(const Matrix & t, const vertex * v)
+ {
+ // Get a pointer to the correct insertion position.
+ vertex * dst = vertices + next*4;
+
+ // Transform.
+ t.transform(dst, dst, 4);
+
+ if(lockp != 0)
+ {
+ // Copy into mapped memory if buffer is locked.
+ memcpy(lockp + (next*4), dst, sizeof(vertex)*4);
+ }
+ else
+ {
+ // ... use glBufferSubData otherwise.
+ glBindBuffer(GL_ARRAY_BUFFER, vbo[0]);
+ glBufferSubData(GL_ARRAY_BUFFER, (next*4)*sizeof(vertex), sizeof(vertex)*4, dst);
+ glBindBuffer(GL_ARRAY_BUFFER, 0);
+ }
+ }
+
} // opengl
} // graphics
} // love
diff --git a/src/modules/graphics/opengl/SpriteBatch.h b/src/modules/graphics/opengl/SpriteBatch.h
index d1f9c383e..bc4f59fd7 100644
--- a/src/modules/graphics/opengl/SpriteBatch.h
+++ b/src/modules/graphics/opengl/SpriteBatch.h
@@ -43,6 +43,7 @@ namespace opengl
{
// Forward declarations.
class Image;
+ class Quad;
class SpriteBatch : public Drawable
{
@@ -84,8 +85,7 @@ namespace opengl
virtual ~SpriteBatch();
void add(float x, float y, float a, float sx, float sy, float ox, float oy);
- //void adds(float x, float y, float a, float sx, float sy, float ox, float oy, float rx, float ry, float rw, float rh);
- //void addf(float x, float y, float a, float sx, float sy, float ox, float oy, Frame * frame);
+ void addq(Quad * quad, float x, float y, float a, float sx, float sy, float ox, float oy);
void clear();
void * lock();
@@ -94,6 +94,10 @@ namespace opengl
// Implements Drawable.
void draw(float x, float y, float angle, float sx, float sy, float ox, float oy) const;
+ private:
+
+ void addv(const Matrix & t, const vertex * v);
+
}; // SpriteBatch
} // opengl
diff --git a/src/modules/graphics/opengl/wrap_Frame.cpp b/src/modules/graphics/opengl/wrap_Frame.cpp
deleted file mode 100644
index 9ccee8129..000000000
--- a/src/modules/graphics/opengl/wrap_Frame.cpp
+++ /dev/null
@@ -1,54 +0,0 @@
-/**
-* Copyright (c) 2006-2009 LOVE Development Team
-*
-* This software is provided 'as-is', without any express or implied
-* warranty. In no event will the authors be held liable for any damages
-* arising from the use of this software.
-*
-* Permission is granted to anyone to use this software for any purpose,
-* including commercial applications, and to alter it and redistribute it
-* freely, subject to the following restrictions:
-*
-* 1. The origin of this software must not be misrepresented; you must not
-* claim that you wrote the original software. If you use this software
-* in a product, an acknowledgment in the product documentation would be
-* appreciated but is not required.
-* 2. Altered source versions must be plainly marked as such, and must not be
-* misrepresented as being the original software.
-* 3. This notice may not be removed or altered from any source distribution.
-**/
-
-// LOVE
-#include "wrap_Frame.h"
-
-namespace love
-{
-namespace graphics
-{
-namespace opengl
-{
- Frame * luax_checkframe(lua_State * L, int idx)
- {
- return luax_checktype(L, idx, "Frame", GRAPHICS_FRAME_T);
- }
-
- int w_Frame_flip(lua_State *L)
- {
- Frame *frame = luax_checktype(L, 1, "Frame", GRAPHICS_FRAME_T);
- frame->flip(luax_toboolean(L, 2), luax_toboolean(L, 3));
- return 0;
- }
-
- static const luaL_Reg w_Frame_functions[] = {
- { "flip", w_Frame_flip },
- { 0, 0 }
- };
-
- int luaopen_frame(lua_State * L)
- {
- return luax_register_type(L, "Frame", w_Frame_functions);
- }
-
-} // opengl
-} // graphics
-} // love
diff --git a/src/modules/graphics/opengl/wrap_Graphics.cpp b/src/modules/graphics/opengl/wrap_Graphics.cpp
index 50f08a8d6..ba5d2bae1 100644
--- a/src/modules/graphics/opengl/wrap_Graphics.cpp
+++ b/src/modules/graphics/opengl/wrap_Graphics.cpp
@@ -168,7 +168,7 @@ namespace opengl
return 1;
}
- int w_newFrame(lua_State * L)
+ int w_newQuad(lua_State * L)
{
int x = luaL_checkint(L, 1);
int y = luaL_checkint(L, 2);
@@ -177,12 +177,12 @@ namespace opengl
int sw = luaL_checkint(L, 5);
int sh = luaL_checkint(L, 6);
- Frame * frame = instance->newFrame(x, y, w, h, sw, sh);
+ Quad * frame = instance->newQuad(x, y, w, h, sw, sh);
if (frame == 0)
return luaL_error(L, "Could not create frame.");
- luax_newtype(L, "Frame", GRAPHICS_FRAME_T, (void*)frame);
+ luax_newtype(L, "Quad", GRAPHICS_QUAD_T, (void*)frame);
return 1;
}
@@ -481,40 +481,7 @@ namespace opengl
}
/**
- * Draws an Image at the specified coordinates, with rotation and
- * scaling along both axes.
- * @param x The x-coordinate.
- * @param y The y-coordinate.
- * @param angle The amount of rotation.
- * @param sx The scale factor along the x-axis. (1 = normal).
- * @param sy The scale factor along the y-axis. (1 = normal).
- * @param ox The offset along the x-axis.
- * @param oy The offset along the y-axis.
- * @param rx The upper-left corner of the source rectangle along the x-axis.
- * @param ry The upper-left corner of the source rectangle along the y-axis.
- * @param rw The width of the source rectangle.
- * @param rw The height of the source rectangle.
- **/
- int w_draws(lua_State * L)
- {
- Image * image = luax_checktype(L, 1, "Image", GRAPHICS_IMAGE_T);
- float x = (float)luaL_optnumber(L, 2, 0.0f);
- float y = (float)luaL_optnumber(L, 3, 0.0f);
- float angle = (float)luaL_optnumber(L, 4, 0.0f);
- float sx = (float)luaL_optnumber(L, 5, 1.0f);
- float sy = (float)luaL_optnumber(L, 6, sx);
- float ox = (float)luaL_optnumber(L, 7, 0);
- float oy = (float)luaL_optnumber(L, 8, 0);
- float rx = (float)luaL_optnumber(L, 9, 0);
- float ry = (float)luaL_optnumber(L, 10, 0);
- float rw = (float)luaL_optnumber(L, 11, image->getWidth());
- float rh = (float)luaL_optnumber(L, 12, image->getHeight());
- image->draws(x, y, angle, sx, sy, ox, oy, rx, ry, rw, rh);
- return 0;
- }
-
- /**
- * Draws an Frame of an Image at the specified coordinates,
+ * Draws an Quad of an Image at the specified coordinates,
* with rotation and scaling along both axes.
*
* @param x The x-coordinate.
@@ -524,20 +491,20 @@ namespace opengl
* @param sy The scale factor along the y-axis. (1 = normal).
* @param ox The offset along the x-axis.
* @param oy The offset along the y-axis.
- * @param f The Frame to dra.
+ * @param f The Quad to dra.
**/
- int w_drawf(lua_State * L)
+ int w_drawq(lua_State * L)
{
Image * image = luax_checktype(L, 1, "Image", GRAPHICS_IMAGE_T);
- float x = (float)luaL_checknumber(L, 2);
- float y = (float)luaL_checknumber(L, 3);
- float angle = (float)luaL_checknumber(L, 4);
- float sx = (float)luaL_checknumber(L, 5);
- float sy = (float)luaL_checknumber(L, 6);
- float ox = (float)luaL_checknumber(L, 7);
- float oy = (float)luaL_checknumber(L, 8);
- Frame * f = luax_checkframe(L, 9);
- image->drawf(x, y, angle, sx, sy, ox, oy, f);
+ Quad * q = luax_checkframe(L, 2);
+ float x = (float)luaL_checknumber(L, 3);
+ float y = (float)luaL_checknumber(L, 4);
+ float angle = (float)luaL_checknumber(L, 5);
+ float sx = (float)luaL_checknumber(L, 6);
+ float sy = (float)luaL_checknumber(L, 7);
+ float ox = (float)luaL_checknumber(L, 8);
+ float oy = (float)luaL_checknumber(L, 9);
+ image->drawq(q, x, y, angle, sx, sy, ox, oy);
return 0;
}
@@ -715,7 +682,7 @@ namespace opengl
{ "newImage", w_newImage },
{ "newGlyph", w_newGlyph },
- { "newFrame", w_newFrame },
+ { "newQuad", w_newQuad },
{ "newFont", w_newFont },
{ "newImageFont", w_newImageFont },
{ "newSpriteBatch", w_newSpriteBatch },
@@ -747,8 +714,7 @@ namespace opengl
{ "getMaxPointSize", w_getMaxPointSize },
{ "draw", w_draw },
- { "draws", w_draws },
- { "drawf", w_drawf },
+ { "drawq", w_drawq },
{ "drawTest", w_drawTest },
{ "print1", w_print1 },
diff --git a/src/modules/graphics/opengl/wrap_Graphics.h b/src/modules/graphics/opengl/wrap_Graphics.h
index 3f6d9101e..9e668ba61 100644
--- a/src/modules/graphics/opengl/wrap_Graphics.h
+++ b/src/modules/graphics/opengl/wrap_Graphics.h
@@ -25,7 +25,7 @@
#include "wrap_Font.h"
#include "wrap_Image.h"
#include "wrap_Glyph.h"
-#include "wrap_Frame.h"
+#include "wrap_Quad.h"
#include "wrap_SpriteBatch.h"
#include "Graphics.h"
@@ -78,7 +78,7 @@ namespace opengl
int w_getPointStyle(lua_State * L);
int w_getMaxPointSize(lua_State * L);
int w_draw(lua_State * L);
- int w_draws(lua_State * L);
+ int w_drawq(lua_State * L);
int w_drawTest(lua_State * L);
int w_print1(lua_State * L);
int w_printf1(lua_State * L);
diff --git a/src/modules/graphics/opengl/wrap_Quad.cpp b/src/modules/graphics/opengl/wrap_Quad.cpp
new file mode 100644
index 000000000..b640c59e4
--- /dev/null
+++ b/src/modules/graphics/opengl/wrap_Quad.cpp
@@ -0,0 +1,79 @@
+/**
+* Copyright (c) 2006-2009 LOVE Development Team
+*
+* This software is provided 'as-is', without any express or implied
+* warranty. In no event will the authors be held liable for any damages
+* arising from the use of this software.
+*
+* Permission is granted to anyone to use this software for any purpose,
+* including commercial applications, and to alter it and redistribute it
+* freely, subject to the following restrictions:
+*
+* 1. The origin of this software must not be misrepresented; you must not
+* claim that you wrote the original software. If you use this software
+* in a product, an acknowledgment in the product documentation would be
+* appreciated but is not required.
+* 2. Altered source versions must be plainly marked as such, and must not be
+* misrepresented as being the original software.
+* 3. This notice may not be removed or altered from any source distribution.
+**/
+
+// LOVE
+#include "wrap_Quad.h"
+
+namespace love
+{
+namespace graphics
+{
+namespace opengl
+{
+ Quad * luax_checkframe(lua_State * L, int idx)
+ {
+ return luax_checktype(L, idx, "Quad", GRAPHICS_QUAD_T);
+ }
+
+ int w_Quad_flip(lua_State *L)
+ {
+ Quad * quad = luax_checktype(L, 1, "Quad", GRAPHICS_QUAD_T);
+ quad->flip(luax_toboolean(L, 2), luax_toboolean(L, 3));
+ return 0;
+ }
+
+ int w_Quad_setViewport(lua_State * L)
+ {
+ 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);
+ quad->setViewport(v);
+ return 0;
+ }
+
+ int w_Quad_getViewport(lua_State * L)
+ {
+ 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);
+ return 4;
+ }
+
+ static const luaL_Reg w_Quad_functions[] = {
+ { "flip", w_Quad_flip },
+ { "setViewport", w_Quad_setViewport },
+ { "getViewport", w_Quad_getViewport },
+ { 0, 0 }
+ };
+
+ int luaopen_frame(lua_State * L)
+ {
+ return luax_register_type(L, "Quad", w_Quad_functions);
+ }
+
+} // opengl
+} // graphics
+} // love
diff --git a/src/modules/graphics/opengl/wrap_Frame.h b/src/modules/graphics/opengl/wrap_Quad.h
similarity index 75%
rename from src/modules/graphics/opengl/wrap_Frame.h
rename to src/modules/graphics/opengl/wrap_Quad.h
index 3ef2f3050..0f40c7297 100644
--- a/src/modules/graphics/opengl/wrap_Frame.h
+++ b/src/modules/graphics/opengl/wrap_Quad.h
@@ -18,12 +18,12 @@
* 3. This notice may not be removed or altered from any source distribution.
**/
-#ifndef LOVE_GRAPHICS_OPENGL_WRAP_FRAME_H
-#define LOVE_GRAPHICS_OPENGL_WRAP_FRAME_H
+#ifndef LOVE_GRAPHICS_OPENGL_WRAP_QUAD_H
+#define LOVE_GRAPHICS_OPENGL_WRAP_QUAD_H
// LOVE
#include
-#include "Frame.h"
+#include "Quad.h"
namespace love
{
@@ -31,12 +31,14 @@ namespace graphics
{
namespace opengl
{
- Frame * luax_checkframe(lua_State * L, int idx);
- int w_Frame_flip(lua_State *L);
+ Quad * luax_checkframe(lua_State * L, int idx);
+ int w_Quad_flip(lua_State *L);
+ int w_Quad_setViewport(lua_State * L);
+ int w_Quad_getViewport(lua_State * L);
int luaopen_frame(lua_State * L);
} // opengl
} // graphics
} // love
-#endif // LOVE_GRAPHICS_OPENGL_WRAP_FRAME_H
+#endif // LOVE_GRAPHICS_OPENGL_WRAP_QUAD_H
diff --git a/src/modules/graphics/opengl/wrap_SpriteBatch.cpp b/src/modules/graphics/opengl/wrap_SpriteBatch.cpp
index 379a1220f..a60f69a97 100644
--- a/src/modules/graphics/opengl/wrap_SpriteBatch.cpp
+++ b/src/modules/graphics/opengl/wrap_SpriteBatch.cpp
@@ -45,6 +45,21 @@ namespace opengl
return 0;
}
+ int w_SpriteBatch_addq(lua_State * L)
+ {
+ SpriteBatch * t = luax_checkspritebatch(L, 1);
+ Quad * q = luax_checktype(L, 2, "Quad", GRAPHICS_QUAD_T);
+ float x = (float)luaL_optnumber(L, 3, 0.0f);
+ float y = (float)luaL_optnumber(L, 4, 0.0f);
+ float angle = (float)luaL_optnumber(L, 5, 0.0f);
+ float sx = (float)luaL_optnumber(L, 6, 1.0f);
+ float sy = (float)luaL_optnumber(L, 7, sx);
+ float ox = (float)luaL_optnumber(L, 8, 0);
+ float oy = (float)luaL_optnumber(L, 9, 0);
+ t->addq(q, x, y, angle, sx, sy, ox, oy);
+ return 0;
+ }
+
int w_SpriteBatch_clear(lua_State * L)
{
SpriteBatch * t = luax_checkspritebatch(L, 1);
@@ -68,6 +83,7 @@ namespace opengl
static const luaL_Reg functions[] = {
{ "add", w_SpriteBatch_add },
+ { "addq", w_SpriteBatch_addq },
{ "clear", w_SpriteBatch_clear },
{ "lock", w_SpriteBatch_lock },
{ "unlock", w_SpriteBatch_unlock },
diff --git a/src/modules/graphics/opengl/wrap_SpriteBatch.h b/src/modules/graphics/opengl/wrap_SpriteBatch.h
index 6c39d99e0..2d1bd826d 100644
--- a/src/modules/graphics/opengl/wrap_SpriteBatch.h
+++ b/src/modules/graphics/opengl/wrap_SpriteBatch.h
@@ -32,6 +32,7 @@ namespace opengl
{
SpriteBatch * luax_checkspritebatch(lua_State * L, int idx);
int w_SpriteBatch_add(lua_State * L);
+ int w_SpriteBatch_addq(lua_State * L);
int w_SpriteBatch_clear(lua_State * L);
int w_SpriteBatch_lock(lua_State * L);
int w_SpriteBatch_unlock(lua_State * L);
diff --git a/src/modules/timer/sdl/Timer.cpp b/src/modules/timer/sdl/Timer.cpp
index 75189fcc1..dfd6217d4 100644
--- a/src/modules/timer/sdl/Timer.cpp
+++ b/src/modules/timer/sdl/Timer.cpp
@@ -69,9 +69,10 @@ namespace sdl
}
}
- void Timer::sleep(unsigned int ms)
+ void Timer::sleep(int ms)
{
- SDL_Delay(ms);
+ if(ms > 0)
+ SDL_Delay(ms);
}
float Timer::getDelta() const
diff --git a/src/modules/timer/sdl/Timer.h b/src/modules/timer/sdl/Timer.h
index 8347fb738..1879dbfb3 100644
--- a/src/modules/timer/sdl/Timer.h
+++ b/src/modules/timer/sdl/Timer.h
@@ -90,7 +90,7 @@ namespace sdl
* usually 1ms.
* @param ms The number of milliseconds to sleep for.
**/
- void sleep(unsigned int ms);
+ void sleep(int ms);
/**
* Gets the time between the last two frames, assuming step is called