[英]how to integrate the opengl window in windows form application
I am using OpenGL and TaoFramework in c# . 我在c#中使用OpenGL和TaoFramework。 I created a window for openGL excluding the windows form and I dont know how can I integrate this window in windows form.
我为openGL创建了一个不包含Windows窗体的窗口,但我不知道如何将该窗口集成到Windows窗体中。
[STAThread]
static void Main()
{
Glut.glutInit();
Glut.glutInitDisplayMode(Glut.GLUT_DOUBLE | Glut.GLUT_RGB | Glut.GLUT_DEPTH);
Glut.glutGetWindow();
Glut.glutInitWindowSize(600, 600);
Glut.glutInitWindowPosition(700, 100);
Glut.glutCreateWindow("Lang Yuzer Robot Arm");
Gl.glEnable(Gl.GL_COLOR_MATERIAL);
Gl.glEnable(Gl.GL_LIGHTING);
Gl.glEnable(Gl.GL_LIGHT0);
Gl.glEnable(Gl.GL_DEPTH_TEST);
Gl.glEnable(Gl.GL_NORMALIZE);
Gl.glEnable(Gl.GL_CULL_FACE);
Glut.glutDisplayFunc(Form1.myDisplay);
Glut.glutReshapeFunc(Form1.myReshape);
Glut.glutIdleFunc(Form1.myIdle);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
Glut.glutMainLoop();
}
}
GLUT is a windowing toolkit; GLUT是一个窗口工具包; WinForms is a different windowing toolkit.
WinForms是一个不同的窗口工具包。 Unless GLUT allows reparenting (unlikely), there is no straightforward way to combine the two.
除非GLUT允许重成族(不太可能),否则没有直接的方法将两者结合起来。
The best solution would be to use OpenTK.GLControl
, which is cross-platform and well maintained. 最好的解决方案是使用
OpenTK.GLControl
,它是跨平台的并且维护良好。 NuGet version available here: https://www.nuget.org/packages/OpenTK.GLControl/ NuGet版本可在此处获得: https : //www.nuget.org/packages/OpenTK.GLControl/
Another solution would be to use Tao.SimpleGlControl
, which is windows-only and no longer maintained. 另一个解决方案是使用
Tao.SimpleGlControl
,它仅用于Windows,不再维护。
Without messing around with Window handles, I would suggest using OpenTK, which uses the Tao Framework. 在不搞乱Window句柄的情况下,我建议使用OpenTK,它使用Tao框架。 This library has an OpenGLControl which makes integrating OpenGL graphics into a windows form.
该库具有OpenGLControl,可将OpenGL图形集成到Windows窗体中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.