■
$ python2.5 -i glutBitmapCharacter.py ['glutBitmapCharacter.py'] >>> print glutBitmapCharacter.__doc__ glutBitmapCharacter( c_void_p(font), c_int(character) ) -> None
Tips:PyOpenGL
PyOpenGL/GLUT | GLUT API/英 | GLUT API/和 | Description |
---|---|---|---|
glutInit | 2.1 glutInit | 2.1 glutInit | initialize the GLUT library. ライブラリを初期化します |
glutCreateWindow | 4.1 glutCreateWindow | 4.1 glutCreateWindow | creates a top-level window. 最上位ウィンドウを生成します |
glutMainLoop | 3.1 glutMainLoop | 3.1 glutMainLoop | enters the GLUT event processing loop. イベント処理ループに入ります |
PyOpenGL はじめました:glutMouseFunc
PyOpenGL はじめました《記事一覧》
glutMouseFunc
《著》小粒ちゃん《監修》小泉ひよ子とタマゴ倶楽部
第0版♪2006/09/21 ● 第1版♪2009/04/07
》作業中です《
■ 概要
glutMouseFunc:ウィンドウを再描画する関数を設定します。
■ 関連記事
GLUT | API:英 | API:和 | Description |
---|---|---|---|
glutMouseFunc | 7.5 glutMouseFunc | 7.5 glutMouseFunc | sets the mouse callback for the current window. マウスコールバックを設定します |
概要:glutBitmapCharacter
$ python2.5 -i glutBitmapCharacter.py
['glutDisplayFunc.py']
>>> print glutBitmapCharacter.__doc__
glutBitmapCharacter( c_void_p(font), c_int(character) ) -> None
イベント Display に呼応してウィンドウ内を再描画する、イベントハンドラー handler が必要です。これは、引数を持たず、値を返さない(None をリターン値とする)関数です。すると、ウィンドウを開いたり、背後に隠れていたウィンドウ(その一部)が前面に現れるときに、イベントハンドラー関数を呼び出します。
def ex_glutDisplayFunc(mode, display): glutInit(argv) glutInitDisplayMode(mode) glutInitWindowPosition(100, 100) glutInitWindowSize(200, 100) glutCreateWindow(title()) glutDisplayFunc(display) glutKeyboardFunc(keyPressed) glutMainLoop()
以下の事例では、この関数を再利用しています。
事例:背景を塗り潰す
$ python2.5 glutDisplayFunc.py -s1
def ex_1(): ex_glutDisplayFunc(GLUT_RGB, display1) def display1(): glClearColor(1.0, 1.0, 0.0, 0.0) # 背景を塗り潰す:黄色 glClear(GL_COLOR_BUFFER_BIT) glFinish()
事例:図形を描く
$ python2.5 glutDisplayFunc.py -s2
def ex_2(): ex_glutDisplayFunc(GLUT_RGB, display_2) def display_2(): glClear(GL_COLOR_BUFFER_BIT) glBegin(GL_LINE_LOOP); # 折れ線を閉じる glColor3d (0.0, 1,0, 0,0) glVertex2d(-0.5, -0.5) glVertex2d( 0.5, -0.5) glVertex2d( 0.5, 0.5) glVertex2d(-0.5, 0.5) glEnd() glFinish()
事例:グラデーションを描く
$ python2.5 glutDisplayFunc.py -s3
def ex_3(): ex_glutDisplayFunc(GLUT_RGB, display_3) def display_3(): glClear(GL_COLOR_BUFFER_BIT) glBegin(GL_POLYGON) # 多角形を描く glColor3d(1.0, 0.0, 0.0) glVertex3d( 0.0, 0.8, 0.0) glColor3d(1.0, 1.0, 0.0) glVertex3d(-0.69282, 0.4, 0.0) glColor3d(0.0, 1.0, 0.0) glVertex3d(-0.69282, -0.4, 0.0) glColor3d(0.0, 1.0, 1.0) glVertex3d( 0.0, -0.8, 0.0) glColor3d(0.0, 0.0, 1.0) glVertex3d( 0.69282, -0.4, 0.0) glColor3d(1.0, 0.0, 1.0) glVertex3d( 0.69282, 0.4, 0.0) glEnd() glFinish()
misc
from OpenGL.GL import * from OpenGL.GLUT import * from sys import argv def title(): global EX return sys.argv[0][:-3]+" #"+EX def keyPressed(*args): print args if args[0] == '\x1b': # escape exit() def ex_(): print argv EX = "" if __name__ == '__main__': for e in argv: if e.startswith("-s"): EX = e[2:] eval("ex_%s()"%EX)
Tips
Last updated♪09/04/21