Exemplo n.º 1
0
//Set up GL
bool GLInit()
{
	//Init window
	if(!WINDOW::Instance()->Init("Many Lights", 640, 480, 8, 8, 8, 8, 24, 8, false, false))
		return false;
	
	//Check for NV_vertex_program
	if(GLEE_NV_vertex_program)
	{
		//default to vp1
		useVP1=true;
		useVP2=false;
		useFixedFunction=false;
	}

	//Check for NV_vertex_program2
	if(GLEE_NV_vertex_program2)
	{
		//default to vp2
		useVP1=false;
		useVP2=true;
		useFixedFunction=false;
	}

	//Init font
	if(!font.Init())
		return false;

	//set viewport
	int height=WINDOW::Instance()->height;
	if(height==0)
		height=1;

	glViewport(0, 0, WINDOW::Instance()->width, height);

	//Set up projection matrix
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	gluPerspective(	45.0f, (GLfloat)WINDOW::Instance()->width/(GLfloat)WINDOW::Instance()->height,
					1.0f, 100.0f);

	//Load identity modelview
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();

	//Shading states
	glShadeModel(GL_SMOOTH);
	glClearColor(backgroundColor.r, backgroundColor.g, backgroundColor.b, backgroundColor.a);
	glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);

	//Depth states
	glClearDepth(1.0f);
	glDepthFunc(GL_LEQUAL);
	glEnable(GL_DEPTH_TEST);

	glEnable(GL_CULL_FACE);

	return true;
}
Exemplo n.º 2
0
//Set up GL
bool GLInit()
{
	//Init window
	if(!WINDOW::Instance()->Init(	"Project Template", 640, 480, 8, 8, 8, 8, 24, 8,
									false, false, true))
		return false;
	
	//Check for OpenGL version/extensions
	//if(!extgl_Extensions.OpenGL14)
	//{
		//LOG::Instance()->OutputError("I require OpenGL 1.4 support");
		//return false;
	//}

	//Init font
	if(!font.Init())
		return false;

	//set viewport
	int height=WINDOW::Instance()->height;
	if(height==0)
		height=1;

	glViewport(0, 0, WINDOW::Instance()->width, height);

	//Set up projection matrix
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	gluPerspective(	45.0f, (GLfloat)WINDOW::Instance()->width/(GLfloat)WINDOW::Instance()->height,
					1.0f, 100.0f);

	//Load identity modelview
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();

	//Shading states
	glShadeModel(GL_SMOOTH);
	glClearColor(backgroundColor.r, backgroundColor.g, backgroundColor.b, backgroundColor.a);
	glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);

	//Depth states
	glClearDepth(1.0f);
	glDepthFunc(GL_LEQUAL);
	glEnable(GL_DEPTH_TEST);

	glEnable(GL_CULL_FACE);

	return true;
}