Should objects draw themselves? (Mixture of geometry and textures)
<p>I am aware that similar questions have been asked many times before. However, this is a different case.</p>

<p>I am writing a game in C++ using SDL2. Currently, all objects draw themselves. They do this because they all draw slightly differently. </p>

<p>For instance, a Button contains a rectangle, drawn with <code>SDL_RenderFillRect();</code></p>

<p>Buttons also contain text, which are drawn using <code>SDL_RenderCopy()</code>, which takes a texture generated by SDL_TTF as a parameter.</p>

<p>Additionally, a MapView widget (basically a grid that can load a tilemap) draws the grid out using a 'for' loop containing horizontal and vertical <code>SDL_RenderDrawLine()</code> calls.</p>

<p>Finally, the tiles themselves are stored as textures, drawn using <code>SDL_RenderCopy()</code>.</p>

<p>I understand that it is generally preferable to NOT have objects draw themselves. However, because there is so much variation in how the objects are drawn, I'm not sure of another way! </p>

<p>I thought it might be possible to have a GetTexture() function for each object, and the ones using textures could simply 'return texture', while the geometric objects could generate a texture. This gets complicated with my MapView object, because the grid is constantly updated when the user navigates around the game world (an offset value is changed and the grid is redrawn when moved). </p>