I have a Render Window working that is used to test objects and text drawn to it. That Render Window is in a class called Engine, that handles all the initializations, program loop, render window events, and disposing.
My Sub Main() initializes an Engine instance, and runs the Engines loop. When I move or resize the Render Window the program freezes until I let the mouse go. So now I need to multi-thread the SFML's already multi-threaded render window. However, when putting the Engine's instance on a separate thread to initialize and run the program loop, I run into the same thing of freezing while I am moving or resizing the window. This make sense as pretty much nothing has changed, and only forwarded the issue to a new thread, yet I am not sure where to handle the freezing issue at so when I move or resize the screen the program keeps cycling.
I'm not sure how good a code example will work in this instance, but it is VB code so as close to pseudo code as possible...
Main Module:
Module Test
Public Enum State
Initializing
Running
Stopped
End Enum
Private m_Engine As Engine
Private EngineThread As Threading.Thread
Sub Main()
EngineThread = New Threading.Thread(AddressOf EngineStart)
EngineThread.Start()
End Sub
Private Sub EngineStart()
m_Engine = New Engine(True)
m_Engine.Initialize()
Do While m_Engine.EngineState = Engine.State.Running
m_Engine.Run()
Loop
m_Engine.DestroyEngine()
End Sub
End Module
Engine Class:
Public Sub New()
End Sub
Public Sub Initialize()
SetState()
ResetClock()
SetContextSettings()
CreateNewRenderWindow()
End Sub
Public Sub Run()
CalculateTime() ' process timing stuff
PrepareScreens() ' set view, dispatch events, clear
DrawStuffToScreens() ' entities, gui, text
PresentScreens() ' display
End Sub
The Render Window is already handling any window events, keyboard input, mouse actions, and joystick events by default, so I am not sure where, or how, to allow the program to continue to process while I am moving or resizing the window. Is this just a default of using the SFML RenderWindow?