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

本文档详细介绍了OpenGL中如何使用绘图工具和管理基本状态来绘制多边形,包括设置坐标、颜色以及多边形的填充和描边等操作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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是否启用
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值