Results 1 to 3 of 3

Thread: Canvas flushing

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

    Default Canvas flushing

    The problem:

    In ClanLib 2.3 the active RenderBatch was managed by GraphicContext and has now been moved to Canvas along with the rest of the higher level 2D functionality. Unfortunately this means applications has to call flush() before flip().

    A possible solution:

    We could move the active RenderBatch back to GraphicContext, along with flush() and set_batcher(batcher). That would allow flip() to call flush() before the flip like in the 2.3 series.

    However, unlike 2.3 GraphicContext will no longer call flush() automatically when you do lower level graphics operations. If an application decides to do its own lower level operations it is responsible for calling flush() first. This has the advantage over 2.3 that we get no overhead from the constant 'is batched flushed' checks we had earlier. It also means that apps working only at the higher 2D level does not have to be aware of batcher flushing.

    This change would also require that RenderBatcher::matrix_changed(modelview, projection) is removed. This shouldn't be a big problem since the batchers are all known by Canvas and can just be told directly if the 2D mapping logic is modified.

  2. #2
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    An alternative is:
    Code:
    void Canvas::flip(DisplayWindow &window, int param)
    {
       flush();
       if (window.is_null())
         throw Exception("What no window!");
       window.flip(param)
    }
    And, if the display window is provided as a constructor parameter (thus is known):
    Code:
    void Canvas::flip(int param)
    {
       flush()
       if (display_window.is_null())
         throw Exception("I can't see through the window");
       display_window.flip(param);
    }
    The last method has the advantage that the application does not have to keep "DisplayWindow" around, can can just use the canvas (after initialisation)

  3. #3
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    Until a decision is made (and someone codes it)....

    I have patched ClanLib 3.0 as follows:

    1) Canvas now stores to display window, is it was provided it, in the constructor.

    2) Added:

    Code:
    Canvas::Canvas(DisplayWindowDescription &desc)
    {
    	DisplayWindow window(desc);
    	*this = Canvas(window);
    }
    3) Added:
    Code:
    void Canvas::flip(int interval)
    {
    	if (impl->display_window.is_null())
    		throw Exception("The display window is not known to this canvas");
    	flush();
    	impl->display_window.flip(interval);
    }

    4) For completeness, added:

    Code:
    void Canvas::flip(DisplayWindow &window, int interval)
    {
    	window.throw_if_null();
    	flush();
    	window.flip(interval);
    }
    5) The Basic2D example now contains:
    Code:
    	Canvas canvas(desc);
    	Slot slot_quit = canvas.get_window().sig_window_close().connect(this, &Basic2D::on_window_close);
    	...
    	canvas.flip(1);

Similar Threads

  1. Patch: No minimum radius in CL_Draw::circle a.k.a Canvas::circle
    By camilo in forum Official ClanLib SDK Forums
    Replies: 2
    Last Post: 11-05-2012, 09:03 AM
  2. Canvas and alpha
    By marcr in forum Official ClanLib SDK Forums
    Replies: 0
    Last Post: 02-09-2008, 04:36 AM
  3. canvas can not run in 16bit color?
    By silekey in forum Official ClanLib SDK Forums
    Replies: 0
    Last Post: 09-13-2007, 02:45 AM
  4. canvas
    By Krux in forum Official ClanLib SDK Forums
    Replies: 0
    Last Post: 08-30-2007, 04:30 PM
  5. canvas ground: fast enough?
    By Krux in forum Official ClanLib SDK Forums
    Replies: 0
    Last Post: 08-27-2007, 06:19 PM

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
  •