Bitmap fonts with SDL / OpenGL

Hi,

I’m planning to use SDL with OpenGL but one thing I’m
a bit unclear about is the best way to overlay my
OpenGL view with bitmap images and bitmap fonts. I’ve
been using my own bitmap fonts with SDL and overlaying
images using colorKeys. Is there a fairly simple way
to be able to do a similar thing when using SDL with
OpenGL?

I’d like to have a 3D openGL view and then overlay
some text and bitmap images over the 3D view. I’m
using Dev C++ with Windows XP.

Thanks,

Guilherme___________________________________________________________
To help you stay safe and secure online, we’ve developed the all new Yahoo! Security Centre. http://uk.security.yahoo.com

Hi,
as far as i know SDL_UpdateRect(screen, 0, 0, 0, 0) does not work when
using OpenGL.
It simples crash.
As a solution you can load your bitmaps into a texture and display it by
using
glOrtho.
Just render your 3D view, then switch to the ortho-modus and render your
font.
Nehe has a tutorial for it, just take a look.

Jonas> Hi,

I’m planning to use SDL with OpenGL but one thing I’m
a bit unclear about is the best way to overlay my
OpenGL view with bitmap images and bitmap fonts. I’ve
been using my own bitmap fonts with SDL and overlaying
images using colorKeys. Is there a fairly simple way
to be able to do a similar thing when using SDL with
OpenGL?

I’d like to have a 3D openGL view and then overlay
some text and bitmap images over the 3D view. I’m
using Dev C++ with Windows XP.

Thanks,

Guilherme


To help you stay safe and secure online, we’ve developed the all new Yahoo! Security Centre. http://uk.security.yahoo.com


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Hi,

I’m planning to use SDL with OpenGL but one thing I’m
a bit unclear about is the best way to overlay my
OpenGL view with bitmap images and bitmap fonts. I’ve
been using my own bitmap fonts with SDL and overlaying
images using colorKeys. Is there a fairly simple way
to be able to do a similar thing when using SDL with
OpenGL?

I’d like to have a 3D openGL view and then overlay
some text and bitmap images over the 3D view. I’m
using Dev C++ with Windows XP.

Thanks,

Guilherme


To help you stay safe and secure online, we’ve developed the all new Yahoo!
Security Centre. http://uk.security.yahoo.com

If you are using palettized bitmaps, create a corresponding RGBA image from your
bitmap with alpha = 0 where the transparent pixels are. If the bitmaps are
already RGB, replace the transparent pixels’ color with black (0,0,0) and set
their alpha to 0 again in the RGBA texture. Then load the texture up to OpenGL.

You don’t need to use ortho view to render your fonts, just set blend mode to
GL_ALWAYS and disable depth checking.

Guilherme De Sousa <g_hds yahoo.co.uk> writes:

Hi,
Fonts in 3D should indeed be rendered using textures alone (e.g. Ogre3D font stuff),
but for the record, it is possible to use the SDL_Flip et al after using the SDL_OPENGLBLIT
flag during video mode speicification. src/video/SDL_video.c:1500ish and
SDL_GL_UpdateRects does just that.

However, that merely creates textures from the ordinary SDL surfaces and displays
them in 3D during the SDL_Flip/SDL_Update. This naturally has a serious impact on
perfomance as you’re forced to flip each frame and SDL_GL_UpdateRects is forced
to recreate the textures regardless of wether the textures actually have changed or not.
And for rendering fonts on screen this is definitely not the way to go, but there
may be legit uses for it, although in most cases when you really need to draw
SDL_Surfaces on 3D it may be more efficient and convenient to do the surfce->texture
"manually" and then use the texture anyway you please.

(e.g. it’s really straight forward to use smpeg to play an mpeg file onto a texture
and then use the texture anywhere you like and not just as flat 2D among your 3D stuff,
but perhaps on a TV monitor in your 3D world. wether smpeg is the way to go
with movie files is another thing.)

cheers,
Tommi Kyntola

JonasScholz at web.de wrote:> Hi,

as far as i know SDL_UpdateRect(screen, 0, 0, 0, 0) does not work when
using OpenGL.
It simples crash.
As a solution you can load your bitmaps into a texture and display it by
using
glOrtho.
Just render your 3D view, then switch to the ortho-modus and render your
font.
Nehe has a tutorial for it, just take a look.

Jonas

Hi,

I’m planning to use SDL with OpenGL but one thing I’m
a bit unclear about is the best way to overlay my
OpenGL view with bitmap images and bitmap fonts. I’ve
been using my own bitmap fonts with SDL and overlaying
images using colorKeys. Is there a fairly simple way
to be able to do a similar thing when using SDL with
OpenGL?

I’d like to have a 3D openGL view and then overlay
some text and bitmap images over the 3D view. I’m
using Dev C++ with Windows XP.

Thanks,

Guilherme


To help you stay safe and secure online, we’ve developed the all new Yahoo! Security Centre. http://uk.security.yahoo.com


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl