only update pixel size during rendering

This commit is contained in:
Михаил Капелько committed 2026-10-19 16:34:19 +03:00
1 parent 8c774edbea
commit 24348ba6ad
1 file changed
+5 -8
@@ -33,7 +33,6 @@ final class RenderGLView: NSOpenGLView {
var swapInterval: Int32 = 1
context.setValues(&swapInterval, for: .swapInterval)
updatePixelSize()
sr_init(pixelWidth, pixelHeight,
RENDER_SHADER_MAIN_VS, RENDER_SHADER_MAIN_FS,
RENDER_SHADER_SHADOW_VS, RENDER_SHADER_SHADOW_FS,
@@ -89,17 +88,15 @@ final class RenderGLView: NSOpenGLView {
needsDisplay = true
}
private func updatePixelSize() {
let backing = convertToBacking(bounds)
pixelWidth = Int32(max(1, backing.width))
pixelHeight = Int32(max(1, backing.height))
}
override func draw(_ dirtyRect: NSRect) {
guard ready, let context = openGLContext else { return }
context.makeCurrentContext()
updatePixelSize()
// Update pixel size
let backing = convertToBacking(bounds)
pixelWidth = Int32(max(1, backing.width))
pixelHeight = Int32(max(1, backing.height))
sr_resize(pixelWidth, pixelHeight)