PDA

View Full Version : [JEDI-SDL & OpenGL] How to render text on OpenGL scene



Loodziek
07-12-2007, 06:14 PM
Hi again guys, it's me again ;) Ok, there's a question: how to render text on OpenGL scene? Blitting text surface doesn't work. Has anyone got any tutorials or examples how to do it?

arthurprs
07-12-2007, 08:06 PM
take a look at http://www.nitrogen.za.org/

you can find the bitmap font generator and the engine

Loodziek
07-12-2007, 08:48 PM
Well, I use SDL_TTF to load fonts, so bitmap fonts are out...

arthurprs
08-12-2007, 12:05 AM
Well, I use SDL_TTF to load fonts, so bitmap fonts are out...

I think you can't use them in opengl :?

WILL
08-12-2007, 04:26 AM
There are tutorials on the NeHe website (http://nehe.gamedev.net/) that can show you how to use TTF via OpenGL it's self. I doubt that you can use the SDL font functions in OpenGL.

Loodziek
08-12-2007, 08:13 AM
Ok, I left TTF and start learning how to use Bitmap fonts :) But there's another question: how to do this without WinAPI? At NeHe I have found Delphi OpenGL demo how to use bitmap fonts, but there's problem. Demo (http://nehe.gamedev.net/data/lessons/delphi/lesson13.zip) author use HFONT to do this. I work with Freepascal and Lazarus, so I can't do it this way. What's "crossplatform" HFONT equivalent?

-Edit-
I have found how to do it in GLUT. Thanks a lot guys ;)


-Edit-
Erm... I still don't know to load bitmap fonts from *.bmp file generated for e.g. with Font Studio 4. Is there any example?

arthurprs
08-12-2007, 03:28 PM
Ok, I left TTF and start learning how to use Bitmap fonts :) But there's another question: how to do this without WinAPI? At NeHe I have found Delphi OpenGL demo how to use bitmap fonts, but there's problem. Demo (http://nehe.gamedev.net/data/lessons/delphi/lesson13.zip) author use HFONT to do this. I work with Freepascal and Lazarus, so I can't do it this way. What's "crossplatform" HFONT equivalent?

-Edit-
I have found how to do it in GLUT. Thanks a lot guys ;)


-Edit-
Erm... I still don't know to load bitmap fonts from *.bmp file generated for e.g. with Font Studio 4. Is there any example?

i writed a png exporter for fontstudio
http://www.freeshells.ch/~arthurpr/PNGEXPORT.rar

Loodziek
13-12-2007, 01:28 PM
I have thinked about it, and it's my idea. We render text on PSDL_Surface, right? So, why don't this surface using glBitmap or glDrawPixels? I'm trying to do that, but I get errors. Is there something wrong? Can you tell my what should I do?

grudzio
13-12-2007, 07:07 PM
Here (http://www.pascalgamedevelopment.com/viewtopic.php?t=3179&start=15) you can find code to render text in OpenGL using sdl_ttf library.

WILL
14-12-2007, 02:48 AM
Ok if you are using SDL and you are using OpenGL for graphics, NONE of your SDL graphics commands can be used. Period. :) The graphics functions and surfaces for SDL and OpenGL are generally not compatible with each other.

That said... the use of both TTF (or other formats) and bitmap/raster fonts are both doable, but have different advantages so decide which you want based on what you think your program needs most and what works best for you.