PyOpenGL はじめました:glDrawElements

PyOpenGL はじめました記事一覧
glDrawElements

《著》小粒ちゃん《監修》小泉ひよ子とタマゴ倶楽部
第1版♪2006/09/21 ● 第2版♪2009/04/07

■ 概要

glDrawElements:基本図形を描画します。

■ 関連記事
GL redbook bluebook Description
glDrawElements Chapter 2 - OpenGL Programming Guide
・Example 2-11 : Two Ways to Use glDrawElements()
Chapter 5. OpenGL Reference Pages
glDrawElements†
render primitives from array data
□□□□□□□□□

概要:glDrawElements

$ cd ../GLUT/glutDisplayFunc/
$ python2.5 -i glutDisplayFunc.py 
['glutDisplayFunc.py']
>>> print glDrawElements.__doc__
glDrawElements( GLenum(mode), GLsizei(count), GLenum(type), POINTER(GLvoid)(indices) ) -> None
>>> 
Variables Description
mode
Specifies what kind of primitives to render.
GL_LINE_LOOP, GL_LINE_STRIP, GL_LINES, GL_POINTS, GL_POLYGON, GL_QUAD_STRIP, GL_QUADS, GL_TRIANGLE_FAN, GL_TRIANGLE_STRIP, GL_TRIANGLES
□□□□□□□□□□□□□□□□□□

事例:グラデーションを描く #2

$ python2.5 glutDisplayFunc.py -s4


def display_4():
    glClear(GL_COLOR_BUFFER_BIT)
    glEnableClientState(GL_COLOR_ARRAY)
    glColorPointer(3, GL_FLOAT, 0, [
        1.0, 0.0, 0.0,
        1.0, 1.0, 0.0,
        0.0, 1.0, 0.0,
        0.0, 1.0, 1.0,
        0.0, 0.0, 1.0,
        1.0, 0.0, 1.0,
        ])
    glEnableClientState(GL_VERTEX_ARRAY)
    glVertexPointer(3, GL_FLOAT, 0, [
         0.0,      0.8, 0.0,
        -0.69282,  0.4, 0.0,
        -0.69282, -0.4, 0.0,
         0.0,     -0.8, 0.0,
         0.69282, -0.4, 0.0,
         0.69282,  0.4, 0.0,
        ])
    glDrawElements(GL_POLYGON, 6, GL_UNSIGNED_BYTE, [    # 多角形を描く
        0, 1, 2, 3, 4, 5,
        ])
    glutSwapBuffers()

Tips

》作業中です《

Last updated♪09/04/30