void
BufferRefImage::update() 
{
   if (!need_update())
      return;

   cerr << "BufferRefImage: Updated!\n";

   assert (_view != 0);
   VIEWimpl *impl = _view->impl();
   assert(impl != 0);

   _observing = false;
   impl->draw_setup();
   impl->draw_frame();
   _observing=true;
   
   glViewport(0,0,_width,_height);
   copy_to_ram();

   _dirty = 0;
  
}
Beispiel #2
0
void
HaloRefImage::update()
{
  // render the scene and read pixels to main memory
   // and/or texture memory

   if (!need_update())
      return;

   static bool debug = Config::get_var_bool("DEBUG_HALO_UPDATE",false);
   err_adv(debug, "HaloRefImage::update: updating...");

    check_resize();

   glPushAttrib(
      GL_LINE_BIT               |
      GL_DEPTH_BUFFER_BIT       |
      GL_ENABLE_BIT             |
      GL_LIGHTING_BIT           |
      GL_VIEWPORT               | // XXX - not needed
      GL_COLOR_BUFFER_BIT       | // XXX - not needed
      GL_TEXTURE_BIT              // XXX - not needed
      );

   // XXX - remove this:
   assert(_view && _view == VIEW::peek());

   // set up lights
   _view->setup_lights();

   // set default state
   // XXX - check
   glLineWidth(1.0);            // GL_LINE_BIT
   glDepthMask(GL_TRUE);        // GL_DEPTH_BUFFER_BIT
   glDepthFunc(GL_LESS);        // GL_DEPTH_BUFFER_BIT
   glEnable(GL_DEPTH_TEST);     // GL_DEPTH_BUFFER_BIT
   glDisable(GL_NORMALIZE);     // GL_ENABLE_BIT
   glDisable(GL_BLEND);         // GL_ENABLE_BIT
   glEnable(GL_CULL_FACE);      // GL_ENABLE_BIT

   glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
   glEnable(GL_COLOR_MATERIAL); // GL_ENABLE_BIT
   glShadeModel(GL_SMOOTH);     // GL_LIGHTING_BIT
  
   // set viewport to ref image size:
   glViewport(0,0,_width,_height); // GL_VIEWPORT_BIT
   draw_objects(_view->drawn());

   // copy image to main memory or texture memory
   // (or both) as requested:
   if (_update_main_mem) {
      if (use_fbos)
         glBindFramebuffer(GL_READ_FRAMEBUFFER, _fbo);
      else
         glReadBuffer(GL_AUX0); //because the image is constructed in aux0
      copy_to_ram();
      if (use_fbos)
         glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
      else
         glReadBuffer(GL_BACK);
   }
   if (_update_tex_mem)
      copy_to_tex_aux(); //copies from aux0

   // clear update flags until next update request is made:
   _update_main_mem = _update_tex_mem = false;

   glPopAttrib();

   // restore viewport to window size:
   int w, h;
   _view->get_size(w,h);
   glViewport(0,0,w,h);
}