Browse Source

Renamed Frame to Quad; added drawq/addq; fixed some bugs.

rude 16 years ago
parent
commit
c52c218ba1

+ 1 - 1
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"

+ 16 - 32
platform/msvc2008/graphics/graphics.vcproj

@@ -188,22 +188,6 @@
 				RelativePath="..\..\..\src\modules\graphics\opengl\Font.h"
 				>
 			</File>
-			<File
-				RelativePath="..\..\..\src\modules\graphics\opengl\Frame.cpp"
-				>
-				<FileConfiguration
-					Name="Debug|Win32"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						ObjectFile="$(IntDir)\graphics\opengl\"
-					/>
-				</FileConfiguration>
-			</File>
-			<File
-				RelativePath="..\..\..\src\modules\graphics\opengl\Frame.h"
-				>
-			</File>
 			<File
 				RelativePath="..\..\..\src\modules\graphics\opengl\GLee.c"
 				>
@@ -286,23 +270,15 @@
 				>
 			</File>
 			<File
-				RelativePath="..\..\..\src\modules\graphics\opengl\SpriteBatch.cpp"
+				RelativePath="..\..\..\src\modules\graphics\opengl\Quad.cpp"
 				>
-				<FileConfiguration
-					Name="Debug|Win32"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						ObjectFile="$(IntDir)\graphics\opengl\"
-					/>
-				</FileConfiguration>
 			</File>
 			<File
-				RelativePath="..\..\..\src\modules\graphics\opengl\SpriteBatch.h"
+				RelativePath="..\..\..\src\modules\graphics\opengl\Quad.h"
 				>
 			</File>
 			<File
-				RelativePath="..\..\..\src\modules\graphics\opengl\TrueTypeFont.cpp"
+				RelativePath="..\..\..\src\modules\graphics\opengl\SpriteBatch.cpp"
 				>
 				<FileConfiguration
 					Name="Debug|Win32"
@@ -314,11 +290,11 @@
 				</FileConfiguration>
 			</File>
 			<File
-				RelativePath="..\..\..\src\modules\graphics\opengl\TrueTypeFont.h"
+				RelativePath="..\..\..\src\modules\graphics\opengl\SpriteBatch.h"
 				>
 			</File>
 			<File
-				RelativePath="..\..\..\src\modules\graphics\opengl\wrap_Font.cpp"
+				RelativePath="..\..\..\src\modules\graphics\opengl\TrueTypeFont.cpp"
 				>
 				<FileConfiguration
 					Name="Debug|Win32"
@@ -330,11 +306,11 @@
 				</FileConfiguration>
 			</File>
 			<File
-				RelativePath="..\..\..\src\modules\graphics\opengl\wrap_Font.h"
+				RelativePath="..\..\..\src\modules\graphics\opengl\TrueTypeFont.h"
 				>
 			</File>
 			<File
-				RelativePath="..\..\..\src\modules\graphics\opengl\wrap_Frame.cpp"
+				RelativePath="..\..\..\src\modules\graphics\opengl\wrap_Font.cpp"
 				>
 				<FileConfiguration
 					Name="Debug|Win32"
@@ -346,7 +322,7 @@
 				</FileConfiguration>
 			</File>
 			<File
-				RelativePath="..\..\..\src\modules\graphics\opengl\wrap_Frame.h"
+				RelativePath="..\..\..\src\modules\graphics\opengl\wrap_Font.h"
 				>
 			</File>
 			<File
@@ -397,6 +373,14 @@
 				RelativePath="..\..\..\src\modules\graphics\opengl\wrap_Image.h"
 				>
 			</File>
+			<File
+				RelativePath="..\..\..\src\modules\graphics\opengl\wrap_Quad.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\..\src\modules\graphics\opengl\wrap_Quad.h"
+				>
+			</File>
 			<File
 				RelativePath="..\..\..\src\modules\graphics\opengl\wrap_SpriteBatch.cpp"
 				>

+ 16 - 48
platform/msvc2008/love.vcproj

@@ -821,30 +821,6 @@
 						RelativePath="..\..\src\modules\graphics\opengl\Font.h"
 						>
 					</File>
