2011-12-18 127 views
0

迄今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應用程序的功能?如何添加其他窗口和麪板?

回答

3

OpenGL只是一個繪圖API。創建頂層窗口不在它的範圍之內。用OpenGL實現GUI工具箱是完全可能的。不過,我認爲你最好使用像Qt或GTK這樣的真正的工具包。

到目前爲止,您使用的不是OpenGL的一部分的GLUT,這是一個適用於小型和簡單示例程序的第三方庫。你不會被迫使用它。

+0

啊哈,感謝您的澄清!我會嘗試Gtk下我想 – wrongusername 2011-12-18 16:57:11

1

如果您使用的是OpenGL硬核,您可能需要查看Clutter。它是一個提供基於OpenGL的小部件的庫。

+0

感謝您的信息! 「硬核」是什麼意思? – wrongusername 2011-12-19 03:30:21

+0

@wrongusername排除非OpenGL窗口和小部件。 – casualcoder 2011-12-20 23:26:00

相關問題