This commit is contained in:
Михаил Капелько committed 2026-10-19 17:08:35 +03:00
1 parent 0da8bfcfa2
commit 30476a880d
5 files changed
+69 -25

No files matched your search

@@ -6,8 +6,8 @@ import SwiftUI
final class RenderGLView: NSOpenGLView {
private var renderTimer: Timer?
private var ready = false
private var pixelWidth: Int32 = 1
private var pixelHeight: Int32 = 1
//private var pixelWidth: Int32 = 1
//private var pixelHeight: Int32 = 1
private var startTime: CFTimeInterval = 0
override init(frame frameRect: NSRect) {
@@ -33,9 +33,7 @@ final class RenderGLView: NSOpenGLView {
var swapInterval: Int32 = 1
context.setValues(&swapInterval, for: .swapInterval)
otherPrintStderr("RenderGLView prepareOpenGL bounds \(bounds) backing \(convertToBacking(bounds))")
sr_init(pixelWidth, pixelHeight,
sr_init(1, 1,
RENDER_SHADER_MAIN_VS, RENDER_SHADER_MAIN_FS,
RENDER_SHADER_SHADOW_VS, RENDER_SHADER_SHADOW_FS,
RENDER_CONFIG)
@@ -84,12 +82,14 @@ final class RenderGLView: NSOpenGLView {
super.reshape()
otherPrintStderr("RenderGLView reshape bounds \(bounds) backing \(convertToBacking(bounds))")
needsDisplay = true
renderSet(F.didReshape, true)
}
override func viewDidChangeBackingProperties() {
super.viewDidChangeBackingProperties()
otherPrintStderr("RenderGLView viewDidChangeBackingProperties bounds \(bounds) backing \(convertToBacking(bounds))")
needsDisplay = true
renderSet(F.didChangeBacking, true)
}
override func draw(_ dirtyRect: NSRect) {
@@ -98,12 +98,14 @@ final class RenderGLView: NSOpenGLView {
context.makeCurrentContext()
// Update pixel size
let pixelSize = renderPixelSize(self)
/*
let backing = convertToBacking(bounds)
otherPrintStderr("RenderGLView draw bounds \(bounds) backing \(backing)")
pixelWidth = Int32(max(1, backing.width))
pixelHeight = Int32(max(1, backing.height))
*/
sr_resize(pixelWidth, pixelHeight)
sr_resize(pixelSize[0], pixelSize[1])
let t = Float(CACurrentMediaTime() - startTime)
+8
View File
@@ -0,0 +1,8 @@
import AppKit
func renderPixelSize(_ view: NSView) -> [Int32] {
let backing = view.convertToBacking(view.bounds)
let w = Int32(max(1, backing.width))
let h = Int32(max(1, backing.height))
return [w, h]
}