! ------ subroutinenumber(n,x,y)
! ------ use opengl_gl use opengl_glu use opengl_glut integer, intent(in) :: n real(gldouble), intent(in) :: x,y
character(len=4) chn integer i
write(chn,'(i4)') n call glmatrixmode(gl_modelview) call glpushmatrix call gltranslated(x,y,0._gldouble) do i=1,4 call glutbitmapcharacter(glut_bitmap_8_by_13,ichar(chn(i:i))) enddo call glpopmatrix
return endsubroutinenumber
subroutine redraw() use logo_mod
if (newModel) then call recalcModelView() endif call glClear(ior(GL_COLOR_BUFFER_BIT,GL_DEPTH_BUFFER_BIT)) call glcalllist(thelist) call glutSwapBuffers() endsubroutine redraw
subroutine mouse(button, state, x, y) use logo_mod implicitnone integer(glcint), intent(inout) :: button, state, x, y real value,xfract,yfract
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 if (button == GLUT_MIDDLE_BUTTON .and. state == GLUT_DOWN) then
xfract = real(x)/real(window_width)
yfract = real(y)/real(window_height)
value = (xfract-.1)*2. if (value >= 0. .and. value <= 1.) then if (yfract > .05 .and. yfract < .10) then
logocolor(1) = value elseif (yfract > .15 .and. yfract < .20) then
logocolor(2) = value elseif (yfract > .25 .and. yfract < .30) then
logocolor(3) = value endif
! print *,logocolor call draw_logo call glutpostredisplay endif endif
endsubroutine mouse
subroutine motion(x, y) use logo_mod integer(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 reshape(w,h) use logo_mod integer(glcint), intent(inout) :: w,h
window_width = w
window_height = h call glviewport(0,0,w,h) endsubroutine reshape
subroutine controlLights(value) use logo_mod integer(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 case (3)
show_colorbars = .not. show_colorbars case (4) call animate endselect call draw_logo call glutPostRedisplay() endsubroutine controlLights
subroutine animate use logo_mod implicitnone real(glfloat) transx,transy,transz,angx,angy integer nstep,i
call glutInit() call glutInitDisplayMode(ior(ior(GLUT_RGB,GLUT_DOUBLE),GLUT_DEPTH))
i = glutCreateWindow("f90gl logo") call glutreshapewindow(320,320)
window_width = 320; window_height = 320 call glutDisplayFunc(redraw) call glutMouseFunc(mouse) call glutMotionFunc(motion) call glutreshapefunc(reshape)
i = glutCreateMenu(controlLights) call glutAddMenuEntry("Toggle right light", 1) call glutAddMenuEntry("Toggle left light", 2) call glutAddMenuEntry("Toggle color bars", 3) call glutAddMenuEntry("Animate",4) call glutAttachMenu(GLUT_RIGHT_BUTTON) call glEnable(GL_CULL_FACE) call glEnable(GL_DEPTH_TEST) call glEnable(GL_LIGHTING) call glenable(gl_normalize) call glMatrixMode(GL_PROJECTION) call gluPerspective(10.0_gldouble, & ! field of view in degree
1.0_gldouble, & ! aspect ratio
1.0_gldouble, & ! Z near
400.0_gldouble) ! Z far call glMatrixMode(GL_MODELVIEW) call gluLookAt( &
2.0_gldouble, 0.0_gldouble, 40.0_gldouble, & ! eye is at (0,0,30)
2.0_gldouble, 0.0_gldouble, 0.0_gldouble, & ! center is at (0,0,0)
0.0_gldouble, 1.0_gldouble, 0._gldouble) ! up is in postivie Y direction call glPushMatrix() ! dummy push so we can pop on model recalc call draw_logo
! This call does nothing; it is just to test GLUTNULLFUNC with arguments call glutDialsFunc(GLUTNULLFUNC)
call glutMainLoop() endprogram main
subroutine draw_logo use logo_mod type (coord),allocatable :: centers(:) real (glfloat),allocatable :: radii(:) real (glfloat) :: x, alpha integer int_color
x = 247./255.
! x = 0. call glclearcolor(x,x,x,1.0) call gldeletelists(thelist,1_glsizei) call glnewlist(thelist,gl_compile)
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.