1. Windows vertical retrace
- Posted by ags <eu at 531pi.co.nz> Jun 21, 2006
- 655 views
Hi All After a quick google it seems to me that there is no way to detect the vertical retrace on the windows desktop (ie 'non-exclusive' mode). With rapidly updating graphics in a small window on my home system with a CRT monitor the flicker is quite noticeable. On my work system with an LCD monitor the effect is not as bad but still there (particularly if the mouse pointer is over the area being drawn). So what do other systems do about this? Flash objects in web pages don't seem to suffer from this and other windowed games seem to get around the problem. How are they doing this? How can we do this in Euphoria, particularly with win32lib? Gary
2. Re: Windows vertical retrace
- Posted by Derek Parnell <ddparnell at bigpond.com> Jun 21, 2006
- 573 views
ags wrote: > > Hi All > > After a quick google it seems to me that there is no way to detect the > vertical > retrace on the windows desktop (ie 'non-exclusive' mode). You don't have to with Windows GUI programming. The 'trick' is to do your drawing onto a Pixmap control and then copy the Pixmap to the Window during the w32HPaint event. The way to trigger that event is to call repaintFG(mywindow) If you want to see how this is down you can explore the 'wordcatcher' demo program that comes with win32lib. -- Derek Parnell Melbourne, Australia Skype name: derek.j.parnell
3. Re: Windows vertical retrace
- Posted by ags <eu at 531pi.co.nz> Jun 21, 2006
- 573 views
Derek Parnell wrote: > > ags wrote: > > > > Hi All > > > > After a quick google it seems to me that there is no way to detect the > > vertical > > retrace on the windows desktop (ie 'non-exclusive' mode). > > You don't have to with Windows GUI programming. The 'trick' is to do your > drawing > onto a Pixmap control and then copy the Pixmap to the Window during the > w32HPaint > event. The way to trigger that event is to call > > repaintFG(mywindow) > > If you want to see how this is down you can explore the 'wordcatcher' demo > program > that comes with win32lib. Ah, got it, thanks, repaintFG works well. One question though.. why is there no non-erasing equivalent for repaintRect? Gary
4. Re: Windows vertical retrace
- Posted by Derek Parnell <ddparnell at bigpond.com> Jun 21, 2006
- 572 views
ags wrote: > One question though.. why is there no non-erasing equivalent for paintRect? Because nobody asked for it.
global procedure redrawRect( integer id, integer x1, integer y1, integer x2, integer y2 ) -- Redraws only a portion of the window atom hWnd atom rect -- Allocate rectangle rect = w32acquire_mem( 0, SIZEOF_RECT ) poke4(rect, {x1,y1,x2,y2}) hWnd = getHandle( id ) -- invalidate sub-window of the current window if w32Func( xInvalidateRect, {hWnd, rect, 0} ) then VOID = w32Func(xSendMessage,{hWnd, WM_PAINT, 0, 0 }) end if -- Free the rectangle structure w32release_mem( rect ) end procedure
-- Derek Parnell Melbourne, Australia Skype name: derek.j.parnell
5. Re: Windows vertical retrace
- Posted by ags <eu at 531pi.co.nz> Jun 21, 2006
- 804 views
- Last edited Jun 22, 2006
Derek Parnell wrote: > > ags wrote: > > > One question though.. why is there no non-erasing equivalent for paintRect? > > Because nobody asked for it. > > }}} <eucode> > global procedure redrawRect( integer id, integer x1, integer y1, integer x2, > integer y2 ) > > -- Redraws only a portion of the window > atom hWnd > atom rect > > -- Allocate rectangle > rect = w32acquire_mem( 0, SIZEOF_RECT ) > poke4(rect, {x1,y1,x2,y2}) > > hWnd = getHandle( id ) > > -- invalidate sub-window of the current window > if w32Func( xInvalidateRect, {hWnd, rect, 0} ) then > VOID = w32Func(xSendMessage,{hWnd, WM_PAINT, 0, 0 }) > end if > > -- Free the rectangle structure > w32release_mem( rect ) > > end procedure > > </eucode> {{{ > -- > Derek Parnell > Melbourne, Australia > Skype name: derek.j.parnell This works well. Though with rapidly updating graphics it still seems better to repaint everything at once. Thanks Gary
6. Re: Windows vertical retrace
- Posted by Cuvier Christian <christian.cuvier at insee.fr> Jun 22, 2006
- 584 views
> Subject: Windows vertical retrace > > > posted by: ags <eu at 531pi.co.nz> > > Hi All > > After a quick google it seems to me that there is no way to > detect the vertical retrace on the windows desktop (ie > 'non-exclusive' mode). > > With rapidly updating graphics in a small window on my home > system with a CRT monitor the flicker is quite noticeable. > On my work system with an LCD monitor the effect is not as > bad but still there (particularly if the mouse pointer is > over the area being drawn). > > So what do other systems do about this? Flash objects in web > pages don't seem to suffer from this and other windowed games > seem to get around the problem. How are they doing this? > How can we do this in Euphoria, particularly with win32lib? > > Gary > > I once read that screen flickering was caused by painting the same area several times in a rapid succession, and that efficient flicker reduction could be made through eliminating the extra drawing. For instance, when you repaint a window, the window gets a WM_ERASEBKGND message to erase the background, then the WM_PAINT. If you paint by copying a whole dc or pixmap, the drawing done while processing the first message is redundant, causes screen flicker and slows the app down. Trap the WM_ERASEBKGND message and process it by just returning -1 (or w32True). Docs say anything nonzero does the job. This particular aspect is not the only source of flicker, but an often overlooked one. Ihave seen it in action. Again, the trick is avoiding to paint a region and then immediately redraw something else in it. HTH CChris
7. Re: Windows vertical retrace
- Posted by ags <eu at 531pi.co.nz> Jun 23, 2006
- 972 views
- Last edited Jun 24, 2006
Cuvier Christian wrote: > > > posted by: ags <eu at 531pi.co.nz> > > With rapidly updating graphics in a small window on my home > > system with a CRT monitor the flicker is quite noticeable. > > On my work system with an LCD monitor the effect is not as > > bad but still there (particularly if the mouse pointer is > > over the area being drawn). > > ... > I once read that screen flickering was caused by painting the same area > several times in a rapid succession, and that efficient flicker reduction > could be made through eliminating the extra drawing. > > For instance, when you repaint a window, the window gets a WM_ERASEBKGND > message to erase the background, then the WM_PAINT. If you paint by copying > a whole dc or pixmap, the drawing done while processing the first message is > redundant, causes screen flicker and slows the app down. Trap the > WM_ERASEBKGND message and process it by just returning -1 (or w32True). Docs > say anything nonzero does the job. > > This particular aspect is not the only source of flicker, but an often > overlooked one. Ihave seen it in action. Again, the trick is avoiding to > paint a region and then immediately redraw something else in it. Thanks for that. I managed to get rid of the flicker by using the non-erasing repaintFG procedure in win32lib (I am not doing the message loop myself). Additionally the redrawRect procedure supplied by Derek Parnell helped me out. I think the main source of flicker I was having was from the background being erased first, but it did look like genuine vertical retrace flicker so maybe the erasing and painting did what you are saying above. In my graphex library (which I have just submitted) I can do multiple rapid drawing of small areas of the window and there is little or no flicker. Updating the whole window at once now produces no flicker at all. Thanks for your help. Gary