
#include "stdafx.h"
#include "CGraf.h"
#include "../Object/2DObject.h"
#include "../GLDef.h"

// CGraf
CGraf::CGraf()
{
	_texBackground = 0;
	_odOkraje = 15;
	_r=1;_b=1;_g=1;
	_bBackground=1;
	_numBods = 0;
}

void CGraf::Render()
{
	glDisable( GL_LIGHTING );
	W_Ortho();
	glLoadIdentity();
		if( _bBackground )
		{
			glColor3f(1,0,0);
			glBegin( GL_QUADS );
				glVertex2f( _rect.x, _rect.y );
				glVertex2f( _rect.x, _rect.y+_rect.height );
				glVertex2f( _rect.x+_rect.width, _rect.y+_rect.height );
				glVertex2f( _rect.x+_rect.width, _rect.y );
			glEnd();
		}

		const od_okraje = _odOkraje;
		TRect temp=_rect;
		temp.x += od_okraje;
		temp.y += od_okraje;
		temp.width -= od_okraje*2;
		temp.height -= od_okraje*2;

		glLineWidth(3.0f);
		// draw okraj
		glColor3f(1,1,1);
		glBegin( GL_LINE_LOOP );
			glVertex2f( temp.x-7, temp.y-7 );
			glVertex2f( temp.x-7, temp.y+temp.height+7 );
			glVertex2f( temp.x+temp.width+7, temp.y+temp.height+7 );
			glVertex2f( temp.x+temp.width+7, temp.y-7 );
		glEnd();
		//textREC.Add("Y 1", temp.y)
		
		glLineWidth(2.0f);
		glColor3f(_r, _g, _b);
		for(register i=0; i < _numBods-1; i++)
		{
			glBegin( GL_LINES );
				glVertex2f( temp.x+_bod[i].x , temp.y+temp.height - _bod[i].y );
				glVertex2f( temp.x+_bod[i+1].x , temp.y+temp.height - _bod[i+1].y );
			glEnd();
		}
		/*glPointSize(5.0f);
		for(register int k=0; k < _numBods; k++)
		{

			glBegin( GL_POINTS );
				glVertex2f( temp.x+_bod[k].x , temp.y+temp.height - _bod[k].y );
			glEnd();
		}*/
	W_Proj();
}