This commit is contained in:
Михаил Капелько committed 2026-10-28 16:46:36 +03:00
1 parent 36392764f7
commit 9d6c2aeb27
5 files changed
+89 -9

No files matched your search

+11
View File
@@ -0,0 +1,11 @@
import Foundation
func renderInit(_ vm: RenderVM) {
vm.glView.openGLContext?.makeCurrentContext()
// Enable VSync
var swapInterval: Int32 = 1
vm.glView.openGLContext?.setValues(&swapInterval, for: .swapInterval)
raybriInit(nil)
}
+13 -2
View File
@@ -4,11 +4,22 @@ final class RenderGLView: UIView {
override init(frame: CGRect) {
super.init(frame: frame)
contentScaleFactor = UIScreen.main.scale
layer.contentsScale = contentScaleFactor
isOpaque = true
isUserInteractionEnabled = false
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func didMoveToWindow() {
super.didMoveToWindow()
guard let window else { return }
renderSet(F.didPrepareIOSGL, true);
}
override func layoutSubviews() {
super.layoutSubviews()
}
}
@@ -17,7 +17,7 @@ final class RenderGLView: NSOpenGLView {
override func prepareOpenGL() {
super.prepareOpenGL()
renderSet(F.didPrepareGL, true)
renderSet(F.didPrepareMacGL, true)
}
override func reshape() {
+20 -6
View File
@@ -4,6 +4,12 @@ output:
ver-mac/src/dialect.swift:
type: swift
BlueContext:
type: context
fields:
didLaunch: Bool
didSetup: Bool
BlueComponent:
type: component
shoulds:
@@ -15,18 +21,14 @@ BlueComponent:
then:
c.didLaunch = true
BlueContext:
type: context
fields:
didLaunch: Bool
didSetup: Bool
RenderContext:
type: context
fields:
backingPixelSize: [Int32]
didLaunch: Bool
didPrepareGL: Bool
didPrepareIOSGL: Bool
didPrepareMacGL: Bool
didSetup: Bool
pixelSize: [Int32]
reshapePixelSize: [Int32]
@@ -48,6 +50,18 @@ RenderComponent:
c.didLaunch == false
then:
c.didLaunch = true
didPrepareGL:
1. For macOS:
if:
c.recentField == F.didPrepareMacGL
then:
c.didPrepareGL = true
2. For iOS:
if:
c.recentField == F.didPrepareIOSGL &&
!c.didPrepareGL
then:
c.didPrepareGL = true
pixelSize:
1. Upon launch:
if:
+44
View File
@@ -122,6 +122,8 @@ public struct F {
public static let backingPixelSize = "backingPixelSize"
public static let didLaunch = "didLaunch"
public static let didPrepareGL = "didPrepareGL"
public static let didPrepareIOSGL = "didPrepareIOSGL"
public static let didPrepareMacGL = "didPrepareMacGL"
public static let didSetup = "didSetup"
public static let pixelSize = "pixelSize"
public static let reshapePixelSize = "reshapePixelSize"
@@ -163,6 +165,8 @@ public struct RenderContext: DialectContext {
public var backingPixelSize = [Int32]()
public var didLaunch = Bool()
public var didPrepareGL = Bool()
public var didPrepareIOSGL = Bool()
public var didPrepareMacGL = Bool()
public var didSetup = Bool()
public var pixelSize = [Int32]()
public var reshapePixelSize = [Int32]()
@@ -180,6 +184,12 @@ public struct RenderContext: DialectContext {
else if (name == "didPrepareGL") {
return didPrepareGL as! T
}
else if (name == "didPrepareIOSGL") {
return didPrepareIOSGL as! T
}
else if (name == "didPrepareMacGL") {
return didPrepareMacGL as! T
}
else if (name == "didSetup") {
return didSetup as! T
}
@@ -209,6 +219,12 @@ public struct RenderContext: DialectContext {
else if (name == "didPrepareGL") {
didPrepareGL = value as! Bool
}
else if (name == "didPrepareIOSGL") {
didPrepareIOSGL = value as! Bool
}
else if (name == "didPrepareMacGL") {
didPrepareMacGL = value as! Bool
}
else if (name == "didSetup") {
didSetup = value as! Bool
}
@@ -275,6 +291,33 @@ func renderShouldResetDidLaunch(_ c: RenderContext) -> RenderContext {
return c
}
func renderShouldResetDidPrepareGL(_ c: RenderContext) -> RenderContext {
var c = c
/* 1. For macOS */
if
c.recentField == F.didPrepareMacGL
{
c.didPrepareGL = true
c.recentField = F.didPrepareGL
return c
}
/* 2. For iOS */
if
c.recentField == F.didPrepareIOSGL &&
!c.didPrepareGL
{
c.didPrepareGL = true
c.recentField = F.didPrepareGL
return c
}
c.recentField = DIALECT_CONTEXT_RECENT_FIELD_NONE
return c
}
func renderShouldResetPixelSize(_ c: RenderContext) -> RenderContext {
var c = c
@@ -322,6 +365,7 @@ func blueRegisterShoulds(_ ctrl: DialectController) {
func renderRegisterShoulds(_ ctrl: DialectController) {
[
renderShouldResetDidLaunch,
renderShouldResetDidPrepareGL,
renderShouldResetPixelSize,
].forEach { f in