
求助一个简单的OpenGL程序运行不了的问题,请高手帮忙啊
程序是#include<windows.h>#include<gl.h>#include<glu.h>#include<glaux.h>voidCALLBACKPaint...
程序是
#include <windows.h>
#include <gl.h>
#include <glu.h>
#include <glaux.h>
void CALLBACK Paint(void)
{ glClearColor(0.0, 0.0, 0.0, 0.0); // 置背景色为黑色
glClear(GL_COLOR_BUFFER_BIT); // 清除颜色缓冲区
glColor3f(1.0, 1.0, 1.0); // 设置象素颜色为白色
glMatrixMode(GL_PROJECTION); // 指定投影矩阵为当前矩阵
glLoadIdentity(); // 使用单位矩阵替换当前矩阵
// 描述一个产生平行投影的透视矩阵
glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0);
glBegin(GL_POLYGON); // 开始定义多边形
glVertex2f(-0.5, -0.5); // 定义顶点
glVertex2f(-0.5, 0.5);
glVertex2f(0.5, 0.5);
glVertex2f(0.5, -0.5);
glEnd(); // 结束多边形的定义
glFlush(); // 强制执行OpenGL函数
}
int main(int argc, char** argv)
{ auxInitDisplayMode(AUX_SINGLE | AUX_RGBA); // 设置窗口的特征
auxInitPosition(0, 0, 500, 500); // 设置程序窗口在屏幕上的位置和大小
auxInitWindow(argv[0]); // 设置窗口的标题
auxMainLoop(Paint);// 指定场景绘制循环函数
return 0;
}
在VC++6.0中新建一个C++source file粘贴进去编译时通过了,但运行时出现n多错误
请问OpenGL程序要怎么什么平台下编译的啊?是不是要创建一个什么工程啊?
--------------------Configuration: opengl - Win32 Debug--------------------
Linking...
opengl.obj : error LNK2001: unresolved external symbol __imp__glFlush@0
opengl.obj : error LNK2001: unresolved external symbol __imp__glEnd@0
opengl.obj : error LNK2001: unresolved external symbol __imp__glVertex2f@8
opengl.obj : error LNK2001: unresolved external symbol __imp__glBegin@4
opengl.obj : error LNK2001: unresolved external symbol __imp__glOrtho@48
opengl.obj : error LNK2001: unresolved external symbol __imp__glLoadIdentity@0
opengl.obj : error LNK2001: unresolved external symbol __imp__glMatrixMode@4
opengl.obj : error LNK2001: unresolved external symbol __imp__glColor3f@12
opengl.obj : error LNK2001: unresolved external symbol __imp__glClear@4
opengl.obj : error LNK2001: unresolved external symbol __imp__glClearColor@16
opengl.obj : error LNK2001: unresolved external symbol _auxMainLoop@4
opengl.obj : error LNK2001: unresolved external symbol _auxInitWindowA@4
opengl.obj : error LNK2001: unresolved external symbol _auxInitPosition@16
opengl.obj : error LNK2001: unresolved external symbol _auxInitDisplayMode@4
Debug/opengl.exe : fatal error LNK1120: 14 unresolved externals
执行 link.exe 时出错.
opengl.exe - 1 error(s), 0 warning(s) 展开
#include <windows.h>
#include <gl.h>
#include <glu.h>
#include <glaux.h>
void CALLBACK Paint(void)
{ glClearColor(0.0, 0.0, 0.0, 0.0); // 置背景色为黑色
glClear(GL_COLOR_BUFFER_BIT); // 清除颜色缓冲区
glColor3f(1.0, 1.0, 1.0); // 设置象素颜色为白色
glMatrixMode(GL_PROJECTION); // 指定投影矩阵为当前矩阵
glLoadIdentity(); // 使用单位矩阵替换当前矩阵
// 描述一个产生平行投影的透视矩阵
glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0);
glBegin(GL_POLYGON); // 开始定义多边形
glVertex2f(-0.5, -0.5); // 定义顶点
glVertex2f(-0.5, 0.5);
glVertex2f(0.5, 0.5);
glVertex2f(0.5, -0.5);
glEnd(); // 结束多边形的定义
glFlush(); // 强制执行OpenGL函数
}
int main(int argc, char** argv)
{ auxInitDisplayMode(AUX_SINGLE | AUX_RGBA); // 设置窗口的特征
auxInitPosition(0, 0, 500, 500); // 设置程序窗口在屏幕上的位置和大小
auxInitWindow(argv[0]); // 设置窗口的标题
auxMainLoop(Paint);// 指定场景绘制循环函数
return 0;
}
在VC++6.0中新建一个C++source file粘贴进去编译时通过了,但运行时出现n多错误
请问OpenGL程序要怎么什么平台下编译的啊?是不是要创建一个什么工程啊?
--------------------Configuration: opengl - Win32 Debug--------------------
Linking...
opengl.obj : error LNK2001: unresolved external symbol __imp__glFlush@0
opengl.obj : error LNK2001: unresolved external symbol __imp__glEnd@0
opengl.obj : error LNK2001: unresolved external symbol __imp__glVertex2f@8
opengl.obj : error LNK2001: unresolved external symbol __imp__glBegin@4
opengl.obj : error LNK2001: unresolved external symbol __imp__glOrtho@48
opengl.obj : error LNK2001: unresolved external symbol __imp__glLoadIdentity@0
opengl.obj : error LNK2001: unresolved external symbol __imp__glMatrixMode@4
opengl.obj : error LNK2001: unresolved external symbol __imp__glColor3f@12
opengl.obj : error LNK2001: unresolved external symbol __imp__glClear@4
opengl.obj : error LNK2001: unresolved external symbol __imp__glClearColor@16
opengl.obj : error LNK2001: unresolved external symbol _auxMainLoop@4
opengl.obj : error LNK2001: unresolved external symbol _auxInitWindowA@4
opengl.obj : error LNK2001: unresolved external symbol _auxInitPosition@16
opengl.obj : error LNK2001: unresolved external symbol _auxInitDisplayMode@4
Debug/opengl.exe : fatal error LNK1120: 14 unresolved externals
执行 link.exe 时出错.
opengl.exe - 1 error(s), 0 warning(s) 展开
3个回答
展开全部
点“工程”->“设置” 有个“连接”选项卡,在下面“对象/模块库”里面加上 opengl32.lib和glu32.lib
试试行不行
这些错误肯定是又有没有链接库造成的,但有没有别的问题就不知道了
试试行不行
这些错误肯定是又有没有链接库造成的,但有没有别的问题就不知道了
展开全部
问题可能出现在头文件上。
我估计你电脑上没有这些头文件,你就直接include了,
#include <glaux.h>
这个文件要是电脑上没有就要自己下一个。
我估计你电脑上没有这些头文件,你就直接include了,
#include <glaux.h>
这个文件要是电脑上没有就要自己下一个。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
编译通过并不代表可以执行,本人觉得好像连接时是不是有参数搞错了,比如没有连接到opengl的库里去,自己手动连接再查查吧
开工程试试,VC里很多东西工程都定义好了的
开工程试试,VC里很多东西工程都定义好了的
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询