if (button == GLUT_LEFT_BUTTON .and. state == GLUT_DOWN) then
moving = .true.
begin = coord(x,y) endif if (button == GLUT_LEFT_BUTTON .and. state == GLUT_UP) then
moving = .false. endif endsubroutine mouse
subroutine motion(x, y) integer(kind=glcint), intent(inout) :: x, y
if (moving) then
angle%x = angle%x + (x - begin%x)
angle%y = angle%y + (y - begin%y)
begin = coord(x,y)
newModel = .true. call glutPostRedisplay() endif endsubroutine motion
subroutine controlLights(value) integer(kind=glcint), intent(inout) :: value
selectcase (value) case (1)
lightZeroSwitch = .not. lightZeroSwitch if (lightZeroSwitch) then call glEnable(GL_LIGHT0) else call glDisable(GL_LIGHT0) endif case (2)
lightOneSwitch = .not. lightOneSwitch if (lightOneSwitch) then call glEnable(GL_LIGHT1) else call glDisable(GL_LIGHT1) endif endselect call glutPostRedisplay() endsubroutine controlLights
endmodule dino_mod
program main
use opengl_gl use opengl_glu use opengl_glut use dino_mod implicitnone
call glutInit() call glutInitDisplayMode(ior(ior(GLUT_RGB,GLUT_DOUBLE),GLUT_DEPTH))
i = glutCreateWindow("glutdino") call glutDisplayFunc(redraw) call glutMouseFunc(mouse) call glutMotionFunc(motion) call glutCreateMenu(controlLights,i) call glutAddMenuEntry("Toggle right light", 1) call glutAddMenuEntry("Toggle left light", 2) call glutAttachMenu(GLUT_RIGHT_BUTTON) call makeDinosaur() call glEnable(GL_CULL_FACE) call glEnable(GL_DEPTH_TEST) call glEnable(GL_LIGHTING) call glMatrixMode(GL_PROJECTION) call gluPerspective(40.0_gldouble, & ! field of view in degree
1.0_gldouble, & ! aspect ratio
1.0_gldouble, & ! Z near
40.0_gldouble) ! Z far call glMatrixMode(GL_MODELVIEW) call gluLookAt( &
0.0_gldouble, 0.0_gldouble, 30.0_gldouble, & ! eye is at (0,0,30)
0.0_gldouble, 0.0_gldouble, 0.0_gldouble, & ! center is at (0,0,0)
0.0_gldouble, 1.0_gldouble, 0.0_gldouble) ! up is in postivie Y direction call glPushMatrix() ! dummy push so we can pop on model recalc call glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 1) call glLightfv(GL_LIGHT0, GL_POSITION, lightZeroPosition) call glLightfv(GL_LIGHT0, GL_DIFFUSE, lightZeroColor) call glLightf(GL_LIGHT0, GL_CONSTANT_ATTENUATION, 0.1) call glLightf(GL_LIGHT0, GL_LINEAR_ATTENUATION, 0.05) call glLightfv(GL_LIGHT1, GL_POSITION, lightOnePosition) call glLightfv(GL_LIGHT1, GL_DIFFUSE, lightOneColor) call glEnable(GL_LIGHT0) call glEnable(GL_LIGHT1) call glutMainLoop() endprogram main
¤ Dauer der Verarbeitung: 0.13 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.