// **************************************************************
void MainScene::init()
{
	// Enables vector normalization
	glEnable(GL_NORMALIZE);

	initGlobals();
	initCameras();
	initLights();

	unsigned long updatePeriod = 50;
	setUpdatePeriod(updatePeriod);

	display();
}
Beispiel #2
0
Datei: main.cpp Projekt: JoaoS/CG
void init(void)
{
	glClearColor(WHITE);
    glShadeModel(GL_SMOOTH);
    glEnable(GL_COLOR_MATERIAL);

    glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE ); 
    criaDefineTexturas();
    initLights();
    glEnable(GL_LIGHTING);  
    glEnable(GL_DEPTH_TEST);
    glEnable(GL_BLEND);    
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    init_levels();
}
Beispiel #3
0
int InitGL(GLvoid)										// All Setup For OpenGL Goes Here
{
	multitextureSupported=initMultitexture();
	if (!LoadGLTextures()) return false;				// Jump To Texture Loading Routine
	
	glEnable(GL_TEXTURE_2D);							// Enable Texture Mapping
	glShadeModel(GL_SMOOTH);							// Enable Smooth Shading
	glClearColor(0.0f, 0.0f, 0.0f, 0.5f);				// Black Background
	glClearDepth(1.0f);									// Depth Buffer Setup
	glEnable(GL_DEPTH_TEST);							// Enables Depth Testing
	glDepthFunc(GL_LEQUAL);								// The Type Of Depth Testing To Do
	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);	// Really Nice Perspective Calculations

	initLights();										// Initialize OpenGL Light	
	return true;										// Initialization Went OK
}
Beispiel #4
0
// Définit le modèle pour affichage à l'écran
void View::display(void)
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Initialisation du buffer de couleur à la couleur de fond


	// Viewport contenant les informations sur la partie en cours
	viewportInfos();
	if(model->getLifes() < 0) {
		model->stopGame();
		gameOver();
	}
	else {
		drawScore();
		drawLifes();
	}

	// Viewport contenant les contrôles souris (boutons)
	viewportControls();
	drawMouseControls();
	drawButton("Reset",100);
	drawButton("Close",150);
	drawButton("View", 200);



	// Viewport contenant le plateau de jeu
	glEnable(GL_DEPTH_TEST);

	initLights();

	viewportWorld(); // Définit une viewport et ses caractéristiques de projection
	drawWorld();
	drawPills();
	drawPacMan();
	drawGhosts();

	glDisable(GL_LIGHT0);
	glDisable(GL_LIGHT1);
	glDisable(GL_LIGHT2);
	glDisable(GL_LIGHT3);
	glDisable(GL_LIGHTING);	// nuit !
	glDisable(GL_DEPTH_TEST);


	glutSwapBuffers(); // Car on travaille en mode "double buffer", cf. main.cpp
}
Beispiel #5
0
void ThreeDimLife::initView() {
    glClearColor(0,0,0,0);
    glShadeModel(GL_SMOOTH);
    
    glPolygonMode(GL_FRONT, GL_FILL);
    
    glEnable(GL_POLYGON_OFFSET_FILL);
    
    glEnable(GL_DEPTH_TEST);

    zoomAmount=75;
    rotateX = 45.0;
    rotateY = 45.0;
    rotateZ = 0.0;

    initLights();
    initMaterials();
}
Beispiel #6
0
void ThreeDimLife::reset() {
    array.clear();
    array.resize(height);
    for (int i=0; i<height; ++i) {
        array[i].resize(width);
        for (int j=0;j<width; ++j) {
            array[i][j].resize(depth, false);
        }
    }
    int num = prob*width*height*depth;
    for (int i=0;i<num; ++i) {
        size_t ri = randUInt(0, height);
        size_t rj = randUInt(0, width);
        size_t rk = randUInt(0, depth);
        array[ri][rj][rk] = true;
    }
    initMaterials();
    initLights();
}
Beispiel #7
0
int main(int argc, char **argv) {
	int i;

	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
	/* process commmand line args */
	for (i = 1; i < argc; ++i) {
		if (!strcmp("-lm", argv[i])) {
			useSAME_AMB_SPEC = !useSAME_AMB_SPEC;
		} else {
			usage(argv[0]);
		}
	}

	glutCreateWindow("GLUT spotlight swing");
	glutDisplayFunc(display);
	glutVisibilityFunc(visibility);

	glMatrixMode(GL_PROJECTION);
	glFrustum(-1, 1, -1, 1, 2, 6);

	glMatrixMode(GL_MODELVIEW);
	glTranslatef(0.0, 0.0, -3.0);
	glRotatef(45.0, 1, 0, 0);

	glEnable(GL_LIGHTING);
	glEnable(GL_NORMALIZE);

	glLightModelfv(GL_LIGHT_MODEL_AMBIENT, modelAmb);
	glLightModelf(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE);
	glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE);

	glMaterialfv(GL_FRONT, GL_AMBIENT, matAmb);
	glMaterialfv(GL_FRONT, GL_DIFFUSE, matDiff);
	glMaterialfv(GL_FRONT, GL_SPECULAR, matSpec);
	glMaterialfv(GL_FRONT, GL_EMISSION, matEmission);
	glMaterialf(GL_FRONT, GL_SHININESS, 10.0);

	initLights();

	glutMainLoop();
	return 0; /* ANSI C requires main to return int. */
}
void PointCloudViewer::init()
{
    glEnable(GL_POINT_SMOOTH);
    glHint(GL_POINT_SMOOTH_HINT, GL_NICEST);
    glEnable(GL_BLEND);
    glPointSize(3);
    glLineWidth(10);
    setMouseTracking(true);


    texid = bindTexture(QImage(rgbImg->ptr(), rgbImg->cols, rgbImg->rows, QImage::Format_RGB888), GL_TEXTURE_2D, GL_RGB, QGLContext::LinearFilteringBindOption);
    initBackground();
    initLights();
    initBuffers();

    restoreStateFromFile();
    setAnimationPeriod(10);
    startAnimation();
}
Beispiel #9
0
/* Initializes the renderer. */
void Renderer::init() {
    // I (Nailen) needed this to get shaders to work
    glewExperimental = GL_TRUE; 
    glewInit();

    // Set the background color and enable the depth buffer, backface culling
    glClearColor(0.0, 0.0, 0.0, 1.0);
    glEnable(GL_DEPTH_TEST);
    glEnable(GL_CULL_FACE);
    glCullFace(GL_BACK);

    // Set up two vertex attribute buffers. This is important because it allows
    // us to copy all of the vertices and normals in the scene to faster memory
    // in the graphics hardware (GPU) before rendering, as opposed to reading
    // each value sequentially from system memory (much slower).
    glGenVertexArrays(1, &this->vb_array);
    glBindVertexArray(this->vb_array);
    glGenBuffers(2, this->vb_objects);

    // Bind the v_v and n_v variables in vertex.glsl to the two buffers
    glBindAttribLocation(this->shader->program, 0, "v_v");
    glBindAttribLocation(this->shader->program, 1, "n_v");

    // Set up the perspective projection matrix
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(this->ui->camera.fov, this->ui->camera.aspect,
        this->ui->camera.near, this->ui->camera.far);

    // Set up the modelview matrix
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    glTranslatef(-this->ui->camera.position.x, -this->ui->camera.position.y,
        -this->ui->camera.position.z);
    glRotatef(radToDeg(-this->ui->camera.angle), this->ui->camera.axis.x,
        this->ui->camera.axis.y, this->ui->camera.axis.z);

    // Initialize the lights, set the material properties for every polygon in
    // the scene, and then compile and activate the shader program
    initLights();
    this->shader->compileShaders();
}
Beispiel #10
0
void initRoomEdition(void)
{
	initLights();
	initBlocks();
	initEntities();
	initInterface();
	initEditorRoom(&editorRoom);
	initContextButtons();
	initSelection(NULL);
	initCamera(&editorCamera);
	// initProjectionMatrixOrtho(&editorCamera, inttof32(-128), inttof32(127),inttof32(-96), inttof32(95), inttof32(-1000), inttof32(1000));
	initProjectionMatrix(&editorCamera, 70*90, inttof32(4)/3, inttof32(1)/10, inttof32(1000)); //TEMP?
	editorCamera.position=vect(0,0,0);
	editorTranslation=vect(0,0,inttof32(-1));
	editorScale=inttof32(1);
	lineOfTouchOrigin=vect(0,0,0);
	lineOfTouchVector=vect(0,0,0);
	currentScreen=false;

	//initial camera setup
	rotateMatrixY(editorCamera.transformationMatrix, 2048+384, true);
	rotateMatrixX(editorCamera.transformationMatrix, 1024+128, false);
	editorScale=inttof32(8*20);

	//controls stuff
	touchRead(&currentTouch);
	oldTouch=currentTouch;

	//cosmetics
	glSetOutlineColor(0,RGB15(0,0,0));
	glSetOutlineColor(1,RGB15(29,15,3));

	glMaterialf(GL_AMBIENT, RGB15(8,8,8));
	glMaterialf(GL_DIFFUSE, RGB15(24,24,24));
	glMaterialf(GL_SPECULAR, RGB15(0,0,0));
	glMaterialf(GL_EMISSION, RGB15(0,0,0));

	glSetToonTableRange(0, 2, RGB15(8,8,8));
	glSetToonTableRange(3, 31, RGB15(24,24,24));

	glLight(0, RGB15(31,31,31), cosLerp(4096)>>3, 0, sinLerp(4096)>>3);
}
Beispiel #11
0
void
display(void)
{
    glClear(GL_COLOR_BUFFER_BIT);

    glPushMatrix();

    glEnable(GL_LIGHTING);
    initLights();
    setLights();

    glPushMatrix();
    glRotatef(-90.0, 1, 0, 0);
    glTranslatef(-1, -1, 0.0);
    drawPlane(200, 200); // xy plane
    glPopMatrix();

    //drawLights();
    glPopMatrix();

    glutSwapBuffers();
}
Beispiel #12
0
    Robot()
    {
      initStructuralConstraints();
      
      initTexture();
      initLights();
      
      initHip();
      initBust();
      initNeck();
      initHead();
      initLeftShoulder();
      initRightShoulder();

      initLeftUpperArmFront();
      initLeftLowerArmFront();
      initRightUpperArmFront();
      initRightLowerArmFront();

      initLeftUpperArmBehind();
      initLeftLowerArmBehind();
      initRightUpperArmBehind();
      initRightLowerArmBehind();
      initLeftFrontHand();
      initRightFrontHand();
      initLeftBehindHand();
      initRightBehindHand();
      initLeftUpperLeg();
      initLeftLowerLeg();
      initRightUpperLeg();
      initRightLowerLeg();
      initLeftFoot();
      initRightFoot();    
      behindArmAngle=0;
      keys = KeyControls();

    }
