//
//  Wumbo-SpriteBatch.h
//  fjords_ios
//
//  Created by Wade McGillis on 4/19/14.
//  Copyright (c) 2014 Wade McGillis. All rights reserved.
//

#ifndef __fjords_ios__Wumbo_SpriteBatch__
#define __fjords_ios__Wumbo_SpriteBatch__

#include "Wumbo-Header.h"
#if PLATFORM_WINDOWS
#include <GL/glew.h>
#endif
namespace Wumbo
{
	typedef struct
	{
		float x;
		float y;
		float z;
		unsigned char r;
		unsigned char g;
		unsigned char b;
		unsigned char a;
		float u;
		float v;
	} WVertex;
	inline WVertex MakeWVertex(float X, float Y, float Z, float R, float G, float B, float A, float U, float V)
	{
		WVertex v;
		v.x = X;
		v.y = Y;
		v.z = Z;
		v.r = R;
		v.g = G;
		v.b = B;
		v.a = A;
		v.u = U;
		v.v = V;
		return v;
	}
	class SpriteBatch
	{
	private:
		GLuint vertexbuffer;
		GLuint vertexarray;
		WVertex wvertices[3*4000];
		unsigned int wvertexcount;
	public:
		SpriteBatch();
		void pushvertex(float x, float y, float z, unsigned int color, float u, float v);
		void pushvertex(float x, float y, float z, unsigned char r, unsigned char g, unsigned char b, unsigned char a, float u, float v);
		void clear();
		void compile();
		void render();
		
		void replaceUV(int vertex, float u, float v);
		void replaceColor(int vertex, unsigned int color);
		void beginModify();
		void endModify();
		
		WVertex *openGet();
		void closeGet();
	};
};

#endif /* defined(__fjords_ios__Wumbo_SpriteBatch__) */
