package com.graphicsengine.spritemesh;

import java.io.IOException;

import com.nucleus.Backend.DrawMode;
import com.nucleus.BackendException;
import com.nucleus.GraphicsPipeline;
import com.nucleus.geometry.Mesh;
import com.nucleus.opengl.geometry.GLMesh;
import com.nucleus.opengl.shader.GLShaderProgram;
import com.nucleus.opengl.shader.GLShaderProgram.Categorizer;
import com.nucleus.opengl.shader.GLShaderProgram.ProgramType;
import com.nucleus.opengl.shader.GLShaderProgram.ShaderType;
import com.nucleus.opengl.shader.GenericShaderProgram;
import com.nucleus.renderer.NucleusRenderer;
import com.nucleus.renderer.Pass;
import com.nucleus.shader.Shader.Shading;

/**
 * SpriteMesh using a geometry shader
 * 
 *
 */
public class SpriteGeometryMesh extends SpriteMesh {

    static class GeometryCategorizer extends Categorizer {

        public GeometryCategorizer(Pass pass, Shading shading, String category) {
            super(pass, shading, category);
        }

        @Override
        public String getPath(ShaderType type) {
            switch (type) {
                case FRAGMENT:
                    return "";
                default:
                    return super.getPath(type);
            }
        }

    }

    protected final static String INVALID_TYPE = "Invalid type: ";

    /**
     * Builder for sprite meshes
     *
     */
    public static class Builder extends GLMesh.Builder<Mesh> {

        public Builder(NucleusRenderer renderer) {
            super(renderer);
        }

        @Override
        public Mesh createInstance() {
            return new SpriteGeometryMesh();
        }

        @Override
        public Mesh create() throws IOException, BackendException {
            setArrayMode(DrawMode.POINTS, objectCount, 0);
            return super.create();
        }

        @Override
        public GraphicsPipeline createPipeline() {
            Shading shading = Shading.flat;
            GeometryCategorizer function = new GeometryCategorizer(null, shading, "sprite");
            GLShaderProgram shader = new GenericShaderProgram(function, ProgramType.VERTEX_GEOMETRY_FRAGMENT);
            return renderer.getAssets().getGraphicsPipeline(renderer, shader);
        }

    }
}

@@ -304,70 +304,8 @@
 am;%0A
-import com.nucleus.opengl.shader.GLShaderProgram.Categorizer;%0A
 impo
@@ -557,16 +557,62 @@
 r.Pass;%0A
+import com.nucleus.shader.Shader.Categorizer;%0A
 import c

Update to changes in graphics-by-gl