# No text displayed using sdl\_ttf

**URL:** <https://discourse.libsdl.org/t/no-text-displayed-using-sdl-ttf/14700>\
**Category:** SDL Development\
**Created:** [July 16, 2007, 6:35pm UTC](https://discourse.libsdl.org/t/no-text-displayed-using-sdl-ttf/14700 "2007-07-16T18:35:46Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bob\_Self](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/b/848f3c/32.png) [@Bob\_Self](https://discourse.libsdl.org/u/Bob_Self)\
**Post date:** [July 16, 2007, 6:35pm UTC](https://discourse.libsdl.org/t/no-text-displayed-using-sdl-ttf/14700/1 "2007-07-16T18:35:46Z")

</div>

I’m trying to display a message on the screen with TTF\_RenderText\_Solid on windows xp.  
I’m playing a video file using SDL and that works fine. I’m also drawing some lines on top  
of the video and that works but I don’t see any text. I’m using sdl\_ttf 2.0.8 and sdl 1.2.11.

I’ve checked all of the return values and everything looks ok, I think.  
Can someone tell me what could be wrong or how to find out what isn’t working that causes no display?  
Here is what I’m doing:

int flags, w, h;  
SDL\_Surface \*screen;  
SDL\_Rect dest = { 50, 50, 200, 30 };

flags = SDL\_HWSURFACE | SDL\_ASYNCBLIT | SDL\_HWACCEL | SDL\_RESIZABLE;  
w = 1200  
h = 800

screen = SDL\_SetVideoMode(w, h, 0, flags);

SDL\_Color textColor = { 255, 0, 0 };  
TTF\_Font \*fnt = TTF\_OpenFont( “c:\windows\fonts\arial.ttf”, 20 );  
strcpy(str, “Hello”);

message = TTF\_RenderText\_Solid(fnt, str, textColor);

int status = SDL\_BlitSurface( message, NULL, screen, &dest );

// no error, but no text

thanks,  
Bob

---

<div class="post-metadata">

**Author:** ![Bob\_Self](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/b/848f3c/32.png) [@Bob\_Self](https://discourse.libsdl.org/u/Bob_Self)\
**Post date:** [July 16, 2007, 9:45pm UTC](https://discourse.libsdl.org/t/no-text-displayed-using-sdl-ttf/14700/2 "2007-07-16T21:45:43Z")

</div>

After SDL\_BlitSurface() I added:

```
SDL_Flip(screen);

```

I neglected to list this line earlier:

```
SDL_DisplayYUVOverlay(vp->bmp, &rect);

```

After adding the SDL\_Flip() line I now see the text, but it is blinking (or  
tearing). How can I get a smooth text display?

BobOn Mon, Jul 16, 2007 at 02:35:46PM -0400, Bob Self wrote:

> I’m trying to display a message on the screen with TTF\_RenderText\_Solid on windows xp.  
> I’m playing a video file using SDL and that works fine. I’m also drawing some lines on top  
> of the video and that works but I don’t see any text. I’m using sdl\_ttf 2.0.8 and sdl 1.2.11.
> 
> I’ve checked all of the return values and everything looks ok, I think.  
> Can someone tell me what could be wrong or how to find out what isn’t working that causes no display?  
> Here is what I’m doing:
> 
> int flags, w, h;  
> SDL\_Surface \*screen;  
> SDL\_Rect dest = { 50, 50, 200, 30 };
> 
> flags = SDL\_HWSURFACE | SDL\_ASYNCBLIT | SDL\_HWACCEL | SDL\_RESIZABLE;  
> w = 1200  
> h = 800
> 
> screen = SDL\_SetVideoMode(w, h, 0, flags);
> 
> SDL\_Color textColor = { 255, 0, 0 };  
> TTF\_Font \*fnt = TTF\_OpenFont( “c:\windows\fonts\arial.ttf”, 20 );  
> strcpy(str, “Hello”);
> 
> message = TTF\_RenderText\_Solid(fnt, str, textColor);
> 
> int status = SDL\_BlitSurface( message, NULL, screen, &dest );

---

<div class="post-metadata">

**Author:** ![Michael\_Kirkland](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/m/f08c70/32.png) [@Michael\_Kirkland](https://discourse.libsdl.org/u/Michael_Kirkland)\
**Post date:** [July 16, 2007, 9:56pm UTC](https://discourse.libsdl.org/t/no-text-displayed-using-sdl-ttf/14700/3 "2007-07-16T21:56:20Z")

</div>

Bob Self wrote:\> On Mon, Jul 16, 2007 at 02:35:46PM -0400, Bob Self wrote:

> > I’m trying to display a message on the screen with TTF\_RenderText\_Solid on windows xp.  
> > I’m playing a video file using SDL and that works fine. I’m also drawing some lines on top  
> > of the video and that works but I don’t see any text. I’m using sdl\_ttf 2.0.8 and sdl 1.2.11.
> > 
> > I’ve checked all of the return values and everything looks ok, I think.  
> > Can someone tell me what could be wrong or how to find out what isn’t working that causes no display?  
> > Here is what I’m doing:
> > 
> > int flags, w, h;  
> > SDL\_Surface \*screen;  
> > SDL\_Rect dest = { 50, 50, 200, 30 };
> > 
> > flags = SDL\_HWSURFACE | SDL\_ASYNCBLIT | SDL\_HWACCEL | SDL\_RESIZABLE;  
> > w = 1200  
> > h = 800
> > 
> > screen = SDL\_SetVideoMode(w, h, 0, flags);
> > 
> > SDL\_Color textColor = { 255, 0, 0 };  
> > TTF\_Font \*fnt = TTF\_OpenFont( “c:\windows\fonts\arial.ttf”, 20 );  
> > strcpy(str, “Hello”);
> > 
> > message = TTF\_RenderText\_Solid(fnt, str, textColor);
> > 
> > int status = SDL\_BlitSurface( message, NULL, screen, &dest );
> 
> After SDL\_BlitSurface() I added:
> 
> SDL\_Flip(screen);
> 
> I neglected to list this line earlier:
> 
> SDL\_DisplayYUVOverlay(vp-\>bmp, &rect);
> 
> After adding the SDL\_Flip() line I now see the text, but it is blinking (or  
> tearing). How can I get a smooth text display?
> 
> Bob

I’m dealing with largely the same issue. I’ve tried using a secondary  
SDL\_Surface for the YUVOverlay, and blitting it on to the screen  
SDL\_Surface. This lets me draw my other surfaces over the video frame  
without flicker, but it’s very slow and I end up dropping a lot of  
frames in the process.

Does anyone know of a clean way to blit extra SDL\_Surfaces to the  
surface attached to a YUVOverlay before it updates?

---

<div class="post-metadata">

**Author:** ![Torsten\_Giebl](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/torsten_giebl/32/2804_2.png) [@Torsten\_Giebl](https://discourse.libsdl.org/u/Torsten_Giebl)\
**Post date:** [July 17, 2007, 12:24pm UTC](https://discourse.libsdl.org/t/no-text-displayed-using-sdl-ttf/14700/4 "2007-07-17T12:24:28Z")

</div>

Hello !

Are you using a YUV Overlay to play your video ?

CU

---

<div class="post-metadata">

**Author:** ![Bob\_Self](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/b/848f3c/32.png) [@Bob\_Self](https://discourse.libsdl.org/u/Bob_Self)\
**Post date:** [July 17, 2007, 1:01pm UTC](https://discourse.libsdl.org/t/no-text-displayed-using-sdl-ttf/14700/5 "2007-07-17T13:01:55Z")

</div>

Yes, see my follow up post above.

BobOn Tue, Jul 17, 2007 at 02:24:28PM +0200, Torsten Giebl wrote:

> Hello !
> 
> Are you using a YUV Overlay to play your video ?
> 
> CU
> 
> * * *
> 
> SDL mailing list  
> SDL at [lists.libsdl.org](http://lists.libsdl.org)  
> [http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org](http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org)

---

<div class="post-metadata">

**Author:** ![Michael\_Kirkland](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/m/f08c70/32.png) [@Michael\_Kirkland](https://discourse.libsdl.org/u/Michael_Kirkland)\
**Post date:** [July 17, 2007, 12:01am UTC](https://discourse.libsdl.org/t/no-text-displayed-using-sdl-ttf/14700/6 "2007-07-17T00:01:07Z")

</div>

Bob Self wrote:

> > flags = SDL\_HWSURFACE | SDL\_ASYNCBLIT | SDL\_HWACCEL | SDL\_RESIZABLE;  
> >   
> > After SDL\_BlitSurface() I added:
> 
> SDL\_Flip(screen);
> 
> I neglected to list this line earlier:
> 
> SDL\_DisplayYUVOverlay(vp-\>bmp, &rect);
> 
> After adding the SDL\_Flip() line I now see the text, but it is blinking (or  
> tearing). How can I get a smooth text display?
> 
> Bob

I’ve noticed that with similar flags to yours, I don’t actually get a  
hardware surface, according the flags in the SDL\_Surface struct. Are you?
