sgldraw3.f90

来自「Fortran 95程序设计&Code-彭国伦」· F90 代码 · 共 40 行

F90
40
字号
module sgl_util
  use sgl
  implicit none
contains
  subroutine Display()
    call sglClearBuffer() 
	call sglColor3f(1.0,0,0) 
	call sglRectV(-0.6, -0.6, 0.6, 0.6)
    call sglColor3i(0,255,0) 
    call sglCircleV(0.0,0.0,1.0) 
	call sglColor3i(0,0,255) 
	call sglLineV(-1.0, 0, 1.0, 0) 
	call sglLineV(0, -1.0, 0.0, 1.0)
	call sglUpdateBuffer();
  end subroutine
  subroutine resize(width, height)
    integer width, height
	real r
	write(*,"('size:'I4' x'I4)") width, height
	r = real(height)/real(width)
	if ( r>1.0 ) then
	  call sglSetVirtual(-1.0, -r, 1.0, +r)
	else
	  call sglSetVirtual(-1.0/r, -1.0, 1.0/r, 1.0)
	end if
  end subroutine
end module

program main
  use sgl_util
  implicit none
  call sglDisplaySub(Display)
  ! 设定当窗口大小改变时会调用resize
  call sglReshapeSub(resize) 
  ! 设定窗口左上角的虚拟座标为(0,0)右下角为(1.0,1.0)
  call sglSetVirtual(-1.0, -1.0, 1.0, 1.0)
  call sglCreateWindow(100,100,500,500,1)
  call sglMainLoop()
  stop
end program

⌨️ 快捷键说明

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