[SDL] text output using OpenGL and SDL?
Laurent Carlier
lordheavy at infonie.fr
Mon Oct 16 06:43:11 PDT 2006
Le lundi 16 octobre 2006 15:31, Andreas Rönnquist a écrit :
> Does anybody have any good examples uploading fonts/text to
> OpenGL-textures, making it use alpha-channel for transparency?
>
> In my code I output some text using TTF_RenderText_Blended to a surface
> - I make a new surface that is modified to work fine with OpenGL (power
> of 2 sized) - and then make an OpenGL-texture with the data simply using
> glTexImage2D. - But I would like it to be truly blended towards the
> _background_. As it is now there is a black square around all the
> letters (no transparency at all), the letters are nicely blended
> towards black, but I dont really know where to start to get the results
> I am after.
>
> The goal is to make text output functionality using OpenGL and OpenGL
> Display Lists.
>
> Anybody have any hints / pointers on where to start?
>
> /Andreas Rönnquist
> andreas,ronnquist at gmail.com
>
Enable belnding :
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
Load you surface with alpha :
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE,
image->pixels);
And it should work like in 2d :)
++
More information about the SDL
mailing list