public RenderBuffer(Shape shape, bool masked, bool supportAnimations, bool layered, bool noTexture = false) { Shape = shape; Masked = masked; this.supportAnimations = supportAnimations; if (noTexture) { vertexArrayObject = new VertexArrayObject(ColorShader.Instance.ShaderProgram); } else if (masked) { if (shape == Shape.Triangle) { vertexArrayObject = new VertexArrayObject(MaskedTriangleShader.Instance.ShaderProgram); } else { vertexArrayObject = new VertexArrayObject(MaskedTextureShader.Instance.ShaderProgram); } } else { vertexArrayObject = new VertexArrayObject(TextureShader.Instance.ShaderProgram); } positionBuffer = new PositionBuffer(false); indexBuffer = new IndexBuffer(); if (noTexture) { colorBuffer = new ColorBuffer(true); layerBuffer = new LayerBuffer(true); vertexArrayObject.AddBuffer(ColorShader.DefaultColorName, colorBuffer); vertexArrayObject.AddBuffer(ColorShader.DefaultLayerName, layerBuffer); } else if (shape == Shape.Triangle) { // map rendering will change the texture offsets often to change the terrain so use non-static buffers textureAtlasOffsetBuffer = new PositionBuffer(false); } else { textureAtlasOffsetBuffer = new PositionBuffer(!supportAnimations); if (layered) { layerBuffer = new LayerBuffer(true); vertexArrayObject.AddBuffer(ColorShader.DefaultLayerName, layerBuffer); } else { baseLineBuffer = new BaseLineBuffer(false); vertexArrayObject.AddBuffer(ColorShader.DefaultLayerName, baseLineBuffer); } } if (masked && !noTexture) { maskTextureAtlasOffsetBuffer = new PositionBuffer(shape != Shape.Triangle && !supportAnimations); vertexArrayObject.AddBuffer(MaskedTextureShader.DefaultMaskTexCoordName, maskTextureAtlasOffsetBuffer); } vertexArrayObject.AddBuffer(ColorShader.DefaultPositionName, positionBuffer); vertexArrayObject.AddBuffer("index", indexBuffer); if (!noTexture) { vertexArrayObject.AddBuffer(TextureShader.DefaultTexCoordName, textureAtlasOffsetBuffer); } }
public void AddBuffer(string name, IndexBuffer buffer) { indexBuffers.Add(name, buffer); }