[SDL] Pre-blitting in multiline text

psychoalienx psychoalienx at gmail.com
Sun Feb 5 19:33:09 PST 2012


Hello,

I'm working with SDL 1.2 in a multiline textfield class using SDL_ttf library. I'm using a vector to store each line of the textfield but the problem comes when I try to render them into the surface.
My idea is to render each one into one surface first and then blit that surface with the screen surface.
I think my error is due my poor knowledge or bad understanding about the surface blitting.

I´ve tried rendering the first line with TTF_RenderText_Solid getting a surface SRF1. The next line with the same ttf function getting a SRF2. Then I tried to blit SRF2 into SRF1 and modifying the Y value of the Rect (to put the second line below the first one). The result in the screen is only the first line is displayed. (I guess is because the width and higth of the SRF1).

Also I've tried to create a new surface with SDL_CreateRGBSurface (with precise dimensions for the all lines can fit) and then blit every line into that surface, and then blit it with the screen surface.
The result is the all lines are displayed but with a black background covering that part of the screen. 

So how I can make this pre-blitting into a surface and then blit that surface into the screen one? The direct blitting of every line into screen surface doesn't work for me (for my program logic).

Thanks in advance for any help you can give me.

Nicolas.




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20120205/d3668352/attachment-0007.htm>


More information about the SDL mailing list