Commit Graph

60 Commits

Author SHA1 Message Date
Alex Szpakowski f0fa63ba47 Backported commits 145524a and 7785b4b from minor into default (Added SpriteBatch:flush, deprecated SpriteBatch:bind/unbind, SpriteBatch:flush is called implicitly when the spritebatch is drawn.) 2014-06-17 21:52:56 -03:00
Alex Szpakowski e4dc533bb2 Minor code cleanup 2014-05-01 14:12:21 -03:00
Alex Szpakowski 40242689b1 Fixed rendering to multiple canvases, removed some redundant OpenGL calls when switching between canvases 2014-01-30 21:09:13 -04:00
Alex Szpakowski 7556fde5e6 Added antialiasing (MSAA) support to Canvases via a new optional parameter. Added Canvas:getFSAA. 2014-01-27 01:31:41 -04:00
Alex Szpakowski 3120a0e650 Goodbye 2013, hello 2014! 2014-01-03 17:28:58 -04:00
Alex Szpakowski aa69a695d3 Canvases can now be used in SpriteBatches, ParticleSystems, and Meshes (resolves issue #782).
Canvases and Images are now subclasses of the new Texture class.
Added setTexture and getTexture methods for Meshes, ParticleSystems, and SpriteBatches (the old set/getImage methods are deprecated but not removed.)
Canvas texture coordinates are no longer flipped.
2014-01-03 17:07:12 -04:00
Alex Szpakowski fb34f5bc9e Auto-padded NPOT images' texture coordinates are now scaled at draw time via the texture matrix (fixes auto-padded images with Meshes.) Also fixed love.graphics.newQuad.
--HG--
branch : Mesh
2013-10-06 23:25:29 -03:00
Alex Szpakowski 1e696c4505 Added Mesh objects and love.graphics.newMesh. Mesh objects are similar to Geometry but they're drawables (the relationship between meshes and images is the opposite of geometry and images.)
Removed Geometry objects and re-added Quads.

example:
local vertices = {{0, 0, 0, 0}, {100, 0, 1, 0}, {100, 100, 1, 1}, {0, 100, 0, 1}}
mesh = love.graphics.newMesh(vertices, image, "fan")
..
love.graphics.draw(mesh, 0, 0)

--HG--
branch : Mesh
2013-09-28 18:26:47 -03:00
Alex Szpakowski 5de43a7207 The Vertex struct is now recognized as POD by C++, also fixed the name to be consistent with other love structs 2013-09-24 11:09:18 -03:00
Alex Szpakowski 2128ba321e Fixed Geometry texture coordinates when using Geometry to draw auto-padded NPOT images (resolves issue #696) 2013-08-01 17:14:20 -03:00
Alex Szpakowski 454ba9d968 love.graphics.newGeometry now takes an optional draw mode argument ("fan", "strip", or "triangles".) "fan" is the default.
This allows for more diverse and complex Geometries, provided the lover understands how to use each mode. See http://escience.anu.edu.au/lecture/cg/surfaceModeling/image/surfaceModeling015.png

Changed love.graphics.newGeometry to optionally accept vertices as individual arguments instead of just a table of vertices (resolves issue #651).
Changed Geometry:setVertex to optionally accept a table containing x,y,u,v,r,g,b,a instead of just individual arguments.

Added Geometry:set/getDrawMode.

Removed the convex-check in love.graphics.newGeometry (all geometry modes have at least some form of concavity support, lovers can do their own check if needed with love.math.isConvex.)

Added an optional "vertex map" table argument to love.graphics.newGeometry (AKA a vertex index array / element array in graphics programming lingo.)
This allows lovers to change the order in which the vertices are used when drawing, or re-use a single vertex multiple times for different parts of the Geometry.
This is especially useful in the "triangles" Geometry draw mode. The vertex map lets you draw very complex (and concave) shapes / meshes without duplicating vertex data.

Added Geometry:set/getVertexMap.
2013-07-10 15:34:10 -03:00
Alex Szpakowski 03bd4c1410 Fixed SpriteBatch:setBufferSize 2013-06-29 00:18:22 -03:00
Alex Szpakowski 3fb78d5458 Added SpriteBatch:setBufferSize (issue #655) 2013-06-29 00:04:56 -03:00
Alex Szpakowski be33d17f89 Added SpriteBatch:getColor 2013-06-14 05:29:05 -03:00
Alex Szpakowski 35984790e5 Added a way for love's reference-counted objects to be released more safely in some situations (e.g. setters) 2013-06-09 02:42:33 -03:00
Alex Szpakowski da9675e424 SpriteBatch:addg can now take triangle Geometries 2013-06-01 14:56:00 -03:00
Alex Szpakowski 0b71fa1483 Added SpriteBatch:getCount and SpriteBatch:getBufferSize, and removed SpriteBatch:isEmpty/isFull. 2013-05-22 18:44:40 -03:00
Alex Szpakowski aa59761177 Fixed smooth lines with love.graphics.origin() after love.graphics.scale 2013-05-12 16:13:32 -03:00
vrld e9d0204cdc Disallow concave shapes as geometry. 2013-05-12 13:01:05 +02:00
Alex Szpakowski 3b05ec0635 Geometries now automatically use per-vertex colors when drawing if any vertex has a custom color set, otherwise the constant color is used.
Still not a perfect solution, but it works better than before
2013-04-23 23:25:45 -07:00
vrld 1e54049fbb Fix SpriteBatch.
Broken in my last commit (6e0f6a4).
2013-04-21 20:01:03 +02:00
vrld 71317c4359 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()
2013-04-21 18:53:13 +02:00
Alex Szpakowski 6fd3038405 Improved clarity/readability of internal OpenGL state shadowing functions 2013-04-17 01:06:33 -03:00
Alex Szpakowski 6a27e1aa2f Ensure the current color is set properly after drawing particlesystems and spritebatches 2013-04-12 15:40:53 -03:00
Alex Szpakowski d3cdb7d609 Added SpriteBatch:isEmpty() and SpriteBatch:isFull() 2013-03-01 17:32:38 -04:00
Alex Szpakowski 1d34dda48b Removed SpriteBatch:remove(id) (reverted commit 2ca82dd)
The implementation had issues with sprite draw order when SpriteBatch:add used indices in the vertex buffer previously freed with SpriteBatch:remove
2013-02-24 09:47:03 -04:00
Alex Szpakowski 77ab120424 Fixed SpriteBatch file includes 2013-02-11 20:27:29 -04:00
Alex Szpakowski ceb0ee6c7e Added SpriteBatch:remove(id) 2013-02-11 18:27:57 -04:00
Alex Szpakowski 96161c66f6 Updated copyright text for the new year 2013-02-05 05:32:49 -04:00
Alexander Szpakowski 3e3f5c6bdd Minor tweaks, balanced disable/enable clientstate calls in SpriteBatches 2013-01-08 05:33:22 -04:00
Alexander Szpakowski 6560019829 opengl graphics module files now always include OpenGL.h rather than GLee.h 2013-01-01 17:54:14 -04:00
vrld b2f1408b12 Fix issue #495: Large spritebatches doesn't render properly 2012-11-23 10:23:44 +01:00
Bart van Strien 7793e7f02f CRLF to LF 2012-07-04 14:40:24 +02:00
rude 81c38e22d0 Applied the new style guidelines.
Well, sort of. Lot's more to be done, but this is a start.
2012-06-28 23:52:33 +02:00
vrld 3f365857ee Replace glMapBufferARB() with temp memory + glBufferSubDataARB().
Instead of letting OpenGL manage the memory mapping, allocate a temporary
block of memory upon VBO:map(). Upon VBO::unmap() the block is copied to
graphics memory using glBufferSubDataARB() and then released.

Hopefully this will fix some weird error with Windows XP + old drivers, where
VBOs can be created, but the mapped memory cannot be allocated resulting in
the sprite batch drawing nothing at all.

According to the interwebs this could actually faster than using OpenGL mapped
memory, because there is no unnecessary syncing involved.
2012-03-07 23:24:29 +01:00
vrld 4947498488 Add VertexBuffer::Mapper for RAII vbo mapping 2012-03-07 22:59:23 +01:00
vrld 17dc8760b9 Replace VertexArray with VertexBuffer in SpriteBatch (less confusing). 2012-03-07 22:35:21 +01:00
Bill Meltsner be55579a22 Happy New Year, have an enormous diff 2012-01-09 02:41:11 -06:00
Bart van Strien 1509403ca7 Add SpriteBatch:getImage (issue #321) 2012-01-08 13:46:01 +01:00
Bart van Strien 0aae9684b3 Automated formatting fix 2011-11-16 11:32:41 +01:00
Bart van Strien dc66ea20c1 Add SpriteBatch:set(q) and make add(q) return the index 2011-10-20 20:19:01 +02:00
Bart van Strien b14ca78109 Add string mapping for spritebatch usage parameter (issue #264) 2011-08-24 12:11:08 +02:00
rude 480f936815 Added 'VertexBuffer' abstraction. SpriteBatches are now always supported.
Also improved memory usage in SpriteBatch. (No need to retain full copy of
sprites in memory. Can read that data back later to save data from OpenGL
context destruction).
2011-08-12 11:35:14 +02:00
Bart van Strien 3c5c4ee604 Add SpriteBatch support to love.graphics.isSupported 2011-07-24 15:37:02 +02:00
rude 387a8ab2dc Issue #262: Add per-sprite colors. 2011-07-23 17:12:29 +02:00
vrld 6ea187b2f1 Use *ARB versions for VBOs in SpriteBatch. Throw error if SpriteBatch not
supported. Prettier overloading of SpriteBatch:add[q]().
2011-07-05 16:06:14 +02:00
vrld d420d68048 Add shear transformation and transform object (issue #152).
Add origin parameters to love.graphics.print.

New shear parameters kx,ky for:
- love.graphics.draw,
- love.graphics.drawq,
- love.graphics.print,
- SpriteBatch:add,
- SpriteBatch:addq.

Transform objects apply to:
- love.graphics.draw,
- love.graphics.drawq,
- love.graphics.print.
2011-07-05 14:33:34 +02:00
Bart van Strien bd158faaaa Revise spritebatch locking (binding now) (issue #231) 2011-06-10 14:40:37 +02:00
José Romero dc2d87a90f Apply patch for issue #219 2011-04-27 16:35:14 +02:00
Bill Meltsner fde708160e bringing in the new year by changing every 2010 to 2011 2011-01-15 14:40:27 -06:00