Create DrawQable class, make Image and Canvas DrawQable, and make love.graphics.drawq take a DrawQable as its first argument

This commit is contained in:
Bill Meltsner
2011-10-04 12:33:34 -04:00
parent 4cb247b3ea
commit 14348f6146
13 changed files with 233 additions and 40 deletions
+1 -1
View File
@@ -276,7 +276,7 @@ namespace opengl
drawv(t, vertices);
}
void Canvas::drawq(Quad * quad, float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky) const
void Canvas::drawq(love::graphics::Quad * quad, float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky) const
{
static Matrix t;
const vertex * v = quad->getVertices();
+7 -10
View File
@@ -1,7 +1,7 @@
#ifndef LOVE_GRAPHICS_CANVAS_H
#define LOVE_GRAPHICS_CANVAS_H
#ifndef LOVE_GRAPHICS_OPENGL_CANVAS_H
#define LOVE_GRAPHICS_OPENGL_CANVAS_H
#include <graphics/Drawable.h>
#include <graphics/DrawQable.h>
#include <graphics/Volatile.h>
#include <graphics/Image.h>
#include <graphics/Color.h>
@@ -10,7 +10,6 @@
#include <common/math.h>
#include <common/Matrix.h>
#include "GLee.h"
#include "Quad.h"
namespace love
{
@@ -18,7 +17,7 @@ namespace graphics
{
namespace opengl
{
class Canvas : public Drawable, public Volatile
class Canvas : public DrawQable, public Volatile
{
public:
Canvas(int width, int height);
@@ -39,11 +38,9 @@ namespace opengl
virtual void draw(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky) const;
/**
* This function draws a section of the canvas using a Quad object.
*
* @param quad Represents the region of the Canvas to draw.
* @copydoc DrawQable::drawq()
**/
void drawq(Quad * quad, float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky) const;
void drawq(love::graphics::Quad * quad, float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky) const;
love::image::ImageData * getImageData(love::image::Image * image);
@@ -85,4 +82,4 @@ namespace opengl
} // graphics
} // love
#endif // LOVE_GRAPHICS_CANVAS_H
#endif // LOVE_GRAPHICS_OPENGL_CANVAS_H
+1 -1
View File
@@ -110,7 +110,7 @@ namespace opengl
drawv(t, vertices);
}
void Image::drawq(Quad * quad, float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky) const
void Image::drawq(love::graphics::Quad * quad, float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky) const
{
static Matrix t;
const vertex * v = quad->getVertices();
+2 -7
View File
@@ -27,11 +27,9 @@
#include <common/config.h>
#include <image/ImageData.h>
#include <graphics/Image.h>
#include "Quad.h"
// OpenGL
#include "GLee.h"
#include <SDL/SDL_opengl.h>
namespace love
{
@@ -114,12 +112,9 @@ namespace opengl
void draw(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky) const;
/**
* 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.
* @copydoc DrawQable::drawq()
**/
void drawq(Quad * quad, float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky) const;
void drawq(love::graphics::Quad * quad, float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky) const;
/**
* Sets the filter mode.
+6 -13
View File
@@ -22,9 +22,8 @@
#define LOVE_GRAPHICS_OPENGL_QUAD_H
// LOVE
#include <common/Object.h>
#include <common/math.h>
#include <graphics/Drawable.h>
#include <graphics/Quad.h>
namespace love
{
@@ -32,19 +31,13 @@ namespace graphics
{
namespace opengl
{
class Quad : public Object
class Quad : public love::graphics::Quad
{
public:
struct Viewport
{
float x, y, w, h;
};
private:
protected:
vertex vertices[4];
Viewport viewport;
float sw, sh;
@@ -19,7 +19,7 @@
**/
#include "wrap_Graphics.h"
#include "DrawQable.h"
#include <image/ImageData.h>
#include <font/Rasterizer.h>
@@ -800,7 +800,7 @@ namespace opengl
}
/**
* Draws an Quad of an Image at the specified coordinates,
* Draws an Quad of a DrawQable at the specified coordinates,
* with rotation and scaling along both axes.
*
* @param q The Quad to draw.
@@ -816,7 +816,7 @@ namespace opengl
**/
int w_drawq(lua_State * L)
{
Image * image = luax_checktype<Image>(L, 1, "Image", GRAPHICS_IMAGE_T);
DrawQable * dq = luax_checktype<DrawQable>(L, 1, "DrawQable", GRAPHICS_DRAWQABLE_T);
Quad * q = luax_checkframe(L, 2);
float x = (float)luaL_checknumber(L, 3);
float y = (float)luaL_checknumber(L, 4);
@@ -827,7 +827,7 @@ namespace opengl
float oy = (float)luaL_optnumber(L, 9, 0);
float kx = (float)luaL_optnumber(L, 10, 0);
float ky = (float)luaL_optnumber(L, 11, 0);
image->drawq(q, x, y, angle, sx, sy, ox, oy, kx, ky);
dq->drawq(q, x, y, angle, sx, sy, ox, oy, kx, ky);
return 0;
}