Skip to content

Commit

Permalink
### 5.5.10
Browse files Browse the repository at this point in the history
- [OpenGL/WPF/ThreadedRenderControl] fixed resize
  • Loading branch information
aszabo314 committed Dec 5, 2024
1 parent 52c4848 commit 945bdfb
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 16 deletions.
3 changes: 3 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
### 5.5.10
- [OpenGL/WPF/ThreadedRenderControl] fixed resize

### 5.5.9
- [OpenGL/WPF] Threaded rendering control

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,31 +190,39 @@ type ThreadedRenderControl(runtime : Runtime, debug : IDebugConfig, samples : in
textures.Add tex

let renderPendingLock = obj()
let mutable renderPending = true
let mutable renderPending = false

let mutable disposed = false


let renderThread =
let handle = runtime.Context.CreateContext()

startThread <| fun () ->
try
let ctx = runtime.Context
use __ = ctx.RenderingLock handle


let mutable depth : option<Texture> = None
let mutable realColor : option<Texture> = None

GL.SetDefaultStates()
GL.BindFramebuffer(FramebufferTarget.Framebuffer, 0)
GL.Disable(EnableCap.Multisample)

let mutable ctxLock = None

while not disposed do
lock renderPendingLock (fun () ->
while not renderPending do
Monitor.Wait renderPendingLock |> ignore
renderPending <- false
)
match ctxLock with
| None ->
let handle = runtime.Context.CreateContext()
let h = ctx.RenderingLock handle
ctxLock <- Some h
GL.SetDefaultStates()
GL.BindFramebuffer(FramebufferTarget.Framebuffer, 0)
GL.Disable(EnableCap.Multisample)
| Some _ -> ()

match task with
| Some task ->
Expand Down Expand Up @@ -417,6 +425,7 @@ type ThreadedRenderControl(runtime : Runtime, debug : IDebugConfig, samples : in
ctx.Delete colorTex
GL.Check()
pushNewTexture fboSize
x.ForceRedraw()

x.SwapBuffers()

Expand All @@ -425,19 +434,20 @@ type ThreadedRenderControl(runtime : Runtime, debug : IDebugConfig, samples : in


override x.OnPaint(e) =
//Log.line "PAINT VER 3"
base.OnPaint(e)
if not loaded then
let screenSize = V2i(x.ClientSize.Width, x.ClientSize.Height)
let fboSize = V2i(max 1 (int (round (float screenSize.X * subsampling))), (int (round (float screenSize.Y * subsampling))))
if fboSize <> sizes.Value then
useTransaction transaction (fun () -> sizes.Value <- fboSize)
let screenSize = V2i(x.ClientSize.Width, x.ClientSize.Height)
let fboSize = V2i(max 1 (int (round (float screenSize.X * subsampling))), (int (round (float screenSize.Y * subsampling))))
if fboSize <> sizes.Value then
transact (fun () -> sizes.Value <- fboSize)

if not loaded then
pushNewTexture fboSize

lock presentTextures (fun () ->
while presentTextures.Count = 0 do
Monitor.Wait presentTextures |> ignore
)
x.ForceRedraw()
// lock presentTextures (fun () ->
// while presentTextures.Count = 0 do
// Monitor.Wait presentTextures |> ignore
// )


loaded <- true
Expand Down

0 comments on commit 945bdfb

Please sign in to comment.