Beispiel #13
0
void initFunc() {

    // Inicializamos GLEW
    GLenum err = glewInit();
    if (GLEW_OK != err) {
        printf("Error: %s\n", glewGetErrorString(err));
    }
    printf("Status: Using GLEW %s\n", glewGetString(GLEW_VERSION));

    // Configuracion de parametros fijos
    glEnable(GL_DEPTH_TEST);
    glEnable(GL_POLYGON_OFFSET_FILL);
    initLights();
    if (WITH_TEXTURES)
        initTextures();
    //glEnable(GL_CULL_FACE);
    //glCullFace(GL_BACK);
    glPolygonOffset(1.0, 1.0);
    glShadeModel(GL_SMOOTH);
    //glEnable(GL_NORMALIZE);
    //glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);

    lastClickTime = glutGet(GLUT_ELAPSED_TIME);
}
Beispiel #14
0
void
initGLEnv(Bool doFog)
{
	GLfloat		spc[4] = {1.0, 1.0, 1.0, 1.0};

	glClearColor(0.0, 0.0, 0.0, 0.0);
	glClearDepth(1.0);
	glDepthFunc(GL_LESS);

	glEnable(GL_COLOR_MATERIAL);
	glMateriali(GL_FRONT, GL_SHININESS, 128);
	glMaterialfv(GL_FRONT, GL_SPECULAR, spc);
	glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, spc);

	glEnable(GL_NORMALIZE);
	glEnable(GL_DEPTH_TEST);
	glShadeModel(GL_SMOOTH);
	glEnable(GL_CULL_FACE);

	initLights();
	if (doFog) initFog();

	Quadratic = gluNewQuadric();
}
Beispiel #15
0
int main ( int argc, char *argv[] ) {

	#pragma region [-- FreeGLUT --]
	
	glutInit (&argc, argv);
	glutInitDisplayMode (GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH );
	glutInitWindowSize( Width, Heigth );
	main_window = glutCreateWindow ("Shaders");
	
	#pragma endregion

	#pragma region [-- GLEW --]
	
	// Inicializacion de GLEW
	GLenum glew_err = glewInit ();

	if ( GLEW_OK != glew_err ){
		cout << "No es posible inicializar GLEW\n";
		return 1;
	}

	

	cout << "Usando GLEW Version: " << glewGetString ( GLEW_VERSION ) << "\n\n";

	#pragma endregion

	initShaders();
	initLights();

	#pragma region [-- AntTweakBar --]
	TwBar *bar; // Pointer to the tweak bar
	TwBar *barLights;
	// Initialize AntTweakBar
    TwInit(TW_OPENGL, NULL);

	glutMouseFunc(mouseClick);

	// Set GLUT event callbacks
    // - Directly redirect GLUT mouse button events to AntTweakBar
    //glutMouseFunc((GLUTmousebuttonfun)TwEventMouseButtonGLUT);
    // - Directly redirect GLUT mouse motion events to AntTweakBar
    glutMotionFunc((GLUTmousemotionfun)TwEventMouseMotionGLUT);
    // - Directly redirect GLUT mouse "passive" motion events to AntTweakBar (same as MouseMotion)
    glutPassiveMotionFunc((GLUTmousemotionfun)TwEventMouseMotionGLUT);
    // - Directly redirect GLUT key events to AntTweakBar
    glutKeyboardFunc((GLUTkeyboardfun)TwEventKeyboardGLUT);
    // - Directly redirect GLUT special key events to AntTweakBar
    glutSpecialFunc((GLUTspecialfun)TwEventSpecialGLUT);
    // - Send 'glutGetModifers' function pointer to AntTweakBar;
    //   required because the GLUT key event functions do not report key modifiers states.
    TwGLUTModifiersFunc(glutGetModifiers);

	bar = TwNewBar("Objetos");
    TwDefine(" Objetos size='225 350' color='25 255 0' "); // change default tweak bar size and color 96 216 224

	// Define the required callback function to copy a std::string (see TwCopyStdStringToClientFunc documentation)
    TwCopyStdStringToClientFunc(CopyStdStringToClient);

	TwAddVarRW(bar, "Cargar figura", TW_TYPE_STDSTRING, &direccion_carga, 
               " label='direccion' group=Cargar help='Define a title for the new tweak bar.' ");

	// Add a button to create a new bar using the title
    TwAddButton(bar, "NewBarCreate", Cargar, &direccion_carga, 
                " label='--> Create' group=Cargar key=c help='Create a new tweak bar.' ");

	TwAddVarRW(bar, "ObjRotation1", TW_TYPE_QUAT4F, &g_Rotation, 
               " label='Object rotation' opened=true help='Change the object orientation.' ");

	// Add 'g_Zoom' to 'bar': this is a modifable (RW) variable of type TW_TYPE_FLOAT. Its key shortcuts are [m] and [M].
    TwAddVarRW(bar, "Zoom", TW_TYPE_FLOAT, &g_Zoom, 
               " min=0.01 max=2.5 step=0.01 keyIncr=m keyDecr=M help='Scale the object (1=original size).' ");
	// Add 'g_Zoom' to 'bar': this is a modifable (RW) variable of type TW_TYPE_FLOAT. Its key shortcuts are [m] and [M].
    TwAddVarRW(bar, "Shinnes", TW_TYPE_FLOAT, &shinnes, 
               " min=0.00 max=200 step=0.1 keyIncr=m keyDecr=M help='Scale the object (1=original size).' ");

	// Add 'Translate' to 'bar': this is a modifable (RW) variable of type TW_TYPE_FLOAT. Its key shortcuts are [xyz] and [xyz].
    TwAddVarRW(bar, "TranslateX", TW_TYPE_FLOAT, &Translation[0], 
               " min=-20.0 max=20 step=0.01 keyIncr=x keyDecr=X help='Scale the object (1=original size).' group='Translation' ");
	TwAddVarRW(bar, "TranslateY", TW_TYPE_FLOAT, &Translation[1], 
               " min=-20.0 max=20 step=0.01 keyIncr=y keyDecr=Y help='Scale the object (1=original size).' group='Translation' ");
	TwAddVarRW(bar, "TranslateZ", TW_TYPE_FLOAT, &Translation[2], 
               " min=-20.0 max=20 step=0.01 keyIncr=z keyDecr=Z help='Scale the object (1=original size).' group='Translation' ");

	barLights = TwNewBar("Luces");
    TwDefine(" Luces size='225 350' position='580 16' color='25 255 0' "); // change default tweak bar size and color 96 216 224

	{
        // ShapeEV associates Shape enum values with labels that will be displayed instead of enum values
        TwEnumVal lightType[3] = { {DIRECTIONALLIGHT, "Direccional"}, {SPOTLIGHT, "Reflector"}, {POINTLIGHT, "Puntual"} };
        // Create a type for the enum lightType
        TwType shapeType = TwDefineEnum("lightType", lightType, 3);
        // add 'g_CurrentShape' to 'bar': this is a variable of type ShapeType. Its key shortcuts are [<] and [>].
		TwAddVarRW(barLights, "Shape", shapeType, &g_light->status, " keyIncr='<' keyDecr='>' help='Change object shape.' ");
    }

	// Add 'g_LightDirection' to 'bar': this is a variable of type TW_TYPE_DIR3F which defines the light direction
	TwAddVarRW(barLights, "LightDir", TW_TYPE_DIR3F, &g_light->spotDirection, 
               " label='Light direction' opened=true help='Change the light direction.' ");

	// Add 'g_MatAmbient' to 'bar': this is a variable of type TW_TYPE_COLOR3F (3 floats color, alpha is ignored)
    // and is inserted into a group named 'Material'.
	TwAddVarRW(barLights, "Ambient", TW_TYPE_COLOR3F, &g_light->ambient, " group='Material' ");

    // Add 'g_MatDiffuse' to 'bar': this is a variable of type TW_TYPE_COLOR3F (3 floats color, alpha is ignored)
    // and is inserted into group 'Material'.
	TwAddVarRW(barLights, "Diffuse", TW_TYPE_COLOR3F, &g_light->diffuse, " group='Material' ");

	// Add 'g_MatDiffuse' to 'bar': this is a variable of type TW_TYPE_COLOR3F (3 floats color, alpha is ignored)
    // and is inserted into group 'Material'.
	TwAddVarRW(barLights, "specular", TW_TYPE_COLOR3F, &g_light->specular, " group='Material' ");

	TwAddVarRW(barLights, "TranslateX", TW_TYPE_FLOAT, &g_light->position.x, 
               " min=-20.0 max=20 step=0.01 keyIncr=x keyDecr=X help='Scale the object (1=original size).' group='Translation' ");
	TwAddVarRW(barLights, "Translatey", TW_TYPE_FLOAT, &g_light->position.y, 
               " min=-20.0 max=20 step=0.01 keyIncr=y keyDecr=Y help='Scale the object (1=original size).' group='Translation' ");
	TwAddVarRW(barLights, "Translatez", TW_TYPE_FLOAT, &g_light->position.z, 
               " min=-20.0 max=20 step=0.01 keyIncr=z keyDecr=Z help='Scale the object (1=original size).' group='Translation' ");

	TwAddVarRW(barLights, "spotExponent", TW_TYPE_FLOAT, &g_light->spotExponent, 
               " min=0.0 max=10 step=1.0 help='Scale the object (1=original size).' ");
	TwAddVarRW(barLights, "spotCutoff", TW_TYPE_FLOAT, &g_light->spotCutoff, 
               " min=0.0 max=60 step=1.0 help='Scale the object (1=original size).' ");
	TwAddVarRW(barLights, "constantAttenuation", TW_TYPE_FLOAT, &g_light->constantAttenuation, 
               " min=0.0  step=1.0 help='Scale the object (1=original size).' ");
	TwAddVarRW(barLights, "linearAttenuation", TW_TYPE_FLOAT, &g_light->linearAttenuation, 
               " min=0.0  step=1.0 help='Scale the object (1=original size).' ");
	TwAddVarRW(barLights, "quadraticAttenuation", TW_TYPE_FLOAT, &g_light->quadraticAttenuation, 
               " min=0.0 max=60 step=1.0 help='Scale the object (1=original size).' ");

	#pragma endregion

	#pragma region [-- Callbacks --]

	glutDisplayFunc(Display);
	glutReshapeFunc(Reshape);

	#pragma endregion
	
	glEnable(GL_DEPTH_TEST);

	
	
	glutMainLoop ();

	return 0;
}
void AppStart(){
	// ----- GLFW Settings -----

	glfwDisable(GLFW_MOUSE_CURSOR); // Hide the mouse cursor

	glfwSwapInterval(0);            // Disable vsync

	// ----- Window and Projection Settings -----

	// Set the window title
	glfwSetWindowTitle("Solar System Model | PMarques / VGomes | April 2016");

	// Setup our viewport to be the entire size of the window
	glViewport(0, 0, (GLsizei)windowWidth, (GLsizei)windowHeight);

	// Change to the projection matrix, reset the matrix and set up our projection
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();

	init();

	glGenTextures(6, skyboxtextures);
	glGenTextures(numeroPlanetas, textures);

	//Inicializar as display lists para estrelas e órbitas
	displayListIndex = glGenLists(3);

	//Fog
	GLfloat fogColor[] = { 0.1, 0.1, 0.1, 1.0 };
	// Activar o nevoeiro
	glEnable(GL_FOG);
	// Define a cor do nevoeiro
	glFogfv(GL_FOG_COLOR, fogColor);
	glFogi(GL_FOG_MODE, GL_EXP2);
	glFogf(GL_FOG_DENSITY, 0.005f);

	loadSkyboxTextures();
	initSistemaSolar();
	//Gerar a displayList de órbitas de planetas
	initPlanetOrbits();
	initLights();
	initEstrelas();


	// Instantiate our pointer to a Camera object providing it the size of the window
	cam = new Camera(windowWidth, windowHeight);

	// Set the mouse cursor to the centre of our window
	glfwSetMousePos(midWindowX, midWindowY);
	//Handle keyboard events
	glfwSetKeyCallback(handleKeypress);
	// Specify the function which should execute when the mouse is moved
	glfwSetMousePosCallback(handleMouseMove);
	glfwSetWindowSizeCallback(ResizeWindow);

	// The deltaTime variable keeps track of how much time has elapsed between one frame and the next.
	// This allows us to perform framerate independent movement i.e. the camera will move at the same
	// overall speed regardless of whether the app's running at (for example) 6fps, 60fps or 600fps!
	double deltaTime = 0.0;

	// Flag to keep our main loop running
	bool running = true;

	std::cout << "Running!" << std::endl;

	while (running)
	{
		// Calculate our camera movement
		cam->move(deltaTime);

		// Draw our scene
		Animate();

		// exit if ESC was pressed or window was closed
		running = !glfwGetKey(GLFW_KEY_ESC) && glfwGetWindowParam(GLFW_OPENED);

		// Call our fpsManager to limit the FPS and get the frame duration to pass to the cam->move method
		deltaTime = fpsManager.enforceFPS();
	}
}
Beispiel #17
0
int main(int argc, char** argv){

  bool loadedScene = false;
  for(int i=1; i<argc; i++){
    string header; string data;
    istringstream liness(argv[i]);
    getline(liness, header, '='); getline(liness, data, '=');
    if(strcmp(header.c_str(), "mesh")==0){
      //renderScene = new scene(data);
      mesh = new obj();
      objLoader* loader = new objLoader(data, mesh);
      mesh->buildVBOs();
      delete loader;
      loadedScene = true;
    }
  }

  if(!loadedScene){
    cout << "Usage: mesh=[obj file]" << endl;
    return 0;
  }

  frame = 0;
  seconds = time (NULL);
  fpstracker = 0;

  // Launch CUDA/GL
  #ifdef __APPLE__
  // Needed in OSX to force use of OpenGL3.2 
  glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3);
  glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 2);
  glfwOpenWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
  glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
  init();
  #else
  init(argc, argv);
  #endif

  initCamera();
  initLights();
  initCuda();

  initVAO();
  initTextures();

  GLuint passthroughProgram;
  passthroughProgram = initShader("shaders/passthroughVS.glsl", "shaders/passthroughFS.glsl");

  glUseProgram(passthroughProgram);
  glActiveTexture(GL_TEXTURE0);

  #ifdef __APPLE__
    // send into GLFW main loop
    while(1){
      display();
      if (glfwGetKey(GLFW_KEY_ESC) == GLFW_PRESS || !glfwGetWindowParam( GLFW_OPENED )){
          kernelCleanup();
          cudaDeviceReset(); 
          exit(0);
      }
    }

    glfwTerminate();
  #else
    glutDisplayFunc(display);
    glutKeyboardFunc(keyboard);
	glutMouseFunc(mouseButton);
	glutMotionFunc(mouseMove);

    glutMainLoop();
  #endif
  kernelCleanup();
  return 0;
}
Beispiel #18
0
/**
 * Initialize the project, doing any necessary opengl initialization.
 * @param camera An already-initialized camera.
 * @param scene The scene to render.
 * @return true on success, false on error.
 */
