As you probably are aware I am new to opengl and sld2
I managed to compile the software without errors.
when I run the programme it creates a bmp file, but it is empty.
I tried several things, but am not able to solve the problem.
I try to save a window of 750x500 pixels (iwidth x iheight) containing an 2D image of a FEM boundary with basepoints and numbering.
the routine that should do the job reads:
subroutine save_image2()
use opengl_glu
use opengl_glut
use common_window
use, intrinsic :: iso_fortran_env, only: i1 => int8, i8 => int64, r8 => real64,&
stderr => error_unit, stdout => output_unit
use :: sdl2
use :: sdl2_image
use :: SDL2_mixer
use :: SDL2_ttf
implicit none
type(c_ptr),dimension(0:iwidth*iheight*3) :: image
type(sdl_surface),pointer :: bitmap
integer :: idepth,ipitch,mm
call glReadPixels(0,0,iwidth,iheight,GL_RGB,GL_UNSIGNED_BYTE,image)
idepth=32
ipitch=4*iwidth
!ipitch=0
bitmap => SDL_Create_RGB_Surface_From(image,iwidth,iheight,idepth,ipitch,&
int(z'000000ff',kind=i8),int(z'0000ff00',kind=i8),&
int(z'00ff0000',kind=i8),int(z'ff000000',kind=i8))
mm=sdl_save_bmp(bitmap,"test.bmp")
endsubroutine save_image2
If I fill out ipitch = 0, I get the empty bmp file
if I fill out ipitch = 4*iwidth I get an error (see below)
At line 28 of file .\save_image2.f90
Fortran runtime error: Pointer actual argument 'bitmap' is not associated
Error termination.
The window sizes iwidth and iheight are obtained via the common block "common_window"
I hope I provided enough information