新手关于opengl的问题

agamenon 2005-03-12 01:53:55
按书上的教程一步一步如下:
new一个win32 simple application
在stdafx.h里加上:
#include <GL/gl.h>
#include <GL/glaux.h>
#include <afxtempl.h>

在把cpp修改为:#include <GL/gl.h>
#include <GL/glaux.h>

#include <windows.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);
  }
编译显示gl.h有一行(WINGDIAPI void APIENTRY glAccum (GLenum op, GLfloat value);)出现如下问题:
gl.h(1152) : error C2144: syntax error : missing ';' before type 'void'
gl.h(1152) : error C2501: 'WINGDIAPI' : missing storage-class or type specifiers
gl.h(1152) : fatal error C1004: unexpected end of file found
还没弄懂程序是怎么回事,新手第一步就遭受如此挫折,还怎么往下进行啊。
望大侠指点迷津




...全文
215 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
agamenon 2005-03-17
  • 打赏
  • 举报
回复
谢谢
syy64 2005-03-16
  • 打赏
  • 举报
回复
上面的程序我机器上能运行,应该是你的系统问题。
syy64 2005-03-15
  • 打赏
  • 举报
回复
#include <windows.h>
#include <GL/gl.h>

#include <GL/glu.h>
#include <GL/glaux.h>
//#include <gl/glut.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);
}
billy145533 2005-03-15
  • 打赏
  • 举报
回复
ding
agamenon 2005-03-15
  • 打赏
  • 举报
回复
还是不认_sleep(1000)

另外我问一句:我的步骤对吗?我看有的书上是这么写的:new 一个win32 空的application而不是simple application,然后插入cpp source文件,在里面代码。我那样编的话会显示gl.h文件有问题:gl\gl.h(1152) : error C2144: syntax error : missing ';' before type 'void'。那一行代码是这样的:WINGDIAPI void APIENTRY glAccum (GLenum op, GLfloat value);

但有的的书上是象我这样的。因为还要修改头文件stdafx.h。

会不会是我的6.0本身就有问题呢??
syy64 2005-03-14
  • 打赏
  • 举报
回复
http://community.csdn.net/Expert/topic/3822/3822923.xml?temp=.7916223
agamenon 2005-03-14
  • 打赏
  • 举报
回复
还是通不过:

1.cpp(21) : error C2065: '_sleep' : undeclared identifier


syy64 2005-03-13
  • 打赏
  • 举报
回复
应该是*.h文件没设对,你的*.cpp没有包含stdafx.h,而且还缺glu.h
agamenon 2005-03-13
  • 打赏
  • 举报
回复
我按你说的加了后编译出现81个错误,全是1.cpp(11) : error C2018: unknown character '0xa1'

19,466

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 图形处理/算法
社区管理员
  • 图形处理/算法社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