OpenGL画一个圆

作者:追风剑情 发布于:2019-6-2 9:56 分类:OpenGL

一、首先确保已经通过NuGet安装了nupengl

二、解决方案平台设置为x64

111.png

因为在x86下要报错,未找到原因

222.png

三、写示例代码


  1. #include <GL/freeglut.h>
  2. //运行发布出来的exe时,不再显示dos窗口,但在VS中运行还是会显示。
  3. #pragma comment(linker, "/subsystem:\"windows\" /entry:\"mainCRTStartup\"")
  4.  
  5. void init()
  6. {
  7. glClearColor(0.0, 0.0, 0.0, 0.0);
  8. }
  9.  
  10. void display()
  11. {
  12. glClear(GL_COLOR_BUFFER_BIT);
  13. glColor3f(1.0, 0.0, 0.0);
  14. glutSolidSphere(0.5, 50, 6);
  15. glFlush();
  16. }
  17.  
  18.  
  19. int main(int argc, char ** argv)
  20. {
  21. glutInit(&argc, argv);
  22. glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA);
  23. glutInitWindowSize(200, 200);
  24. glutInitWindowPosition(0, 0);
  25. glutCreateWindow("第一个窗口");
  26. init();
  27. glutDisplayFunc(display);
  28. glutMainLoop();
  29. return 0;
  30. }


四、运行

111.png

标签: OpenGL

Powered by emlog  蜀ICP备18021003号-1   sitemap

川公网安备 51019002001593号