PDA

View Full Version : HDC, HWND and GLUT



M/\dm/\n
02-23-2004, 10:18 AM
I'd like to use wglFontOutlines & wglFontBitmaps, but they require HDC. To get HDC I must have HWND of the window I'm rendering to, but I have 2 windows in GLUT. Is there some way to get HWND of rendering window?

M/\dm/\n
02-24-2004, 04:28 AM
??
I know that I could get dc by caling hDC=GetDC(hWnd), but hwnd is usually assigned value by function CreateWindowEx(...., in glut I window is allready created http://www.opengl.org/discussion_boards/ubb/frown.gif
Do I have to get hdc by parsing all active windows & checking their titles??? What do you people do when you have to set up pbuffer, hdc is needed too...

mw
02-24-2004, 04:55 AM
Why do you use GLUT then? If you use Windows specific code (wgl..) you may as well set up your OpenGL window (and rendering context) yourself.

You could search the GLUT source, where window handles are stored, GLUT won't expose these, however (I think), since this would mean to lose cross platform compatibility.

Relic
02-24-2004, 05:22 AM
Platform independence is out of the way if you use wgl functions, means you can also use:
HGLRC wglGetCurrentContext(void);
HDC wglGetCurrentDC(void);

Hint, it sometimes helps if you have a look at a function reference list. http://www.opengl.org/discussion_boards/ubb/wink.gif

M/\dm/\n
02-24-2004, 05:58 AM
Don't want to jump to pure w32 app right now, but will do that. About function list, havn't found a place to find them all together.

Anyway, thanks http://www.opengl.org/discussion_boards/ubb/smile.gif

Vlasko
02-24-2004, 08:23 AM
Try GetActiveWindow() maybe it will work

M/\dm/\n
02-25-2004, 03:28 AM
wglGetCurrentDC works like it should, thanks.

Relic
02-25-2004, 04:09 AM
Originally posted by M/\dm/\n:
[B]About function list, havn't found a place to find them all together.
B]

For any Windows related programming question MSDN is the first choice.

E.g. wgl functions are here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/opengl/ntopnglo_4e7n.asp