水围国际社区青年公寓:opengl编程

来源:百度文库 编辑:神马品牌网 时间:2024/04/28 14:53:47
我使用的编程工具是VC6.0。
看过一些书,上面的基于opengl的vc程序是依托MFC的,我想请教一下高手,能独立于MFC编写opengl程序吗?该如何编写?

注:现在在看得一本书:《Opengl超级宝典》
它介绍的第一个程序如下:

#include <Opengl.h>

void RenderScene(void)
{
glClear(GL_COLOR_BUFFER_BIT);
}

void SetupRC(void)
{
glClearColor(0.0f, 0.0f, 1.0f, 1.0f);
}

void main(void)
{
glutInitDisplay(GLUT_SINGLE | GLUT_RGB);
glutCreateWindow("Simple");
glutDisplayFunc(RenderScene);

Setup();

glutMainLoop();
}

我首先是建立了一个win32控制台程序,然后项工程里加入C++源文件,将上述代码加入,并在工程设置选项里将opengl32.lib、glu32.lib、glaux.lib添加进去。
编译,提示说:
Compiling...
code.cpp
d:\c++study\simple\code.cpp(1) : fatal error C1083: Cannot open include file: 'OpenGL.h': No such file or directory
Error executing cl.exe.

simple.exe - 1 error(s), 0 warning(s)

我将#include <opengl.h>改成#include <gl.h> #include <glut.h>
编译,提示说:
Compiling...
code.cpp
d:\c++study\simple\code.cpp(1) : fatal error C1083: Cannot open include file: 'GL.h': No such file or directory
Error executing cl.exe.

simple.exe - 1 error(s), 0 warning(s)

我用windows自带的搜索功能搜索到了gl.h和glut.h将他们复制粘贴到
C:\Program Files\VC6\VC98\Include下。
编译,问题更多:
Compiling...
code.cpp
c:\program files\vc6\vc98\include\gl.h(1152) : error C2144: syntax error : missing ';' before type 'void'
c:\program files\vc6\vc98\include\gl.h(1152) : error C2501: 'WINGDIAPI' : missing storage-class or type specifiers
c:\program files\vc6\vc98\include\gl.h(1152) : fatal error C1004: unexpected end of file found
Error executing cl.exe.

simple.exe - 3 error(s), 0 warning(s)

请问高手们,我下一步该怎么办?