Difference between revisions of "SpriteBatch:bind"

(Added SpriteBatch locking)
 
m
 
(11 intermediate revisions by 9 users not shown)
Line 1: Line 1:
Binds the SpriteBatch to the memory.
+
{{newin|[[0.8.0]]|080|type=function|text=It has been renamed from [[SpriteBatch:lock]]}}
 +
{{deprecatedin|[[0.9.2]]|092|type=function|text=It happens automatically since this version}}
 +
{{oldin|[[0.10.0]]|100|type=function|text=Use [[SpriteBatch:flush]] if absolutely necessary}}
  
Binding a SpriteBatch before updating its content can improve the performance as it doesn't push each update to the graphics card separately. Don't forget to [[Source:unbind|unbind]] the SpriteBatch or the updates won't show up.
+
Binds the [[SpriteBatch]] to memory for more efficient updating.
 +
 
 +
Binding a SpriteBatch before updating its content can improve the performance as it doesn't push each update to the graphics card separately. Don't forget to [[SpriteBatch:unbind|unbind]] the SpriteBatch or the updates won't show up.
 
== Function ==
 
== Function ==
 
=== Synopsis ===
 
=== Synopsis ===
Line 14: Line 18:
 
=== Updating a SpriteBatch with binding ===
 
=== Updating a SpriteBatch with binding ===
 
<source lang="lua">
 
<source lang="lua">
function update_spritebatch(sb)
+
function update_spritebatch(spritebatch)
sb:bind()
+
spritebatch:bind()
  
for i = 1, 10 do
+
for i = 1, 100 do
add_tile(sb)
+
add_tile(spritebatch)
 
end
 
end
  
sb:unbind()
+
spritebatch:unbind()
 
end
 
end
 
</source>
 
</source>
 
== See Also ==
 
== See Also ==
 
* [[parent::SpriteBatch]]
 
* [[parent::SpriteBatch]]
* [[SpriteBatch::unbind]]
+
* [[SpriteBatch:unbind]]
 
[[Category:Functions]]
 
[[Category:Functions]]
{{#set:Description=Binds the SpriteBatch to the memory.}}
+
{{#set:Description=Binds the SpriteBatch to memory for more efficient updating.}}
{{#set:Since=080}}
 
 
== Other Languages ==
 
== Other Languages ==
 
{{i18n|SpriteBatch:bind}}
 
{{i18n|SpriteBatch:bind}}

Latest revision as of 15:48, 4 December 2023

Available since LÖVE 0.8.0
It has been renamed from SpriteBatch:lock.
Deprecated in LÖVE 0.9.2
It happens automatically since this version.
Removed in LÖVE 0.10.0
Use SpriteBatch:flush if absolutely necessary.


Binds the SpriteBatch to memory for more efficient updating.

Binding a SpriteBatch before updating its content can improve the performance as it doesn't push each update to the graphics card separately. Don't forget to unbind the SpriteBatch or the updates won't show up.

Function

Synopsis

SpriteBatch:bind( )

Arguments

None.

Returns

Nothing.

Examples

Updating a SpriteBatch with binding

function update_spritebatch(spritebatch)
	spritebatch:bind()

	for i = 1, 100 do
		add_tile(spritebatch)
	end

	spritebatch:unbind()
end

See Also

Other Languages