bool OpenglProject::initialize( Camera* camera, Scene* scene )
{
	
	// TODO opengl initialization code and precomputation of mesh/heightmap

    //copy scene
    this->scene = *scene;
	textureArr = imageio_load_image("texture/image1.png", &textureWidth, &textureHeight);
//	std::cout<<"\nimagesize:"<<textureWidth<<"*"<<textureHeight<<"\n";
	
	/*********some initialization***********/
	glClearColor(0.0, 0.0, 0.0, 0.0);
	glEnable(GL_DEPTH_TEST);
	glEnable(GL_NORMALIZE);
	glEnable(GL_BLEND);

	/**********texture************/
	if(textureHeight != -1 && textureWidth != -1)
	{
		glEnable(GL_TEXTURE_2D);
		glGenTextures(1, &texture);	
		glBindTexture(GL_TEXTURE_2D, *textureArr);
		glTexImage2D(GL_TEXTURE_2D, 0, 4, textureWidth, textureHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE,textureArr);
		glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
		glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
	}
	/*********lights**************/
	initLights();

	/**************camera****************/
	glMatrixMode(GL_PROJECTION);
	gluPerspective(camera->get_fov_degrees(), camera->get_aspect_ratio(), camera->get_near_clip(), camera->get_far_clip());
	glMatrixMode(GL_MODELVIEW);
	

	/************calculate the normal ************/
	meshNormal = new Vector3[scene->mesh.num_vertices];
	Vector3 tempPoint1, tempPoint2, tempPoint3, normalVec;
	int index1, index2, index3;

	//initialize the mesh array
	for(int i = 0; i < scene->mesh.num_vertices; i++){
		meshNormal[i] = Vector3(0.0,0.0,0.0);
	}

	//calculate the normal vector for each point
	for( int i = 0; i < scene->mesh.num_triangles; i++){
		index1 = scene->mesh.triangles[i].vertices[0];
		index2 = scene->mesh.triangles[i].vertices[1];
		index3 = scene->mesh.triangles[i].vertices[2];
		tempPoint1 = scene->mesh.vertices[index1];
		tempPoint2 = scene->mesh.vertices[index2];
		tempPoint3 = scene->mesh.vertices[index3];
		normalVec = cross((tempPoint2 - tempPoint1),(tempPoint3 - tempPoint1));
		meshNormal[index1] += normalVec;
		meshNormal[index2] += normalVec;
		meshNormal[index3] += normalVec;
		
	} 

	//normalize the normal
	for( int i = 0; i < scene->mesh.num_vertices; i++){
		
		meshNormal[i] = normalize(meshNormal[i]);
	}

	
	
	

	/****** read the mesh from the scene *****/
	meshList = glGenLists(1);
	glNewList(meshList, GL_COMPILE);
	glBegin(GL_TRIANGLES);
		for(int i = 0 ; i < scene->mesh.num_triangles; i++){
			index1 = scene->mesh.triangles[i].vertices[0];
			index2 = scene->mesh.triangles[i].vertices[1];
			index3 = scene->mesh.triangles[i].vertices[2];	
			
				

					glNormal3f(meshNormal[index1].x, meshNormal[index1].y, meshNormal[index1].z);
					tempPoint1 = scene->mesh.vertices[index1];
					glVertex3f(tempPoint1.x, tempPoint1.y, tempPoint1.z);
					
					//std::cout<<"0:"<<tempPoint;  //for debug
				
					glNormal3f(meshNormal[index2].x, meshNormal[index2].y, meshNormal[index2].z);
					tempPoint2 = scene->mesh.vertices[index2];
					glVertex3f(tempPoint2.x, tempPoint2.y, tempPoint2.z);
					
					//std::cout<<"1:"<<tempPoint;  //for debug
				
					glNormal3f(meshNormal[index3].x, meshNormal[index3].y, meshNormal[index3].z);
					tempPoint3 = scene->mesh.vertices[index3];
					glVertex3f(tempPoint3.x, tempPoint3.y, tempPoint3.z);
					
					//std::cout<<"2:"<<tempPoint;  //for debug

		}
		glEnd();
	glEndList();
	 
	


	/**********precompute of heightmap *********/
	//std::cout<<"\nSIZE:" <<SIZE<<"\n";
	float currHeight;
	int index = 0; 
	/*for ( double  i = -1.0;i <= 1.0; i += delta){
		for ( double j = -1.0; j <= 1.0; j += delta){
			std::cout<<"i:"<<i<<" j:"<<j<<" index"<<index<<"\n";
			currHeight = scene->heightmap->compute_height(Vector2(i,j));
			heightmapMeshVertice[index] = Vector3(i, currHeight,j);
			index++;
		}
		std::cout<<"index:"<<index<<"\n";
	} */
	double positionX = -1.0, positionY = -1.0 ;
	for(int i = 0; i < SIZE; i++){
		positionY = -1.0;
		for(int j = 0; j < SIZE; j++){
	//		std::cout<<"i:"<<i<<" j:"<<j<<" index"<<index<<"pos:"<<positionX<<" "<<positionY<<"\n";
			currHeight = scene->heightmap->compute_height(Vector2(positionX,positionY));
			heightmapMeshVertice[index] = Vector3(positionX, currHeight,positionY);
			positionY += delta;
			index++;
		}
		positionX += delta;
	//	std::cout<<"index:"<<index<<"\n";
	}
//	std::cout<<"delta:"<<delta<<"\n";
	num_heightmap_vertice = index;
//	std::cout<<"index for vertice:"<<index<<"\n"; // for debug
	
	/*********create the mesh for the water surface ***********/
	int indexOfTri = 0; // index of triangels;
	double tempResult;
	for( double j = -1.0; j < 0.99 ; j += delta){
		for ( double i = -1.0; i < 0.99; i += delta){
			tempResult = (((i - (-1.0)) * ( SIZE-1 ) ) / 2.0) * SIZE + ( ( (j - (-1.0)) * (SIZE - 1) ) / 2.0);
			index1 = static_cast<int>(tempResult+0.5);
			if(fmod((index1+1), SIZE) != 0){
				index2 = index1 + 1;
				index3 = index1 +1 +SIZE;

				heightmapMeshTriangle[indexOfTri].vertices[0] = index1;
				heightmapMeshTriangle[indexOfTri].vertices[1] = index2;
				heightmapMeshTriangle[indexOfTri].vertices[2] = index3;
				indexOfTri ++;

				index2 = index1 + SIZE + 1;
				index3 = index1 + SIZE;

				heightmapMeshTriangle[indexOfTri].vertices[0] = index1;
				heightmapMeshTriangle[indexOfTri].vertices[1] = index2;
				heightmapMeshTriangle[indexOfTri].vertices[2] = index3;
				indexOfTri++;
			}
			/*else{
				std::cout<<"index1:"<<index1<<"\n";
			}*/
		}
	}



	num_heightmap_triangles = indexOfTri;
//	std::cout<<"indexoftri:"<<indexOfTri; // for debug

	/**********average the normal**************/
	heightmapMeshNormal = new Vector3[num_heightmap_vertice];
	for(int i = 0; i < num_heightmap_vertice; i++){
		heightmapMeshNormal[i] = Vector3(0.0,0.0,0.0);
	}
   
		
    return true;
}
Beispiel #19
0
/**
 * Initialize the project, doing any necessary opengl initialization.
 * @param camera An already-initialized camera.
 * @param mesh The mesh to be rendered and subdivided.
 * @param texture_filename The filename of the texture to use with the mesh.
 *  Is null if there is no texture data with the mesh or no texture filename
 *  was passed in the arguments, in which case textures should not be used.
 * @return true on success, false on error.
 */
