NetBeans 6.0 有一个 OpenGL 开发包,但那是基于 OpenGL 的 Java 包装 JOGL 的,况且 NetBeans 6.0 要到年底才发布正式版,目前的开发版都不太稳定。我这里说的是搭建 Windows 本地的 OpenGL 开发环境。按照以下步骤:

  1. 下载必备的工具:NetBeans IDE 5.5.1、NetBeans C/C++ 开发包、MinGW、GLUT。前三个安装,GLUT 解压缩到一个目录下。
  2. 配置 NetBeans C/C++ 开发包和 MinGW,在我前面的文章中有,不重复了。
  3. 把 GLUT 目录加入到系统的环境变量中,确保 glut32.dll 可见。
  4. 把 glut.h 复制到 MinGW 安装目录下的 include\GL 中。

这样环境就算搭建好了。在编译的时候还有点注意事项。在 C/C++ 项目的属性里面,把 glut32.lib 文件加入到库中(用绝对路径),并设置库选项 -lopengl32 和 -lglu32。glut32.dll 不是标准 Windows 库,所以不能用 -lglut32。现在已经可以顺利生成项目了。在分发的时候,最好复制一份开发时用的 glut32.dll 到生成的程序所在的目录中,以防用户没有安装 glut32.dll 或版本冲突。

    There is an OpenGL development pack for NetBeans 6.0, but that is based on JOGL, the Java wrapper of OpenGL, and, besides, the final version of NetBeans 6.0 is scheduled to be released in the end of this year, and the current development versions are not very stable. My meaning here is to build a Windows native OpenGL development environment. Follow the steps below:

  1. Download necessary tools: NetBeans IDE 5.5.1, NetBeans C/C++ development pack, MinGW, GLUT. Install the first three and unpack GLUT to a directory.
  2. Configure NetBeans C/C++ development pack and MinGW, which has been detailed in my previous article and will not be repeated here.
  3. Add GLUT directory to the system’s environment variables to make sure glut32.dll is visible.
  4. Copy glut.h to include\GL under MinGW installation directory.

Like this the environment is set up. There are still some points to be noticed while compiling. In the properties of a C/C++ project, add glut32.lib into libraries (using absolute path), and set libraries options to -lopengl32 and -lglu32. glut32.dll is not a standard Windows library, so -lglut32 is useless. Now the project can be built successfully. When distributing, it it best to install glut32.dll used during development into the same directory as the built application, for avoiding the situation that the user doesn’t install glut32.dll or version conflict.