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

    Render Delegation

    General and Gameplay Programming

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


    [size="5"][b]Intent[/b][/size]
    [indent][bquote]Pass-off special render cases to Model code.[/bquote][/indent]
    [size="5"][b]Problem[/b][/size]
    [indent][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][/indent]
    [size="5"][b]Solution[/b][/size]
    [indent][bquote]An example clot in View code:

    [code]if (typeToDraw==DARTH_VADERS_SHIP)
    drawSpecialShieldEffect();[/code]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]
    [/indent][size="5"] [b]Structure[/b][/size]
    [indent][bquote]Not available at this time.[/bquote][/indent]
    [size="5"][b]Examples[/b][/size]
    [indent][bquote]No examples at this time. Email [email="kevin@gamedev.net"]kevin@gamedev.net[/email] to contribute.[/bquote][/indent]
    [size="5"][b]Issues and Risks[/b][/size]
    [indent][bquote]Use Render Delegation when:
    [list][*]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.[/list][indent] [/indent] Don't use Render Delegation when:
    [list][*]There are only a few special cases and the cost (compile time, encapsulation) of including render interfaces in Model code is very high.[/list][/bquote][indent] [/indent] [/indent]
    [size="5"][b]Related Patterns[/b][/size]
    [indent][bquote]Render Delegation passes draw commands from View to Model.

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


      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.