Example #1
0
  Console_State::Console_State()
    : m_virtual_screen(Point2f(0.0f, 0.0f), Point2f(float(get_Window().get_width() * 600.0f / get_Window().get_height()), 600.0f)),
    m_projector(m_virtual_screen),
    m_bg(Vertex2f_Color(Point2f(0.0f, 0.0f), get_Colors()["console_border"]),
         Vertex2f_Color(Point2f(0.0f, 54.0f + 7.0f * get_Fonts()["system_36_x600"].get_text_height()), get_Colors()["console_border"]),
         Vertex2f_Color(Point2f(m_virtual_screen.second.x, 54.0f + 7.0f * get_Fonts()["system_36_x600"].get_text_height()), get_Colors()["console_border"]),
         Vertex2f_Color(Point2f(m_virtual_screen.second.x, 0.0f), get_Colors()["console_border"])),
    m_log(Point2f(18.0f, 18.0f),
          Point2f(m_virtual_screen.second.x - 18.0f,
                  18.0f + 6.0f * get_Fonts()["system_36_x600"].get_text_height()),
          "system_36_x600",
          "",
          get_Colors()["console_foreground"],
          false),
    m_prompt(Point2f(18.0f, 36.0f + 6.0f * get_Fonts()["system_36_x600"].get_text_height()),
             Point2f(m_virtual_screen.second.x - 18.0f,
                     36.0f + 7.0f * get_Fonts()["system_36_x600"].get_text_height()),
             "system_36_x600",
             "",
             get_Colors()["console_foreground"],
             true),
    m_log_dirty(false),
    m_child(0)
  {
    m_functions["args"] = new Console_Function;

    m_log.give_BG_Renderer(new Widget_Renderer_Color(get_Colors()["console_background"]));
    m_prompt.give_BG_Renderer(new Widget_Renderer_Color(get_Colors()["console_background"]));
  }
Example #2
0
  bool Video_DX9::begin_prerender() {
    assert(!m_render_target && !m_render_to_surface);

    if(g_video_dx9_reset) {
      const HRESULT result = m_d3d_device->TestCooperativeLevel();
      
      if(result == D3DERR_DEVICELOST)
        return false;
      else if(result == D3DERR_DRIVERINTERNALERROR)
        throw Video_Device_Failure();
      
      if(result == D3DERR_DEVICENOTRESET) {
        if(FAILED(m_d3d_device->Reset(m_d3d_parameters)))
          throw Video_Device_Failure();
      
        g_video_dx9_reset = false;

        init_context();
      }
    }

    get_Textures().unlose_resources();
    get_Fonts().unlose_resources();

    return true;
  }
Example #3
0
  void Video_GL::render_all() {
    assert(!m_render_target);

#ifdef _WINDOWS
    glFlush();
#else
    glFinish();
#endif

    get_Textures().unlose_resources();
    get_Fonts().unlose_resources();

    get_Game().prerender();

    glViewport(0, 0, get_screen_width(), get_screen_height());

    if(!is_zwrite_enabled())
      glDepthMask(GL_TRUE);
    set_clear_color_impl(get_clear_color());
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    if(!is_zwrite_enabled())
      glDepthMask(GL_FALSE);

    get_Game().render();

    /*** Begin CPU saver ***/
#ifdef MANUAL_GL_VSYNC_DELAY
   Timer &tr = get_Timer();
   
   if(get_vertical_sync()) {
     Time buffer_swap_start_time = tr.get_time();
     
     const unsigned int time_allowed = 1000u/60u - 2u;
     const unsigned int new_time_taken = buffer_swap_start_time.get_ticks_since(m_buffer_swap_end_time);
     m_time_taken = (1.0f - m_weight_new) * m_time_taken + m_weight_new * new_time_taken;
     
     if(m_time_taken < time_allowed)
       SDL_Delay(static_cast<unsigned int>(time_allowed - m_time_taken));
   }
#endif
    
    /// Swap the buffers <-- NOT part of the CPU saver, but the reason it is "needed"
#if SDL_VERSION_ATLEAST(1,3,0)
   SDL_GL_SwapWindow(get_window());
#else
   SDL_GL_SwapBuffers();
#endif
    
#ifdef MANUAL_GL_VSYNC_DELAY
   m_buffer_swap_end_time = tr.get_time();
#endif
  }
