[Mono-winforms-list] Handle Problem

Jackson Harper jackson@ximian.com
Tue, 12 Oct 2004 08:54:12 -0700


On Tue, 2004-10-12 at 11:09 -0400, Miguel de Icaza wrote:
> Hello,
> 
> > How to link(bind) OpenGL to window, which was created with MONO SWF?
> > 
> > for Windows and Microsoft .NET it is not a problem:
> > We get a handle from window in C# code and in C++ code
> > void Create(HWND hwnd)
> > {
> >   dc=GetDC(cwnd);
> > 
> >   int iPixelFormat = ChoosePixelFormat(dc,&rPFD);
> >   if(!SetPixelFormat(dc,iPixelFormat,&rPFD)) FAIL("SetPixelFormat failed!");
> >   if(!(hRC = wglCreateContext(dc))) FAIL("wglCreateContext failed!");
> > //we have OpenGL context
> > }
> > 
> > How TODO so under mono and linux?
> 
> Well, today Windows.Forms is not completed so I would not claim that you
> can do this.  But thanks for pointing this out, if you could write a
> complete sample, then we will make sure that the same mechanism is
> available on Windows.Forms.
> 
> That being said, it seems that the above is too specific to Windows, as
> the same concept of a "DC" does not exist in X windows.  The best thing
> to do would be to pass the HWND (which we probably are mapping to X IDs
> on X).
> 
> Where does `wglCreateContext' come from?

  wglCreateContext is for creating a context on windows. On X you will
need to use glXCreateContext and glXChooseVisual. Either that or use
GLUT. The Form.Handle property returns the Handle created by
XOpenDisplay so this is the handle that you will need for
glXCreateContext and glXCreateVisual.

Jackson


> 
> _______________________________________________
> Mono-winforms-list maillist  -  Mono-winforms-list@lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-winforms-list