View Full Version : Embedding OpenGL graphics in a webpage
Hi, I'm trying to convert the graphics for a Netscape plug-in I wrote to OpenGL, but am not sure how to go about drawing into the existing window. A handler to this window is passed to the plug-in by Netscape Communicator. At this point, the current implementation subclasses the window so that it can draw into it. Is there something like this that I can do in OpenGL? Any other ideas on how to put graphics into an existing window given a handler for it?
07-03-2002, 08:50 AM
Any other ideas on how to put graphics into an existing window given a handler for it?
what do mean by a "handle" to the window? if you mean a Device Context, then yes, you could create a rendering context for that device context and render to it. without any code to look at, I couldn;t help you further.
BTW the above would only work on a windows machine.
07-03-2002, 09:02 AM
If you have a handle, then you can get a DC from that and create a render context with that DC.
Thanks for the help. I think I'm headed in the right direction now.
One more question:
I'm working off of an example I found on the opengl.org website (http://www.opengl.org/developers/documentation/OGL_userguide/OpenGLonWin-11.html), but have run into a bit of a snag. I'm getting a bunch of errors with the following line of code:
hDC = GetDC(hWnd);
where hDC is an HDC and hWnd is an HWND. The first error is that GetDC does not take any parameters. The second is about not being able to convert the result of GetDC from type CDC to HDC. Any ideas on what could be causing these errors?
P.S. I've included the files windows.h, GL/gl.h, and GL/glu.h.
07-04-2002, 12:06 AM
I think you are using MFC! (arrrrrggg).
CDC is a wrapper class for an hDC. CWnd is a wrapper class for an hWnd.
Presumably, you are within a window class already, in which case you can just say:
CDC MyDC = GetDC ();
Or something like that! (e.g. CDD MyDC ( GetDC () ). Etc. I can't remember exactly how it goes.......
07-04-2002, 07:49 AM
CDC *pDC = GetDC();
HDC hDC = pDC->GetSafeHdc();
Or... you could do this...
HDC hDC = ::GetDC(hWnd);
Since you're already in a CWnd derived class, I would tend to go with the first method. Since you are already using MFC for other stuff, you may as well be consistent and use the MFC functions for that as well.
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.