#ifndef V2Ddraw_cpp
#define V2Ddraw_cpp

#include<math.h>
#include<GL/glew.h>
#include<GL/glut.h>
#include "VTexture.h"

/*! \brief V2Ddraw: Hilfsklasse zum Zeichnen von 2D Primitiven.
 */
class V2Ddraw {

public:

/*! Zeichnet ein QUAD.
*/
static void drawBox(int x, int y, int width, int height) {
	glBegin(GL_QUADS);
		glVertex2f(x,y);
		glVertex2f(x+width,y);
		glVertex2f(x+width,y+height);
		glVertex2f(x,y+height);
	glEnd();
}
/*! Zeichnet ein QUAD mit Textur-Koordinaten.
*/
static void drawBox(int x, int y, int width, int height, int temp) {
	glBegin(GL_QUADS);
		glTexCoord2f(0.0f,0.0f);
		glVertex2f(x,y);
		glTexCoord2f(1.0f,0.0f);
		glVertex2f(x+width,y);
		glTexCoord2f(1.0f,1.0f);
		glVertex2f(x+width,y+height);
		glTexCoord2f(0.0f,1.0f);
		glVertex2f(x,y+height);
	glEnd();
}
/*! Zeichnet ein QUAD mit Textur.
*/
static void drawTexBox(VTexture* tex,int x, int y, int width, int height) {
	glEnable(GL_TEXTURE_2D);
	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA,GL_DST_ALPHA);
	tex->bind();
	glBegin(GL_QUADS);
		glTexCoord2f(0,1);
		glVertex2f(x,y);
		glTexCoord2f(1,1);
		glVertex2f(x+width,y);
		glTexCoord2f(1,0);
		glVertex2f(x+width,y+height);
		glTexCoord2f(0,0);
		glVertex2f(x,y+height);
	glEnd();
	glDisable(GL_TEXTURE_2D);
	glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
/*! Zeichnet ein Rechteck.
*/
static void drawRect(int x, int y, int width, int height) {
	glBegin(GL_LINE_LOOP);
		glVertex2f(x,y);
		glVertex2f(x+width,y);
		glVertex2f(x+width,y+height);
		glVertex2f(x,y+height);
	glEnd();
}
/*! Zeichnet einen Kreis.
*/
static void drawCircle(int x, int y, int radius) {
	glBegin(GL_LINE_LOOP);
		for(float angle = 0; angle < 360; angle+=45) {
			glVertex2f(x + sin(angle)*radius, y + cos(angle)*radius);
		}
	glEnd();
}

};

#endif
