PART ONE
step1: Install the IDE Microsoft Visual Studio by the "Visual Studio installer". Ensure that your IDE had already downloaded the "使用C++的桌面开发" components .
step2: Run your IDE and click the “创建新项目(N)”.
step3: Click the “控制台应用”, than "下一步(N)" .
step4: Input a name in "ConsoleApplication", here is "OpenGL" . Than click the "创建(C)".
step5: Right-Click the "OpenGL", than Left_Click the "管理NuGet程序包(N)" . Make sure that "浏览" is choosed. Input "nupengl' in "搜索(Ctrl+L) ", than click the "安装" button with your Computer is working ONLINE.
step6: Cloose the "NuGet: OpenGL" and "输出".
step7: Delete the codes in "OpenGL.cpp" and copy&paste codes showing in PART TWO, Click the "本地Windows调试器" to run the pasted codes in "OpenGL.cpp".
PART TWO
codes.cpp
#include#include using namespace std; int main(int argc, char** argv) { cout << argc << "n" << *argv << endl; glutInit(&argc, argv); glutCreateWindow(*argv); glutMainLoop(); return 0; }
PART THREE
代码分析
1、在Visual Studio中安装glut窗口库,因为OpenGL库的头文件gl.h、glu.h包含在glut库中,故在#include
2、在main()中,glutInit()完成对glut库的初始化。glutCreateWindow()根据主函数传入的*argv,在GPU端启用屏幕缓冲区,获得对显存的使用权。屏幕缓冲区具体使用方法,见Default Framebuffer。
注:NuGet程序包中,也可以单独安装glew、glfw等。



