/** \brief Create the GUI object. * * Creates the GUI and sets its "visible" state. * \param vis Set "visible" state. Defaults to true. */ CGUIMain::CGUIMain(bool vis) : visible(vis) { fntInit(); puInit(); puSetDefaultStyle(PUSTYLE_SMALL_BEVELLED); // Light grey, no transparency puSetDefaultColourScheme(0.85, 0.85, 0.85, 1.0); // Menu entries and callback mapping // Caution: submenu-entries must be declared in reverse order! // File menu const char *file_submenu[] = {_("Exit"), _("Save this Flight's Log as.."),_("Save Settings"), NULL}; static puCallback file_submenu_cb[] = {file_exit_cb, file_set_record_cb, file_save_cb, NULL}; // View submenu const char *view_submenu[] = { _("Inspect Wind"), _("Reset Zoom"),_("Zoom -"), _("Zoom +"), _("Toggle Verbosity"), _("Toggle Wind vectors"), _("Toggle HUD Compass"), _("Toggle Test Mode"), _("Toggle Training Mode"), _("Toggle Fullscreen"), NULL}; puCallback view_submenu_cb[] = { view_wind_cb, view_unzoom_cb, view_zoomout_cb, view_zoomin_cb, view_verbosity_cb, view_windvectors_cb, view_hudcompass_cb, view_testmode_cb, view_train_cb, view_fullsc_cb, NULL}; // Simulation menu const char *sim_submenu[] = {_("Restart"), NULL}; puCallback sim_submenu_cb[] = {sim_restart_cb, NULL}; // Options menu const char *opt_submenu[] = {_("Audio"), _("Controls"), _("Video"), _("Wind, Thermals"), _("Launch"), _("Location"), _("Airplane"), NULL}; puCallback opt_submenu_cb[] = { opt_audio_cb, opt_ctrl_general_cb, opt_video_cb, opt_windthermal_cb, opt_launch_cb, opt_location_cb, opt_plane_cb, NULL}; // Game menu const char *game_submenu[] = {"F3F", NULL}; static puCallback game_submenu_cb[] = {game_f3f_cb, NULL}; // Help menu const char *help_submenu[] = {_("About"), _("Keys"), _("Help"), NULL}; puCallback help_submenu_cb[] = {help_about_cb, help_keys_cb, help_web_cb, NULL}; // Robots menu const char *robot_submenu[] = {_("Remove all Robots"), _("Load Robot"), NULL}; puCallback robot_submenu_cb[] = {robot_rm_all_cb, robot_load_cb, NULL}; // create the menu bar main_menu_bar = new puMenuBar() ; main_menu_bar->add_submenu(_("File"), (char**)file_submenu, file_submenu_cb); main_menu_bar->add_submenu(_("View"), (char**)view_submenu, view_submenu_cb); main_menu_bar->add_submenu(_("Simulation"), (char**)sim_submenu, sim_submenu_cb); main_menu_bar->add_submenu(_("Options"), (char**)opt_submenu, opt_submenu_cb); main_menu_bar->add_submenu(_("Game"), (char**)game_submenu, game_submenu_cb); main_menu_bar->add_submenu(_("Robots"), (char**)robot_submenu, robot_submenu_cb); main_menu_bar->add_submenu(_("Help"), (char**)help_submenu, help_submenu_cb); main_menu_bar->close(); // create the verbosity display verboseOutput = new puText(30, 30); verboseOutput->setColour(PUCOL_LABEL, 1, 0.1, 0.1); if (Video::textureFont) { verboseOutput->setLabelFont(Video::textureFont); } verboseOutput->reveal(); // create the text widgets for HUD compass for( int i = 0; i <= nCompass; i++ ) { compass_x[i] = new puText(0, 0); compass_x[i]->setColour(PUCOL_LABEL, 1., 0.1, 0.1, 0.7); compass_x[i]->setLabelPlace(PUPLACE_BOTTOM_CENTERED); if (Video::window_xsize > 800) //compass_x[i]->setLabelFont(PUFONT_HELVETICA_18); compass_x[i]->setLabel(""); compass_x[i]->hide(); } for( int i = 0; i <= nCompass; i++ ) { compass_y[i] = new puText(0, 0); compass_y[i]->setColour(PUCOL_LABEL, 1., 0.1, 0.1, 0.7); compass_y[i]->setLabelPlace(PUPLACE_CENTERED_RIGHT); if (Video::window_xsize > 800) //compass_y[i]->setLabelFont(PUFONT_HELVETICA_18); compass_y[i]->setLabel(""); compass_y[i]->hide(); } // show or hide the GUI if (visible) { main_menu_bar->reveal(); SDL_ShowCursor(SDL_ENABLE); } else { main_menu_bar->hide(); if (Global::TXInterface->inputMethod() == T_TX_Interface::eIM_mouse) SDL_ShowCursor(SDL_ENABLE); else SDL_ShowCursor(SDL_DISABLE); } }
void begin() { // old-BATB didn't like to be initialized more than once :( // hence, ignore re-init for specified parts, and continue with previous state static bool empty = true; // clear exit, making possible to start over again //do_exit = false; // copied from old::main: //MainWindow::winPosX = 100; //MainWindow::winPosY = 100; //MainWindow::winWidth = 640; //MainWindow::winHeight = 480; // init glut //glutInitWindowPosition(MainWindow::winPosX, MainWindow::winPosY); //glutInitWindowSize (MainWindow::winWidth, MainWindow::winHeight); //glutInit (&argc, argv); //glutInitDisplayMode (GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); //MainWindow::main_window = glutCreateWindow("Beat About the Bush"); MainWindow::enableDisplayFunc(); // implemented as GLFW: GLFWwindow* win = glfwGetCurrentContext(); glfwSetKeyCallback( win, MainWindow::glfwKey ); //glutKeyboardFunc (MainWindow::keyDownFn); //glutSpecialFunc (MainWindow::specialDownFn); ////glutKeyboardUpFunc (MainWindow::keyUpFn); ////glutSpecialUpFunc (MainWindow::specialUpFn); glfwSetCursorPosCallback( win, MainWindow::glfwCursorPos ); //glutMouseFunc (MainWindow::mousefn); glfwSetMouseButtonCallback( win, MainWindow::glfwMouseButton); //glutMotionFunc (MainWindow::motionfn); glfwSetWindowSizeCallback( win, MainWindow::glfwWindowSize ); //glutReshapeFunc (MainWindow::reshapefn); glfwSetWindowFocusCallback( win, MainWindow::glfwWindowFocus ); //glutVisibilityFunc (MainWindow::visibility); if ( empty ) { // init plib, with no GLUT-binding! puInitOLD(); puSetDefaultStyle ( PUSTYLE_SMALL_SHADED ); puSetDefaultColourScheme ( 0.3f, 0.4f, 0.6f, 1.0f); // Initialize the "OpenGL Extension Wrangler" library //glewInit(); } mainWindow.initLights(); if ( empty ) { mainWindow.init(); printVersions(); // Make sure that OpenGL 2.0 is supported by the driver int gl_major, gl_minor; getGlVersion(&gl_major, &gl_minor); printf("GL_VERSION major=%d minor=%d\n", gl_major, gl_minor); if (gl_major < 2) { printf("GL_VERSION major=%d minor=%d\n", gl_major, gl_minor); printf("Support for OpenGL 2.0 is required for this demo...exiting\n"); //exit(1); old::exit(1); return; } // init shaders GLchar *dayVSSource, *dayFSSource; readShaderSource( old::file("shader/day").c_str(), &dayVSSource, &dayFSSource); dayShader = installShaders(dayVSSource, dayFSSource); float forestGreen[] = {34.0/255, 139.0/255, 34.0/255}; //float auburn[] = {113.0/255, 47.0/255, 38.0/255}; float grey[] = {0.5, 0.5, 0.5}; //float sepia[] = {112.0/255, 66.0/255, 20.0/255}; setUniform3f(dayShader, "GrassColor", forestGreen[0], forestGreen[1], forestGreen[2]); setUniform3f(dayShader, "RockColor", grey[0], grey[1], grey[2]); //setUniform3f(dayShader, "DirtColor", sepia[0], sepia[1], sepia[2]); //setUniform4f(dayShader, "LightPos", 0.0, 0.0, 100.0, 1.0); setUniform1f(dayShader, "Scale", 1.0); setUniform1f(dayShader, "TerrainHigh", 0.1); setUniform1f(dayShader, "TerrainLow", 0.1); setUniform1i(dayShader, "Trees", 0); // sampler setUniform1i(dayShader, "AltGrad", 1); // sampler setUniform1i(dayShader, "Noise", 2); // sampler GLchar *nightVSSource, *nightFSSource; readShaderSource( old::file("shader/night3").c_str(), &nightVSSource, &nightFSSource); nightShader = installShaders(nightVSSource, nightFSSource); setUniform3f(nightShader, "BrickColor", 1.0, 0.3, 0.2); setUniform3f(nightShader, "MortarColor", 0.85, 0.86, 0.84); setUniform2f(nightShader, "BrickSize", 0.30, 0.15); setUniform2f(nightShader, "BrickPct", 0.90, 0.85); setUniform1i(nightShader, "numEnabledLights", 2); setUniform3f(nightShader, "GrassColor", forestGreen[0], forestGreen[1], forestGreen[2]); setUniform3f(nightShader, "RockColor", grey[0], grey[1], grey[2]); setUniform1f(nightShader, "Scale", 1.0); setUniform1f(nightShader, "TerrainHigh", 0.1); setUniform1f(nightShader, "TerrainLow", 0.1); setUniform1i(nightShader, "Trees", 0); // sampler setUniform1i(nightShader, "AltGrad", 1); // sampler setUniform1i(nightShader, "Noise", 2); // sampler GLchar *nightTreeVS, *nightTreeFS; readShaderSource( old::file("shader/nightTree").c_str(), &nightTreeVS, &nightTreeFS); nightTrees = installShaders(nightTreeVS, nightTreeFS); setUniform1i(nightTrees, "Trees", 0); // sampler // BUGFIX: free( dayVSSource ); free( dayFSSource ); free( nightVSSource ); free( nightFSSource ); free( nightTreeVS ); free( nightTreeFS ); } // enter main loop //if (dayShader && nightShader) // glutMainLoop(); //return 0; empty = false; }