Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
29285 Discussions

Redrawing glut window during processing

jaeger0
Beginner
637 Views

I have a Quickwinaplication, with a glut driven Window, wher I display something with opengl.
I start a heave computation (Fem_3D), by using a threaded progress bar dialog (Progress). So during computation
the progress bar updates and handls an eventually user stop. So after each progress bar update (IsCancelSignalled) I want to update also the glut window, however It does not work. Either by setting the global variable update, which is handled in the Display_Idle subroutine, nor by directly calling the redraw_window function. The Display_Idle subroutine is only processed if no other process is running, means, we are in the main qickwin loop waiting for an event. So I quess It is something the same with the glutMainLoop. Redrawing works only if I click on the glut window during computation. So glut reacts on userinteraction and really redraws the Windos.

Any Idea how to handle the problem

subroutine FEM_3D(Dlg)
..
do i=1, 100
call IsCancelSignalled(Dlg,progress,...,stop)
if (stop) then
call Exit_Dialog
return
endif
update = .TRUE.
call redraw_window
...
.. heavy computations
enddo
end

subroutineIsCancelSiglalled(Dlg, progress,.., stop)
..
if (stop_button) stop = .TRUE.
retlog =DlgSet(Dlg,IDC_Progress_Bar, progress)
end subroutine

subroutine Progress
..
hThread =CreateThread(NULL_SA,0,LOC(FEM_3D), Loc(Dlg), o, loc(idThread))
retlog = dlgSetSug(dlg,IDC_PROGRESS_STOP.update_Progress_THREAD)
retlog = DlgModal(Dlg)
..
end

subroutine Display_IDLE
..
if (update) call redraw_window
..
end

subroutine InitDraw
..
call glutInit
call glutIdleFunc(Display_IDLE)
call glutMainLoop
end subroutine

Program Vsim
..
call InitDraw
do while(.NOT. VSIM_EXIT)
sleepqq(100)
enddo
..
end

0 Kudos
1 Reply
Paul_Curtis
Valued Contributor I
637 Views

Quickwin is creating more problems for you than it is solving; you really want to handle your own message loop, which would provide the atomic level of control you need.

That said, the progress-bar control should be run in a single persistent thread created by the main window, not, as shown in your code, by creating a new thread every time the progress-update is called. And you also should use $BeginThreadEx( ) to do this, since CreateThread( ) has a well-documented memory leak.

If you create your own plot window to draw into, then you can send this window an explicit, forcing, redraw message during the computation loop; it is not clear what is accomplished by your calls to "redraw_window", since this function has no argument such as the window handle, which would indicate which window is to be redrawn -- is the plot in the main window, or in a child to the main window? Again, this fuzzy imprecise relation to the actual windows API is the problem with Quickwin.

0 Kudos
Reply