write(unit=chn,fmt="(i4)") n call glmatrixmode(GL_MODELVIEW) call glpushmatrix() call gltranslated(x,y,0.0_gldouble) do i=1,4 call glutbitmapcharacter(GLUT_BITMAP_8_BY_13,ichar(chn(i:i))) enddo call glpopmatrix()
return endsubroutinenumber
subroutine redraw()
if (newModel) then call recalcModelView() endif call glclear(ior(GL_COLOR_BUFFER_BIT,GL_DEPTH_BUFFER_BIT)) call glcalllist(thelist) call glutswapbuffers() return endsubroutine redraw
subroutine mouse(button, state, x, y) integer(kind=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-0.1)*2.0 if (value >= 0.0 .and. value <= 1.0) then if (yfract > 0.05 .and. yfract < 0.10) then
logocolor(1) = value elseif (yfract > 0.15 .and. yfract < 0.20) then
logocolor(2) = value elseif (yfract > 0.25 .and. yfract < 0.30) then
logocolor(3) = value endif
! print *,logocolor call draw_logo() call glutpostredisplay() endif endif
return 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 return endsubroutine motion
subroutine freshape(w,h) integer(kind=glcint), intent(inout) :: w,h
window_width = w
window_height = h call glviewport(0,0,w,h) return endsubroutine freshape
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 case (3)
show_colorbars = .not. show_colorbars case (4) call animate() endselect call draw_logo() call glutpostredisplay() return endsubroutine controlLights
subroutine draw_logo() type (coord),allocatable,dimension(:) :: centers real (kind=glfloat),allocatable,dimension(:) :: radii real (kind=glfloat) :: x, alpha integer :: int_color, i
x = 247.0/255.0
! x = 0. call glclearcolor(x,x,x,1.0) call gldeletelists(thelist,1_glsizei) call glnewlist(thelist,GL_COMPILE)
call gllightmodelfv(GL_LIGHT_MODEL_AMBIENT, (/0.25,0.25,0.25,1.0/)) call gllightfv(GL_LIGHT0, GL_POSITION, lightZeroPosition) call gllightfv(GL_LIGHT0, GL_DIFFUSE, lightZeroColor) call gllightfv(GL_LIGHT0, GL_SPECULAR, lightZeroColor) call gllightfv(GL_LIGHT1, GL_POSITION, lightOnePosition) call gllightfv(GL_LIGHT1, GL_DIFFUSE, lightOneColor) if (lightZeroSwitch) then call glenable(GL_LIGHT0) else call gldisable(GL_LIGHT0) endif if (lightOneSwitch) then call glenable(GL_LIGHT1) else call gldisable(GL_LIGHT1) endif call glenable(GL_LIGHTING) call glpolygonmode(GL_FRONT_AND_BACK, GL_FILL)
! curve of f allocate(centers(41),radii(41)) call glpushmatrix() call glrotatef(25.0_glfloat,0.0_glfloat,0.0_glfloat,1.0_glfloat) do i=1,41
x = (i-21)/20.0_glfloat
centers(i)%x = x
centers(i)%y = -x*(x-1.3)*(x+1.3) if (x<=-0.5) then
radii(i) = 0.2*x+0.2 elseif (x>=0.5) then
radii(i) = 0.2-0.2*x else
radii(i) = 0.1_glfloat endif enddo call glmaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, logocolor) call glmaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, logocolor) call glmaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 128.0_glfloat) call make_letter(centers,radii) call glpopmatrix() deallocate(centers,radii)
! crossbar of f allocate(centers(4),radii(4))
centers(1) = coord(-0.4,0.0)
centers(2) = coord(-0.4,0.0)
centers(3) = coord(0.4,0.0)
centers(4) = coord(0.4,0.0)
radii(1) = 0.0
radii(2) = 0.1
radii(3) = 0.1
radii(4) = 0.0 call make_letter(centers,radii) deallocate(centers,radii)
! left part of 9 allocate(centers(28),radii(28)) call glpushmatrix() call gltranslatef(1.0_glfloat,0.0_glfloat,0.0_glfloat) call glrotatef(10.0_glfloat,0.0_glfloat,0.0_glfloat,-1.0_glfloat) do i=1,28
alpha = (i-6)*PI/20.0 + PI/2.0 + PI/10.0
centers(i)%x = 0.4*cos(alpha)
centers(i)%y = 0.4*sin(alpha) + 0.4
radii(i) = 0.1 if (i>20) then
radii(i) = (28-i)/80.0 endif enddo call make_letter(centers,radii) call glpopmatrix() deallocate(centers,radii)
! right part of 9 allocate(centers(25),radii(25)) call glpushmatrix() call gltranslatef(1.0_glfloat,0.0_glfloat,0.0_glfloat) call glrotatef(10.0_glfloat,0.0_glfloat,0.0_glfloat,-1.0_glfloat) do i=1,25
alpha = (i-1)*PI/20.0 - PI/2.0 - 4.0*PI/20.0
centers(i)%x = 0.5*cos(alpha)
centers(i)%y = 0.8*sin(alpha)
radii(i) = 0.1 if (i<5) then
radii(i) = i/50.0 endif enddo call make_letter(centers,radii) call glpopmatrix() deallocate(centers,radii)
! 0 allocate(centers(42),radii(42)) call glpushmatrix() call gltranslatef(2.4_glfloat,0.0_glfloat,0.0_glfloat) do i=1,42
alpha = (i-1)*PI/20.0
centers(i)%x = 0.6*cos(alpha)
centers(i)%y = 0.8*sin(alpha)
radii(i) = 0.1 enddo call make_letter(centers,radii) call glpopmatrix() deallocate(centers,radii)
! g allocate(centers(15+56),radii(15+56))
! right part of g call glpushmatrix() call gltranslatef(3.6_glfloat,-0.5_glfloat,0.0_glfloat)
! call glrotatef(10.0_glfloat,0.0_glfloat,0.0_glfloat,-1.0_glfloat) do i=1,15
alpha = (i-1)*PI/20.0 - PI/2.0 - 4.0*PI/20.0
centers(i)%x = 0.5*cos(alpha) - 0.1
centers(i)%y =1.2*sin(alpha)
radii(i) = 0.1 if (i<5) then
radii(i) = i/50.0 endif enddo
! left part of g
! call glrotatef(20.0_glfloat,0.0_glfloat,0.0_glfloat,-1.0_glfloat) do i=1+15,55+15
alpha = 3.0*(i-1-15)*PI/80.0
centers(i)%x = 0.4*cos(alpha)
centers(i)%y = 0.4*sin(alpha)
radii(i) = 0.1 enddo
centers(56+15) = centers(55+15)
radii(56+15) = 0.0 call make_letter(centers,radii) call glpopmatrix() deallocate(centers,radii)
! l allocate(centers(41),radii(41)) call glpushmatrix() call gltranslatef(4.6_glfloat,0.0_glfloat,0.0_glfloat) call glrotatef(25.0_glfloat,0.0_glfloat,0.0_glfloat,1.0_glfloat) do i=1,41
x = (i-21)/20.0_glfloat
centers(i)%x = x
centers(i)%y = -x*(x-1.4)*(x+1.4) if (x<=-0.5) then
radii(i) = 0.2*x+0.2 elseif (x>=0.5) then
radii(i) = 0.2-0.2*x else
radii(i) = 0.1_glfloat endif enddo call make_letter(centers,radii) call glpopmatrix() deallocate(centers,radii)
call glendlist()
return endsubroutine draw_logo
endmodule logo_mod
program main
use opengl_gl use opengl_glu use opengl_glut use logo_mod implicitnone
integer :: i, window_width, window_height
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(freshape) call glutcreatemenu(controlLights,i) 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.0_gldouble) ! up is in postivie Y direction call glpushmatrix() ! dummy push so we can pop on model recalc call draw_logo()
call glutmainloop() stop endprogram main
¤ Dauer der Verarbeitung: 0.2 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.