Package com.esotericsoftware.spine

Source Code of com.esotericsoftware.spine.SkeletonRenderer

package com.esotericsoftware.spine;

import com.esotericsoftware.spine.attachments.Attachment;
import com.esotericsoftware.spine.attachments.RegionAttachment;

import com.badlogic.gdx.graphics.GL11;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.utils.Array;

public class SkeletonRenderer {
  public void draw (SpriteBatch batch, Skeleton skeleton) {
    Array<Slot> drawOrder = skeleton.drawOrder;
    boolean additive = false;
    for (int i = 0, n = drawOrder.size; i < n; i++) {
      Slot slot = drawOrder.get(i);
      Attachment attachment = slot.attachment;
      if (attachment instanceof RegionAttachment) {
        RegionAttachment regionAttachment = (RegionAttachment)attachment;
        regionAttachment.updateVertices(slot);
        float[] vertices = regionAttachment.getVertices();
        if (slot.data.getAdditiveBlending() != additive) {
          additive = !additive;
          if (additive)
            batch.setBlendFunction(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
          else
            batch.setBlendFunction(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        }
        batch.draw(regionAttachment.getRegion().getTexture(), vertices, 0, vertices.length);
      }
    }
    if (additive) batch.setBlendFunction(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
  }
}
TOP

Related Classes of com.esotericsoftware.spine.SkeletonRenderer

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.