It is currently Thu Dec 12, 2019 7:25 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: OpenWindowedScreen resizable
PostPosted: Wed May 08, 2019 9:20 am 
Offline
User
User

Joined: Thu Dec 13, 2018 9:58 pm
Posts: 13
Location: france
thanks to Ollivier from the French forum for the help
Quote:
OpenWindowedScreen(GadgetID(0), 0, 0, ScreenW, ScreenH)

you can open a screen on a gadget
Code:
#MainWin = 0
#ScreenWin = 1
ScreenW = 2048
ScreenH = 2048
InitSprite()

If OpenWindow(#MainWin, 0, 0, 400, 300, Str(ScreenW) + " x " + Str(ScreenH), #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_SizeGadget | #PB_Window_MaximizeGadget)
 
  MDIGadget(0, 0, 0, WindowWidth(#MainWin), WindowHeight(#MainWin), 0, 0, #PB_MDI_AutoSize | #PB_MDI_BorderLess)

  OpenWindowedScreen(GadgetID(0), 0, 0, ScreenW, ScreenH) ;, 0, 0, 0, #PB_Screen_NoSynchronization)
 
  CreateSprite(101, ScreenW, ScreenH, #PB_Sprite_AlphaBlending)
  If StartDrawing(SpriteOutput(101) )
    For I = 1 To 1000
      x = Random(ScreenW)
      y = Random(ScreenH)
      r = 50 + Random(50)
      c = RGB(Random(255), Random(255), Random(255) )
      Circle(x, y, r, c)
      Circle(x - ScreenW, y, r, c)
      Circle(x + ScreenW, y, r, c)
    Next
    StopDrawing()
  EndIf
 
  x = 0
  Repeat
    DisplaySprite(101, x, 0)
    DisplaySprite(101, ScreenW + x, 0)
    x - 1
    If x <= 0 - ScreenW
      X = 0
    EndIf
    FlipBuffers()
    Delay(3)
  Until WindowEvent() = #PB_Event_CloseWindow
EndIf

_________________
Sorry for my English. My language is French


Top
 Profile  
Reply with quote  
 Post subject: Re: OpenWindowedScreen resizable
PostPosted: Wed May 08, 2019 11:15 am 
Offline
Moderator
Moderator
User avatar

Joined: Thu Dec 31, 2009 11:05 pm
Posts: 1108
Location: Berlin (Germany)
Good idea and works fine. 8)

_________________
ImageImageImageImage Image


Top
 Profile  
Reply with quote  
 Post subject: Re: OpenWindowedScreen resizable
PostPosted: Wed May 08, 2019 11:59 am 
Offline
User
User

Joined: Thu Dec 13, 2018 9:58 pm
Posts: 13
Location: france
Without blocking the animation when resizing or moving
Code:
#MainWin = 0
#ScreenWin = 1
Global ScreenW = 2048
Global ScreenH = 2048

InitSprite()

Procedure UpdateScreen()
  ResizeGadget(0, #PB_Ignore, #PB_Ignore,  WindowWidth(#MainWin), WindowHeight(#MainWin))
EndProcedure

Procedure Scrolling()
  Static x
 
    DisplaySprite(101, x, 0)
    DisplaySprite(101, ScreenW + x, 0)
    x - 1
    If x <= 0 - ScreenW
      X = 0
    EndIf
    FlipBuffers()
 
EndProcedure

If OpenWindow(#MainWin, 0, 0, 400, 300, Str(ScreenW) + " x " + Str(ScreenH), #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_SizeGadget | #PB_Window_MaximizeGadget)
  AddWindowTimer(#MainWin,1,1)
  MDIGadget(0, 0, 0, WindowWidth(#MainWin), WindowHeight(#MainWin), 0, 0, #PB_MDI_BorderLess )

  OpenWindowedScreen(GadgetID(0), 0, 0, ScreenW, ScreenH,0,0,0,#PB_Screen_NoSynchronization)
 
  CreateSprite(101, ScreenW, ScreenH, #PB_Sprite_AlphaBlending)
  If StartDrawing(SpriteOutput(101) )
    For I = 1 To 1000
      x = Random(ScreenW)
      y = Random(ScreenH)
      r = 50 + Random(50)
      c = RGB(Random(255), Random(255), Random(255) )
      Circle(x, y, r, c)
      Circle(x - ScreenW, y, r, c)
      Circle(x + ScreenW, y, r, c)
    Next
    StopDrawing()
  EndIf
 
  x = 0
  DisplaySprite(101, x, 0)
  DisplaySprite(101, ScreenW + x, 0)
  FlipBuffers()
 
  BindEvent(#PB_Event_SizeWindow, @UpdateScreen())
  BindEvent(#PB_Event_Timer,@Scrolling())

  Repeat
  Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf

_________________
Sorry for my English. My language is French


Top
 Profile  
Reply with quote  
 Post subject: Re: OpenWindowedScreen resizable
PostPosted: Wed May 08, 2019 3:54 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun Sep 11, 2016 2:17 pm
Posts: 577
Interesting but the second example does is just black for me.


Top
 Profile  
Reply with quote  
 Post subject: Re: OpenWindowedScreen resizable
PostPosted: Wed May 08, 2019 4:57 pm 
Offline
User
User

Joined: Thu Dec 13, 2018 9:58 pm
Posts: 13
Location: france
can be a screen refresh problem
the same but with a thread
Code:
#MainWin = 0
#ScreenWin = 1
Global ScreenW = 2048
Global ScreenH = 2048
Global Thread
Global ThreadSemaphore = CreateSemaphore()

InitSprite()

Procedure UpdateScreen()
  WaitSemaphore(ThreadSemaphore)
  ResizeGadget(0, #PB_Ignore, #PB_Ignore,  WindowWidth(#MainWin), WindowHeight(#MainWin))
  SignalSemaphore(ThreadSemaphore)
EndProcedure

Procedure Scrolling(nul)
 
  Repeat
    WaitSemaphore(ThreadSemaphore)
    TrySemaphore(ThreadSemaphore)
    DisplaySprite(101, x, 0)
    DisplaySprite(101, ScreenW + x, 0)
    x - 1
    If x <= 0 - ScreenW
      X = 0
    EndIf
    FlipBuffers()
    SignalSemaphore(ThreadSemaphore)
    Delay(20)   ; 3
    ForEver

EndProcedure

If OpenWindow(#MainWin, 0, 0, 400, 300, Str(ScreenW) + " x " + Str(ScreenH), #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_SizeGadget | #PB_Window_MaximizeGadget)
 
  MDIGadget(0, 0, 0, WindowWidth(#MainWin), WindowHeight(#MainWin), 0, 0, #PB_MDI_BorderLess )

  OpenWindowedScreen(GadgetID(0), 0, 0, ScreenW, ScreenH)
 
  CreateSprite(101, ScreenW, ScreenH, #PB_Sprite_AlphaBlending)
  If StartDrawing(SpriteOutput(101) )
    For I = 1 To 1000
      x = Random(ScreenW)
      y = Random(ScreenH)
      r = 50 + Random(50)
      c = RGB(Random(255), Random(255), Random(255) )
      Circle(x, y, r, c)
      Circle(x - ScreenW, y, r, c)
      Circle(x + ScreenW, y, r, c)
    Next
    StopDrawing()
  EndIf
 
  x = 0
  DisplaySprite(101, x, 0)
  DisplaySprite(101, ScreenW + x, 0)
  FlipBuffers()
 
   BindEvent(#PB_Event_SizeWindow, @UpdateScreen())
   Thread = CreateThread(@Scrolling(),0)
   SignalSemaphore(ThreadSemaphore)

  Repeat
  Until WaitWindowEvent() = #PB_Event_CloseWindow
  KillThread(Thread) : FreeSemaphore(ThreadSemaphore)
EndIf

_________________
Sorry for my English. My language is French


Top
 Profile  
Reply with quote  
 Post subject: Re: OpenWindowedScreen resizable
PostPosted: Thu May 09, 2019 11:29 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun Sep 11, 2016 2:17 pm
Posts: 577
All examples work with PureBasic 5.71b with 5.62 only the first one works? :|


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: Majestic-12 [Bot] and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye