1. 绘图工具
(1)Clear颜色:
glClearColor( R, G, B, A); //设置窗口背景颜色
缓冲区:
glClearDepth(1.0); //设置
glClear( GL_COLOR_BUFFER_BIT | XX );
GL_COLOR_BUFFER_BIT 颜色缓冲区
GL_DEPTH_BUFFER_BIT 深度缓冲区
GL_ACCUM_BUFFER_BIT 累积缓冲区
GL_STENCIL_BUFFER_BIT 模板缓冲区
(2)颜色
glColor_ _( );
注:在OpenGL中,很多函数的末尾会指示出参数的类型和个数,如:
glColor3f(1.0, 1.0, 1.0); glColor4i( 1, 1, 1, 1 );
数字:参数个数
参数类型: f, i,
若最后有v,表示参数中有数组。
注:glColor的控制区域是直到下一个glColor出现。
(3)坐标系统
glViewPort( x, y, w, h );
(x,y)左下角
(w,h)右上角
glOrth2D(0.0, w, 0.0, h);
2. 绘制多边形
glBegin(Type);glVertex_ _( 点坐标 );
glVertex_ _( 点坐标 );
glVertex_ _( 点坐标 );
……
glEnd();
(1)Type:
GL_POINTS Individual points(点)
GL_LINES Pairs of vertices interpreted as individual line segments(线)
GL_LINE_STRIP Series of connected line segments
GL_LINE_LOOP Same as above, with a segment added between last and first vertices
GL_TRIANGLES Triples of vertices interpreted as triangles
GL_TRIANGLE_STRIP Linked strip of triangles
GL_TRIANGLE_FAN Linked fan of triangles
GL_QUADS Quadruples of vertices interpreted as four-sided polygons
GL_QUAD_STRIP Linked strip of quadrilaterals
GL_POLYGON Boundary of a simple, convex polygon

(2)glBegin(), glEnd()中可以放的语句
Command Purpose of Command
glVertex*() set vertex coordinates
glColor*() set RGBA color
glIndex*() set color index
glSecondaryColor*() set secondary color for post-texturing application
glNormal*() set normal vector coordinates
glMaterial*() set material properties
glFogCoord*() set fog coordinates
glTexCoord*() set texture coordinates
glMultiTexCoord*() set texture coordinates for multitexturing
glVertexAttrib*() set generic vertex attribute
glEdgeFlag*() control drawing of edges
glArrayElement() extract vertex array data
glEvalCoord*(),glEvalPoint*() generate coordinates
glCallList(),glCallLists() execute display list(s)
3. 基本状态管理
glEnable(XX); 启用功能XXglDisable(XX); 关闭功能XX
glIsEnable(XX); 功能XX是否启用
本文档详细介绍了OpenGL中如何使用绘图工具和管理基本状态来绘制多边形,包括设置坐标、颜色以及多边形的填充和描边等操作。

被折叠的 条评论
为什么被折叠?



