InitSprite()
OpenScreen(800,600,32,"SOFTWARE")
InitKeyboard()
PX= Random(799) : PY= Random(599) : BYEBYE= 0
Repeat ; THE PROGRAM'S MAIN LOOP STARTS HERE
RELEASE= ElapsedMilliseconds()+ 20 ; LIMITS LOOP SPEED TO 50 Hz
; GATHER THIS LOOP ITERATION'S USER INPUT STATE VARIABLES FROM SYSTEM
ExamineKeyboard()
If KeyboardPushed(#PB_Key_Escape) : BYEBYE+ 1 : EndIf ; EXIT PROGRAM UNCONDITIONALLY WHEN USER PRESSES ESCAPE
; POPULATE THE SCREEN
ClearScreen($111144)
StartDrawing(ScreenOutput()) : DrawingMode(#PB_2DDrawing_Transparent)
; Box(0,0,800,600,$111144) ; WORKS
DrawText(40,40,"(0,0)",$8888FF) : LineXY(40,40,0,0,$8888FF)
DrawText(40,530,"(0,599)",$8888FF) : LineXY(40,560,0,599,$8888FF)
DrawText(675,40,"(799,0)",$8888FF) : LineXY(752,40,799,0,$8888FF)
DrawText(650,530,"(799,599)",$8888FF) : LineXY(760,560,799,599,$8888FF)
Box(250,225,275,110,$000000)
DrawText(275,250,"Pointer's X @ "+Str(PX),$8888FF)
DrawText(275,280,"Pointer's Y @ "+Str(PY),$8888FF)
StopDrawing() : FlipBuffers()
; LOOP SPEED LIMIT
If ElapsedMilliseconds() < RELEASE
Repeat : Delay(2) : Until ElapsedMilliseconds() > RELEASE
EndIf
Until BYEBYE
End
PB5.31 ClearScreen() does not work after OpenScreen()
PB5.31 ClearScreen() does not work after OpenScreen()
Keep it BASIC.
Re: PB5.31 ClearScreen() does not work after OpenScreen()
I get the same compiler error as in your other report: http://www.purebasic.fr/english/viewtop ... 61#p455161
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
ClearScreen() can't be called inside a StartDrawing()/StopDrawing() block.c4s wrote:I get the same compiler error as in your other report: http://www.purebasic.fr/english/viewtop ... 61#p455161
Sorry c4s, while testing this snippet in Windows® I got that error, and had corrected my source before you were able to post your reply.
Therefore this report is a programmer error.
I caused it by directly replacing the (full screen erasing) Box() command while trying to get the Linux windowed mode working.
I apologize for anyone's wasted time.
The error is detected right away in Windows® (when the debugger is on).
However when compiled in Linux, the ClearScreen() function can be called from within a StartDrawing()/StopDrawing() block,
and if displayed within a window it actually works, as the following code demonstates.
(OpenScreen() is replaced by OpenWindow()/OpenWindowedScreen() and ClearScreen() in the drawing block)
So maybe it's not a programmer error after all.
Code: Select all
InitSprite()
OpenWindow(0,0,0,800,600,"SOFTWARE",#PB_Window_ScreenCentered|#PB_Window_MinimizeGadget)
OpenWindowedScreen(WindowID(0),0,0,800,600,#True,0,0)
InitKeyboard()
PX= Random(799) : PY= Random(599) : BYEBYE= 0
Repeat ; THE PROGRAM'S MAIN LOOP STARTS HERE
RELEASE= ElapsedMilliseconds()+ 20 ; LIMITS LOOP SPEED TO 50 Hz
; GATHER THIS LOOP ITERATION'S USER INPUT STATE VARIABLES FROM SYSTEM
ExamineKeyboard()
If KeyboardPushed(#PB_Key_Escape) : BYEBYE+ 1 : EndIf ; EXIT PROGRAM UNCONDITIONALLY WHEN USER PRESSES ESCAPE
Repeat
X= WindowEvent() : If X = #PB_Event_CloseWindow : End : EndIf
Until X = 0
; POPULATE THE SCREEN
StartDrawing(ScreenOutput()) : DrawingMode(#PB_2DDrawing_Transparent)
ClearScreen($111144)
; Box(0,0,800,600,$111144) ; WORKS
DrawText(40,40,"(0,0)",$8888FF) : LineXY(40,40,0,0,$8888FF)
DrawText(40,530,"(0,599)",$8888FF) : LineXY(40,560,0,599,$8888FF)
DrawText(675,40,"(799,0)",$8888FF) : LineXY(752,40,799,0,$8888FF)
DrawText(650,530,"(799,599)",$8888FF) : LineXY(760,560,799,599,$8888FF)
Box(250,225,275,110,$000000)
DrawText(275,250,"Pointer's X @ "+Str(PX),$8888FF)
DrawText(275,280,"Pointer's Y @ "+Str(PY),$8888FF)
StopDrawing() : FlipBuffers()
; LOOP SPEED LIMIT
If ElapsedMilliseconds() < RELEASE
Repeat : Delay(2) : Until ElapsedMilliseconds() > RELEASE
EndIf
Until BYEBYE
End
Keep it BASIC.