opengl的头文件的问题?

znr 2003-04-12 10:52:02
来自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> 后,运行成功.
又有,OpenGL基础图形编程中,多以
#include "glos.h"
#include <GL/gl.h>
#include <GL/glaux.h>为头文件.
我将其改为
#include <windows.h>
#include <GL/gl.h>
#include <GL/glaux.h> 后,编译出错,为什么?
...全文
399 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
FatGarfield 2003-04-27
  • 打赏
  • 举报
回复
我结帖
谢谢FatGarfield() 100分

呵呵,真可爱。
znr 2003-04-26
  • 打赏
  • 举报
回复
我结帖
谢谢FatGarfield() 100分
znr 2003-04-24
  • 打赏
  • 举报
回复
首先,感谢FatGarfield() 的帮助!
程序,我已调通。你说程序没问题,我后来明白了不是程序代码的问题,是程序中每一行都有不可见字符,导致了编译的错误。我是从另一个文档剪贴了程序进入VC++6的,我后来
在每一行首DELETE两个字符,就成功编译了。
pingtai 2003-04-20
  • 打赏
  • 举报
回复
把glos.h文件打开看看就知道了,这是用户自己编的,
不是OpenGL的库函数。
DavidBone 2003-04-17
  • 打赏
  • 举报
回复
up
cpsoft 2003-04-15
  • 打赏
  • 举报
回复
我只在子窗口中实现Opengl所以没有用glut库!
光看glos.h的名字,估计是用来在不同的操作系统平台上编译用的,比方说数据类型,数据位数的不同!
FatGarfield 2003-04-13
  • 打赏
  • 举报
回复
程序已经发出,请查收。
husarb 2003-04-13
  • 打赏
  • 举报
回复
vc下的OpenGL程序多用glut来写,它是gl的一个扩展。
建议你看《OpenGL超级宝典〉
znr 2003-04-13
  • 打赏
  • 举报
回复
我用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"吗?
znr 2003-04-13
  • 打赏
  • 举报
回复
OpenGL基础图形编程中,举一例,源代码如下:
//辅助库应用例程
#include "glos.h"
#include <gl/gl.h>
#include <gl/glaux.h>

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

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

void CALLBACK myReshape(GLsizei w,GLsizei h)
{
glViewport(0,0,w,h);
  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  if(w<=h)
   glOrtho(-1.5,1.5,-1.5*(GLfloat)h/(GLfloat)w, 1.5*(GLfloat)h/(GLfloat)w,-10.0,10.0);
  else
    glOrtho(-1.5*(GLfloat)h/(GLfloat)w, 1.5*(GLfloat)h/(GLfloat)w,-1.5,1.5,-10.0,10.0);
  glMatrixMode(GL_MODELVIEW);
  glLoadIdentity();
}

void CALLBACK display(void)
{
  glColor3f(1.0,1.0,0.0);
  auxWireSphere(1.0);
  glFlush();
}

void main(void)
{
  auxInitDisplayMode(AUX_SINGLE|AUX_RGBA);
  auxInitPosition(0,0,500,500);
  auxInitWindow("AUX_SAMPLE");
  myinit();
  auxReshapeFunc(myReshape);
  auxMainLoop(display);
}
//以上程序运行结果是在屏幕窗口内绘制一个黄色的网状球体,
//这个程序充分体现了辅助库的基本应用方法。

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

4,445

社区成员

发帖
与我相关
我的任务
社区描述
图形图像/机器视觉
社区管理员
  • 机器视觉
  • 迪菲赫尔曼
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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