Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

text output in opengl

chunky_lover_23
Beginner
465 Views

in an attempt to recreate the useful but now defunct glutbitmapcharacter routine, I'm attempting to use the fwglUseFontBitmaps routine as described at: https://msdn.microsoft.com/en-us/library/windows/desktop/dd374392(v=vs.85).aspx

Unfortunately the code fails  (okay=false, istatus = 0) when the fwglUseFontBitmaps function is called.  Any ideas ?

Please ignore the font stuff  - this was me starting to code up the NeHe tutorial - but since I cant get the fwglUseFontBitmaps to work I abandoned all hope.

subroutine setup_winfont(fontbase)

!

! routine to setup windows fonts for future output - based on arial font

use IFWINA

use IFOPNGL

!

integer(k_glint) :: fontbase

integer(HANDLE) :: hDC ! Device Context

integer(HANDLE) :: hRC ! OpenGL Context

integer(HANDLE) :: hWnd ! Window

integer(HANDLE) :: hinstance

integer(HANDLE),save :: hFont=0

integer(HANDLE),save :: oldFont=0

integer(HANDLE) :: hmemDC

integer font_height, istatus

logical keys(256)

logical okay

!

hmemDC = CreateCompatibleDC (hDC)

istatus= SelectObject (hmemDC, GetStockObject (SYSTEM_FONT))

write(*,*)'istatus ',istatus

write(*,*)'fontbase is ',fontbase

okay= fwglUseFontBitmaps(hmemDC, 0, 255, 1000)

write(*,*)' okay = ',okay

0 Kudos
3 Replies
Stephen_Sutcliffe1
465 Views

Try creating a display list first.

eg

integer :: fbase

fbase = fglGenLists(255)

and then refer to this in your call to fwglUseFontBitmaps(hmemDC,0,255,fbase)

Hope this helps

Steve

0 Kudos
JVanB
Valued Contributor II
465 Views

There is a more complete example in Norman Lawrence's book. A perhaps more complete example, but designed to be compatible with gfortran rather than ifort can be found at http://home.comcast.net/~kmbtib/Fortran_stuff/gridview.zip in the gridview.f90 file, subroutine MakeFont.

0 Kudos
chunky_lover_23
Beginner
465 Views

thanks to all who replied.  I've managed to get the text to display.  Here is the code in case anyone else needs it..  The winmods  module is a stripped down version of the ringmods module contained in the opengl examples. 

subroutine setup_winfont(iheight)
!
! routine to setup windows fonts for future output - based on arial font
use IFWINA
use IFOPNGL
use winMods
!
integer(HANDLE),save :: hFont=0 
integer(HANDLE),save :: oldFont=0 

integer font_height, istatus
logical okay

font_height=-iheight  ! use minus to get nearest character height
fontbase = fglGenLists(255)

hFont = CreateFont (font_height, & !
				    0,0,0, &
					FW_NORMAL, FALSE,FALSE,FALSE, &
					ANSI_CHARSET, OUT_DEFAULT_PRECIS, &
					CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, &
					DEFAULT_PITCH .OR. FF_DONTCARE, &
					"arial")

istatus = SelectObject(hDC, hfont)  !          // Selects The Font We Want
! istatus= SelectObject (hDC, GetStockObject (SYSTEM_FONT)) 
okay= fwglUseFontBitmaps(hDC, 0, 255, fontbase)  



end
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
subroutine print_text(output_str,x_pos,y_pos,fontbase)
!
use IFWINA
use IFOPNGL
!
! routine to disply text at the position with the current font
!
character*(*) output_str
integer(k_glint) ::  fontbase
!
call fglRasterPos2f(x_pos, y_pos)
call fglPushAttrib(GL_LIST_BIT)             ! Pushes The Display List Bits     ( NEW ) 
call fglListBase(fontbase)    
call fglCallLists(len(output_str), GL_UNSIGNED_BYTE, loc(output_str)) ! Draws The Display List Text
call fglPopAttrib()              
!
end

 

0 Kudos
Reply