| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1604 人关注过本帖
标题:关于一个简单的OPENGL程序无法运行的问题请这方面的高手解答一下1
只看楼主 加入收藏
renhao153
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2007-11-10
收藏
 问题点数:0 回复次数:3 
关于一个简单的OPENGL程序无法运行的问题请这方面的高手解答一下1
这是一个在VC6的WIN32控制台下的程序
#include "GL/gl.h"
#include "GL/glu.h"
#include "GL/glaux.h"
#include "stdlib.h"

void display(void)
{
    glClear(GL_COLOR_BUFFER_BIT);
    glColor3f(1.0,1.0,1.0);
    glLoadIdentity();
    glTranslatef(0.0,0.0,-5.0);
    glScalef(1.0,2.0,1.0);
    auxWireCube(1.0);
    glFlush();
}
void myinit(void)
{
    glShadeModel(GL_FLAT);
}
void myReshape(int w,int h)
{
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glFrustum(-1.0,1.0,-1.0,1.0,1.5,20.0);
    glMatrixMode(GL_MODELVIEW);
    glViewport(0,0,w,h);
}
int main(int argc,char **argv)
{
    auxInitDisplayMode(AUX_SINGLE|AUX_RGB);
    auxInitPosition(0,0,500,500);
    auxInitWindow(argv[0]);
    myinit();
    auxReshapeFunc(myReshape);
    auxMainLoop(display);
}

