Some windowed screen questions

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,

OK, first some info - I'm looking to use a windowed screen in my application so that I can draw faster to a window.

Am I correct in thinking the width and height in the OpenWindowedScreen command sets the width and height of the screen itself, and then the x,y,rightoffset and bottomoffset specify the position and size within the window? (Seems to be, but doesn't come out well in the docs.)

The Autostretch parameter - does it work? The code I had is this, and it doesn't (the docs say the display should be resized when the window is but on my system it stays 380x280 pixels in the top-left of the window):

Code: Select all

If InitSprite()=0 : End : EndIf
If OpenWindow(0,5,5,400,300,#PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_SizeGadget,"GeoWorld")
    If OpenWindowedScreen(WindowID(), 10, 10, 380, 280, 1, 0, 0)
        ClearScreen(0,0,200)
        FlipBuffers()
    Else
        MessageRequester("foo", "failed to open windowed screen", #PB_MessageRequester_OK)
    EndIf
    While quitprog=0
        ev.l=WaitWindowEvent()
        While ev0
            Select ev
                Case #PB_EventCloseWindow : quitprog=-1
                Case #PB_EventRepaint : FlipBuffers() : FlipBuffers()
            EndSelect
            ev=WindowEvent()
        Wend
    Wend  ; Window main event loop
    CloseWindow(0)
EndIf
End
Is there some way to manually resize the display of the screen in the window?

I'm guessing there would be no way to resize a screen (not stretch it) without closing and opening it, so is there some way you can draw a sprite to a window directly, without the screen? It would need a "CreateSprite" command be added to the spritelib though (which would be a generally useful addition I think).

Sorry for the lame questions.


--
It's not minimalist - I'm increasing efficiency by reducing input effort.
(Win98first ed. + SP1, PB3.20)
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 Danilo.

Code: Select all

If InitSprite()=0 : End : EndIf
If OpenWindow(0,5,5,400,300,#PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_SizeGadget,"GeoWorld")
If OpenWindowedScreen(WindowID(), 10, 10, 380, 280, 1, 10, 10) = 0
   MessageRequester("foo", "failed to open windowed screen", #PB_MessageRequester_OK)
EndIf


Repeat
    Select WindowEvent():sleep_(1)
      Case #PB_EventCloseWindow : quitprog = 1
    EndSelect
    If IsScreenActive()
       ClearScreen(0,0,200)
       FlipBuffers()
    Else
       sleep_(200)
    EndIf
Until quitprog = 1


CloseWindow(0)
EndIf
cya,
...Danilo

(registered PureBasic user)
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 fred.

Don't forget to put SetFrameRate(xx) when using a windowed screen else the whole CPU will be stolen (no VBlank sync on a WindowedScreen).

Fred - AlphaSND
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.

@Danilo:
Thanks for the code, you've sent me in the correct direction. It seems as long as I redraw the screen when the window is resized then the display is OK. Any chance of a #PB_EventResize event Fred?

@Fred:
Don't forget to put SetFrameRate(xx) when using a windowed screen else the whole CPU will be stolen (no VBlank sync on a WindowedScreen).
Do I need that even if I am not using the windowed screen as a continuously updating screen, like you would get in a game? My application only needs to display a static image (well, it updates when buttons and things will be clicked on).

Thanks guys.


--
It's not minimalist - I'm increasing efficiency by reducing input effort.
(Win98first ed. + SP1, PB3.20)
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 PB.

> Any chance of a #PB_EventResize event Fred?

You can use #WM_SIZE for now to know when a window's size has changed.


PB - Registered PureBasic Coder
Post Reply