Page 1 of 2
Flickers White Screen opening a Windowed Screen
Posted: Wed Feb 24, 2010 7:20 pm
by SoulReaper
Hello
I seem to be have a problem with the following code below i have checked it on PB 4.31 on Windows XP & PB 4.41 and Windows 7 and they are the same.
The program seems to flicker white for a few flips in windowed mode then goes black as expected, its the few flickers i cannot seem to understand why this is happening...
in full screen mode it is fine, any help please
it is more pronouced in debug mode.
Code: Select all
Version$="v1.2"
_Window=#True
If InitEngine3D()=0
MessageRequester("Error", "Failed to open 3D Engine", 0) : End
EndIf
If InitKeyboard()=0 Or InitSprite()=0
MessageRequester("Error", "Can't open DirectX 7 or Greater", 0) : End
EndIf
ExamineDesktops()
MonitorFrequency=DesktopFrequency(0)
If MonitorFrequency=0 : MessageRequester("Error", "Failed to open a 800*600 screen!",0) : End : EndIf
If _Window=#False
If OpenScreen(800,600,16,version$,#PB_Screen_WaitSynchronization,MonitorFrequency)
Else
MessageRequester("Error", "Failed to open a 800*600 16 bit screen",0)
EndIf
EndIf
If _Window=#True
OpenWindow(0,0,0,800,600,Version$,#PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_SizeGadget|#PB_Window_MaximizeGadget)
If OpenWindowedScreen(WindowID(0),0,0,800,600,1,0,0,#PB_Screen_WaitSynchronization)
Else
MessageRequester("Error", "Failed to open a 800*600 32 bit screen",0)
EndIf
EndIf
Repeat
ExamineKeyboard()
FlipBuffers()
If _Window=#True
Repeat
Event=WindowEvent()
If Event=#PB_Event_CloseWindow : End : EndIf
Until Event=0
EndIf
Until KeyboardPushed(#PB_Key_Escape)
Thankyou for any help
Kevin

Re: Flickers White Screen opening a Windowed Screen
Posted: Wed Feb 24, 2010 7:35 pm
by Kaeru Gaman
ok.. now you got me wondering.
I tested it and it PERMANENTLY flickers.
even if I add the missing ClearScreen,
put InitEngine3D after InitSprite,
add a RenderWorld() to the Mainloop...
nothing helps.
only when I eliminate InitEngine3D the flicker vanishes...
don't get this... why is Engine3D not fully compatible with a WindowedScreen?
btw, I got XPpro
Re: Flickers White Screen opening a Windowed Screen
Posted: Wed Feb 24, 2010 7:40 pm
by Demivec
Kaeru Gaman wrote:ok.. now you got me wondering.
I tested it and it PERMANENTLY flickers.
even if I add the missing ClearScreen,
put InitEngine3D after InitSprite,
add a RenderWorld() to the Mainloop...
nothing helps.
only when I eliminate InitEngine3D the flicker vanishes...
don't get this... why is Engine3D not fully compatible with a WindowedScreen?
I get identical results with Windows XP SP3 x86.
In addition, I ran software a week ago and have rebooted several times (keeping the computer powered up) since then and I get portions of these former images as part of the flicker.

Re: Flickers White Screen opening a Windowed Screen
Posted: Wed Feb 24, 2010 9:08 pm
by nco2k
the startup flicker has nothing to do with the engine3d and it isnt white either, its the window background color. i reported something
similar (see 2nd part). no flickering in 4.20.
c ya,
nco2k
Re: Flickers White Screen opening a Windowed Screen
Posted: Thu Feb 25, 2010 11:49 am
by Trond
About the permanent flicker:
When you use the 3d engine, the 2d drawing is done on top of the 3d image. But, you never render any 3d image in your code, so all you get is garbage. Note that to use RenderWorld() you need to create a camera first, else you'll still get garbage.
Code: Select all
Version$="v1.2"
_Window=#True
InitSprite()
InitEngine3D()
If _Window=#False
OpenScreen(800,600,16,version$,#PB_Screen_WaitSynchronization,MonitorFrequency)
Else
OpenWindow(0,0,0,800,600,Version$,#PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_SizeGadget|#PB_Window_MaximizeGadget)
OpenWindowedScreen(WindowID(0),0,0,800,600,1,0,0,#PB_Screen_WaitSynchronization)
EndIf
CreateCamera(0, 0, 0, 800, 600)
Debug "done"
Repeat
RenderWorld()
FlipBuffers()
If _Window=#True
Repeat
Event=WindowEvent()
If Event=#PB_Event_CloseWindow : End : EndIf
Until Event=0
EndIf
Until 0=1
Re: Flickers White Screen opening a Windowed Screen
Posted: Thu Feb 25, 2010 12:47 pm
by Kaeru Gaman
Trond wrote: Note that to use RenderWorld() you need to create a camera first ...
goodness you ... goodness me

industrial desease ...
my mistake, thanks for enlighting.
Re: Flickers White Screen opening a Windowed Screen
Posted: Thu Feb 25, 2010 2:23 pm
by SoulReaper
Thankyou for trying to help but it still fickers when flipping buffers at the very beginning in windowed mode
this time i have took out all 3d commands just to show that it is still there...
Code: Select all
Version$="v1.2"
_Window=#True
InitSprite()
If _Window=#False
OpenScreen(800,600,16,version$,#PB_Screen_WaitSynchronization,MonitorFrequency)
Else
OpenWindow(0,0,0,800,600,Version$,#PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_SizeGadget|#PB_Window_MaximizeGadget)
OpenWindowedScreen(WindowID(0),0,0,800,600,1,0,0,#PB_Screen_WaitSynchronization)
EndIf
Repeat
FlipBuffers()
If _Window=#True
Repeat
Event=WindowEvent()
If Event=#PB_Event_CloseWindow : End : EndIf
Until Event=0
EndIf
Until 0=1
Re: Flickers White Screen opening a Windowed Screen
Posted: Thu Feb 25, 2010 2:24 pm
by Trond
Confirmed.
Re: Flickers White Screen opening a Windowed Screen
Posted: Thu Feb 25, 2010 2:52 pm
by Kaeru Gaman
I also conform this short flicker, but when I compile an exe it shortens down to a single frame's blink.
I don't know what's the reason, but compared with the three seconds of sheer blackness the resolution change causes when opening a fullscreen, it appears meaningless to me.
Re: Flickers White Screen opening a Windowed Screen
Posted: Thu Feb 25, 2010 6:56 pm
by SoulReaper
@Trond and Kaeru Gaman and nco2k thankyou for confirming this problem, the reason why it bothers me is that it looks unprofessional.
Maybe Fred and Team could look into this in more depth as windowed screens are used alot in Pure Basic.
I will post this on the bugs section.
Kind Regards
Kevin

Re: Flickers White Screen opening a Windowed Screen
Posted: Mon Aug 16, 2010 8:57 am
by moogle
This problem has been with PB for quite a while IIRC (v4.00?)
I've whittled it down to the WindowEvent() procedure
This code shows the screen how I thought it would be, but if you uncomment the Event = WindowEvent() line the screen shows Blue (RGB(0, 64, 127)) and then white, then back to Blue. I don't know how to make it work properly and handle the window events? It's one of these things where you think ahh PB is awesome and then find annoying little bugs like this. Like it's been said in other posts the white flicker is more prominent in debug mode.
What's weird is when I try to record it with screen capture the window opens fine, with the Event handling in.
Looks like the only way to stop this happening is to use API (SDL or some others) to open your own windowed screen...
Would be nice if the PB team could comment here or in the bug post, because it sort of seems to me that the Sprite/Screen/Game parts of PB are much lesser priority
PS - It works fine if compiled under the OpenGL subsystem.
Code: Select all
If (InitSprite() And InitSprite3D()) = 0
MessageRequester("Error", "Can't open DirectX", 0)
End
EndIf
pWnd=OpenWindow(#PB_Any, 0, 0, 640, 480, "PB White Flicker", #PB_Window_MinimizeGadget | #PB_Window_ScreenCentered | #PB_Window_BorderLess)
If pWnd
SetWindowColor(pWnd, RGB(0,64,127))
If Not OpenWindowedScreen(WindowID(pWnd), 0, 0, 640, 480, 0, 0, 0, #PB_Screen_SmartSynchronization)
MessageRequester("Error", "Can't open windowed screen!", 0)
End
EndIf
Else
MessageRequester("Error", "Can't open window!", 0)
EndIf
Repeat
Repeat
;Event = WindowEvent()
Select Event
Case #PB_Event_CloseWindow
Quit = 1
EndSelect
Until Event = 0
ClearScreen(RGB(0,64,127))
FlipBuffers()
Delay(10)
Until Quit Or (GetKeyState_(#VK_ESCAPE)&%10000000 And GetActiveWindow() = pWnd)
CloseScreen()
End
Re: Flickers White Screen opening a Windowed Screen
Posted: Tue Aug 17, 2010 1:05 am
by Rescator
I see no flicker here (too fast probably) but I did notice this oddity...
Does the same happen to others?
Wat happens for me is that the first flipbuffer loop (3 frames of flipping) seem to do nothing.
It is only if If the main loop flip buffer is used that the window actually turns black.
Code: Select all
Version$="v1.2"
_Window=#True
If InitEngine3D()=0
MessageRequester("Error", "Failed to open 3D Engine", 0) : End
EndIf
If InitKeyboard()=0 Or InitSprite()=0
MessageRequester("Error", "Can't open DirectX 7 or Greater", 0) : End
EndIf
ExamineDesktops()
MonitorFrequency=DesktopFrequency(0)
If MonitorFrequency=0 : MessageRequester("Error", "Failed to open a 800*600 screen!",0) : End : EndIf
If _Window=#False
If OpenScreen(800,600,16,version$,#PB_Screen_WaitSynchronization,MonitorFrequency)
Else
MessageRequester("Error", "Failed to open a 800*600 16 bit screen",0)
EndIf
EndIf
If _Window=#True
OpenWindow(0,0,0,800,600,Version$,#PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_SizeGadget|#PB_Window_MaximizeGadget|#PB_Window_Invisible)
If OpenWindowedScreen(WindowID(0),0,0,800,600,1,0,0,#PB_Screen_WaitSynchronization)
Define i.i
Repeat
If _Window=#True
Repeat
Event=WindowEvent()
Until Event=0
EndIf
FlipBuffers()
ExamineKeyboard()
i+1
Until i=3
HideWindow(0,#False)
Else
MessageRequester("Error", "Failed to open a 800*600 32 bit screen",0)
EndIf
EndIf
Repeat
If _Window=#True
Repeat
Event=WindowEvent()
If Event=#PB_Event_CloseWindow : End : EndIf
Until Event=0
EndIf
; FlipBuffers()
ExamineKeyboard()
Until KeyboardPushed(#PB_Key_Escape)
Re: Flickers White Screen opening a Windowed Screen
Posted: Tue Aug 17, 2010 1:39 am
by moogle
Rescator wrote:I see no flicker here (too fast probably) but I did notice this oddity...
Does the same happen to others?
Wat happens for me is that the first flipbuffer loop (3 frames of flipping) seem to do nothing.
It is only if If the main loop flip buffer is used that the window actually turns black.
By a flicker I mean if the ClearScreen color is black and the window color is black when I open a window like the code above it will open a window with a black background, then when it creates the windowedscreen (PB's DirectX version) it flashes white and then after it's cleared one more time it goes back to black and then it's all alright.
OpenGL has no white flashes.
Yes your code doesn't turn the screen black for me too.
I think the main loop turns it black because whilst the window is hidden flipbuffers doesn't work.
If you check the WindowEvent() values in the first loop (window hidden) they just return 0 and 1 which arent event types it seems?
This was fixed in another version and then it appeared again. I'm guessing it's when the 2DDrawing changed but I'm going to check.
Re: Flickers White Screen opening a Windowed Screen
Posted: Sun Aug 21, 2011 6:50 am
by moogle
moogle wrote:What's weird is when I try to record it with screen capture the window opens fine, with the Event handling in.
Bit of a correction, it just seems that the flicker is random and not a screen capture program stopping it.
After recording another thing I thought I'd record this one too just to see if it ever shows up.
http://www.youtube.com/watch?v=EHMUmQTf_Mg&hd=1
It never existed before PB4.4 iirc.
Re: Flickers White Screen opening a Windowed Screen
Posted: Sun Aug 21, 2011 7:41 am
by netmaestro
Check the bugs forum, it's fixed for the upcoming 4.60b4.