TTF within a SDL-OpenGL context

Hi,

I am beginning to play arround with SDL and also OpenGL. I am interested
in Open GL just because in my firsts tests, plain SDL seemed too slow;
arround 40FPS for a TTF text counting down. My hardware is not the best
but glxgears gives me much better results with real-time 3D scene
rendering.

I started some tests with OpenGL on SDL, basically I got the SDL website
example where you spin a cube. I just wanted to put some real-time FPS
counter with a TTF verdana font, but can’t see any text on the GL scene
and it makes it so slow than you think it is just stopped.

(Before trying to use the ttf I had like 400FPS while rotating the cube,
afterwards I just had 3FPS!!!)

What am I doing wrong?
How can I use TTF fonts on a GL context scene? (Preferably SDL native
solution or C, not C++ like GLTT)

Thanks in advance for you help!

(I attach the failing program)

Jose
-------------- next part --------------
A non-text attachment was scrubbed…
Name: sdltest2.c
Type: text/x-csrc
Size: 11625 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20041108/9416e126/attachment.c

Ok, I skimmed the code and I couldn’t find anything wrong there, let’s
see about the compiler environment you are using.

One thing that will tell you exactly where the time of your
application is going to is profiling. In GCC put the option -pg in
both compiling and linking. Then you run the program to use gprof and
see the profiling informationOn Mon, 08 Nov 2004 19:09:26 +0100, Jose Luis Vazquez Gonzalez wrote:

Hi,

I am beginning to play arround with SDL and also OpenGL. I am interested
in Open GL just because in my firsts tests, plain SDL seemed too slow;
arround 40FPS for a TTF text counting down. My hardware is not the best
but glxgears gives me much better results with real-time 3D scene
rendering.

I started some tests with OpenGL on SDL, basically I got the SDL website
example where you spin a cube. I just wanted to put some real-time FPS
counter with a TTF verdana font, but can’t see any text on the GL scene
and it makes it so slow than you think it is just stopped.

(Before trying to use the ttf I had like 400FPS while rotating the cube,
afterwards I just had 3FPS!!!)

What am I doing wrong?
How can I use TTF fonts on a GL context scene? (Preferably SDL native
solution or C, not C++ like GLTT)

Thanks in advance for you help!

(I attach the failing program)

Jose


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


“The reasonable man adapts himself to the world: the unreasonable one
persists in trying to adapt the world to himself. Therefore all
progress depends on the unreasonable man.” George Bernard Shaw

“We live together, you and I, in a dark time when all official history
is propaganda” John Taylor Gatto,
http://www.johntaylorgatto.com/underground/prologue7.htm

[…]

I started some tests with OpenGL on SDL, basically I got the SDL website
example where you spin a cube. I just wanted to put some real-time FPS
counter with a TTF verdana font, but can’t see any text on the GL scene
and it makes it so slow than you think it is just stopped.

(Before trying to use the ttf I had like 400FPS while rotating the cube,
afterwards I just had 3FPS!!!)

What am I doing wrong?
How can I use TTF fonts on a GL context scene? (Preferably SDL native
solution or C, not C++ like GLTT)

You cannot mix the SDL 2D API with OpenGL.
Instead, upload your SDL surface as OpenGL texture and draw that.

IIRC, there is an example in test/testgl.c how to convert your SDL surface to
an OpenGL texture.

Regards,
Johannes

< http://libufo.sourceforge.net > The OpenGL GUI ToolkitAm Montag 08 November 2004 19:09 schrieb Jose Luis Vazquez Gonzalez: