PDA

View Full Version : opengl window turns blank when i move it



terencegbh
11-29-2010, 11:35 PM
Hi,

I am using fortran to run a simulation program and has a opengl display code as below:

call fauxInitDisplaymode (IOR(AUX_SINGLE,AUX_RGB))
call fauxInitPosition (0, 0, 400, 400)
ret = fauxInitWindow ("Bubble window"C)
call fglClearColor (0.0, 0.0, 0.0, 0.0)
call fglClear(GL_COLOR_BUFFER_BIT)
call fglMatrixMode (GL_PROJECTION)
call fglLoadIdentity ()
call fglOrtho(DBLE(-1.0),DBLE(1.0),DBLE(-1.0),DBLE(1.0),
& DBLE(-1.0),DBLE(1.0))
call fglColor3f (1.0, 1.0, 1.0)
call fglBegin(GL_POINTS)
do I=1, 102
call fglVertex2f(rj(I)*mult, -(zj(I)+0.d0)*mult) !Plot points
enddo
do I=1, 102
call fglVertex2f(-rj(I)*mult, -(zj(I)+0.d0)*mult) !Mirror to -x
ENDDO
call fglEnd()
call fglFlush()
call fglClear(GL_DEPTH_BUFFER_BIT)
call fglClear(GL_COLOR_BUFFER_BIT)

my problem is that as long as i dont touch it, it will display perfectly, however as long as i click on any other windows or move this display window, the whole screen will turn blank thereafter. Hope anyone can assist me in this.

Thanks.
terence

ugluk
11-29-2010, 11:44 PM
Lol, I think you need to refresh your rendering repeatedly, because you invalidate your window contents as you move it. Nice cryptic fortran GL coding!

terencegbh
11-30-2010, 01:35 AM
hi, what do meanyou by refresh my rendering repeatedly?
which parts of the code should i transfer inside my computation loop and which parts should i leave out? i tried putting the whole chunch in the loop but gets the 'failed to register window class' error instead.

thanks for your prompt help man.

V-man
11-30-2010, 06:19 AM
It turns black because you are clearing your screen. Look at the last 2 calls to glClear.
Also, normally people OR those 2 things : write glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)

NeHe has some Visual Fortran project such as
http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=02

and there are others at http://nehe.gamedev.net

dukey
11-30-2010, 03:38 PM
Clear the screen before rendering, not after :) Problem solved !
With a single buffered screen, really the driver could present the image at any time. You can't guarantee it'll only do it after a flush of the pipeline.

ugluk
11-30-2010, 04:55 PM
Have any of you folks realized he flushes and finishes before he clears? In effect his clear does not take effect. He ought to be rendering in a loop, that would be triggered by either a timer or when his window contents become invalidated.

terencegbh
11-30-2010, 07:28 PM
dear all, thanks for the responses. i tried shifting the clearing of screen before rendering but that doesnt work too. looked through the tutorials briefly but couldnt find anything i could follow. also, the originally black with white display screen actually turns completely white (i.e. not responding) if i shift it or click anywhere, otherwise it does it job fine. The problem is I have another output screen right behind this opengl display and its blocked all the time. I need to shift it.
Finally yes i render in a loop, here is the more comprehensive version of the code:

SCR=0
call fauxInitDisplaymode (IOR(AUX_SINGLE,AUX_RGB))
call fauxInitPosition (0, 0, 400, 400)
ret = fauxInitWindow ("Bubble window"C)
call fglClearColor (0.0, 0.0, 0.0, 0.0)
call fglClear(GL_COLOR_BUFFER_BIT)
call fglMatrixMode (GL_PROJECTION)
call fglLoadIdentity ()
call fglOrtho(DBLE(-1.0),DBLE(1.0),DBLE(-1.0),DBLE(1.0),
& DBLE(-1.0),DBLE(1.0))

!Loop starts here
IF (SCR.EQ.SCROUTP) THEN
call fglClear(GL_COLOR_BUFFER_BIT)
call fglColor3f (1.0, 1.0, 1.0)
call fglBegin(GL_POINTS)
do I=1, 102
call fglVertex2f(rj(I)*mult, -(zj(I)+0.d0)*mult) !Plot points
enddo
do I=1, 102
call fglVertex2f(-rj(I)*mult, -(zj(I)+0.d0)*mult) !Mirror to -x
ENDDO
call fglEnd()
SCR=0
call fglFlush()
ENDIF

appreciate all gurus help! =)

terencegbh
12-01-2010, 08:12 PM
up up up up up

ugluk
12-01-2010, 09:31 PM
Hehe, you got us there with your fortran ;)

terencegbh
12-02-2010, 09:45 PM
=(