您的位置:首页 > 运维架构

OpenGL笔记:二. 绘制几何图形

2013-03-11 11:05 579 查看

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);    启用功能XX
    glDisable(XX);    关闭功能XX
    glIsEnable(XX);    功能XX是否启用
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: