It is currently Tue Jul 23, 2019 3:24 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: PB 5.70 LTS - AddWindowTimer() Program Freeze Up
PostPosted: Thu Jan 31, 2019 8:06 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun Jul 07, 2013 11:35 am
Posts: 400
Location: Canada
Hello everyone,

Apparently, using AddWindowTimer(0, 123, 16) to have the frame rate about 60 fps for an OpenGLGadget() is freezing up the program randomly.

Code:
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Project name : Program Freeze Up
; File Name : Program Freeze up Bug.pb
; File version: 1.0.0
; Programming : BUG DEMO
; Programmed by : StarBootics
; Date : 31-01-2019
; Last Update : 31-01-2019
; PureBasic code : V5.70 LTS x64
; Platform : Ubuntu 18.10 x64
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Bug description
;
; Randomly the program freeze up completely. Impossible to
; open the menu. The progress bar stop progressing. Etc
;
; It's still possible to close the program by clicking on
; the close button on the title bar.
;
; If we change the timer time from 16ms to 32ms or higher
; values the bug simply vanish.
;
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

Procedure GLSetup(Width.l, Height.l)
 
  glViewport_(0, 0, Width, Height)
 
  glFrontFace_(#GL_CCW)
  glCullFace_(#GL_BACK)
  glEnable_(#GL_DEPTH_TEST)
  glDepthFunc_(#GL_LESS)
  glEnable_(#GL_CULL_FACE)
  glEnable_(#GL_TEXTURE_2D)
 
  glHint_(#GL_PERSPECTIVE_CORRECTION_HINT, #GL_NICEST)
  glClearColor_(0.0, 0.0, 0.0, 1.0)
 
EndProcedure

Procedure RenderViewer(Gadget)
 
  SetGadgetAttribute(Gadget, #PB_OpenGL_SetContext, #True)
 
  ; clear framebuffer And depth-buffer
 
  glClear_(#GL_COLOR_BUFFER_BIT | #GL_DEPTH_BUFFER_BIT)
 
 
  glFinish_()
 
  SetGadgetAttribute(Gadget, #PB_OpenGL_FlipBuffers, #True)
 
EndProcedure

If OpenWindow(0, 0, 0, 800, 600, "Exemple Minuteur", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  If CreateMenu(0, WindowID(0))   
    MenuTitle("Projet")
    MenuItem(1, "Ouvrir"   +Chr(9)+"Ctrl+O")
    MenuItem(2, "Enregistrer"   +Chr(9)+"Ctrl+E")
    MenuItem(3, "Enregistrer sous"+Chr(9)+"Ctrl+R")
    MenuItem(4, "Fermer"  +Chr(9)+"Ctrl+F")
  EndIf
 
  OpenGLGadget(0, 5, 5, WindowWidth(0) - 10, WindowHeight(0) - 30 - MenuHeight(), #PB_OpenGL_8BitStencilBuffer|#PB_OpenGL_24BitDepthBuffer)
  GLSetup(GadgetWidth(0), GadgetHeight(0))
 
  ProgressBarGadget(1, 5, 540, 380, 20, 0, 100)
 
  ; Ajout du minuteur n°123 dans la fenêtre 0 qui se déclenchera toutes les 16 ms
 
  AddWindowTimer(0, 123, 16) ; about 60 fps
 
  Value = 0
  Repeat
    Event = WaitWindowEvent()
   
    If Event = #PB_Event_Timer And EventTimer() = 123
      RenderViewer(0)
      Value = (Value + 5) % 100
      SetGadgetState(1, Value)
    EndIf   
   
  Until Event = #PB_Event_CloseWindow
EndIf

; <<<<<<<<<<<<<<<<<<<<<<<
; <<<<< END OF FILE <<<<<
; <<<<<<<<<<<<<<<<<<<<<<<


Best regards
StarBootics

_________________
The Stone Age did not end due to a shortage of stones !


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

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


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