I have two codes where main window has always open graphics screens - some have %gr open other %pl open. Then I open additional window with %og (OpenGL) and try to save OpenGL plot into PNG file.
The code with %gr saves content of OpenGL %og screen OK but the one with %pl does not - it produces just black region. Pressing shortcut set via accelerator %ac might also save content of %pl graphics screen depending on currently active window.
Here is the code which i use to save content of %og screen. I also tried different approach with i = export_image@(PNGfilename) but it does not work with %og completely.
integer function SaveOpengl_Bitmap()
include <clearwin.ins>,nolist
include <opengl.ins>,nolist
integer wOpGL,hOpGL
common /OpenGL_image_size/wOpGL,hOpGL
wOpGL=clearwin_info@('OPENGL_WIDTH')
hOpGL=clearwin_info@('OPENGL_DEPTH')
call do_bitmap(wOpGL,hOpGL)
SaveOpengl_Bitmap=2
end
subroutine do_bitmap(wOpGL,hOpGL)
include <clearwin.ins>,nolist
include <opengl.ins>,nolist
integer wOpGL,hOpGL,ierr,koff,kount,i,j,k
CHARACTER*1 ImageData(3*(wOpGL+3)*hOpGL), ImageDib(3,wOpGL,hOpGL)
CHARACTER*128 file_name
logical exst
ImageData=' '
ImageDib =' '
call glReadPixels(0,0,wOpGL,hOpGL, GL_RGB,GL_UNSIGNED_BYTE,ImageData)
koff=mod(wOpGL,4)
kount=0
do j=1,hOpGL
do i=1,wOpGL
do k=1,3
kount=kount+1
ImageDib(k,i,hOpGL-j+1)=ImageData(kount)
end do
end do
kount=kount+koff
end do
file_name='Opengl .png'
k=0
5 k=k+1
write(file_name(7:9),'(I3.3)')k
INQUIRE(FILE=file_name,EXIST=EXST)
IF (EXST) go to 5
call put_dib_block@(file_name,ImageDib,wOpGL,hOpGL, 0,0,wOpGL,hOpGL,24,ierr)
if(ierr.eq.0) then
! CALL POP('Screen Saved in OpenGLxxxx.png current Dir')
print*,'Screen Saved in OpenGLxxxx.png current Dir'
endif
return
end