Game Development Reference
In-Depth Information
The extra logic transforms it to this code.
int _currentTextureId = -1;
public void DrawSprite(Sprite sprite)
{
if (sprite.Texture.Id == _currentTextureId)
{
_batch.AddSprite(sprite);
}
else
{
_batch.Draw(); // Draw all with current texture
// Update texture info
_currentTextureId = sprite.Texture.Id;
Gl.glBindTexture(Gl.GL_TEXTURE_2D, _currentTextureId);
_batch.AddSprite(sprite);
}
}
Rerun the project and you should see something similar to Figure 9.10.
Figure 9.10
Correct texturing.
 
Search WWH ::




Custom Search