Пример #1
0
	void draw() {
	  dt = gui_t.dtime();
		gui_f_time += dt;
		gui_g_time += dt;

		float f_wait;
		bool run_always = false;
		f_wait = 1.0f/100.0f;
	  if (run_always || gui_f_time > f_wait)
	  {

      if (first) {
        start_engine();
        cl_server.set_command_lists(&internal_cmd_in,&internal_cmd_out);
        cl_server.start();
        first = false;
      }
      
      ++frame_count;

	    gui_fullscreen_fpstimer += gui_f_time;
	      current_fps = f2s(round(1.0f/gui_f_time),2);
	    if (gui_fullscreen_fpstimer > 1) {
	      vsx_string h = fpsstring + " @ "+ current_fps+ "fps";
	      gui_fullscreen_fpstimer = 0;
	    }

	  	gui_f_time = 0;

      glDepthMask(GL_TRUE);
      glClearColor(0.0f,0.0f,0.0f,1.0f);

      glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
	    
      if (vxe) {
        vxe->process_message_queue(&internal_cmd_in,&internal_cmd_out);
        vxe->render();

        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();											// Reset The Modelview Matrix
        glEnable(GL_BLEND);
        ++frame_counter;
        ++delta_frame_counter;
      }
    }
    pgv.iterations = -1;
    pgv.process_garbage();
	}
Пример #2
0
bool app_draw(int id)
{
  if (id == 0) {
    my_draw.draw();
  } else
  {
    if (dual_monitor) {
      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);	// Clear Screen And Depth Buffer
      vxe->process_message_queue(&internal_cmd_in,&internal_cmd_out);
      vxe->render();
      glDisable(GL_DEPTH_TEST);

      glMatrixMode(GL_PROJECTION);
      glLoadIdentity();
      glMatrixMode(GL_MODELVIEW);
      glLoadIdentity();											// Reset The Modelview Matrix
      glEnable(GL_BLEND);
      ++frame_counter;
      ++delta_frame_counter;
      float dt = time2.dtime();
      delta_frame_time+= dt;
      total_time += dt;
      if (delta_frame_counter == 100) {
        delta_fps = 100.0f/delta_frame_time;
        delta_frame_counter = 0;
        delta_frame_time = 0.0f;
      }
      glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
      glColor4f(0,0,0,0.4f);
      glBegin(GL_QUADS);									// Draw A Quad
        glVertex3f(-1.0f, 1.0f, 0.0f);					// Top Left
        glVertex3f( 1.0f, 1.0f, 0.0f);					// Top Right
        glVertex3f( 1.0f,0.92f, 0.0f);					// Bottom Right
        glVertex3f(-1.0f,0.92f, 0.0f);					// Bottom Left
      glEnd();											// Done Drawing The Quad
      myf.print(vsx_vector(-1.0f,0.92f)," Fc "+i2s(frame_counter)+" Fps "+f2s(delta_fps)+" T "+f2s(total_time)+" Tfps "+f2s(frame_counter/total_time)+" MC "+i2s(vxe->get_num_modules())+" VSX Ultra (c) Vovoid",0.07);
    }
  }
  return true;
}
Пример #3
0
  void draw()
  {
    if (first)
    {
      profiler = vsx_profiler_manager::get_instance()->get_profiler();
      load_desktop_a();
      first = false;
    }

    dt = gui_t.dtime();
    gui_f_time += dt;
    gui_g_time += dt;

    ++frame_count;

    vsx_widget_time::get_instance()->set_dtime( dt );
    vsx_widget_time::get_instance()->increase_time( dt );
    desktop->vsx_command_process_f();

    desktop->frames = frame_count;



      profiler->sub_begin("init_frame");
          desktop->init_frame();
      profiler->sub_end();

      profiler->sub_begin("desktop draw");
          desktop->draw();
      profiler->sub_end();

      profiler->sub_begin("draw 2d");
          desktop->draw_2d();
      profiler->sub_end();

      vsx_command_process_garbage();
  }
