int MENUS::render() { RECT screen = *ui_screen(); gfx_mapscreen(screen.x, screen.y, screen.w, screen.h); static bool first = true; if(first) { if(config.ui_page == PAGE_INTERNET) client_serverbrowse_refresh(0); else if(config.ui_page == PAGE_LAN) client_serverbrowse_refresh(1); first = false; } if(client_state() == CLIENTSTATE_ONLINE) { color_tabbar_inactive = color_tabbar_inactive_ingame; color_tabbar_active = color_tabbar_active_ingame; } else { render_background(); color_tabbar_inactive = color_tabbar_inactive_outgame; color_tabbar_active = color_tabbar_active_outgame; } RECT tab_bar; RECT main_view; // some margin around the screen ui_margin(&screen, 10.0f, &screen); if(popup == POPUP_NONE) { // do tab bar ui_hsplit_t(&screen, 24.0f, &tab_bar, &main_view); ui_vmargin(&tab_bar, 20.0f, &tab_bar); render_menubar(tab_bar); // news is not implemented yet if(config.ui_page <= PAGE_NEWS || config.ui_page > PAGE_SETTINGS || (client_state() == CLIENTSTATE_OFFLINE && config.ui_page >= PAGE_GAME && config.ui_page <= PAGE_CALLVOTE)) { client_serverbrowse_refresh(BROWSETYPE_INTERNET); config.ui_page = PAGE_INTERNET; } // render current page if(client_state() != CLIENTSTATE_OFFLINE) { if(game_page == PAGE_GAME) render_game(main_view); else if(game_page == PAGE_SERVER_INFO) render_serverinfo(main_view); else if(game_page == PAGE_CALLVOTE) render_servercontrol(main_view); else if(game_page == PAGE_SETTINGS) render_settings(main_view); } else if(config.ui_page == PAGE_NEWS) render_news(main_view); else if(config.ui_page == PAGE_INTERNET) render_serverbrowser(main_view); else if(config.ui_page == PAGE_LAN) render_serverbrowser(main_view); else if(config.ui_page == PAGE_DEMOS) render_demolist(main_view); else if(config.ui_page == PAGE_FAVORITES) render_serverbrowser(main_view); else if(config.ui_page == PAGE_SETTINGS) render_settings(main_view); // else if(config.ui_page == PAGE_TEE-NG) // renger_settings(main_teeng); } else { // make sure that other windows doesn't do anything funnay! //ui_set_hot_item(0); //ui_set_active_item(0); char buf[128]; const char *title = ""; const char *extra_text = ""; const char *button_text = ""; int extra_align = 0; if(popup == POPUP_MESSAGE) { title = message_topic; extra_text = message_body; button_text = message_button; } else if(popup == POPUP_CONNECTING) { title = localize("Connecting to"); extra_text = config.ui_server_address; // TODO: query the client about the address button_text = localize("Abort"); if(client_mapdownload_totalsize() > 0) { title = localize("Downloading map"); str_format(buf, sizeof(buf), "%d/%d KiB", client_mapdownload_amount()/1024, client_mapdownload_totalsize()/1024); extra_text = buf; } } else if(popup == POPUP_DISCONNECTED) { title = localize("Disconnected"); extra_text = client_error_string(); button_text = localize("Ok"); extra_align = -1; } else if(popup == POPUP_PURE) { title = localize("Disconnected"); extra_text = localize("The server is running a non-standard tuning on a pure game type."); button_text = localize("Ok"); extra_align = -1; } else if(popup == POPUP_PASSWORD) { title = localize("Password Incorrect"); extra_text = client_error_string(); button_text = localize("Try again"); } else if(popup == POPUP_QUIT) { title = localize("Quit"); extra_text = localize("Are you sure that you want to quit?"); } else if(popup == POPUP_FIRST_LAUNCH) { title = localize("Welcome to Teeworlds"); extra_text = localize("As this is the first time you launch the game, please enter your nick name below. It's recommended that you check the settings to adjust them to your liking before joining a server."); button_text = localize("Ok"); extra_align = -1; } RECT box, part; box = screen; ui_vmargin(&box, 150.0f, &box); ui_hmargin(&box, 150.0f, &box); // render the box ui_draw_rect(&box, vec4(0,0,0,0.5f), CORNER_ALL, 15.0f); ui_hsplit_t(&box, 20.f, &part, &box); ui_hsplit_t(&box, 24.f, &part, &box); ui_do_label(&part, title, 24.f, 0); ui_hsplit_t(&box, 20.f, &part, &box); ui_hsplit_t(&box, 24.f, &part, &box); ui_vmargin(&part, 20.f, &part); if(extra_align == -1) ui_do_label(&part, extra_text, 20.f, -1, (int)part.w); else ui_do_label(&part, extra_text, 20.f, 0, -1); if(popup == POPUP_QUIT) { RECT yes, no; ui_hsplit_b(&box, 20.f, &box, &part); ui_hsplit_b(&box, 24.f, &box, &part); ui_vmargin(&part, 80.0f, &part); ui_vsplit_mid(&part, &no, &yes); ui_vmargin(&yes, 20.0f, &yes); ui_vmargin(&no, 20.0f, &no); static int button_abort = 0; if(ui_do_button(&button_abort, localize("No"), 0, &no, ui_draw_menu_button, 0) || escape_pressed) popup = POPUP_NONE; static int button_tryagain = 0; if(ui_do_button(&button_tryagain, localize("Yes"), 0, &yes, ui_draw_menu_button, 0) || enter_pressed) client_quit(); } else if(popup == POPUP_PASSWORD) { RECT label, textbox, tryagain, abort; ui_hsplit_b(&box, 20.f, &box, &part); ui_hsplit_b(&box, 24.f, &box, &part); ui_vmargin(&part, 80.0f, &part); ui_vsplit_mid(&part, &abort, &tryagain); ui_vmargin(&tryagain, 20.0f, &tryagain); ui_vmargin(&abort, 20.0f, &abort); static int button_abort = 0; if(ui_do_button(&button_abort, localize("Abort"), 0, &abort, ui_draw_menu_button, 0) || escape_pressed) { if(config.cl_autoconnect) config.cl_autoconnect == 0; else popup = POPUP_NONE; } static int button_tryagain = 0; if(ui_do_button(&button_tryagain, localize("Try again"), 0, &tryagain, ui_draw_menu_button, 0) || enter_pressed) { client_connect(config.ui_server_address); } ui_hsplit_b(&box, 60.f, &box, &part); ui_hsplit_b(&box, 24.f, &box, &part); ui_vsplit_l(&part, 60.0f, 0, &label); ui_vsplit_l(&label, 100.0f, 0, &textbox); ui_vsplit_l(&textbox, 20.0f, 0, &textbox); ui_vsplit_r(&textbox, 60.0f, &textbox, 0); ui_do_label(&label, localize("Password"), 20, -1); ui_do_edit_box(&config.password, &textbox, config.password, sizeof(config.password), 14.0f, true); } else if(popup == POPUP_FIRST_LAUNCH) { RECT label, textbox; ui_hsplit_b(&box, 20.f, &box, &part); ui_hsplit_b(&box, 24.f, &box, &part); ui_vmargin(&part, 80.0f, &part); static int enter_button = 0; if(ui_do_button(&enter_button, localize("Enter"), 0, &part, ui_draw_menu_button, 0) || enter_pressed) popup = POPUP_NONE; ui_hsplit_b(&box, 40.f, &box, &part); ui_hsplit_b(&box, 24.f, &box, &part); ui_vsplit_l(&part, 60.0f, 0, &label); ui_vsplit_l(&label, 100.0f, 0, &textbox); ui_vsplit_l(&textbox, 20.0f, 0, &textbox); ui_vsplit_r(&textbox, 60.0f, &textbox, 0); ui_do_label(&label, localize("Nickname"), 20, -1); ui_do_edit_box(&config.player_name, &textbox, config.player_name, sizeof(config.player_name), 14.0f); } else { ui_hsplit_b(&box, 20.f, &box, &part); ui_hsplit_b(&box, 24.f, &box, &part); ui_vmargin(&part, 120.0f, &part); static int button = 0; if(ui_do_button(&button, button_text, 0, &part, ui_draw_menu_button, 0) || escape_pressed || enter_pressed) { if(popup == POPUP_CONNECTING) client_disconnect(); popup = POPUP_NONE; } } } return 0; }
int main(int argc, char** argv) { int x = 0, y = 0, sample = 0, subpixel = 0; int i = 1; while (true) { if (i >= argc) break; if (std::string(argv[i]).compare("-x") == 0) { i++; x = atoi(argv[i]); i++; continue; } if (std::string(argv[i]).compare("-y") == 0) { i++; y = atoi(argv[i]); i++; continue; } if (std::string(argv[i]).compare("-s") == 0) { i++; sample = atoi(argv[i]); i++; continue; } if (std::string(argv[i]).compare("-p") == 0) { i++; subpixel = atoi(argv[i]); i++; continue; } } if (x == 0 || y == 0 || sample == 0 || subpixel == 0) { std::cout << "argv error. using default setting." << std::endl; x = 640; y = 480; sample = 4; subpixel = 2; } std::cout << "width:" << x << std::endl; std::cout << "height:" << y << std::endl; std::cout << "sample:" << sample << std::endl; std::cout << "subpixel:" << subpixel << std::endl; Setting render_settings(x, y, sample, subpixel); Camera cam(Imath::V3d(50.0, 52.0, 220.0), Imath::V3d(0.0, -0.04, -30.0).normalized(), Imath::V3d(0.0, -1.0, 0.0)); Screen screen(cam, render_settings); ImageBuffer image(render_settings.reso_w * render_settings.reso_h); //Mesh mesh = Mesh(); //mesh.push_back(Triangle(Imath::V3d(12.8, 5.0, -10), Imath::V3d(5.0, 20.0, -10), Imath::V3d(20.0, 20.0, -10))); //Geometry geom(mesh, Imath::V3d(0, 0, 0), Imath::C3f(0.7, 0.5, 0.5)); //Geometry geom(mesh, Imath::V3d(0, 0, 0), Imath::C3f(0.7, 0.5, 0.5)); Scene scene; //scene.geometries.push_back(geom); scene.geometries.push_back(Geometry(Sphere(Imath::V3d(1e5 + 1, 40.8, 81.6), 1e5), Imath::V3d(1e5 + 1, 40.8, 81.6), Imath::C3f(0.75, 0.25, 0.25), Imath::C3f(0, 0, 0), Reflection::Diffuse)); scene.geometries.push_back(Geometry(Sphere(Imath::V3d(-1e5 + 99, 40.8, 81.6), 1e5), Imath::V3d(-1e5 + 99, 40.8, 81.6), Imath::C3f(0.25, 0.25, 0.75), Imath::C3f(0, 0, 0), Reflection::Diffuse)); scene.geometries.push_back(Geometry(Sphere(Imath::V3d(50, 40.8, 1e5), 1e5), Imath::V3d(50, 40.8, 1e5), Imath::C3f(0.75, 0.75, 0.75), Imath::C3f(0, 0, 0), Reflection::Diffuse)); scene.geometries.push_back(Geometry(Sphere(Imath::V3d(50, 40.8, -1e5 + 250), 1e5), Imath::V3d(50, 40.8, -1e5 + 250), Imath::C3f(0.0, 0.0, 0.0), Imath::C3f(0, 0, 0), Reflection::Diffuse)); scene.geometries.push_back(Geometry(Sphere(Imath::V3d(50, 1e5, 81.6), 1e5), Imath::V3d(50, 1e5, 81.6), Imath::C3f(0.75, 0.75, 0.75), Imath::C3f(0, 0, 0), Reflection::Diffuse)); scene.geometries.push_back(Geometry(Sphere(Imath::V3d(50, -1e5 + 81.6, 81.6), 1e5), Imath::V3d(50, -1e5 + 81.6, 81.6), Imath::C3f(0.75, 0.75, 0.75), Imath::C3f(0, 0, 0), Reflection::Diffuse)); scene.geometries.push_back(Geometry(Sphere(Imath::V3d(65, 20, 20), 20), Imath::V3d(65, 20, 20), Imath::C3f(0.25, 0.75, 0.25), Imath::C3f(0, 0, 0), Reflection::Diffuse)); scene.geometries.push_back(Geometry(Sphere(Imath::V3d(27, 16.5, 47), 16.5), Imath::V3d(27, 16.5, 47), Imath::C3f(0.99, 0.99, 0.99), Imath::C3f(0, 0, 0), Reflection::Specular)); scene.geometries.push_back(Geometry(Sphere(Imath::V3d(77, 16.5, 78), 16.5), Imath::V3d(77, 16.5, 78), Imath::C3f(0.99, 0.99, 0.99), Imath::C3f(0, 0, 0), Reflection::Refraction)); scene.geometries.push_back(Geometry(Sphere(Imath::V3d(50, 90, 81.6), 15.0), Imath::V3d(50, 90, 81.6), Imath::C3f(0.0, 0.0, 0.0), Imath::C3f(36, 36, 36), Reflection::Diffuse)); //scene.geometries.push_back(Geometry(Triangle(Imath::V3d(12.8, 5.0, -10), Imath::V3d(5.0, 20.0, -10), Imath::V3d(20.0, 20.0, -10)), Imath::V3d(65, 20, 20), Imath::C3f(0.75, 0.75, 0.75), Imath::C3f(0, 0, 0), Reflection::Diffuse)); render(render_settings,cam,screen,scene,image); write_bmp("out_complete.bmp", image, render_settings); return 0; }
int main(void) { int done=0; srand(time(NULL)); initXWindows(); init_opengl(); //declare game object Game game; game.numberDefenseMissiles=0; //JG game.nparticles=MAX_PARTICLES; game.numberDefenseMissiles=0; // JBC 5/19/16 // added globally accesible defMissileSpeed so that we can // change it dynamically game.defMissileSpeed = 10; initStruc(&game); //Structures sh; //Changed call for function prototype 5-17-16 -DT createEMissiles(&game, 0, 0); initRadar(&game); initUFO(&game); initHighScores(&game); //JR - Menu Object Shapes and Locations drawMenu(&game); drawSettings(&game); game.sounds.loadAudio(); //start animation while (!done) { int state = gameState(&game); while (XPending(dpy)) { XEvent e; XNextEvent(dpy, &e); check_mouse(&e, &game); done = check_keys(&e, &game); } if (state == 1) { render_menu(&game); } else if (state == 2) { drawSettings(&game); render_settings(&game); } else if (state == 3) { render_newgame(&game); } else if (state == 0 || state == 5) { if (lvlState(&game) < 0) { movement(&game); render(&game); } if (lvlState(&game) == 1) { levelEnd(&game); } } else { render_gameover(&game); } glXSwapBuffers(dpy, win); } cleanupXWindows(); return 0; }