Android support, attempt-1 #8

Open
kornerr wants to merge 62 commits from and1 into master
pull from: and1
5 changed files with 89 additions and 9 deletions
Showing only changes of commit 9d6c2aeb27 - Show all commits

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) { override init(frame: CGRect) {
super.init(frame: frame) super.init(frame: frame)
contentScaleFactor = UIScreen.main.scale isOpaque = true
layer.contentsScale = contentScaleFactor isUserInteractionEnabled = false
} }
required init?(coder: NSCoder) { required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented") 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() { override func prepareOpenGL() {
super.prepareOpenGL() super.prepareOpenGL()
renderSet(F.didPrepareGL, true) renderSet(F.didPrepareMacGL, true)
} }
override func reshape() { override func reshape() {
+20 -6
View File
@@ -4,6 +4,12 @@ output:
ver-mac/src/dialect.swift: ver-mac/src/dialect.swift:
type: swift type: swift
BlueContext:
type: context
fields:
didLaunch: Bool
didSetup: Bool
BlueComponent: BlueComponent:
type: component type: component
shoulds: shoulds:
@@ -15,18 +21,14 @@ BlueComponent:
then: then:
c.didLaunch = true c.didLaunch = true
BlueContext:
type: context
fields:
didLaunch: Bool
didSetup: Bool
RenderContext: RenderContext:
type: context type: context
fields: fields:
backingPixelSize: [Int32] backingPixelSize: [Int32]
didLaunch: Bool didLaunch: Bool
didPrepareGL: Bool didPrepareGL: Bool
didPrepareIOSGL: Bool
didPrepareMacGL: Bool
didSetup: Bool didSetup: Bool
pixelSize: [Int32] pixelSize: [Int32]
reshapePixelSize: [Int32] reshapePixelSize: [Int32]
@@ -48,6 +50,18 @@ RenderComponent:
c.didLaunch == false c.didLaunch == false
then: then:
c.didLaunch = true 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: pixelSize:
1. Upon launch: 1. Upon launch:
if: if:
+44
View File
@@ -122,6 +122,8 @@ public struct F {
public static let backingPixelSize = "backingPixelSize" public static let backingPixelSize = "backingPixelSize"
public static let didLaunch = "didLaunch" public static let didLaunch = "didLaunch"
public static let didPrepareGL = "didPrepareGL" public static let didPrepareGL = "didPrepareGL"
public static let didPrepareIOSGL = "didPrepareIOSGL"
public static let didPrepareMacGL = "didPrepareMacGL"
public static let didSetup = "didSetup" public static let didSetup = "didSetup"
public static let pixelSize = "pixelSize" public static let pixelSize = "pixelSize"
public static let reshapePixelSize = "reshapePixelSize" public static let reshapePixelSize = "reshapePixelSize"
@@ -163,6 +165,8 @@ public struct RenderContext: DialectContext {
public var backingPixelSize = [Int32]() public var backingPixelSize = [Int32]()
public var didLaunch = Bool() public var didLaunch = Bool()
public var didPrepareGL = Bool() public var didPrepareGL = Bool()
public var didPrepareIOSGL = Bool()
public var didPrepareMacGL = Bool()
public var didSetup = Bool() public var didSetup = Bool()
public var pixelSize = [Int32]() public var pixelSize = [Int32]()
public var reshapePixelSize = [Int32]() public var reshapePixelSize = [Int32]()
@@ -180,6 +184,12 @@ public struct RenderContext: DialectContext {
else if (name == "didPrepareGL") { else if (name == "didPrepareGL") {
return didPrepareGL as! T return didPrepareGL as! T
} }
else if (name == "didPrepareIOSGL") {
return didPrepareIOSGL as! T
}
else if (name == "didPrepareMacGL") {
return didPrepareMacGL as! T
}
else if (name == "didSetup") { else if (name == "didSetup") {
return didSetup as! T return didSetup as! T
} }
@@ -209,6 +219,12 @@ public struct RenderContext: DialectContext {
else if (name == "didPrepareGL") { else if (name == "didPrepareGL") {
didPrepareGL = value as! Bool didPrepareGL = value as! Bool
} }
else if (name == "didPrepareIOSGL") {
didPrepareIOSGL = value as! Bool
}
else if (name == "didPrepareMacGL") {
didPrepareMacGL = value as! Bool
}
else if (name == "didSetup") { else if (name == "didSetup") {
didSetup = value as! Bool didSetup = value as! Bool
} }
@@ -275,6 +291,33 @@ func renderShouldResetDidLaunch(_ c: RenderContext) -> RenderContext {
return c 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 { func renderShouldResetPixelSize(_ c: RenderContext) -> RenderContext {
var c = c var c = c
@@ -322,6 +365,7 @@ func blueRegisterShoulds(_ ctrl: DialectController) {
func renderRegisterShoulds(_ ctrl: DialectController) { func renderRegisterShoulds(_ ctrl: DialectController) {
[ [
renderShouldResetDidLaunch, renderShouldResetDidLaunch,
renderShouldResetDidPrepareGL,
renderShouldResetPixelSize, renderShouldResetPixelSize,
].forEach { f in ].forEach { f in