调试第一个opengl 程序竟然有误,请大家多多帮忙。

superzrb 华兴 2003-08-26 05:00:14
感觉是vc6环境没设置好:
出错问题是:
Compiling...
aa.cpp
c:\program files\microsoft visual studio\vc98\include\gl\gl.h(1152) : error C2144: syntax error : missing ';' before type 'void'
c:\program files\microsoft visual studio\vc98\include\gl\gl.h(1152) : error C2501: 'WINGDIAPI' : missing storage-class or type specifiers
c:\program files\microsoft visual studio\vc98\include\gl\gl.h(1152) : fatal error C1004: unexpected end of file found
Error executing cl.exe.

aa.obj - 3 error(s), 0 warning(s)

源代码如下:
#include <GL/gl.h>
#include <GL/glaux.h>
#include "glos.h"

void main(void)
{
auxInitDisplayMode(AUX_SINGLE|AUX_RGBA);
auxInitPosition(0,0,500,500);
auxInitWindow("simple");
glClearColor(0.0,0.0,0.0,0.0);
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0,0.0,0.0);
glRectf(-0.5,-0.5,0.5,0.5);
glFlush();
_sleep(1000);
}
...全文
13 点赞 收藏 5
写回复
5 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
MooseWOler 2003-08-27
2楼写的没错,但是运行之前还要把opengl32.lib,glu32.lib,glaux.lib
3个库import进去,这样就没问题了。
回复
superzrb 2003-08-27
库opengl32.lib,glu32.lib,glaux.lib我在project的settting中本就已经设置好了。

FatGarfield说的是对的。给分了。
回复
rogueking 2003-08-26
先看看其他地方有没有调过gl.h,glu.h,glaux.h三个文件。再试试二楼的方法。
回复
FatGarfield 2003-08-26

#include "windows.h"
#include <GL/gl.h>
#include <GL/glaux.h>

void main(void)
{
auxInitDisplayMode(AUX_SINGLE|AUX_RGBA);
auxInitPosition(0,0,500,500);
auxInitWindow("simple");
glClearColor(0.0,0.0,0.0,0.0);
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0,0.0,0.0);
glRectf(-0.5,-0.5,0.5,0.5);
glFlush();
_sleep(1000);
}
回复
gzshd 2003-08-26

#include <GL/gl.h>
#include <GL/glaux.h>
#include "glos.h"

#pragma comment(lib,"opengl32.lib");
#pragma comment(lib,"glu32.lib");
#pragma comment(lib,"glaux.lib");

void main(void)
{
auxInitDisplayMode(AUX_SINGLE|AUX_RGBA);
auxInitPosition(0,0,500,500);
auxInitWindow("simple");
glClearColor(0.0,0.0,0.0,0.0);
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0,0.0,0.0);
glRectf(-0.5,-0.5,0.5,0.5);
glFlush();
_sleep(1000);
}
回复
发帖
图形处理/算法
创建于2007-09-28

1.9w+

社区成员

VC/MFC 图形处理/算法
申请成为版主
帖子事件
创建了帖子
2003-08-26 05:00
社区公告
暂无公告