[[it] 本帖最后由 renhao153 于 2008-7-13 13:11 编辑 [/it]]
搜索更多相关主题的帖子: OPENGL void include 
2008-07-13 13:10
renhao153
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2007-11-10
收藏
得分:0 
急回复一下高手们出的错误是
Compiling...
cs.c
d:\vc98\include\gl\gl.h(1152) : error C2054: expected '(' to follow 'WINGDIAPI'
d:\vc98\include\gl\gl.h(1152) : error C2085: 'APIENTRY' : not in formal parameter list
d:\vc98\include\gl\gl.h(1152) : error C2146: syntax error : missing ',' before identifier 'glAccum'
d:\vc98\include\gl\gl.h(1152) : error C2143: syntax error : missing ';' before '('
d:\vc98\include\gl\gl.h(1152) : error C2059: syntax error : ')'
d:\vc98\include\gl\gl.h(1153) : error C2054: expected '(' to follow 'WINGDIAPI'
d:\vc98\include\gl\gl.h(1153) : error C2085: 'APIENTRY' : not in formal parameter list
d:\vc98\include\gl\gl.h(1153) : error C2146: syntax error : missing ',' before identifier 'glAlphaFunc'
d:\vc98\include\gl\gl.h(1153) : error C2143: syntax error : missing ';' before '('
d:\vc98\include\gl\gl.h(1153) : error C2059: syntax error : ')'
d:\vc98\include\gl\gl.h(1154) : error C2054: expected '(' to follow 'WINGDIAPI'
d:\vc98\include\gl\gl.h(1154) : error C2085: 'APIENTRY' : not in formal parameter list
d:\vc98\include\gl\gl.h(1154) : error C2146: syntax error : missing ',' before identifier 'glAreTexturesResident'
d:\vc98\include\gl\gl.h(1154) : error C2143: syntax error : missing ';' before '('
d:\vc98\include\gl\gl.h(1154) : error C2059: syntax error : ')'
d:\vc98\include\gl\gl.h(1155) : error C2054: expected '(' to follow 'WINGDIAPI'
d:\vc98\include\gl\gl.h(1155) : error C2085: 'APIENTRY' : not in formal parameter list
d:\vc98\include\gl\gl.h(1155) : error C2146: syntax error : missing ',' before identifier 'glArrayElement'
d:\vc98\include\gl\gl.h(1155) : error C2143: syntax error : missing ';' before '('
d:\vc98\include\gl\gl.h(1155) : error C2059: syntax error : ')'
d:\vc98\include\gl\gl.h(1156) : error C2054: expected '(' to follow 'WINGDIAPI'
d:\vc98\include\gl\gl.h(1156) : error C2085: 'APIENTRY' : not in formal parameter list
d:\vc98\include\gl\gl.h(1156) : error C2146: syntax error : missing ',' before identifier 'glBegin'
d:\vc98\include\gl\gl.h(1156) : error C2143: syntax error : missing ';' before '('
d:\vc98\include\gl\gl.h(1156) : error C2059: syntax error : ')'
d:\vc98\include\gl\gl.h(1157) : error C2054: expected '(' to follow 'WINGDIAPI'
d:\vc98\include\gl\gl.h(1157) : error C2085: 'APIENTRY' : not in formal parameter list
d:\vc98\include\gl\gl.h(1157) : error C2146: syntax error : missing ',' before identifier 'glBindTexture'
d:\vc98\include\gl\gl.h(1157) : error C2143: syntax error : missing ';' before '('
d:\vc98\include\gl\gl.h(1157) : error C2059: syntax error : ')'
d:\vc98\include\gl\gl.h(1158) : error C2054: expected '(' to follow 'WINGDIAPI'
d:\vc98\include\gl\gl.h(1158) : error C2085: 'APIENTRY' : not in formal parameter list
d:\vc98\include\gl\gl.h(1158) : error C2146: syntax error : missing ',' before identifier 'glBitmap'
d:\vc98\include\gl\gl.h(1158) : error C2143: syntax error : missing ';' before '('
d:\vc98\include\gl\gl.h(1158) : error C2059: syntax error : ')'
d:\vc98\include\gl\gl.h(1159) : error C2054: expected '(' to follow 'WINGDIAPI'
d:\vc98\include\gl\gl.h(1159) : error C2085: 'APIENTRY' : not in formal parameter list
d:\vc98\include\gl\gl.h(1159) : error C2146: syntax error : missing ',' before identifier 'glBlendFunc'
d:\vc98\include\gl\gl.h(1159) : error C2143: syntax error : missing ';' before '('
d:\vc98\include\gl\gl.h(1159) : error C2059: syntax error : ')'
d:\vc98\include\gl\gl.h(1160) : error C2054: expected '(' to follow 'WINGDIAPI'
d:\vc98\include\gl\gl.h(1160) : error C2085: 'APIENTRY' : not in formal parameter list
d:\vc98\include\gl\gl.h(1160) : error C2146: syntax error : missing ',' before identifier 'glCallList'
d:\vc98\include\gl\gl.h(1160) : error C2143: syntax error : missing ';' before '('
d:\vc98\include\gl\gl.h(1160) : error C2059: syntax error : ')'
d:\vc98\include\gl\gl.h(1161) : error C2054: expected '(' to follow 'WINGDIAPI'
d:\vc98\include\gl\gl.h(1161) : error C2085: 'APIENTRY' : not in formal parameter list
d:\vc98\include\gl\gl.h(1161) : error C2146: syntax error : missing ',' before identifier 'glCallLists'
d:\vc98\include\gl\gl.h(1161) : error C2143: syntax error : missing ';' before '('
d:\vc98\include\gl\gl.h(1161) : error C2059: syntax error : ')'
d:\vc98\include\gl\gl.h(1162) : error C2054: expected '(' to follow 'WINGDIAPI'
d:\vc98\include\gl\gl.h(1162) : error C2085: 'APIENTRY' : not in formal parameter list
d:\vc98\include\gl\gl.h(1162) : error C2146: syntax error : missing ',' before identifier 'glClear'
d:\vc98\include\gl\gl.h(1162) : error C2143: syntax error : missing ';' before '('
d:\vc98\include\gl\gl.h(1162) : error C2059: syntax error : ')'
d:\vc98\include\gl\gl.h(1163) : error C2054: expected '(' to follow 'WINGDIAPI'
d:\vc98\include\gl\gl.h(1163) : error C2085: 'APIENTRY' : not in formal parameter list
d:\vc98\include\gl\gl.h(1163) : error C2146: syntax error : missing ',' before identifier 'glClearAccum'
d:\vc98\include\gl\gl.h(1163) : error C2143: syntax error : missing ';' before '('
d:\vc98\include\gl\gl.h(1163) : error C2059: syntax error : ')'
d:\vc98\include\gl\gl.h(1164) : error C2054: expected '(' to follow 'WINGDIAPI'
d:\vc98\include\gl\gl.h(1164) : error C2085: 'APIENTRY' : not in formal parameter list
d:\vc98\include\gl\gl.h(1164) : error C2146: syntax error : missing ',' before identifier 'glClearColor'
d:\vc98\include\gl\gl.h(1164) : error C2143: syntax error : missing ';' before '('
d:\vc98\include\gl\gl.h(1164) : error C2059: syntax error : ')'
d:\vc98\include\gl\gl.h(1165) : error C2054: expected '(' to follow 'WINGDIAPI'
d:\vc98\include\gl\gl.h(1165) : error C2085: 'APIENTRY' : not in formal parameter list
d:\vc98\include\gl\gl.h(1165) : error C2146: syntax error : missing ',' before identifier 'glClearDepth'
d:\vc98\include\gl\gl.h(1165) : error C2143: syntax error : missing ';' before '('
d:\vc98\include\gl\gl.h(1165) : error C2059: syntax error : ')'
d:\vc98\include\gl\gl.h(1166) : error C2054: expected '(' to follow 'WINGDIAPI'
d:\vc98\include\gl\gl.h(1166) : error C2085: 'APIENTRY' : not in formal parameter list
d:\vc98\include\gl\gl.h(1166) : error C2146: syntax error : missing ',' before identifier 'glClearIndex'
d:\vc98\include\gl\gl.h(1166) : error C2143: syntax error : missing ';' before '('
d:\vc98\include\gl\gl.h(1166) : error C2059: syntax error : ')'
d:\vc98\include\gl\gl.h(1167) : error C2054: expected '(' to follow 'WINGDIAPI'
d:\vc98\include\gl\gl.h(1167) : error C2085: 'APIENTRY' : not in formal parameter list
d:\vc98\include\gl\gl.h(1167) : error C2146: syntax error : missing ',' before identifier 'glClearStencil'
d:\vc98\include\gl\gl.h(1167) : error C2143: syntax error : missing ';' before '('
d:\vc98\include\gl\gl.h(1167) : error C2059: syntax error : ')'
d:\vc98\include\gl\gl.h(1168) : error C2054: expected '(' to follow 'WINGDIAPI'
d:\vc98\include\gl\gl.h(1168) : error C2085: 'APIENTRY' : not in formal parameter list
d:\vc98\include\gl\gl.h(1168) : error C2146: syntax error : missing ',' before identifier 'glClipPlane'
d:\vc98\include\gl\gl.h(1168) : error C2143: syntax error : missing ';' before '('
d:\vc98\include\gl\gl.h(1168) : error C2059: syntax error : ')'
d:\vc98\include\gl\gl.h(1169) : error C2054: expected '(' to follow 'WINGDIAPI'
d:\vc98\include\gl\gl.h(1169) : error C2085: 'APIENTRY' : not in formal parameter list
d:\vc98\include\gl\gl.h(1169) : error C2146: syntax error : missing ',' before identifier 'glColor3b'
d:\vc98\include\gl\gl.h(1169) : error C2143: syntax error : missing ';' before '('
d:\vc98\include\gl\gl.h(1169) : error C2059: syntax error : ')'
d:\vc98\include\gl\gl.h(1170) : error C2054: expected '(' to follow 'WINGDIAPI'
d:\vc98\include\gl\gl.h(1170) : error C2085: 'APIENTRY' : not in formal parameter list
d:\vc98\include\gl\gl.h(1170) : error C2146: syntax error : missing ',' before identifier 'glColor3bv'
d:\vc98\include\gl\gl.h(1170) : error C2143: syntax error : missing ';' before '('
d:\vc98\include\gl\gl.h(1170) : error C2059: syntax error : ')'
d:\vc98\include\gl\gl.h(1171) : error C2054: expected '(' to follow 'WINGDIAPI'
d:\vc98\include\gl\gl.h(1171) : error C2085: 'APIENTRY' : not in formal parameter list
d:\vc98\include\gl\gl.h(1171) : error C2146: syntax error : missing ',' before identifier 'glColor3d'
d:\vc98\include\gl\gl.h(1171) : error C2143: syntax error : missing ';' before '('
d:\vc98\include\gl\gl.h(1171) : error C2059: syntax error : ')'
d:\vc98\include\gl\gl.h(1172) : error C2054: expected '(' to follow 'WINGDIAPI'
d:\vc98\include\gl\gl.h(1172) : fatal error C1003: error count exceeds 100; stopping compilation
2008-07-13 13:14
水中无月
Rank: 1
等 级:新手上路
帖 子:190
专家分:9
注 册:2008-6-17
收藏
得分:0 
#include <windows.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glaux.h>
#include <stdlib.h>