-					<File
-						RelativePath="..\..\src\modules\graphics\opengl\Frame.cpp"
-						>
-						<FileConfiguration
-							Name="Debug|Win32"
-							>
-							<Tool
-								Name="VCCLCompilerTool"
-								ObjectFile="$(IntDir)\graphics\opengl\"
-							/>
-						</FileConfiguration>
-						<FileConfiguration
-							Name="Release|Win32"
-							>
-							<Tool
-								Name="VCCLCompilerTool"
-								ObjectFile="$(IntDir)\graphics\opengl\"
-							/>
-						</FileConfiguration>
-					</File>
-					<File
-						RelativePath="..\..\src\modules\graphics\opengl\Frame.h"
-						>
-					</File>
 					<File
 						RelativePath="..\..\src\modules\graphics\opengl\GLee.c"
 						>
@@ -950,39 +926,23 @@
 						>
 					</File>
 					<File
-						RelativePath="..\..\src\modules\graphics\opengl\SpriteBatch.cpp"
+						RelativePath="..\..\src\modules\graphics\opengl\Quad.cpp"
 						>
 					</File>
 					<File
-						RelativePath="..\..\src\modules\graphics\opengl\SpriteBatch.h"
+						RelativePath="..\..\src\modules\graphics\opengl\Quad.h"
 						>
 					</File>
 					<File
-						RelativePath="..\..\src\modules\graphics\opengl\TrueTypeFont.cpp"
+						RelativePath="..\..\src\modules\graphics\opengl\SpriteBatch.cpp"
 						>
-						<FileConfiguration
-							Name="Debug|Win32"
-							>
-							<Tool
-								Name="VCCLCompilerTool"
-								ObjectFile="$(IntDir)\graphics\opengl\"
-							/>
-						</FileConfiguration>
-						<FileConfiguration
-							Name="Release|Win32"
-							>
-							<Tool
-								Name="VCCLCompilerTool"
-								ObjectFile="$(IntDir)\graphics\opengl\"
-							/>
-						</FileConfiguration>
 					</File>
 					<File
-						RelativePath="..\..\src\modules\graphics\opengl\TrueTypeFont.h"
+						RelativePath="..\..\src\modules\graphics\opengl\SpriteBatch.h"
 						>
 					</File>
 					<File
-						RelativePath="..\..\src\modules\graphics\opengl\wrap_Font.cpp"
+						RelativePath="..\..\src\modules\graphics\opengl\TrueTypeFont.cpp"
 						>
 						<FileConfiguration
 							Name="Debug|Win32"
@@ -1002,11 +962,11 @@
 						</FileConfiguration>
 					</File>
 					<File
-						RelativePath="..\..\src\modules\graphics\opengl\wrap_Font.h"
+						RelativePath="..\..\src\modules\graphics\opengl\TrueTypeFont.h"
 						>
 					</File>
 					<File
-						RelativePath="..\..\src\modules\graphics\opengl\wrap_Frame.cpp"
+						RelativePath="..\..\src\modules\graphics\opengl\wrap_Font.cpp"
 						>
 						<FileConfiguration
 							Name="Debug|Win32"
@@ -1026,7 +986,7 @@
 						</FileConfiguration>
 					</File>
 					<File
-						RelativePath="..\..\src\modules\graphics\opengl\wrap_Frame.h"
+						RelativePath="..\..\src\modules\graphics\opengl\wrap_Font.h"
 						>
 					</File>
 					<File
@@ -1085,6 +1045,14 @@
 						RelativePath="..\..\src\modules\graphics\opengl\wrap_Image.h"
 						>
 					</File>
+					<File
+						RelativePath="..\..\src\modules\graphics\opengl\wrap_Quad.cpp"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\modules\graphics\opengl\wrap_Quad.h"
+						>
+					</File>
 					<File
 						RelativePath="..\..\src\modules\graphics\opengl\wrap_SpriteBatch.cpp"
 						>

+ 1 - 1
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<size;i++)
 		{

+ 1 - 1
src/common/Matrix.h

@@ -141,7 +141,7 @@ namespace love
 		* @param src The source vertices.
 		* @param size The number of vertices.
 		**/
-		void transform(vertex * dst, const vertex * src, int size);
+		void transform(vertex * dst, const vertex * src, int size) const;
 
 	}; // Matrix
 

+ 2 - 2
src/common/types.h

@@ -43,7 +43,7 @@ namespace love
 		// Graphics
 		GRAPHICS_DRAWABLE_ID,
 		GRAPHICS_IMAGE_ID,
-		GRAPHICS_FRAME_ID,
+		GRAPHICS_QUAD_ID,
 		GRAPHICS_GLYPH_ID,
 		GRAPHICS_ANIMATION_ID,
 		GRAPHICS_COLOR_ID,
