OpenGL(一)Introduction

  • 前言:参考网上的OpenGL学习教程,记录自己学习过程的点滴收获。
  • OpenGL
    • OpenGL, also known as the Open Graphics Library, is a library designed for cross platform 3D graphics. It is directly, the only competitor to Direct3D in the DirectX library. OpenGL is also hardware accelerated, just like Direct3D, and both of these libraries are the main focus for graphics card performance.
  • GLUT(OpenGL实用工具包)
    • GLUT (The OpenGL Utility), is a tool which allows the creation of windows and handling of input on multiple systems. Making OpenGL cross-platform and extremely simple to set up.
    • 更多见:http://www.opengl.org/resources/libraries/glut/
  • 环境搭建(vs2005)
    • 下载glut文件(glut.h、glut32.dll、glut32.lib)
    • 拷贝glut文件至相应目录
      • glut.h--->vs2005安装目录\VC\PlatformSDK\include\GL
      • glut32.lib--->vs2005安装目录\VC\PlatformSDK\Lib
      • glut32.dll--->C:\WINDOWS\system32
  • 小试一把^-^
    • 建一空的控制台工程
    • 代码如下:
       1 #include <GL/glut.h>
      2
      3 void myDisplay(void)
      4 {
      5 glClear(GL_COLOR_BUFFER_BIT);
      6 glRectf(-0.5f, -0.5f, 0.5f, 0.5f);
      7 glFlush();
      8 }
      9
      10 int main(int argc, char *argv[])
      11 {
      12 glutInit(&argc, argv);
      13 glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);
      14 glutInitWindowPosition(100, 100);
      15 glutInitWindowSize(400, 400);
      16 glutCreateWindow("OpenGL程序");
      17 glutDisplayFunc(&myDisplay);
      18 glutMainLoop();
      19 return 0;
      20 }
    • 结果:

      OpenGL(一)Introduction

  • 参考:

你可能感兴趣的:(OpenGL)