void Team_Select_State::render() {
        Widget_Gamestate::render();

		render_image("Teamselect", Point2f(0.0f,0.0f), Point2f(1024.0f,1024.0f));
		get_Fonts()["system_36_800x600"].render_text("Player 1" ,Point2f(270, 30), Color(0x99FF1111));
		get_Fonts()["system_36_800x600"].render_text("Player 2" ,Point2f(750, 30), Color(0x99FF1111));
		get_Fonts()["system_36_800x600"].render_text("Player 3" ,Point2f(270, 330), Color(0x99FF1111));
		get_Fonts()["system_36_800x600"].render_text("Player 4" ,Point2f(750, 330), Color(0x99FF1111));

		for(int player_idx = 0; player_idx < 4; player_idx ++){

			render_image("Wanted",Point2f(-40.0f + player_render_offset[player_idx].x, 0.0f + player_render_offset[player_idx].y), Point2f(290.0f + player_render_offset[player_idx].x, 330.0f + player_render_offset[player_idx].y));

			if(player_state[player_idx] != 0){
				render_image("Snowball",Point2f(233.0f + player_render_offset[player_idx].x, 67.0f + 42.0f * player_cursor[player_idx] + player_render_offset[player_idx].y), Point2f(265.0f + player_render_offset[player_idx].x, 97.0f + 42.0f * player_cursor[player_idx] + player_render_offset[player_idx].y));
				get_Fonts()["cat"].render_text("Gender      > " + player_gender[player_idx] ,Point3f(265 + player_render_offset[player_idx].x, 72 + player_render_offset[player_idx].y, 0), Vector3f(0.28 ,0,0), Vector3f(0,0.28,0), Color(0x99FF1111));
				get_Fonts()["cat"].render_text("Team        > " + player_team[player_idx] ,Point3f(265 + player_render_offset[player_idx].x, 114 + player_render_offset[player_idx].y, 0), Vector3f(0.28 ,0,0), Vector3f(0,0.28,0), Color(0x99FF1111));
				get_Fonts()["cat"].render_text("Control     > " + player_control[player_idx] ,Point3f(265 + player_render_offset[player_idx].x, 156 + player_render_offset[player_idx].y, 0), Vector3f(0.28 ,0,0), Vector3f(0,0.28,0), Color(0x99FF1111));
				get_Fonts()["cat"].render_text("Sensitivity > " + itoa(player_sensitivity_state[player_idx]) ,Point3f(265 + player_render_offset[player_idx].x, 198 + player_render_offset[player_idx].y, 0), Vector3f(0.28 ,0,0), Vector3f(0,0.28,0), Color(0x99FF1111));
				render_image(player_gender[player_idx] + player_team[player_idx] + "Regular", Point2f(55 + player_render_offset[player_idx].x,125 + player_render_offset[player_idx].y),Point2f(188 + player_render_offset[player_idx].x,258 + player_render_offset[player_idx].y));
			}
			else
				render_image("Join",Point2f(250.0f + player_render_offset[player_idx].x, 100.0f + player_render_offset[player_idx].y), Point2f(400.0f + player_render_offset[player_idx].x, 250.0f + player_render_offset[player_idx].y));

			if(player_state[player_idx] >= 2){
				render_image("Ready",Point2f(100.0f + player_render_offset[player_idx].x, 70.0f + player_render_offset[player_idx].y), Point2f(430.0f + player_render_offset[player_idx].x, 400.0f + player_render_offset[player_idx].y));
			}
		}

		if(player_state[0] == 2)
			get_Fonts()["system_36_800x600"].render_text("P1 Press A to continue" ,Point2f(510, 568), Color(0xFF000000));

		if(loading){
			render_image("Loading", Point2f(0.0f,0.0f), Point2f(1024.0f,1024.0f));
			start_game += 1.0f;
		}


    }
  void Video_DX9::render_all() {
    assert(!m_render_target);

    static bool reset = false;

    if(reset) {
      const HRESULT result = m_d3d_device->TestCooperativeLevel();
      
      if(result == D3DERR_DEVICELOST)
        return;
      else if(result == D3DERR_DRIVERINTERNALERROR)
        throw Video_Device_Failure();
      
      if(result == D3DERR_DEVICENOTRESET) {
        if(FAILED(m_d3d_device->Reset(&m_d3d_parameters)))
          throw Video_Device_Failure();
      
        reset = false;

        init_context();
      }
    }

    get_Textures().unlose_resources();
    get_Fonts().unlose_resources();
    
    HRESULT result = m_d3d_device->Present(0, 0, 0, 0);
    
    if(result == S_OK) {
      D3DVIEWPORT9 vp = {0, 0, DWORD(get_screen_width()), DWORD(get_screen_height()), 0, 1};
      m_d3d_device->SetViewport(&vp);
      m_d3d_device->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(get_clear_color().r_ub(), get_clear_color().g_ub(), get_clear_color().b_ub()), 1.0f, 0);
      m_d3d_device->BeginScene();

      get_Game().render();
      
      m_d3d_device->EndScene();
    }
    else if(result == D3DERR_DEVICELOST) {
      reset = true;
      return;
    }
    else if(result == D3DERR_DEVICEREMOVED) {
      throw Video_Device_Failure();
    }
  }
Example #6
0
void Text::render(Point2f pos) {
  get_Fonts()[String(font)].render_text(String(*text), pos, Color(), justify);
}
Example #7
0
void Text::render() {
  get_Fonts()[String(font)].render_text(String(*text), Point2f(x, y), Color(), justify);
}