⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sgldraw5.f90

📁 Fortran 95程序设计&Code-彭国伦
💻 F90
字号:
module sgl_util
  use sgl
  implicit none
  real, parameter :: PI = 3.14159
  real, parameter :: range = PI*3
  real, save :: left, right, top, bottom
  integer, save :: width, height
contains
  subroutine Display()
    integer, parameter :: segments = 100
	real x0,x1,y0,y1,xinc
    xinc = (right-left)/segments
    call sglClearBuffer() 
	call sglColor3i(255,0,0)
	call sglLine(0,height/2,width,height/2)
	call sglLine(width/2,0, width/2,height)
	call sglColor3i(255,255,255)
    x0 = left
	y0 = sin(x0)
	do while( x0 <= right )
	  x1 = x0+xinc
	  y1 = sin(x1)
	  call sglLineV(x0,y0, x1,y1)
	  x0 = x1
	  y0 = y1
    end do
	call sglUpdateBuffer()
  end subroutine
  subroutine resize(w, h)
    integer w, h
	real r
	width = w
	height = h
	r = real(height)/real(width)
	if ( r>1.0 ) then
	  left = -range
	  right = range
	  top = r*range
	  bottom = -r*range
	else
	  left = -range/r
	  right = range/r
	  top = range
	  bottom = -range
	end if
	call sglSetVirtual( left, top, right, bottom )
  end subroutine
end module

program main
  use sgl_util
  implicit none
  call sglDisplaySub(Display)
  call sglReshapeSub(resize) 
  call sglCreateWindow(100,100,400,400,1)
  call sglMainLoop()
  stop
end program

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -