为什么一定要#include "glos.h"?

znr znr 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
我用VC++6.0,最初先调试了来自BBS水木清华站的OPENGL源代码,多以
#include "glos.h"
#include <GL/gl.h>
#include <GL/glaux.h>
#include "windows.h" 为头文件.
我将其改为
#include <windows.h>
#include <GL/gl.h>
#include <GL/glaux.h> 后,运行成功.

举例一个源代码如下:
//////////////////////////////////////////////////////////////////
//weitu.cpp
#include <windows.h>
#include <gl/gl.h>
#include <gl/glaux.h>

void myinit(void);
void CALLBACK display(void);
void CALLBACK reshape(GLsizei w,GLsizei h);
//定义字符位图,从下到上(即第一个数据是字模的最下一行,依次类推):
// 11111111
// 11111111
// 11000011
// 11000011
// 11000011
// 11111111
// 11111111
// 11000011
// 11000011
// 11000011
// 11111111
// 11111111
//组成一个 8 字
GLubyte rasters[12]={0xff,0xff,0xc3,0xc3,0xc3,0xff,0xff,
0xc3,0xc3,0xc3,0xff,0xff};

void myinit(void)
{
auxInitDisplayMode(AUX_SINGLE|AUX_RGBA);
auxInitPosition(0,0,500,500);
auxInitWindow("sample1");
glClearColor(0.0,0.0,0.0,0.0);
glClear(GL_COLOR_BUFFER_BIT);

//描述位图数据在计算机内存中的存储方式,不必深究
glPixelStorei(GL_UNPACK_ALIGNMENT,1);

}

void CALLBACK reshape(GLsizei w,GLsizei h)
{

glViewport(0,0,w,h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0,w,0,h,-1.0,1.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}

void CALLBACK display(void)
{
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

//先定义红色填充:
glColor3f(1.0,0.0,1.0);
glRasterPos2i(100,200);
//在2个不同位置绘制 8 (紫色)
glBitmap(8,12,0.0,0.0,20.0,20.0,rasters);
glBitmap(8,12,0.0,0.0,20.0,20.0,rasters);

//绘制另一个 8 (黄色)
glColor3f(1.0,1.0,0.0);
glRasterPos2i(150,200);
glBitmap(8,12,0.0,0.0,0.0,0.0,rasters);

glFlush();
}
void main(void)
{
myinit();

auxReshapeFunc(reshape);
auxMainLoop(display);
}
//end of sample
///////////////////////////////////////////////////////

现在,我开始调试<<OpenGL基础图形编程>>中的源代码,多以
#include "glos.h"
#include <GL/gl.h>
#include <GL/glaux.h>为头文件.
我将其改为
#include <windows.h>
#include <GL/gl.h>
#include <GL/glaux.h> 后,编译出错,为什么?

举例一个源代码如下:
//位图字符例程

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


void myinit(void);
void CALLBACK myReshape(GLsizei w, GLsizei h);
void CALLBACK display(void);

GLubyte rasters[12] = {
    0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xfc,
    0xfc, 0xc0, 0xc0, 0xc0, 0xff, 0xff};

void myinit(void)
{
  glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
  glClearColor (0.0, 0.0, 0.0, 0.0);
  glClear(GL_COLOR_BUFFER_BIT);
}

void CALLBACK display(void)
{
  glColor3f (1.0, 0.0, 1.0);
  glRasterPos2i (100, 200);
  glBitmap (8, 12, 0.0, 0.0, 20.0, 20.0, rasters);
  glBitmap (8, 12, 0.0, 0.0, 0.0, 0.0, rasters);
  glColor3f (1.0, 1.0, 0.0);
  glRasterPos2i (150, 200);
  glBitmap (8, 12, 0.0, 0.0, 0.0, 0.0, rasters);

  glFlush();
}

void CALLBACK myReshape(GLsizei w, GLsizei h)
{
  glViewport(0, 0, w, h);
  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  glOrtho (0, w, 0, h, -1.0, 1.0);
  glMatrixMode(GL_MODELVIEW);
}

void main(void)
{
  auxInitDisplayMode (AUX_SINGLE | AUX_RGBA);
  auxInitPosition (0, 0, 500, 500);
  auxInitWindow ("Bitmap");
  myinit();
  auxReshapeFunc (myReshape);
  auxMainLoop(display);
}

//以上程序运行结果是显示三个相同的字符F。
//OpenGL函数库只提供了最底层操作,即用glRasterPos*()和glBitmap()
//在屏幕上定位和画一个位图。

为什么一定要#include "glos.h"? 而"glos.h"又不在OPENGL的开发库中,
教程中对"glos.h"的介绍,远不如gl.h,glu.h,glut.h,glaux.h多.

我在WINXP里,也没有找到"glos.h".还要上网去下载"glos.h"吗?
...全文
评论 5
收藏 已收藏
分享
返回顶部
znr
机器视觉 4,514 成员 15,347 内容