
opentk + WPF
Posted Wednesday, 24 February, 2010 - 13:44 by micoren inHi
I have to create a wpf application that host an opengl viewport.
I have my wpf application with my UI, now I need to create the opengl viewport.
Searching in this site brought me to this.
I read the entire discussion and added the example code to my application.
The problem is this: I am not able to find a way to restrict the graphic context(my viewport) inside a border or a defined area; the viewport is always at fullsize inside my window.
At the beginning of the project description there is an introduction that says :"Right now, it is possible to create an OpenTK.GLControl and host it in a WPF using a WindowsFormsHost."
So I thought that in this way It was easier to restrict the viewport to a specific area, I've included opentk dll and set the using to opentk but I can't find the GLControl class.
Any suggestions?
thank you


Comments
Re: opentk + WPF
I forgot to say that I work with C#.
I think that the solution for the case without the windowsFormHost is in this method:
In the creation of the graphicsContext how can I tell to not cover the entire form?
If it can't be done in this way how can I create the graphics context inside the windowsFormHost?
Re: opentk + WPF
GLControl resides in OpenTK.GLControl.dll so make sure you include that, too.
Your code above may not work reliably due to airspace restrictions. Last time I tried this I encountered graphics corruption.
However, what you can do is create a WindowsFormsHost and instantiate a GraphicsContext directly on its window handle (without going through GLControl). There's no inherent advantage or disadvantage to this approach over using GLControl, both are pretty much equivalent in this case.
Edit: example code for GLControl (from an earlier discussion on opengl.org).
Re: opentk + WPF
Thank you!!!
It worked!!!
Now I created my viewport.
thank again