It is currently Thu Oct 22, 2020 7:18 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: [Done] SetFrameRate() causes stutter
PostPosted: Sun Jun 10, 2012 7:34 am 
Offline
Addict
Addict
User avatar

Joined: Sun Apr 27, 2003 8:12 am
Posts: 2075
Location: USA
In the following code, the box will stutter, from time to time, while scrolling. If you remove "SetFrameRate()", it scrolls smoothly.

Code:
InitSprite()

OpenWindow(0, 0, 0,1280, 720, "Scroll", #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_MinimizeGadget)
OpenWindowedScreen(WindowID(0), 0, 0, 1280, 720, 0, 0, 0)

  CreateSprite(1, 128, 128)
   StartDrawing(SpriteOutput(1))
    DrawingMode(#PB_2DDrawing_Default)
     Box(0, 0, 128, 128, RGB(0, 0, 220))
   StopDrawing()
   
X = 0   
   
Repeat
 
  Event = WindowEvent()
 
  FlipBuffers()
  ClearScreen(RGB(235, 235, 235))
  SetFrameRate(60)
 
  DisplaySprite(1, X, 360 - 64)
 
  X + 4
 
  If X = 1280
     X = 0 -128
  EndIf
 
Until Event = #PB_Event_CloseWindow

_________________
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef

Mac: 10.13.6 / 1.4GHz Core 2 Duo / 2GB DDR3 / Nvidia 320M
PC: Win 7 / AMD 64 4000+ / 3GB DDR / Nvidia 720GT


Even the vine knows it surroundings but the man with eyes does not.


Top
 Profile  
Reply with quote  
 Post subject: Re: SetFrameRate() causes stutter
PostPosted: Sun Jun 10, 2012 7:59 am 
Offline
Enthusiast
Enthusiast

Joined: Mon Feb 16, 2009 10:42 am
Posts: 536
Location: sweden
Confirmed.
Have a look in activity monitor on windows manager (goes up to 50% for me, if I click the titlebar everything will freeze until i release and after this it will run extremely well for a short while. also - the windows manager goes down in cpu while holding the window title bar).
Here is a fullscreen example, same behavour:
Code:
InitSprite()

OpenScreen(1366,768,16,"")
CreateSprite(1, 128, 128)
StartDrawing(SpriteOutput(1))
DrawingMode(#PB_2DDrawing_Default)
Box(0, 0, 128, 128, RGB(0, 0, 220))
StopDrawing()

X = 0   
InitKeyboard()
Repeat
 
  FlipBuffers()
  ClearScreen(RGB(235, 235, 235))
  SetFrameRate(60)
 
  DisplaySprite(1, X, 360 - 64)
 
  X + 4
 
  If X = 1280
    X = 0 -128
  EndIf
  ExamineKeyboard()
Until KeyboardInkey()


Top
 Profile  
Reply with quote  
 Post subject: Re: SetFrameRate() causes stutter
PostPosted: Sun Jun 10, 2012 8:27 am 
Offline
Addict
Addict
User avatar

Joined: Sun Apr 27, 2003 8:12 am
Posts: 2075
Location: USA
I tried to create a timer but it gives the same effect. The timers return is not always about the same value. I'm sure this is what is causing this effect. It looks like it may be best to create games in full screen and set the refresh rate.

Code:
InitSprite()

OpenWindow(0, 0, 0,1280, 720, "Scroll", #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_MinimizeGadget)
OpenWindowedScreen(WindowID(0), 0, 0, 1280, 720, 0, 0, 0)

  CreateSprite(1, 128, 128)
   StartDrawing(SpriteOutput(1))
    DrawingMode(#PB_2DDrawing_Default)
     Box(0, 0, 128, 128, RGB(0, 0, 220))
   StopDrawing()
   
   X = 0
   StartTime = ElapsedMilliseconds()
   
Repeat
 
  Event = WindowEvent()
 
  FlipBuffers()
  ClearScreen(RGB(235, 235, 235))
 
  ElapsedTime = ElapsedMilliseconds() - StartTime
 
  If ElapsedTime >= 16
     StartTime = ElapsedMilliseconds()
     X + 4
  EndIf
 
  If X = 1280
     X = 0 -128
  EndIf
 
  DisplaySprite(1, X, 360 - 64)
 
Until Event = #PB_Event_CloseWindow

_________________
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef

Mac: 10.13.6 / 1.4GHz Core 2 Duo / 2GB DDR3 / Nvidia 320M
PC: Win 7 / AMD 64 4000+ / 3GB DDR / Nvidia 720GT


Even the vine knows it surroundings but the man with eyes does not.


Top
 Profile  
Reply with quote  
 Post subject: Re: SetFrameRate() causes stutter
PostPosted: Wed Nov 14, 2012 4:23 pm 
Offline
Addict
Addict
User avatar

Joined: Tue Dec 23, 2003 3:54 am
Posts: 1851
Thanks for posting this. I thought I was imagining it...

I haven't found a good way to eliminate the stutter yet - fullscreen or windowed, regardless of SetFrameRate().

_________________
On GitHub: PB Includes - IDE Tools - Color Themes - IDE Branches - TabBarGadget Mods


Top
 Profile  
Reply with quote  
 Post subject: Re: SetFrameRate() causes stutter
PostPosted: Fri Feb 21, 2020 11:26 am 
Offline
Administrator
Administrator

Joined: Fri May 17, 2002 4:39 pm
Posts: 14116
Location: France
Fixed.


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

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 3 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