Computer Graphics wpxuhpu edu cn http Opengl cnblogs
计算机图形学 Computer Graphics 徐文鹏 wpxu@hpu. edu. cn 教学博客http: // Opengl. cnblogs. com 个人博客http: //wpxu 21 st. blog. 163. com
Open. GL库 • 与窗口系统的连接 – X Windows系统:GLX – Windows: WGL,函数以wgl开头 – Macintosh: AGL 9
软件组织 application program Open. GL Motif widget or similar GLUT GLX, AGL or WGL X, Win 32, Mac O/S software and/or hardware 11 GLU GL
simple. cpp 13 #include <GL/glut. h> void mydisplay(){ gl. Clear(GL_COLOR_BUFFER_BIT); gl. Begin(GL_POLYGON); gl. Vertex 2 f(-0. 5, -0. 5); gl. Vertex 2 f(-0. 5, 0. 5); gl. Vertex 2 f(0. 5, -0. 5); gl. End(); gl. Flush(); } int main(int argc, char** argv){ glut. Create. Window("simple"); glut. Display. Func(mydisplay); glut. Main. Loop(); }
如何获取Open. GL? • Open. GL核心库与实用库:Windows 98, NT 3. 5后系 统自带 • C/C++语言编程库:VC 6 • GLUT: – 下载: www. opengl. org/resources/libraries/glutdlls 37 beta. zip – 安装: 5个文件 – 头文件,库文件,dll文件 15
Open. GL体系 geometry pipeline Immediate Mode Polynomial Evaluator CPU Display List Per Vertex Operations & Primitive Assembly Rasterization Texture Memory Pixel Operations 16 Per Fragment Operations Frame Buffer
Open. GL体系 17
Open. GL #defines • 绝大多数常数采用#define在头文件gl. h, glu. h和 glut. h中定义 – 注意#include <glut. h>会自动包含其它两个头文件 – 如: – gl. Begin(GL_POLYGON); – gl. Clear(GL_COLOR_BUFFER_BIT); • 在头文件中也定义了Open. GL数据类型: GLfloat, Gldouble, …. 20
Open. GL函数名称的格式 function name dimensions gl. Vertex 3 f(x, y, z) belongs to GL library x, y, z are floats gl. Vertex 3 fv(p) p is a pointer to an array 22
- Slides: 24