【PyOpenGL】~ ワイヤフレーム ~【v0.03】
基本的に、http://www21.atwiki.jp/opengl/pages/35.htmlを真似てるだけ。
設定値を調べるのが勉強になる。
当分は模写模写
当分は模写模写
# -*- coding: utf-8 -*-
from OpenGL.GL import *
from OpenGL.GLU import *
from OpenGL.GLUT import *
import sys
white = [1.0, 1.0, 1.0, 1.0]
lightpos = [200.0, 1000.0, -500.0, 1.0]
def init():
glClearColor(0.3, 0.3, 0.3, 1.0)
glEnable(GL_DEPTH_TEST)
glEnable(GL_LIGHTING)
glEnable(GL_LIGHT0)
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)
def idle():
glutPostRedisplay()
def display():
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
glViewport(0, 0, 320, 240)
glMatrixMode(GL_PROJECTION)
glLoadIdentity()
gluPerspective(30.0, 320 / 240, 1.0, 1000.0)
glMatrixMode(GL_MODELVIEW)
glLoadIdentity()
gluLookAt(150.0, 150.0, -150.0, 0.0,0.0,0.0,0.0,1.0,0.0)
glLightfv(GL_LIGHT0, GL_POSITION, lightpos)
glMaterialfv(GL_FRONT, GL_DIFFUSE, white)
glutSolidSphere(40.0, 16, 16)
glutSwapBuffers()
def main():
glutInit(sys.argv)
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE)
glutInitWindowSize(320, 240)
glutInitWindowPosition(100, 100)
glutCreateWindow("OpenGL")
glutDisplayFunc(display)
glutIdleFunc(idle)
init()
glutMainLoop()
if __name__ == "__main__":
main()