Jump to content
  • Advertisement
Sign in to follow this  

SDL and NeHe's "glPrint"

This topic is 3371 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I set out a few hours earlier to add font support for my game, thinking it might be a trivial matter, but of course, that's always naive foolishness. The font code on NeHe seems fairly straightforward, the only problem being that I'm using SDL, and as such don't have access to the window handle or device context. So, thinking I'd found my solution, I came across SDL_GetWMInfo. This returns a struct containing, among other information, the window handle. Unfortunately, this seems to return 0 instead of a valid window handle. I've also tried the windows function FindWindow(NULL, "SDL_app") but that returns null as well. I am indeed calling all of these functions post SDL initialization. The offending code:
GLvoid VideoManager::BuildFont(GLvoid)					
	HFONT	font;										
	HFONT	oldfont;									

	SDL_SysWMinfo info;

	HDC hDC = GetDC(info.window);

	m_base = glGenLists(96);								

	font = CreateFont(	-24,							
						"Courier New");					

	oldfont = (HFONT)SelectObject(hDC, font);           
	wglUseFontBitmaps(hDC, 32, 96, m_base);				
	SelectObject(hDC, oldfont);							

I would use SDL_ttf, but it seems I'd have to blit the result via SDL_BlitSurface, and that can't be used as I'm in OpenGL mode. Any suggestions?

Share this post

Link to post
Share on other sites
You can use a custom bitmap font instead.
I did a demo in assembly language here...
Somewhere around here i have a C version i can post later.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!