为什么一定要#include "glos.h"?
我用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"吗?
#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"吗?
...全文
相关推荐
在vs2008下配置opengl
关于vs2008下opengl中glaux的配置
OpenGL基础篇
作者从自身学习的经验出发,从入门开始讲起,介绍openGL的基础,简单易懂。适合想快速入门的读者。
opengl入门教程.doc
OPENGL中有115个核心函数,可以在任何OPENGL平台上使用 OPENGL实用库比上面这115个函数高一级,提供高级调用 OPENGL辅助库本来是提供初学者入门的函数,不保证在任何平台 的使用,但恰好可以在WIN32下使用,所以本讲座将大量引用
OPENGL(14) c++曲面构造 网格线.docx
OPENGL(14) c++曲面构造 网格线
vs2008下的opengl配置
vs2008下的opengl配置 ,GLaux+(OpenGL辅助库)


