#ifdef _WIN32
#include <windows.h>
#endif
#include "stdafx.h"
#include <GL/glu.h>

static int NUM_LINHAS_LATITUDE = 100;
static int NUM_LINHAS_LONGITUDE = 100;

/**
 Assinaturas dos métodos
 */
void RenderEsfera(GLdouble x, GLdouble y, GLdouble z, GLdouble raio);

void initVisual()
{
	glClearColor(0.0f, 0.0f, 0.0f, 0.0f);

	glEnable(GL_DEPTH_TEST);
}

void DisplayVisual()
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	

	// Seta o tipo de matriz que será utilizado
	// http://www.opengl.org/developers/documentation/man_pages/hardcopy/GL/html/gl/matrixmode.html?glMatrixMode#first_hit
	glMatrixMode(GL_MODELVIEW); 
	
	// Carrega a matriz identidade
	glLoadIdentity();
	
	// Mudança de escala
	// http://www.opengl.org/developers/documentation/man_pages/hardcopy/GL/html/gl/scale.html?glScalef#first_hit
//	glScalef(2.5f, 2.5f, 2.5f);
     
	RenderEsfera(0.0, 0.0, 0.0, 0.5);
//	RenderEsfera(10.0, 5.0, 0.0, 0.2);
//	RenderEsfera(20.0, 0.0, 5.0, 0.1);
	glFinish();
	glutSwapBuffers();
}

void ReshapeVisual(int w, int h)
{
	glViewport(0, 0, (GLsizei)w, (GLsizei)h);

	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	gluPerspective(60.0f, (GLfloat)w / (GLfloat) h, 1.0f, 20.0f);
}
   
int main(int argc, char ** argv)
{
	glutInit(&argc, argv);

	glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH | GLUT_RGB);
	glutInitWindowSize(640, 480);
	glutInitWindowPosition(0, 0);
	glutCreateWindow(argv[0]);

	initVisual();

	glutDisplayFunc(DisplayVisual);
	glutReshapeFunc(ReshapeVisual);

	glutMainLoop();

	return 0;
}


void RenderEsfera(GLdouble x, GLdouble y, GLdouble z, GLdouble raio) {
	//  http://www.opengl.org/developers/documentation/man_pages/hardcopy/GL/html/gl/translate.html?glTranslatef#first_hit
    glTranslatef(x,y,z);
	glutSolidSphere(raio, NUM_LINHAS_LATITUDE, NUM_LINHAS_LONGITUDE);
}


