Use *ARB versions for VBOs in SpriteBatch. Throw error if SpriteBatch not

supported. Prettier overloading of SpriteBatch:add[q]().
This commit is contained in:
vrld
2011-07-05 16:06:14 +02:00
parent dd143c76ac
commit 6ea187b2f1
5 changed files with 90 additions and 62 deletions
+17 -9
View File
@@ -1306,14 +1306,22 @@ AAIAAAxQCuxfDzz1AB8IAAAAAAC6ufC4AAAAALrCZ5H+if4dCkwHbQAAAAgAAQAAAAAAAA==
return lgprint(text, x,y, unpack_transform(...))
end
local temp_img = love.graphics.newImage(love.image.newImageData(0,0))
local temp_spritebatch = love.graphics.newSpriteBatch(temp_img, 0)
local sb_meta = getmetatable(temp_spritebatch)
local add, addq = sb_meta.add, sb_meta.addq
function sb_meta:add(x,y, ...)
return add(self, x,y, unpack_transform(...))
end
function sb_meta:addq(quad, x,y, ...)
return addq(self, quad, x,y, unpack_transform(...))
local newSpritebatch = love.graphics.newSpriteBatch
function love.graphics.newSpriteBatch(image, size)
local sb = newSpritebatch(image, size)
local meta = getmetatable(sb)
local add = meta.add
function meta:add(x,y, ...)
return add(self, x,y, unpack_transform(...))
end
local addq = meta.addq
function meta:addq(quad, x,y, ...)
return addq(self, quad, x,y, unpack_transform(...))
end
love.graphics.newSpriteBatch = newSpritebatch
return sb
end
end
+31 -26
View File
@@ -5086,32 +5086,37 @@ const unsigned char graphics_lua[] =
0x65, 0x78, 0x74, 0x2c, 0x20, 0x78, 0x2c, 0x79, 0x2c, 0x20, 0x75, 0x6e, 0x70, 0x61, 0x63, 0x6b, 0x5f, 0x74,
0x72, 0x61, 0x6e, 0x73, 0x66, 0x6f, 0x72, 0x6d, 0x28, 0x2e, 0x2e, 0x2e, 0x29, 0x29, 0x0a,
0x09, 0x65, 0x6e, 0x64, 0x0a,0x0a,
0x09, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x74, 0x65, 0x6d, 0x70, 0x5f, 0x69, 0x6d, 0x67, 0x20, 0x3d, 0x20,
0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x67, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63, 0x73, 0x2e, 0x6e, 0x65, 0x77, 0x49,
0x6d, 0x61, 0x67, 0x65, 0x28, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2e, 0x6e, 0x65,
0x77, 0x49, 0x6d, 0x61, 0x67, 0x65, 0x44, 0x61, 0x74, 0x61, 0x28, 0x30, 0x2c, 0x30, 0x29, 0x29, 0x0a,
0x09, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x74, 0x65, 0x6d, 0x70, 0x5f, 0x73, 0x70, 0x72, 0x69, 0x74, 0x65,
0x62, 0x61, 0x74, 0x63, 0x68, 0x20, 0x3d, 0x20, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x67, 0x72, 0x61, 0x70, 0x68,
0x69, 0x63, 0x73, 0x2e, 0x6e, 0x65, 0x77, 0x53, 0x70, 0x72, 0x69, 0x74, 0x65, 0x42, 0x61, 0x74, 0x63, 0x68,
0x28, 0x74, 0x65, 0x6d, 0x70, 0x5f, 0x69, 0x6d, 0x67, 0x2c, 0x20, 0x30, 0x29, 0x0a,
0x09, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x73, 0x62, 0x5f, 0x6d, 0x65, 0x74, 0x61, 0x20, 0x3d, 0x20, 0x67,
0x65, 0x74, 0x6d, 0x65, 0x74, 0x61, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x28, 0x74, 0x65, 0x6d, 0x70, 0x5f, 0x73,
0x70, 0x72, 0x69, 0x74, 0x65, 0x62, 0x61, 0x74, 0x63, 0x68, 0x29, 0x0a,
0x09, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x61, 0x64, 0x64, 0x2c, 0x20, 0x61, 0x64, 0x64, 0x71, 0x20, 0x3d,
0x20, 0x73, 0x62, 0x5f, 0x6d, 0x65, 0x74, 0x61, 0x2e, 0x61, 0x64, 0x64, 0x2c, 0x20, 0x73, 0x62, 0x5f, 0x6d,
0x65, 0x74, 0x61, 0x2e, 0x61, 0x64, 0x64, 0x71, 0x0a,
0x09, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x73, 0x62, 0x5f, 0x6d, 0x65, 0x74, 0x61, 0x3a,
0x61, 0x64, 0x64, 0x28, 0x78, 0x2c, 0x79, 0x2c, 0x20, 0x2e, 0x2e, 0x2e, 0x29, 0x0a,
0x09, 0x09, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x61, 0x64, 0x64, 0x28, 0x73, 0x65, 0x6c, 0x66, 0x2c,
0x20, 0x78, 0x2c, 0x79, 0x2c, 0x20, 0x75, 0x6e, 0x70, 0x61, 0x63, 0x6b, 0x5f, 0x74, 0x72, 0x61, 0x6e, 0x73,
0x66, 0x6f, 0x72, 0x6d, 0x28, 0x2e, 0x2e, 0x2e, 0x29, 0x29, 0x0a,
0x09, 0x65, 0x6e, 0x64, 0x0a,
0x09, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x73, 0x62, 0x5f, 0x6d, 0x65, 0x74, 0x61, 0x3a,
0x61, 0x64, 0x64, 0x71, 0x28, 0x71, 0x75, 0x61, 0x64, 0x2c, 0x20, 0x78, 0x2c, 0x79, 0x2c, 0x20, 0x2e, 0x2e,
0x2e, 0x29, 0x0a,
0x09, 0x09, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x61, 0x64, 0x64, 0x71, 0x28, 0x73, 0x65, 0x6c, 0x66,
0x2c, 0x20, 0x71, 0x75, 0x61, 0x64, 0x2c, 0x20, 0x78, 0x2c, 0x79, 0x2c, 0x20, 0x75, 0x6e, 0x70, 0x61, 0x63,
0x6b, 0x5f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x66, 0x6f, 0x72, 0x6d, 0x28, 0x2e, 0x2e, 0x2e, 0x29, 0x29, 0x0a,
0x09, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x6e, 0x65, 0x77, 0x53, 0x70, 0x72, 0x69, 0x74, 0x65, 0x62, 0x61,
0x74, 0x63, 0x68, 0x20, 0x3d, 0x20, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x67, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63,
0x73, 0x2e, 0x6e, 0x65, 0x77, 0x53, 0x70, 0x72, 0x69, 0x74, 0x65, 0x42, 0x61, 0x74, 0x63, 0x68, 0x0a,
0x09, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x67, 0x72, 0x61,
0x70, 0x68, 0x69, 0x63, 0x73, 0x2e, 0x6e, 0x65, 0x77, 0x53, 0x70, 0x72, 0x69, 0x74, 0x65, 0x42, 0x61, 0x74,
0x63, 0x68, 0x28, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2c, 0x20, 0x73, 0x69, 0x7a, 0x65, 0x29, 0x0a,
0x09, 0x09, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x73, 0x62, 0x20, 0x3d, 0x20, 0x6e, 0x65, 0x77, 0x53, 0x70,
0x72, 0x69, 0x74, 0x65, 0x62, 0x61, 0x74, 0x63, 0x68, 0x28, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2c, 0x20, 0x73,
0x69, 0x7a, 0x65, 0x29, 0x0a,
0x09, 0x09, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x6d, 0x65, 0x74, 0x61, 0x20, 0x3d, 0x20, 0x67, 0x65, 0x74,
0x6d, 0x65, 0x74, 0x61, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x28, 0x73, 0x62, 0x29, 0x0a,0x0a,
0x09, 0x09, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x61, 0x64, 0x64, 0x20, 0x3d, 0x20, 0x6d, 0x65, 0x74, 0x61,
0x2e, 0x61, 0x64, 0x64, 0x0a,
0x09, 0x09, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x6d, 0x65, 0x74, 0x61, 0x3a, 0x61, 0x64,
0x64, 0x28, 0x78, 0x2c, 0x79, 0x2c, 0x20, 0x2e, 0x2e, 0x2e, 0x29, 0x0a,
0x09, 0x09, 0x09, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x61, 0x64, 0x64, 0x28, 0x73, 0x65, 0x6c, 0x66,
0x2c, 0x20, 0x78, 0x2c, 0x79, 0x2c, 0x20, 0x75, 0x6e, 0x70, 0x61, 0x63, 0x6b, 0x5f, 0x74, 0x72, 0x61, 0x6e,
0x73, 0x66, 0x6f, 0x72, 0x6d, 0x28, 0x2e, 0x2e, 0x2e, 0x29, 0x29, 0x0a,
0x09, 0x09, 0x65, 0x6e, 0x64, 0x0a,0x0a,
0x09, 0x09, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x61, 0x64, 0x64, 0x71, 0x20, 0x3d, 0x20, 0x6d, 0x65, 0x74,
0x61, 0x2e, 0x61, 0x64, 0x64, 0x71, 0x0a,
0x09, 0x09, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x6d, 0x65, 0x74, 0x61, 0x3a, 0x61, 0x64,
0x64, 0x71, 0x28, 0x71, 0x75, 0x61, 0x64, 0x2c, 0x20, 0x78, 0x2c, 0x79, 0x2c, 0x20, 0x2e, 0x2e, 0x2e, 0x29, 0x0a,
0x09, 0x09, 0x09, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x61, 0x64, 0x64, 0x71, 0x28, 0x73, 0x65, 0x6c,
0x66, 0x2c, 0x20, 0x71, 0x75, 0x61, 0x64, 0x2c, 0x20, 0x78, 0x2c, 0x79, 0x2c, 0x20, 0x75, 0x6e, 0x70, 0x61,
0x63, 0x6b, 0x5f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x66, 0x6f, 0x72, 0x6d, 0x28, 0x2e, 0x2e, 0x2e, 0x29, 0x29, 0x0a,
0x09, 0x09, 0x65, 0x6e, 0x64, 0x0a,0x0a,
0x09, 0x09, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x67, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63, 0x73, 0x2e, 0x6e, 0x65,
0x77, 0x53, 0x70, 0x72, 0x69, 0x74, 0x65, 0x42, 0x61, 0x74, 0x63, 0x68, 0x20, 0x3d, 0x20, 0x6e, 0x65, 0x77,
0x53, 0x70, 0x72, 0x69, 0x74, 0x65, 0x62, 0x61, 0x74, 0x63, 0x68, 0x0a,
0x09, 0x09, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x73, 0x62, 0x0a,
0x09, 0x65, 0x6e, 0x64, 0x0a,
0x65, 0x6e, 0x64, 0x0a,
}; // [graphics.lua]