Area under mouse not being redrawn

Windows specific forum
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by tinman.

Hi,

I have a slight problem. I use a windowed screen in my application for displaying an image. When the image changes I simply draw to the screen and then call FlipBuffers(). If I need to repaint the whole of the image, I call FlipBuffers() twice.

The problem is that if the mouse pointer is over the area of my window which is the screen, then the area under the mouse pointer gets restored (along with the mouse pointer) *after* I draw my new image.

I don't know if this is due to Windows (98), but it is probably due to me not knowing exactly how to update windows (and what happens internally) in the case of windowed screens.

Any advice would be appreciated. I can also send code to anyone interested.

Cheers.

Update: Here is some code to illustrate (you need to move the mouse to get it to redraw the area under it on my system - so put the mouse over the shape, click with the left button and move it away):

Code: Select all

#WindowWidth = 400
#WindowHeight = 300

#ScreenWidth = #WindowWidth - 4 - 4
#ScreenHeight = #WindowHeight - 4 - 4

#NumberVertices = 5

If InitSprite()=0 : End : EndIf

ds_Zoom.w = 10

Procedure DrawStuff()
    Shared ds_Zoom
    
    StartDrawing(ScreenOutput())

    FrontColor(0,0,0)
    Box(0, 0, #ScreenWidth, #ScreenHeight)

    FrontColor(255, 0, 0)
    For vertex = 0 To #NumberVertices-1
        x_start = #ScreenWidth/2 + ds_Zoom * Sin((vertex * 360 / #NumberVertices) * 3.1412 / 180)
        y_start = #ScreenHeight/2 + ds_Zoom * Cos((vertex * 360 / #NumberVertices) * 3.1412 / 180)
        
        For vertoo = 0 To #NumberVertices-1
            If vertex  vertoo
                x_end = #ScreenWidth/2 + ds_Zoom * Sin((vertoo * 360 / #NumberVertices) * 3.1412 / 180)
                y_end = #ScreenHeight/2 + ds_Zoom * Cos((vertoo * 360 / #NumberVertices) * 3.1412 / 180)
                
                LineXY(x_start, y_start, x_end, y_end)
            EndIf
        Next
    Next
    
    StopDrawing()
    
    FlipBuffers()
EndProcedure


If OpenWindow(0, 0, 0, #WindowWidth, #WindowHeight, #PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_SizeGadget, "foo")

    SetFrameRate(120)
    If OpenWindowedScreen(WindowID(0), (#WindowWidth-#ScreenWidth)/2, (#WindowHeight-#ScreenHeight)/2, #ScreenWidth, #ScreenHeight, 0, #WindowWidth-(#WindowWidth-#ScreenWidth)/2, #WindowHeight-(#WindowHeight-#ScreenHeight)/2)
        DrawStuff()
        
        quit.w=0
        Repeat
            ev.l=WaitWindowEvent()
            While ev0
                Select ev
                    Case #PB_EventCloseWindow
                        quit = 1
            
                    Case #PB_EventRePaint
                        FlipBuffers() : FlipBuffers()
                    
                    Case #WM_LBUTTONUP
                        ds_Zoom + 10
                        DrawStuff()
            
                    Case #WM_RBUTTONUP
                        ds_Zoom - 10
                        If ds_Zoom 

-- 
It's not minimalist - I'm increasing efficiency by reducing input effort.
(Win98first ed. + SP1, PB3.40)
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Pupil.

try and drop the SetFrameRate() line and see if you get better result, on my computer it works much better if that command is commented out. With this line cpu-utilization pendles between 0 and 100% without 0 - 10% approx..
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by freak.

There is no problem here (using Win2k) but you could try putting

ShowCursor_(#FALSE)
and
ShowCursor_(#TRUE)

around your FlipBuffers() line.

Timo
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by tinman.
Originally posted by Pupil

try and drop the SetFrameRate() line and see if you get better result, on my computer it works much better if that command is
Thanks. Originally I did not have the SetFrameRate command in there, but I added it today and it made no difference. Guess I couldn't be bothered taking it out :) Didn;t know about the CPU usage though, cheers.

@freak
Thanks, I'll try that out. Brilliant, it works great.


I love you guys ;p


--
It's not minimalist - I'm increasing efficiency by reducing input effort.
(Win98first ed. + SP1, PB3.40)
Post Reply