Jump to content

  • Log In with Google      Sign In   
  • Create Account


Like
0Likes
Dislike

Render Delegation

By Zachary Booth Simpson | Published Jun 19 2001 05:27 PM in General Programming

render model view special cases code delegation draw time
If you find this article contains errors or problems rendering it unreadable (missing images or files, mangled code, improper text formatting, etc) please contact the editor so corrections can be made. Thank you for helping us improve this resource

© 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.


Intent

Pass-off special render cases to Model code.


Problem

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.


Solution

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.

Structure

Not available at this time.


Examples

No examples at this time. Email kevin@gamedev.net to contribute.


Issues and Risks

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.


Related Patterns

Render Delegation passes draw commands from View to Model.

Render Delegation may be part of an Appearance Map.






Comments

Note: Please offer only positive, constructive comments - we are looking to promote a positive atmosphere where collaboration is valued above all else.




PARTNERS