OpenGL学习笔记一、基础

1.openGL程序要包含的头文件:

<GL/gl.h>

<GL/glu.h>

分别为openGL的基本库和GLU库

windows需要先包含windows.h

openGL扩展需要包含"glext.h"

访问支持openGL的窗口接口库,例如GLX,需要添加<X11/Xlib.h>和<GL/glx.h>

WGL需要添加windows.h

使用GLUT实现窗口管理任务,需要添加<GL/glut.h>,此时不再需要包含gl.h和glu.h

2.GLUT初始化窗口

glutInit初始化

glutInitDisplayMode指定RGBA或者颜色索引模式,另外可指定单缓冲或者双缓冲

glutInitWindowPosition窗口左上位置

glutInitWindowSize

int glutCreateWindow创作支持openGL渲染环境的窗口

 

显示回调函数:通过glutDisplayFunc(void (*func)(void))注册重绘窗口时要调用的回调函数

运行程序:glutMainLoop()进入主循环。

事件处理:

glutReshapeFunc, glutKeyboardFunc, glutMotionFunc

空闲处理:glutIdleFunc

三维描绘:glutWireCube,glutSolidCube,glutWireSphere,glutSolidSphere

posted @ 2010-09-19 00:23  某身  阅读(1461)  评论(0编辑  收藏  举报