vc++6.0中写的OpenGL 函数 编译中有问题,请大家帮帮忙。
#include<iostream.h>
#include<windows.h>
#include<conio.h>
#include<gl/gl.h>
#include<gl/glu.h>
#include<gl/glaux.h>
void CALLBACK ChangeSize(void)
{
GLfloat h,w;
if(h==0)
h=1;
glViewport(0, 0, w, h);
glLoadIdentity( );
if(w<=h)
{
glOrhto(0.0, 250.0, 0.0, 250*h/w, 1.0, -1.0);
}
else
glOrtho(0.0, 250*w/h, 0.0, 250.0, 1.0, -1.0);
}
void CALLBACK ReaderScene(void)
{
glClearColor(0.0f,0.0f,1.0f,0.0f); //设置窗口的颜色
glClear(GL_COLOR_BUFFER_BIT); //清除颜色缓冲区
glColor3f(0.0,1.0,0.0); //设置可视区的颜色
glRectf(100,150,150,100); //设置可视区的大小
glFlush(); //执行gl命令
_sleep(3000); //设置所创建的窗口显示的时间
}
void main(void)
{
auxInitDisplayMode(AUX_SINGLE|AUX_RGBA); //设置所将要创建窗口的模式
auxInitPosition(100,100,250, 500); //创建窗口的位置
auxInitWindow("simple"); //窗口的名字
auxReshapeFunc(ChangeSize);
auxMainLoop(ReaderScene);
}
--------------------Configuration: hu5 - Win32 Debug--------------------
Compiling...
sh5.cpp
E:\Program Files\Microsoft Visual Studio\MyProjects\hu5\sh5.cpp(13) : warning C4244: 'argument' : conversion from 'float' to 'int', possible loss of data
E:\Program Files\Microsoft Visual Studio\MyProjects\hu5\sh5.cpp(13) : warning C4244: 'argument' : conversion from 'float' to 'int', possible loss of data
E:\Program Files\Microsoft Visual Studio\MyProjects\hu5\sh5.cpp(17) : error C2065: 'glOrhto' : undeclared identifier
E:\Program Files\Microsoft Visual Studio\MyProjects\hu5\sh5.cpp(38) : error C2664: 'auxReshapeFunc' : cannot convert parameter 1 from 'void (void)' to 'void (__stdcall *)(int,int)'
None of the functions with this name in scope match the target type
执行 cl.exe 时出错.
sh5.obj - 1 error(s), 0 warning(s)
[解决办法]
E:\Program Files\Microsoft Visual Studio\MyProjects\hu5\sh5.cpp(17) : error C2065: 'glOrhto ' : undeclared identifier
很明显的提示错误信息啊。那个函数的头文件没有被包含
[解决办法]
好象是在glut.h中吧,你试试
#include <gl/glut.h >