Пример #4
0
  void draw() {
    if (record_movie) {
      vxe->set_constant_frame_progression(1.0f / 60.0f);
      vxe->play();
    }

    if (desktop)
    {
      desktop->vsx_command_process_f();
    }

    if (first) {
      intro = new vsx_logo_intro;
    }
    dt = gui_t.dtime();
    gui_f_time += dt;
    gui_g_time += dt;

    float f_wait;
    bool run_always = false;
    if (desktop)
    {
      if (desktop->global_framerate_limit == -1)
      {
        run_always = true;
      }
      else
      {
        f_wait = 1.0f/desktop->global_framerate_limit;
      }
    }
    else
    {
      f_wait = 1.0f/100.0f;
    }

    if (run_always || gui_f_time > f_wait)
    {
      ++frame_count;

      if (desktop) {
        desktop->dtime = gui_f_time;
        desktop->time += desktop->dtime;
        desktop->frames = frame_count;
      }
      gui_fullscreen_fpstimer += gui_f_time;
      current_fps = f2s(round(1.0f/gui_f_time),2);
      if (gui_fullscreen_fpstimer > 1)
      {
        vsx_string h = fpsstring + " @ "+ current_fps+ "fps";
        gui_fullscreen_fpstimer = 0;
      }

      gui_f_time = 0;
      if (!*gui_prod_fullwindow)
      {
        if (desktop) {
          desktop->init_frame();
          desktop->draw();
          desktop->draw_2d();
        }
      }
      if (!dual_monitor)
      {
        vxe->process_message_queue(&internal_cmd_in,&internal_cmd_out);
      }

      if (*gui_prod_fullwindow)
      {

        glDepthMask(GL_TRUE);
        glClearColor(0.0f,0.0f,0.0f,1.0f);

        glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

        #ifndef NO_INTRO
          if (vxe->e_state == VSX_ENGINE_STOPPED)
          {
            //intro->draw(true);
          }
        #endif
        if (vxe && !dual_monitor) {
          vxe->render();
          glDisable(GL_DEPTH_TEST);

          glMatrixMode(GL_PROJECTION);
          glLoadIdentity();
          glMatrixMode(GL_MODELVIEW);
          glLoadIdentity();
          glEnable(GL_BLEND);
          ++frame_counter;
          ++delta_frame_counter;

          delta_frame_time+= dt;
          total_time += dt;
          if (delta_frame_counter == 100) {
            delta_fps = 100.0f/delta_frame_time;
            delta_frame_counter = 0;
            delta_frame_time = 0.0f;
          }

          if (gui_prod_fullwindow_helptext)
          {
            glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
            glColor4f(0,0,0,0.4f);
            glBegin(GL_QUADS);                  // Draw A Quad
              glVertex3f(-1.0f, 1.0f, 0.0f);          // Top Left
              glVertex3f( 1.0f, 1.0f, 0.0f);          // Top Right
              glVertex3f( 1.0f,0.92f, 0.0f);          // Bottom Right
              glVertex3f(-1.0f,0.92f, 0.0f);          // Bottom Left
            glEnd();                      // Done Drawing The Quad
            myf.print(vsx_vector(-1.0f,0.92f)," Fc "+i2s(frame_counter)+" Fps "+f2s(delta_fps)+" T "+f2s(total_time)+" Tfps "+f2s(frame_counter/total_time)+" MC "+i2s(vxe->get_num_modules())+" VSX Ultra (c) 2003-2010 Vovoid - Alt+T=toggle this text, Ctrl+Alt+P=screenshot (data dir), Alt+F=performance mode ",0.03f);
          }
        }
        if (desktop && desktop->performance_mode) {
          glClear(GL_DEPTH_BUFFER_BIT);
          desktop->init_frame();
          desktop->draw();
          desktop->draw_2d();
        }
      }
      #ifndef NO_INTRO
        //intro->draw();
      #endif
      if (!first && !desktop)
      {
        pgv.iterations = -1;
      }
      pgv.process_garbage();
      if (first)
      {
        if (!dual_monitor) {
          vxe->init();
          vxe->start();
        }
        load_desktop_a();
        first = false;
      }
    } else
    {
      int zz = (int)((f_wait-gui_f_time)*1000.0f);
      if (zz < 0) zz = 0;
      //printf("zz%d ",zz);
      //Sleep(zz);
    }
    //------------------------------------------------------------------
    // movie recording
    //------------------------------------------------------------------
    if (record_movie)
    {
      GLint viewport[4];
      glGetIntegerv(GL_VIEWPORT, viewport);
      char* pixeldata = (char*)malloc( viewport[2] * viewport[3] * 3 );
      char* pixeldata_flipped = (char*)malloc( viewport[2] * viewport[3] * 3 );
      take_screenshot = false;
      glReadPixels(0,0,viewport[2],viewport[3],GL_RGB,GL_UNSIGNED_BYTE, (GLvoid*)pixeldata);
      int x3 = viewport[2]*3;
      int hi = viewport[3];
      for (int y = 0; y < hi; y++)
      {
        for (int x = 0; x < x3; x++)
        {
          pixeldata_flipped[y*x3+x] = pixeldata[ (hi-y)*x3+x];
        }
      }

      CJPEGTest jpeg;
      jpeg.m_nResX = viewport[2];
      jpeg.m_nResY = viewport[3];
      jpeg.m_pBuf = (unsigned char*)pixeldata_flipped;

      //char filename[32768];
      #if PLATFORM_FAMILY == PLATFORM_FAMILY_UNIX
      if (access((vsx_get_data_path()+"videos").c_str(),0) != 0) mkdir((vsx_get_data_path()+"/videos").c_str(),0700);
        //sprintf(filename, "%sscreenshots/%d_%d_%d_rgb.jpg",vsx_get_data_path().c_str(),(int)time(0),viewport[2],viewport[3]);
      #endif
      vsx_string err;
      char mfilename[32];
      sprintf(mfilename, "%05d", movie_frame_count);

      jpeg.SaveJPEG( vsx_get_data_path()+"videos"+DIRECTORY_SEPARATOR+vsx_string(mfilename)+"_"+ i2s(viewport[2]) + "_" + i2s(viewport[3])+".jpg", err, 100 );
      jpeg.m_pBuf = 0;
      free(pixeldata);
      free(pixeldata_flipped);
      movie_frame_count++;
    }

    //------------------------------------------------------------------
    // screenshots
    //------------------------------------------------------------------

    if (take_screenshot)
    {
      GLint viewport[4];
      glGetIntegerv(GL_VIEWPORT, viewport);
      char* pixeldata = (char*)malloc( viewport[2] * viewport[3] * 3 );
      char* pixeldata_flipped = (char*)malloc( viewport[2] * viewport[3] * 3 );
      take_screenshot = false;
      glReadPixels(0,0,viewport[2],viewport[3],GL_RGB,GL_UNSIGNED_BYTE, (GLvoid*)pixeldata);

      int x3 = viewport[2]*3;
      int hi = viewport[3];
      for (int y = 0; y < hi; y++)
      {
        for (int x = 0; x < x3; x++)
        {
          pixeldata_flipped[y*x3+x] = pixeldata[ (hi-y)*x3+x];
        }
      }

      CJPEGTest jpeg;
      jpeg.m_nResX = viewport[2];
      jpeg.m_nResY = viewport[3];
      jpeg.m_pBuf = (unsigned char*)pixeldata_flipped;

      //char filename[32768];
      #if PLATFORM_FAMILY == PLATFORM_FAMILY_UNIX
      if (access((vsx_get_data_path()+"screenshots").c_str(),0) != 0) mkdir((vsx_get_data_path()+"/screenshots").c_str(),0700);
        //sprintf(filename, "%sscreenshots/%d_%d_%d_rgb.jpg",vsx_get_data_path().c_str(),(int)time(0),viewport[2],viewport[3]);
      #endif
      /*FILE* fp = fopen(filename,"wb");
      fwrite(pixeldata_flipped, 1, viewport[2] * viewport[3] * 3, fp);
      fclose(fp);*/
      vsx_string err;
      jpeg.SaveJPEG( vsx_get_data_path()+"screenshots"+DIRECTORY_SEPARATOR+i2s(time(0))+"_"+ i2s(viewport[2]) + "_" + i2s(viewport[3])+".jpg", err, 100 );
      jpeg.m_pBuf = 0;
      free(pixeldata);
      free(pixeldata_flipped);
    }
  } // ::draw()