在OpenGL应用程序添加菜单栏和其他窗口
迄今OpenGL的程序的主要功能我的代码基本上是这样的:在OpenGL应用程序添加菜单栏和其他窗口
int main(int argc, char **argv)
{
glutInit(&argc, argv); // Initialize GLUT
glutInitDisplayMode(GLUT_SINGLE); // Set up a basic display buffer (only single buffered for now)
glutInitWindowSize(500, 500); // Set the width and height of the window
glutInitWindowPosition(100, 100); // Set the position of the window (on your screen)
glutCreateWindow("Statistical Mechanics Simulation"); // Set the title for the window
glutDisplayFunc(display); // Tell GLUT to use the method "display" for rendering
glutReshapeFunc(reshape); // Tell GLUT to use the method "reshape" for rendering
glutIdleFunc(simulate);
containers.push_back(Container(Coordinate(-50, -50, -50), Coordinate(100, 100, 50)));
containers[0].addParticle(Particle(1, 5, Coordinate(30, 30, 0), Coordinate(5, 3, 0)));
containers[0].addParticle(Particle(4, 2, Coordinate(-10, 20, 0), Coordinate(0, 0, 0)));
containers[0].addParticle(Particle(5, 5, Coordinate(0, 0, 0), Coordinate(50, 0, 0)));
glutMainLoop(); // Enter GLUT's main loop
return 0;
}
什么将菜单栏添加到此OpenGL的顶部的最佳方式窗口,以便它可以更像普通Windows应用程序的功能?如何添加其他窗口和面板?
OpenGL只是一个绘图API。创建顶层窗口不在它的范围之内。用OpenGL实现GUI工具箱是完全可能的。不过,我认为你最好使用像Qt或GTK这样的真正的工具包。
到目前为止,您使用的不是OpenGL的一部分的GLUT,!这是一个适用于小型和简单示例程序的第三方库。你不会被迫使用它。
如果您使用的是OpenGL硬核,您可能需要查看Clutter。它是一个提供基于OpenGL的小部件的库。
感谢您的信息! “硬核”是什么意思? – wrongusername 2011-12-19 03:30:21
@wrongusername排除非OpenGL窗口和小部件。 – casualcoder 2011-12-20 23:26:00
啊哈,感谢您的澄清!我会尝试Gtk下我想 – wrongusername 2011-12-18 16:57:11