Fast wxFont rendering on a wxGLCanvas

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
Jengu
Earned a small fee
Earned a small fee
Posts: 20
Joined: Fri Jun 24, 2005 9:45 am

Fast wxFont rendering on a wxGLCanvas

Post by Jengu »

I'm trying to figure out a quick way to render text using wxFonts on a wxGLCanvas. This is proving to be sort of hard.

First, I draw the text to a wxMemoryDC. Then I convert the wxMemoryDC to a wxBitmap. Then I convert the wxBitmap to a wxImage. THEN I use wxImage::GetData() to make an OpenGL texture.

This is really inefficient and slow. Is there a faster way? The only thing I can think of is using a separate library for font rendering (one of the many OpenGL wrappers around freetype).
User avatar
Ryan Norton
wxWorld Domination!
wxWorld Domination!
Posts: 1319
Joined: Mon Aug 30, 2004 6:01 pm

Re: Fast wxFont rendering on a wxGLCanvas

Post by Ryan Norton »

Jengu wrote:I'm trying to figure out a quick way to render text using wxFonts on a wxGLCanvas. This is proving to be sort of hard.

First, I draw the text to a wxMemoryDC. Then I convert the wxMemoryDC to a wxBitmap. Then I convert the wxBitmap to a wxImage. THEN I use wxImage::GetData() to make an OpenGL texture.

This is really inefficient and slow. Is there a faster way? The only thing I can think of is using a separate library for font rendering (one of the many OpenGL wrappers around freetype).
wxGLCanvas is a pretty light wrapper... for fonts you'll have to get down to platform-specific gl calls like the windows version at
http://msdn.microsoft.com/library/defau ... o_1h6f.asp
[Mostly retired moderator, still check in to clean up some stuff]
geon
I live to help wx-kind
I live to help wx-kind
Posts: 189
Joined: Tue Sep 07, 2004 4:10 pm
Location: Sweden, Uppsala

Post by geon »

White your own print function. I reccoment you put your font in a pre-rendered texture and render each character as a quad.
Post Reply