@@ -99,7 +99,7 @@ namespace love
 	// Graphics.
 	const bits GRAPHICS_DRAWABLE_T = (bits(1) << GRAPHICS_DRAWABLE_ID) | OBJECT_T;
 	const bits GRAPHICS_IMAGE_T = (bits(1) << GRAPHICS_IMAGE_ID) | GRAPHICS_DRAWABLE_T;
-	const bits GRAPHICS_FRAME_T = (bits(1) << GRAPHICS_FRAME_ID) | OBJECT_T;
+	const bits GRAPHICS_QUAD_T = (bits(1) << GRAPHICS_QUAD_ID) | OBJECT_T;
 	const bits GRAPHICS_GLYPH_T = (bits(1) << GRAPHICS_GLYPH_ID) | GRAPHICS_DRAWABLE_T;
 	const bits GRAPHICS_ANIMATION_T = (bits(1) << GRAPHICS_ANIMATION_ID) | GRAPHICS_DRAWABLE_T;
 	const bits GRAPHICS_COLOR_T = (bits(1) << GRAPHICS_COLOR_ID) | OBJECT_T;

+ 0 - 7
src/modules/filesystem/physfs/Filesystem.cpp

@@ -74,8 +74,6 @@ namespace physfs
 		save_path_full = std::string(getAppdataDirectory()) + std::string(LOVE_PATH_SEPARATOR);
 		save_path_full += save_path_relative;
 
-		std::cout << save_path_full << std::endl;
-
 		// We now have something like:
 		// save_identity: game
 		// save_path_relative: ./LOVE/game
@@ -282,11 +280,6 @@ namespace physfs
 		if(!lua_isstring(L, 2))
 			return luaL_error(L, "Second argument must be a string.");
 
-		// The third paramter must be a number to indicate the size of
-		// the data.
-		if(!lua_isnumber(L, 3))
-			return luaL_error(L, "Third argument must be a number.");
-
 		if(lua_isstring(L, 1))
 		{
 			// Create the file.

+ 2 - 1
src/modules/graphics/opengl/Font.h

@@ -22,8 +22,9 @@
 #define LOVE_GRAPHICS_OPENGL_FONT_H
 
 // LOVE
-#include <filesystem/File.h>
+#include <common/Object.h>
 #include <graphics/Volatile.h>
+#include <filesystem/File.h>
 
 namespace love
 {

+ 7 - 2
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)

+ 2 - 2
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.

+ 2 - 12
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
-	{
-		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
+	void Image::drawq(Quad * quad, float x, float y, float angle, float sx, float sy, float ox, float oy) 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);

+ 5 - 17
src/modules/graphics/opengl/Image.h

@@ -22,13 +22,12 @@
 #define LOVE_GRAPHICS_OPENGL_IMAGE_H
 
 // LOVE
+#include <common/Matrix.h>
+#include <common/math.h>
 #include <common/config.h>
 #include <image/ImageData.h>
-#include <common/math.h>
 #include <graphics/Image.h>
-#include "Frame.h"
-#include <common/Matrix.h>
-#include <common/math.h>
+#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.

+ 39 - 14
src/modules/graphics/opengl/Frame.cpp → 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 <common/Matrix.h>
 
 // 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;
+		refresh(v, sw, sh);
+	}
+
+	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)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;
+		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);
 	}
 
-	Frame::~Frame()
+	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;
 	}

+ 39 - 26
src/modules/graphics/opengl/Frame.h → 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 <common/Object.h>
@@ -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

+ 48 - 12
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

+ 6 - 2
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

+ 0 - 54
src/modules/graphics/opengl/wrap_Frame.cpp

@@ -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<Frame>(L, idx, "Frame", GRAPHICS_FRAME_T);
-	}
-	
-	int w_Frame_flip(lua_State *L)
-	{
-		Frame *frame = luax_checktype<Frame>(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

+ 17 - 51
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<Image>(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<Image>(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 },

+ 2 - 2
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);

+ 79 - 0
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<Quad>(L, idx, "Quad", GRAPHICS_QUAD_T);
+	}
+	
+	int w_Quad_flip(lua_State *L)
+	{
+		Quad * quad = luax_checktype<Quad>(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<Quad>(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<Quad>(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

+ 8 - 6
src/modules/graphics/opengl/wrap_Frame.h → 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 <common/runtime.h>
-#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

+ 16 - 0
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<Quad>(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 },

+ 1 - 0
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);

+ 3 - 2
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

+ 1 - 1
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