1 / 122
文档名称:

计算机图形学(opengl总结).ppt

格式:ppt   大小:9,006KB   页数:122页
下载后只包含 1 个 PPT 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

分享

预览

计算机图形学(opengl总结).ppt

上传人:977562398 2022/6/24 文件大小:8.79 MB

下载得到文件列表

计算机图形学(opengl总结).ppt

文档介绍

文档介绍:计算机图形学(OpenGL总结)
第一页,共122页。
参考书
1、OpenGL编程指南(第八版),Dave Shreiner等(李军等译),***出版社,2014年。
2、计算机图形学(第四版),Donald Hearn
*
*
第十二页,共122页。
OpenGL初步编程
在Windows下开发和创建一个OpenGL程序的基本步骤:
第一步,选择一个编译环境,如VC++
第二步,安装GLUT工具包
第三步,建立一个OpenGL工程
第四步,编译连接
第五步,执行程序
第十三页,共122页。
OpenGL初步编程
OpenGL库和头文件:
动态库: 放入windows\system32目录下
静态库:
头文件: \GL文件夹下
第十四页,共122页。
程序结构
绝大多数OpenGL程序具有类似的结构,包含下
述函数
main():
定义回调函数
打开一个或多个具有指定属性的窗口
进入事件循环(最后一条可执行语句)
init(): 设置状态变量
视图
属性• 回调
显示函数
输入和窗口函数
第十五页,共122页。
#include <GL/> // includes and
void display() {
. . .
}
void init() {
. . .
}
int main( int argc, char **argv) {
. . .
}
第十六页,共122页。
void display() {
glClear( GL_COLOR_BUFFER_BIT); // Clear the frame buffer
glColor3f( , , ); // Set current color to green
glBegin( GL_POLYGON); // Draw the triangle
glVertex2f( -, -);
glVertex2f( , -);
glVertex2f( 0, );
glEnd();
glFlush(); // Force to display the new drawings immediately
}
第十七页,共122页。
void init() {
glClearColor( , , , ); // Set the clear color to black
// Specify the boundaries of the viewing window
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(-, , -, ); // The para are: (left, right, bottom, top)
glMatrixMode(GL_MODELVIEW);
}
第十八页,共122页。
int main( int argc, char **argv) {
glutInit( &argc, argv); // Initialize GLUT function callings
// Set window size (width, height) in number of pixels glutInitWindowSize( 400, 400);
// Set window position, from the left and top of the screen,
glutInitWindowPosition( 200, 100); // in numbers of pixels
// Specify a window creation event
glutCreateWindow( "Green Triangle");

// Specify the drawing