Ubuntu下glfw的安装与使用

前端之家收集整理的这篇文章主要介绍了Ubuntu下glfw的安装与使用前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

编译D435出错

CMake Error: The following variables are used in this project,but they are set to NOTFOUND.

第一步,下载glfw

到地址www.glfw.org下载glfw source code:glfw-3.2.1.zip,解压

$unzip glfw-3.2.1.zip -d glfw-3.2.1


第二步,编译安装glfw

1. 安装依赖库,
$sudoapt-get build-dep glfw
$sudo apt-get install cmake xorg-dev libglu1-mesa-dev
2.进入 glfw3-3.x.x 目录,建立glfw-build子目录,
$sudo mkdir glfw-build
3. 进入glfw-build,使用cmake命令生成Makefile
$sudo cmake ../
4. make && make install
$sudo make
$sudo make install

第三步,使用glfw

建立main.cpp 输入下面的代码
[plain] view plain copy
  1. #include
  2. intmain(void)
  3. {
  4. GLFWwindow*window;
  5. /*Initializethelibrary*/
  6. if(!glfwInit())
  7. return-1;
  8. /*CreateawindowedmodewindowanditsOpenGLcontext*/
  9. window=glfwCreateWindow(640,480,"HelloWorld",NULL,NULL);
  10. if(!window)
  11. {
  12. glfwTerminate();
  13. return-1;
  14. }
  15. /*Makethewindow'scontextcurrent*/
  16. glfwMakeContextCurrent(window);
  17. /*Loopuntiltheuserclosesthewindow*/
  18. while(!glfwWindowShouldClose(window))
  19. {
  20. /*Renderhere*/
  21. /*Swapfrontandbackbuffers*/
  22. glfwSwapBuffers(window);
  23. /*Pollforandprocessevents*/
  24. glfwPollEvents();
  25. }
  26. glfwTerminate();
  27. return0;
  28. }

猜你在找的Ubuntu相关文章