package speiger.src.coreengine.rendering.guiOld.renderer;

import java.nio.FloatBuffer;

import speiger.src.coreengine.rendering.models.buffers.BufferAttribute;
import speiger.src.coreengine.rendering.models.buffers.VertexArray;
import speiger.src.coreengine.rendering.utils.values.BufferState;

public class GuiModel extends VertexArray
{
	protected int count;

	public GuiModel(int instances, BufferAttribute... attr)
	{
		bind();
		createBuffer(attr).withState(BufferState.STREAM_DRAW).allocate(instances).unbind();
		unbind();
	}
		
	public static GuiModel createTextureModel(int instances)
	{
		return new GuiModel(instances * 9, new BufferAttribute(0, 3), new BufferAttribute(1, 2), new BufferAttribute(2, 4));
	}
	
	@Override
	public int size()
	{
		return count;
	}
	
	public GuiModel setData(float[] data, int vertexes)
	{
		count = vertexes;
		buffer(0).bind().set(data).unbind();
		return this;
	}
	
	public GuiModel storeData(float[] data, int vertexes)
	{
		count = vertexes;
		buffer(0).bind().fill(0, data).unbind();
		return this;
	}
	
	public GuiModel storeData(FloatBuffer buffer)
	{
		buffer(0).bind().fill(0, buffer).unbind();
		return this;
	}
}
