#include "EPSGV/Application.h"

#ifdef _WIN32
	#include "Windows.h"
#endif

#include "GL/gl.h"
#include "GL/glut.h"

#include "EPSG/Scene.h"

EPSG::Scene* EPSGV::Application::s_root = NULL;

void EPSGV::Application::execute( int argc, char* args[] )
{
	glutInit( &argc, args );
	glutInitDisplayMode( GLUT_DOUBLE | GLUT_DEPTH | GLUT_RGB );
	glutInitWindowSize( 800, 700 );
	glutCreateWindow( "E.P. Scene Graph Viewer" );
	glutDisplayFunc( &EPSGV::Application::redraw );
	glutKeyboardFunc( &EPSGV::Application::keyboard );
	glutMainLoop();
}

void EPSGV::Application::loadScene( EPSG::Scene* root )
{
	s_root = root;
}

void EPSGV::Application::redraw()
{
	if( s_root == NULL )
		return;

	s_root->display();
	glutSwapBuffers();
}

void EPSGV::Application::keyboard( unsigned char key, int x, int y )
{
	
}