How to display a glut window inside Windows Form?
glutCreateWindow("Example") create another form,
glutCreateSubWindow(hwnd, 0, 0, 100, 100), where hwnd is handle to my main Window Form in C#, i get an AccessViolation Exception.
The Glut program is in a C++ DLL. My application is on C# WPF. I need to display glut view at my C# Form
C++ code:
extern "C"
{
__declspec(dllexport) int InitGlut(int hwnd, int top, int left, int width, int height)
{
glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
glutInitWindowPosition(top,left);
glutInitWindowSize(320,320);
//glutCreateWindow("Example");
glutCreateSubWindow(hwnd, top, left, width, height);
glutDisplayFunc(renderScene);
glutMainLoop();
return 0;
}
}
C# code:
const string pathToDll = "../../../Release/MyDLL.dll";
[DllImport(pathToDll)]
public static extern int InitGlut(IntPtr hwnd, int top, int left, int width, int height);
private void Window_Loaded(object sender, RoutedEventArgs e)
{
IntPtr hwnd = new WindowInteropHelper(Application.Current.MainWindow).Handle;
InitGlut(hwnd, 0, 0, 100, 100);
}