bool GeometryProject::initialize( const Camera* camera, const MeshData* mesh, const char* texture_filename )
{
    this->mesh = *mesh;

    /***********************************************/
    textureHeight = -1;
    textureWidth = -1;
    if(texture_filename != NULL) {
        textureArr = imageio_load_image(texture_filename, &textureWidth, &textureHeight);
    } else {
        hasTexture = false;
    }
    /************some initialization*****************/
    glClearColor(0.0,0.0,0.0,0.0);
    glEnable(GL_DEPTH_TEST);
    glEnable(GL_LIGHTING);
    glEnable(GL_NORMALIZE);

    /************texture********************/
    if(textureHeight != -1 && textureWidth != -1)
    {
        hasTexture = true;

    } else {
        hasTexture = false;
    }
    std::cout<<"has Texture:"<<hasTexture<<"\n";
    if(hasTexture) {
        glEnable(GL_TEXTURE_2D);
        glGenTextures(1, &texture);
        glBindTexture(GL_TEXTURE_2D, *textureArr);
        glTexImage2D(GL_TEXTURE_2D, 0, 4, textureWidth, textureHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE,textureArr);
        glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
        glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
    }
    /**************camera****************/
    glMatrixMode(GL_PROJECTION);
    gluPerspective(camera->get_fov_degrees(), camera->get_aspect_ratio(), camera->get_near_clip(), camera->get_far_clip());
    glMatrixMode(GL_MODELVIEW);
    /*************lights******************/
    initLights();

    /******read the data from the mesh, do some initialization**********/
    std::cout<<"read the data from the mesh and do some initialization"<<"\n";
    num_vertice = mesh->num_vertices;
    oldVerticeArr = new Vertex[num_vertice];
    oldAdjVerticeArr = new AdjVertice[num_vertice];

    for(int i = 0; i < num_vertice; i++) {
        oldVerticeArr[i] = mesh->vertices[i];
        oldAdjVerticeArr[i].boundary = false;
        oldAdjVerticeArr[i].num_AdjVertice = 0;
    }
    num_triangles = mesh->num_triangles;
    oldTriangleArr = new Triangle[num_triangles];
    for(int i = 0; i < num_triangles; i++) {
        oldTriangleArr[i] = mesh->triangles[i];
    }

    /*********find the adj between vertices*****************/
    std::cout<<"find the adj between vertices"<<"\n";
    unsigned int index1, index2, index3;
    for(int i = 0; i <num_triangles; i++) {

        index1 = oldTriangleArr[i].vertices[0];
        index2 = oldTriangleArr[i].vertices[1];
        index3 = oldTriangleArr[i].vertices[2];

        findAdjVertice(index1, index2, index3, oldAdjVerticeArr);
        findAdjVertice(index2, index1, index3, oldAdjVerticeArr);
        findAdjVertice(index3, index1, index2, oldAdjVerticeArr);
    }

    setDisplayList();

    firstSubdivision = true;
    // TODO opengl initialization code
    return true;
}
Beispiel #20
0
/**
* Initialize an EGL context for the current display.
*/
static int engine_init_display(struct engine* engine) {
	// initialize OpenGL ES and EGL

	/*
	* Here specify the attributes of the desired configuration.
	* Below, we select an EGLConfig with at least 8 bits per color
	* component compatible with on-screen windows
	*/
	const EGLint attribs[] = {
		EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
		EGL_BLUE_SIZE, 8,
		EGL_GREEN_SIZE, 8,
		EGL_RED_SIZE, 8,
		EGL_ALPHA_SIZE, 8,
		EGL_DEPTH_SIZE, 16,
		EGL_NONE
	};
	EGLint w, h, format;
	EGLint numConfigs;
	EGLConfig config;
	EGLSurface surface;
	EGLContext context;

	EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY);

	eglInitialize(display, 0, 0);

	/* Here, the application chooses the configuration it desires. In this
	* sample, we have a very simplified selection process, where we pick
	* the first EGLConfig that matches our criteria */
	eglChooseConfig(display, attribs, &config, 1, &numConfigs);

	/* EGL_NATIVE_VISUAL_ID is an attribute of the EGLConfig that is
	* guaranteed to be accepted by ANativeWindow_setBuffersGeometry().
	* As soon as we picked a EGLConfig, we can safely reconfigure the
	* ANativeWindow buffers to match, using EGL_NATIVE_VISUAL_ID. */
	eglGetConfigAttrib(display, config, EGL_NATIVE_VISUAL_ID, &format);

	ANativeWindow_setBuffersGeometry(engine->app->window, 0, 0, format);

	surface = eglCreateWindowSurface(display, config, engine->app->window, NULL);

	const EGLint attribList[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE };
	context = eglCreateContext(display, config, EGL_NO_CONTEXT, attribList);

	if (eglMakeCurrent(display, surface, surface, context) == EGL_FALSE) {
		LOGW("Unable to eglMakeCurrent");
		return -1;
	}

	eglQuerySurface(display, surface, EGL_WIDTH, &w);
	eglQuerySurface(display, surface, EGL_HEIGHT, &h);

	engine->display = display;
	engine->context = context;
	engine->surface = surface;
	engine->width = w;
	engine->height = h;

	initEngine(engine);
	initLights(engine);
	initScene(engine);
	initParticle(engine);

	return 0;
}
Beispiel #21
0
void initGame(void)
{
	lcdMainOnTop();
	int oldv=getMemFree();
	NOGBA("mem free : %dko (%do)",getMemFree()/1024,getMemFree());
	NOGBA("initializing...");
	videoSetMode(MODE_5_3D | DISPLAY_BG3_ACTIVE);
	videoSetModeSub(MODE_5_2D | DISPLAY_BG3_ACTIVE);
	
	glInit();
	
	vramSetPrimaryBanks(VRAM_A_TEXTURE,VRAM_B_TEXTURE,VRAM_C_LCD,VRAM_D_MAIN_BG_0x06000000);
	vramSetBankH(VRAM_H_SUB_BG);
	vramSetBankI(VRAM_I_SUB_BG_0x06208000);
	
	glEnable(GL_TEXTURE_2D);
	// glEnable(GL_ANTIALIAS);
	glDisable(GL_ANTIALIAS);
	glEnable(GL_BLEND);
	glEnable(GL_OUTLINE);
	
	glSetOutlineColor(0,RGB15(0,0,0)); //TEMP?
	glSetOutlineColor(1,RGB15(0,0,0)); //TEMP?
	glSetOutlineColor(7,RGB15(31,0,0)); //TEMP?
	glSetToonTableRange(0, 15, RGB15(8,8,8)); //TEMP?
	glSetToonTableRange(16, 31, RGB15(24,24,24)); //TEMP?
	
	glClearColor(31,31,0,31);
	glClearPolyID(63);
	glClearDepth(0x7FFF);

	glViewport(0,0,255,191);
	
	// initVramBanks(1);
	initVramBanks(2);
	initTextures();
	initSound();
	
	initCamera(NULL);
	
	initPlayer(NULL);
	
	initLights();
	initParticles();
	
	initMaterials();
	
	loadMaterialSlices("slices.ini");
	loadMaterials("materials.ini");
	loadControlConfiguration("config.ini");
	
	initElevators();
	initWallDoors();
	initTurrets();
	initBigButtons();
	initTimedButtons();
	initEnergyBalls();
	initPlatforms();
	initCubes();
	initEmancipation();
	initDoors();
	initSludge();
	initPause();

	initText();

	NOGBA("lalala");

	getPlayer()->currentRoom=&gameRoom;
	
	currentBuffer=false;
	
	getVramStatus();
	fadeIn();
	
	mainBG=bgInit(3, BgType_Bmp16, BgSize_B16_256x256, 0, 0);
	bgSetPriority(mainBG, 0);
	REG_BG0CNT=BG_PRIORITY(3);
	
	#ifdef DEBUG_GAME
		consoleInit(&bottomScreen, 3, BgType_Text4bpp, BgSize_T_256x256, 16, 0, false, true);
		consoleSelect(&bottomScreen);
	#endif
	
	// glSetToonTableRange(0, 14, RGB15(16,16,16));
	// glSetToonTableRange(15, 31, RGB15(26,26,26));
	
	initPortals();
	
	//PHYSICS
	initPI9();

	strcpy(&mapFilePath[strlen(mapFilePath)-3], "map");
	newReadMap(mapFilePath, NULL, 255);
	
	transferRectangles(&gameRoom);
	makeGrid();
	generateRoomGrid(&gameRoom);
	gameRoom.displayList=generateRoomDisplayList(&gameRoom, vect(0,0,0), vect(0,0,0), false);
	
	getVramStatus();
	
	startPI();

	NOGBA("START mem free : %dko (%do)",getMemFree()/1024,getMemFree());
	NOGBA("vs mem free : %dko (%do)",oldv/1024,oldv);

	levelInfoCounter=60;
}
Beispiel #22
0
//<<<<<<<<<<<<<<<<<<<<<<< myInit >>>>>>>>>>>>>>>>>>>>
void myInit(void) {
	//create planet objects with their data
	sun = planet::Planet(1, 10.0);
	mercury = planet::Planet(doyMercury, hodMercury, daysMercury, hoursMercury,
			distanceMercury, moonsMercury, sizeMercury, AnimateInc,  2,
			12);
	venus = planet::Planet(doyVenus, hodVenus, daysVenus, hoursVenus,
			distanceVenus, moonsVenus, sizeVenus, AnimateInc,  3, 12);
	earth = planet::Planet(doyEarth, hodEarth, daysEarth, hoursEarth,
			distanceEarth, moonsEarth, sizeEarth, AnimateInc,  4, 12);
	mars = planet::Planet(doyMars, hodMars, daysMars, hoursMars, distanceMars,
			moonsMars, sizeMars, AnimateInc,  5, 12);
	jupiter = planet::Planet(doyJupiter, hodJupiter, daysJupiter, hoursJupiter,
			distanceJupiter, moonsJupiter, sizeJupiter, AnimateInc,  6,
			12);
	saturn = planet::Planet(doySaturn, hodSaturn, daysSaturn, hoursSaturn,
			distanceSaturn, moonsSaturn, sizeSaturn, AnimateInc,  7, 12);
	uranus = planet::Planet(doyUranus, hodUranus, daysUranus, hoursUranus,
			distanceUranus, moonsUranus, sizeUranus, AnimateInc,  8, 12);
	neptune = planet::Planet(doyNeptune, hodNeptune, daysNeptune, hoursNeptune,
			distanceNeptune, moonsNeptune, sizeNeptune, AnimateInc,  9,
			12);
	pluto = planet::Planet(doyPluto, hodPluto, daysPluto, hoursPluto,
			distancePluto, moonsPluto, sizePluto, AnimateInc,  10, 12);

	solarSystem.push_back(sun);
	solarSystem.push_back(mercury);
	solarSystem.push_back(venus);
	solarSystem.push_back(earth);
	solarSystem.push_back(mars);
	solarSystem.push_back(jupiter);
	solarSystem.push_back(saturn);
	solarSystem.push_back(uranus);
	solarSystem.push_back(neptune);
	solarSystem.push_back(pluto);

	//read texture files and set textures
	pix[1].parseFile("images/sun.txt");
	pix[1].setTexture(1); // create texture

	pix[2].parseFile("images/mercury.txt");
	pix[2].setTexture(2); // create texture

	pix[3].parseFile("images/venus.txt");
	pix[3].setTexture(3); // create texture

	pix[4].parseFile("images/earth.txt");
	pix[4].setTexture(4); // create texture

	pix[5].parseFile("images/mars.txt");
	pix[5].setTexture(5); // create texture

	pix[6].parseFile("images/jupiter.txt");
	pix[6].setTexture(6); // create texture

	pix[7].parseFile("images/saturn.txt");
	pix[7].setTexture(7); // create texture

	pix[8].parseFile("images/uranus.txt");
	pix[8].setTexture(8); // create texture

	pix[9].parseFile("images/neptune.txt");
	pix[9].setTexture(9); // create texture

	pix[10].parseFile("images/pluto.txt");
	pix[10].setTexture(10); // create texture

	pix[11].parseFile("images/stars.txt");
	pix[11].setTexture(11); // skybox texture

	pix[12].parseFile("images/kaiokenx4.txt");
	pix[12].setTexture(12); // moon texture

	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	gluOrtho2D(0.0, WIDTH, 0.0, HEIGHT);

	glShadeModel( GL_SMOOTH);
	glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // background is white
	glClearDepth(1.0);
	glEnable( GL_DEPTH_TEST);
	glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
	initLights();
}
Beispiel #23
0
void pressNormalKeys(unsigned char key, int x, int y)
{
	if(key == 27) // ESC
	{
		destroyObjects();
		exit(0);

	}
	else if(key == '1')
	{
		glPolygonMode(GL_FRONT_AND_BACK, GL_POINT);
	}
	else if(key == '2')
	{
		glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
	}
	else if(key == '3')
	{
		glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
	}
	else if(key == '4'){
		turnLinearFogOn();
		FOG_ON = 1;
	}
	else if(key == '5'){
		turnExpFogOn();
		FOG_ON = 1;
	}
	else if(key == '6'){
		turnExp2FogOn();
		FOG_ON = 1;
	}
	else if(key == '7'){
		glDisable(GL_FOG);
		FOG_ON = 0;
	}
	else if((key == 'A') || (key == 'a'))
	{
		_camera->deltaAnglev = 0.02f;
	}
	else if((key == 'Z') || (key == 'z'))
	{
		_camera->deltaAnglev = -0.02f;
	}
	else if((key == 'S') || (key == 's'))
	{
		_camera->deltaSpeed = 0.01f;
	}
	else if((key == 'X') || (key == 'x'))
	{
		_camera->deltaSpeed = -0.01f;
	}
	else if((key == 'N') || (key == 'n'))
	{
		glutLeaveGameMode();
		
		OGLWindow_initWindowMode();
		
				// Inicializações
		init();
		initCamera();
		initLights();
		initGameTime();
		SSController_Initialize();

		// Registar funções de callback
		glutDisplayFunc(display);
		glutReshapeFunc(reshape);
		glutIdleFunc(display);
		glutIgnoreKeyRepeat(1);
		glutKeyboardFunc(pressNormalKeys);
		glutKeyboardUpFunc(releaseNormalKeys);
		glutSpecialFunc(pressSpecialKey);
		glutSpecialUpFunc(releaseSpecialKey);
		glutMotionFunc(mouseMove);

	// - Directly redirect GLUT mouse button events to AntTweakBar
	glutMouseFunc((GLUTmousebuttonfun)TwEventMouseButtonGLUT);
	// - Directly redirect GLUT mouse "passive" motion events to AntTweakBar (same as MouseMotion)
	glutPassiveMotionFunc((GLUTmousemotionfun)TwEventMouseMotionGLUT);
	}
	else if((key == 'F') || (key == 'f'))
	{
		OGLWindow_initGameMode();
		
		// Inicializações
		init();
		initCamera();
		initLights();
		initGameTime();
		SSController_Initialize();

		// Registar funções de callback
		glutDisplayFunc(display);
		glutReshapeFunc(reshape);
		glutIdleFunc(display);
		glutIgnoreKeyRepeat(1);
		glutKeyboardFunc(pressNormalKeys);
		glutKeyboardUpFunc(releaseNormalKeys);
		glutSpecialFunc(pressSpecialKey);
		glutSpecialUpFunc(releaseSpecialKey);
		glutMotionFunc(mouseMove);

	// - Directly redirect GLUT mouse button events to AntTweakBar
	glutMouseFunc((GLUTmousebuttonfun)TwEventMouseButtonGLUT);
	// - Directly redirect GLUT mouse "passive" motion events to AntTweakBar (same as MouseMotion)
	glutPassiveMotionFunc((GLUTmousemotionfun)TwEventMouseMotionGLUT);

	} else if(key=='U' || key=='u') {
		TimeScale -= 10.0f;
	} else if(key=='I' || key=='i') {
		TimeScale += 10.0f;
	} else if(key=='O' || key=='o') {
		Planet_setOrbitVisibility(!Planet_getOrbitVisibility());
		orbits = !orbits;
	} else if(key=='C' || key=='c') {
		manualCam = !manualCam;
	}
}