Some experiments with fullscreen/windowed switching

This commit is contained in:
Aaron Mueller 2011-01-13 23:43:21 +01:00
parent 3e01463af7
commit bfe5051bac
2 changed files with 51 additions and 14 deletions

View file

@ -2,24 +2,61 @@
; Very simple game to get started with PureBasic and the game development. ; Very simple game to get started with PureBasic and the game development.
; 2011 - Ruben Mueller, Aaron Mueller ; 2011 - Ruben Mueller, Aaron Mueller
Procedure DrawMenuBackground(screen) fullscreen = 0
StartDrawing(WindowOutput(screen)) title.s = "Pongr - Build " + Str(#PB_Editor_BuildCount)
Box(0, 0, 800, 600, RGB(0, 0, 0))
StopDrawing() Procedure DrawOnScreen()
CreateSprite(0, 20, 20)
If StartDrawing(SpriteOutput(0))
Box(0, 0, 20, 20, RGB(255, 0, 155))
Box(5, 5, 10, 10, RGB(155, 0, 255))
StopDrawing()
EndIf
EndProcedure EndProcedure
; Initialize subsystems
If InitSprite() = 0 Or InitKeyboard() = 0
MessageRequester("Error", "Sorry, cant boot up.", 0)
End
EndIf
; Start the main loop which will create the window, wait for events and draw things ; Start the main loop which will create the window, wait for events and draw things
; on the screen. To escape from this loop, press ESC or close the window. ; on the screen. To escape from this loop, press ESC or close the window.
screen = OpenWindow(#PB_Any, 0, 0, 800, 600, "Pongr - Build " + Str(#PB_Editor_BuildCount), #PB_Window_ScreenCentered) If OpenWindow(0, 0, 0, 800, 600, title, #PB_Window_ScreenCentered)
If screen > 0 If OpenWindowedScreen(WindowID(0), 0, 0, 800, 600, 0, 0, 0)
DrawMenuBackground(screen) EndIf
Repeat Repeat
event = WaitWindowEvent() ; Event loop
Until event = #PB_Event_CloseWindow Repeat
event = WindowEvent()
Until event = 0
; Handle input
ExamineKeyboard()
; Does not work properly ...
; http://www.purebasic.fr/german/viewtopic.php?f=4&t=23730&p=285175
If KeyboardPushed(#PB_Key_F)
CloseScreen()
If fullscreen = 0
OpenScreen(800, 600, 32, title)
fullscreen = 1
Else
OpenWindowedScreen(WindowID(0), 0, 0, 800, 600, 0, 0, 0)
fullscreen = 0
EndIf
EndIf
; Draw the stuff on the screen
FlipBuffers()
ClearScreen(RGB(0, 200, 0))
DrawOnScreen()
Delay(1)
Until KeyboardPushed(#PB_Key_Escape)
EndIf EndIf
; IDE Options = PureBasic 4.51 (Linux - x64) ; IDE Options = PureBasic 4.51 (Linux - x64)
; CursorPosition = 19 ; CursorPosition = 37
; FirstLine = 8
; Folding = - ; Folding = -
; EnableXP ; EnableXP
; EnableCompileCount = 0 ; EnableCompileCount = 0

View file

@ -10,12 +10,12 @@
<section name="data"> <section name="data">
<explorer view="../../../" pattern="0"/> <explorer view="../../../" pattern="0"/>
<log show="1"/> <log show="1"/>
<lastopen date="2011-01-13 00:47" user="aaron" host="deskFu"/> <lastopen date="2011-01-13 23:43" user="aaron" host="deskFu"/>
</section> </section>
<section name="files"> <section name="files">
<file name="pong.pb"> <file name="pong.pb">
<config load="0" scan="1" panel="1" warn="1" lastopen="1"/> <config load="0" scan="1" panel="1" warn="1" lastopen="1"/>
<fingerprint md5="1bbc75d1989874173042c5b54d72373c"/> <fingerprint md5="2dc43b582138ebdc5da153593cc44acd"/>
</file> </file>
</section> </section>
<section name="targets"> <section name="targets">
@ -24,7 +24,7 @@
<outputfile value="build/pongr"/> <outputfile value="build/pongr"/>
<executable value="build/pongr"/> <executable value="build/pongr"/>
<options unicode="1" thread="1" xpskin="1" debug="1"/> <options unicode="1" thread="1" xpskin="1" debug="1"/>
<compilecount enable="1" value="12"/> <compilecount enable="1" value="25"/>
<buildcount enable="1" value="3"/> <buildcount enable="1" value="3"/>
</target> </target>
</section> </section>