Results 1 to 3 of 3

Thread: GUI_Manager::exec()

  1. #1
    Lesser Wizard
    Join Date
    Jun 2007
    Posts
    109

    Default GUI_Manager::exec()

    This new GUI system is beating me up. Nose bloodied, I continue on, a masochist.

    Question; why does gui_manager.exec(false); seem to clear the background all on its own? Running in texture mode here, in system mode it's just a-okay and works fine.

    Though everything behind it seems to flicker, probably something to do with my display window?

    I'm running out of ideas.
    Last edited by catch22; 05-30-2009 at 07:10 AM.

  2. #2
    ClanLib Developer
    Join Date
    Sep 2006
    Location
    Denmark
    Posts
    554

    Default

    The texture window manager creates all top-level components in their own textures. Then when the CL_DisplayWindow wants to be redrawn, the texture manager itself renders each of the textures to the window and does a flip() or update().

    In contrast, the system window manager has a separate CL_DisplayWindow for each top-level component, and when a CL_DisplayWindow wants to be redrawn, it directs the request to the func_render() of the top-level component and when the function finishes it calls flip() or update().

    If you want to control yourself how the texture WM renders the textures (i.e. to supply your own background or do shader effects on them), you can hook up on CL_GUIWindowManagerTexture::func_repaint() and use CL_GUIWindowManagerTexture::get_windows() to retrieve the textures.

    Because the GUI manages the 'dirty regions' of a window itself, you must never ever call flip() or update() on the CL_DisplayWindow yourself, unless you are doing it in the func_repaint() callback.

    Simply put, this is what exec() does:

    Code:
    int CL_GUIManager::exec()
    {
      while (!quit_request)
      {
        if (message_arrived())
          dispatch_message_to_component();
        if (operation_system_wants_redraw())
        {
           if (is_texture_wm())
           {
             if (app_hooked_func_repaint())
             {
               func_repaint().invoke();
             }
             else
             {
               dispwind.get_gc().clear(CL_Colorf::black);
               for each (CL_GUIWindowManagerTextureWindow)
                 dispwind.get_gc().draw_texture(..);
               dispwind.flip();
             }
           }
           else // system WM
           {
             CL_GUIComponent *c = find_toplevel_component_for_dispwindow();
             c->func_render().invoke(dispwind.get_gc());
             dispwind.flip();
           }
        }
    
        foreach (constant_repaint_window or CL_GUIComponent::invalidate_rect() window)
        {
           if (is_texture_wm())
           {
              CL_Texture t = find_toplevel_component_texture();
              CL_GraphicContext gc = dispwind.get_gc();
              gc.set_frame_buffer(create_framebuffer_for_texture(t));
              component->func_render().invoke(gc);
              gc.reset_frame_buffer();
              dispwind.invalidate();
           }
           else
           {
              dispwind.invalidate();
           }
        }
    
        if (!constant_repaint)
          wait_for_new_messages();
      }
      return quit_code;
    }
    I hope this help understand what is going on.

  3. #3
    Lesser Wizard
    Join Date
    Jun 2007
    Posts
    109

    Default

    Ah thanks so much for the explanation. I have figured it out!!

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •