[SDL] Pre-blitting in multiline text

Jonathan Dearborn grimfang4 at gmail.com
Mon Feb 6 05:45:52 PST 2012


Hey,

What does your call to SDL_CreateRGBSurface() look like?  You either want
to enable alpha blending and make the background transparent or disable
alpha blending and set a colorkey value (probably black from your
description).

Another option is NFont.  The development version has some textbox methods.

Jonny D


On Sun, Feb 5, 2012 at 10:33 PM, psychoalienx <psychoalienx at gmail.com>wrote:

> **
> 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.
>
> _______________________________________________
> SDL mailing list
> SDL at lists.libsdl.org
> http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20120206/6dbb69b2/attachment-0008.htm>


More information about the SDL mailing list