3
\$\begingroup\$

As a direct result of this question that I asked a few days ago, I want to draw potentially-complex geometry to a SDL_Texture or, I suppose, an SDL_Surface. Ultimately, I want the foreground of a 2D platformer on this texture so that I cant draw a specific portion to the screen, as explained in the above link. Most of the geometry will be simple rectangles, but I would also like to draw slopes and possibly circles. Diving into OpenGL seems like a viable option at this point, but if I could avoid it, that would be grand.

\$\endgroup\$
1
  • \$\begingroup\$ You might be interested in the SDL_gpu library found at code.google.com/p/sdl-gpu . It looks like it may be a good middle ground between only being able to draw lines and rectangles, and diving fully into OpenGL. \$\endgroup\$
    – joeforker
    Jun 13, 2014 at 20:05

1 Answer 1

3
\$\begingroup\$

SDL_SetRenderTarget(SDL_Renderer *renderer,SDL_Texture *texture)

After calling this, any drawing functions using this renderer will be drawn into the specified texture, instead of to the screen. (Passing NULL for the texture will make subsequent drawing functions draw to the screen again)

Note that the texture must have been created using the SDL_TEXTUREACCESS_TARGET flag.

More details are available in the on-line documentation.

\$\endgroup\$
1
  • \$\begingroup\$ I actually found the same function this morning before looking at stackexchange. Thanks! \$\endgroup\$
    – igrad
    May 18, 2014 at 17:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .