• 06/19/01 11:27 PM
    Sign in to follow this  

    Render Delegation

    General and Gameplay Programming

    Myopic Rhino
    (C) 2000 - Zachary Booth Simpson. Copied with permission from http://www.mine-control.com/zack. If you find any of this work useful, please sign Zack's guest book: http://www.mine-cont...i/gbook-zbs.cgi.


    [size="5"]Intent
    [bquote]Pass-off special render cases to Model code.[/bquote]

    [size="5"]Problem
    [bquote]Generic View code often becomes clotted with special cases, especially near the end of a project. Render Delegation gets the special cases out of the View code and into Model subclasses.[/bquote]

    [size="5"]Solution
    [bquote]An example clot in View code:

    if (typeToDraw==DARTH_VADERS_SHIP)
    drawSpecialShieldEffect();
    To encapsulate these kinds of special cases, the View delegates the draw back to the Model. For example: objectToDraw->draw(x,y)

    It is common for the view to do the transformation and sorting work and pass screen coordinates to the draw method of a model.[/bquote]
    [size="5"] Structure
    [bquote]Not available at this time.[/bquote]

    [size="5"]Examples
    [bquote]No examples at this time. Email [email="kevin@gamedev.net"]kevin@gamedev.net[/email] to contribute.[/bquote]

    [size="5"]Issues and Risks
    [bquote]Use Render Delegation when:
    • You want to ensure reusability / encapsulation of the renderer.
    • The View code becomes clotted with special cases.
    • Every model tends to have a different implementations of render.
      Don't use Render Delegation when:
      • There are only a few special cases and the cost (compile time, encapsulation) of including render interfaces in Model code is very high.[/bquote]

    [size="5"]Related Patterns
    [bquote]Render Delegation passes draw commands from View to Model.

    Render Delegation may be part of an Appearance Map.[/bquote]


      Report Article
    Sign in to follow this  


    User Feedback

    Create an account or sign in to leave a review

    You need to be a member in order to leave a review

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now

    There are no reviews to display.