Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /** Flushes the batch. */
- public void flush () {
- flushes++;
- buffer.flip();
- MESH.setVertices(buffer);
- lastTexture.bind();
- MESH.draw();
- buffer.clear();
- RenderUtil.unbindTextures();
- }
- /** Begins the SpriteBatch. */
- public void begin () {
- if (rendering) {
- new IllegalStateException("You have to SpriteBatch.end() before calling begin again!").printStackTrace();
- }
- flushes = 0;
- rendering = true;
- shader.bind();
- shader.setUniformMat4f("projection", camera.getCombined());
- shader.setUniformVec4("color", color);
- }
- /** Ends the SpriteBatch, also flushes it. */
- public void end () {
- if (!rendering) {
- new IllegalStateException("You've to SpriteBatch.begin before ending the spritebatch").printStackTrace();
- }
- rendering = false;
- flush();
- RenderUtil.unbindShaders();
- RenderUtil.unbindTextures();
- }
- /** Switches the textures and flushes the old one.
- * @param t */
- private void switchTextures (Texture t) {
- if (lastTexture != null) {
- flush();
- }
- lastTexture = t;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement