2
\$\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\$
  • \$\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 '14 at 20:05
2
\$\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\$
  • \$\begingroup\$ I actually found the same function this morning before looking at stackexchange. Thanks! \$\endgroup\$ – igrad May 18 '14 at 17:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.