森の妖精ことビリー・ヘリントン氏の来日がアナウンスされました!
http://anime-ch.nicovideo.jp/static/wonderful_hobby9
楽しみですね。
- ネタ元
http://www.dolfyn.net/dolfyn/f03gl_en.html
いわゆる Green Book からのサンプルのつづき。
元プログラムからの修正点は、RESHAPE ルーチンの引数の value 属性を消したこと。C binding を消したこと。
module fgl03mod use opengl_gl integer(kind=GLint) :: winWidth = 400, winHeight = 300 integer(kind=GLuint) :: Hexagon real :: xc, yc end module fgl03mod program fgl03 use opengl_gl use opengl_glu use opengl_glut use fgl03mod interface callbacks subroutine draw_hexagon() end subroutine draw_hexagon subroutine reshape(w,h) use opengl_gl integer(glcint), intent(in) :: w,h end subroutine reshape end interface callbacks integer(kind=GLint) :: iwin call glutInit call glutInitDisplayMode(GLUT_SINGLE + GLUT_RGB ) call glutInitWindowPosition( 100, 100) call glutInitWindowSize( winWidth, winHeight ) iwin = glutCreateWindow("fgl03 Reshape and Display lists"//char(0)) call initialize call glutDisplayFunc( draw_hexagon ) call glutReshapeFunc( reshape ) call glutMainLoop() end program fgl03 subroutine initialize use OpenGL_GL use fgl03mod integer(GLint) :: ix, iy ! set circle center coordinates xc = 0.5*float(winWidth) yc = 0.5*float(winHeight) call glClearColor(1.0, 1.0, 1.0, 0.0) Hexagon = glGenLists(1) call glNewList( Hexagon, GL_COMPILE) call glColor3f( 1.0, 0.0, 0.0 ) call glBegin(GL_POLYGON) do i=1,7 theta = 6.2831853 * float(i)/ 6.0 x = xc + 150.*cos(theta) y = yc + 150.*sin(theta) ix = x iy = y call glVertex2i( ix, iy) end do call glEnd() call glEndList() end subroutine initialize subroutine reshape(newWidth, newHeight) use OpenGL_GL use OpenGL_GLU use fgl03mod integer(kind=GLcint), intent(IN) :: newWidth, newHeight real(kind=GLdouble) :: Zero, Width, Height Zero = 0.0 Width = newWidth Height = newHeight call glMatrixMode( GL_PROJECTION ) call glLoadIdentity() call gluOrtho2D( Zero, Width, Zero, Height ) call glClear( GL_COLOR_BUFFER_BIT ) end subroutine reshape subroutine draw_hexagon use OpenGL_GL use fgl03mod call glClear( GL_COLOR_BUFFER_BIT ) call glCallList( Hexagon ) call glFlush() end subroutine draw_hexagon
DOS窓は略