mirror of
https://github.com/love2d/love.git
synced 2026-08-18 19:54:22 +02:00
Add Geometries (replaces Quads).
A Geometry is a collection of vertices describing a non self-intersecting
(simple) polygon. In addition to screen coordinates, the vertices have
attributes for texture coordinates (s,t) and color (r,g,b,a).
It can be used as a quad, to display distorted images, or anything in between.
Added:
^^^^^^
-- geometry from table, where table has the format:
-- info = {
-- {x,y, s,t, [r = 255, g = 255, b = 255, a = 255]}
-- {x,y, s,t, [r = 255, g = 255, b = 255, a = 255]}
-- ...
-- }
geom = love.graphics.newGeometry(info)
-- convenience wrapper for quads (same as before)
geom = love.graphics.newQuad(x,y, w,h, sw,sh)
-- retrieve vertex i (1-indexed)
x,y,s,t,r,g,b,a = geom:getVertex(i)
-- set vertex i (1-indexed)
geom:setVertex(i, x,y, s,t, [r,g,b,a])
-- flip geometry
geom:flip(x, y)
Renamed:
^^^^^^^^
love.graphics.drawq() -> love.graphics.drawg()
Removed:
^^^^^^^^
quad:setViewport()
quad:getViewport()
This commit is contained in:
@@ -32,6 +32,7 @@
|
||||
#include "graphics/Drawable.h"
|
||||
#include "graphics/Volatile.h"
|
||||
#include "graphics/Color.h"
|
||||
#include "graphics/Geometry.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
@@ -42,7 +43,6 @@ namespace opengl
|
||||
|
||||
// Forward declarations.
|
||||
class Image;
|
||||
class Quad;
|
||||
class VertexBuffer;
|
||||
class VertexIndex;
|
||||
|
||||
@@ -62,7 +62,7 @@ public:
|
||||
virtual ~SpriteBatch();
|
||||
|
||||
int add(float x, float y, float a, float sx, float sy, float ox, float oy, float kx, float ky, int index = -1);
|
||||
int addq(Quad *quad, float x, float y, float a, float sx, float sy, float ox, float oy, float kx, float ky, int index = -1);
|
||||
int addg(Geometry *geom, float x, float y, float a, float sx, float sy, float ox, float oy, float kx, float ky, int index = -1);
|
||||
void clear();
|
||||
|
||||
void *lock();
|
||||
@@ -81,7 +81,7 @@ public:
|
||||
void setColor(const Color &color);
|
||||
|
||||
/**
|
||||
* Disable per-quad colors for this SpriteBatch. The next call to
|
||||
* Disable per-geometry colors for this SpriteBatch. The next call to
|
||||
* draw will use the global color for all sprites.
|
||||
*/
|
||||
void setColor();
|
||||
@@ -104,7 +104,7 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
void addv(const vertex *v, int index);
|
||||
void addv(const vertex *v, int index, int sprite_size = 4);
|
||||
|
||||
/**
|
||||
* Set the color for vertices.
|
||||
@@ -129,7 +129,7 @@ private:
|
||||
vertex sprite[4];
|
||||
|
||||
// Current color. This color, if present, will be applied to the next
|
||||
// added quad.
|
||||
// added geometry.
|
||||
Color *color;
|
||||
|
||||
VertexBuffer *array_buf;
|
||||
|
||||
Reference in New Issue
Block a user