/* ** This is the initializer function of the display structure. ** It puts every parameter to default value, then creates the window ** and prints the loading screen before loading the assets. */ int init_display(t_display *d) { if (init_structures(d) == -1) return (-1); if (SDL_Init(SDL_INIT_EVERYTHING) || TTF_Init()) return (-1); SDL_WM_SetCaption("Zappy", NULL); d->w = SDL_SetVideoMode(1440, 900, 32, SDL_SWSURFACE); d->loading_screen = SDL_LoadBMP("./assets/screens/loading_screen.bmp"); if (d->w == NULL || d->loading_screen == NULL) return (-1); display_loading_screen(d, 0); if (launch_music(d) == -1) return (-1); d->font = TTF_OpenFont("./assets/fonts/filxgirl.ttf", 30); if (!d->font) return (-1); load_images(d); if (strlen(SDL_GetError()) > 0) return (-1); if (display_loading_screen(d, 1) == -1) return (-1); return (0); }
void Renderer::renderclient(Mailbox in) { FpsCounter fpsc(20); fpsc.start(); for (auto& cmd : gua::concurrent::pull_items_range<Item, Mailbox>(in)) { auto window_name(cmd.serialized_cam->config.get_output_window_name()); if (window_name != "") { auto window = WindowDatabase::instance()->lookup(window_name); if (window && !window->get_is_open()) { window->open(); } // update window if one is assigned if (window && window->get_is_open()) { window->set_active(true); window->start_frame(); if (window->get_context()->framecount == 0) { display_loading_screen(*window); } // make sure pipeline was created std::shared_ptr<Pipeline> pipe = nullptr; auto pipe_iter = window->get_context()->render_pipelines.find( cmd.serialized_cam->uuid); if (pipe_iter == window->get_context()->render_pipelines.end()) { pipe = std::make_shared<Pipeline>( *window->get_context(), cmd.serialized_cam->config.get_resolution()); window->get_context()->render_pipelines.insert( std::make_pair(cmd.serialized_cam->uuid, pipe)); } else { pipe = pipe_iter->second; } window->rendering_fps = fpsc.fps; if (cmd.serialized_cam->config.get_enable_stereo()) { if (window->config.get_stereo_mode() == StereoMode::NVIDIA_3D_VISION) { #ifdef GUACAMOLE_ENABLE_NVIDIA_3D_VISION if ((window->get_context()->framecount % 2) == 0) { auto img(pipe->render_scene(CameraMode::LEFT, *cmd.serialized_cam, *cmd.scene_graphs)); if (img) window->display(img, true); } else { auto img(pipe->render_scene(CameraMode::RIGHT, *cmd.serialized_cam, *cmd.scene_graphs)); if (img) window->display(img, false); } #else Logger::LOG_WARNING << "guacamole has not been compiled with NVIDIA 3D Vision support!" << std::endl; #endif } else { // TODO: add alternate frame rendering here? -> take clear and render methods auto img(pipe->render_scene(CameraMode::LEFT, *cmd.serialized_cam, *cmd.scene_graphs)); if (img) window->display(img, true); img = pipe->render_scene(CameraMode::RIGHT, *cmd.serialized_cam, *cmd.scene_graphs); if (img) window->display(img, false); } } else { auto img(pipe->render_scene(cmd.serialized_cam->config.get_mono_mode(), *cmd.serialized_cam, *cmd.scene_graphs)); if (img) window->display(img, cmd.serialized_cam->config.get_mono_mode() != CameraMode::RIGHT); } pipe->clear_frame_cache(); // swap buffers window->finish_frame(); ++(window->get_context()->framecount); fpsc.step(); } } } }
void Renderer::draw_single_threaded(std::vector<SceneGraph const*> const& scene_graphs) { for (auto graph : scene_graphs) { graph->update_cache(); } auto sgs = garbage_collected_copy(scene_graphs); for (auto graph : scene_graphs) { for (auto& cam : graph->get_camera_nodes()) { auto window_name(cam->config.get_output_window_name()); auto serialized_cam(cam->serialize()); if (window_name != "") { auto window = WindowDatabase::instance()->lookup(window_name); if (window && !window->get_is_open()) { window->open(); } // update window if one is assigned if (window && window->get_is_open()) { window->set_active(true); window->start_frame(); if (window->get_context()->framecount == 0) { display_loading_screen(*window); } // make sure pipeline was created std::shared_ptr<Pipeline> pipe = nullptr; auto pipe_iter = window->get_context()->render_pipelines.find( serialized_cam.uuid); if (pipe_iter == window->get_context()->render_pipelines.end()) { pipe = std::make_shared<Pipeline>( *window->get_context(), serialized_cam.config.get_resolution()); window->get_context()->render_pipelines.insert( std::make_pair(serialized_cam.uuid, pipe)); } else { pipe = pipe_iter->second; } window->rendering_fps = application_fps_.fps; if (serialized_cam.config.get_enable_stereo()) { if (window->config.get_stereo_mode() == StereoMode::NVIDIA_3D_VISION) { #ifdef GUACAMOLE_ENABLE_NVIDIA_3D_VISION if ((window->get_context()->framecount % 2) == 0) { auto img(pipe->render_scene(CameraMode::LEFT, serialized_cam, *sgs)); if (img) window->display(img, true); } else { auto img(pipe->render_scene(CameraMode::RIGHT, serialized_cam, *sgs)); if (img) window->display(img, false); } #else Logger::LOG_WARNING << "guacamole has not been compiled with NVIDIA 3D Vision support!" << std::endl; #endif } else { auto img(pipe->render_scene(CameraMode::LEFT, serialized_cam, *sgs)); if (img) window->display(img, true); img = pipe->render_scene(CameraMode::RIGHT, serialized_cam, *sgs); if (img) window->display(img, false); } } else { auto img(pipe->render_scene(serialized_cam.config.get_mono_mode(), serialized_cam, *sgs)); if (img) window->display(img, serialized_cam.config.get_mono_mode() != CameraMode::RIGHT); } pipe->clear_frame_cache(); // swap buffers window->finish_frame(); ++(window->get_context()->framecount); } } } } application_fps_.step(); }