#pragma comment(lib, "opengl.lib")
#pragma comment(lib, "glu.lib")
#pragma comment(lib, "glaux.lib")

void display(void)
{
    glClear(GL_COLOR_BUFFER_BIT);
    glColor3f(1.0,1.0,1.0);
    glLoadIdentity();
    glTranslatef(0.0,0.0,-5.0);
    glScalef(1.0,2.0,1.0);
    auxWireCube(1.0);
    glFlush();
}

void myinit(void)
{
    glShadeModel(GL_FLAT);
}

void myReshape(int w,int h)
{
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glFrustum(-1.0,1.0,-1.0,1.0,1.5,20.0);
    glMatrixMode(GL_MODELVIEW);
    glViewport(0,0,w,h);
}

int main(int argc,char **argv)
{
    auxInitDisplayMode(AUX_SINGLE|AUX_RGB);
    auxInitPosition(0,0,500,500);
    auxInitWindow(argv[0]);
    myinit();
    auxReshapeFunc((AUXRESHAPEPROC)myReshape);
    auxMainLoop((AUXMAINPROC)display);
    return 0;
}


小小地帮助你一下,希望这些代码对你有用

十里平湖霜满天,寸寸青丝愁华年,对月形单望相互,只羡鸳鸯不羡仙.
2008-07-13 20:26
renhao153
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2007-11-10
收藏
得分:0 
谢谢
auxReshapeFunc((AUXRESHAPEPROC)myReshape);
    auxMainLoop((AUXMAINPROC)display);
中的(AUXRESHAPEPROC)为什么要这样加了
2008-07-14 10:34
快速回复:关于一个简单的OPENGL程序无法运行的问题请这方面的高手解答一下1
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016606 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved