This commit is contained in:
Михаил Капелько committed 2026-10-19 06:35:18 +03:00
1 parent 0010ef00a6
commit fbea0673c1
7 files changed
+26 -22

No files matched your search

@@ -1,23 +1,9 @@
import SwiftUI
import AppKit
import QuartzCore
import RaylibBridge
import SwiftUI
/// A raylib-driven 3D scene (rendered through rlgl into an NSOpenGLView) that
/// sits behind the SwiftUI interface.
struct RaylibGLView: NSViewRepresentable {
func makeNSView(context: Context) -> RaylibGLNSView {
RaylibGLNSView(frame: .zero)
}
func updateNSView(_ nsView: RaylibGLNSView, context: Context) {}
}
/// An OpenGL view whose context is rendered directly by raylib's rlgl layer,
/// without letting raylib create its own window. Mirrors the reference sample
/// (`swiftraylib`), but drives a single cube that is rotated by the application
/// every frame.
final class RaylibGLNSView: NSOpenGLView {
final class RenderGLView: NSOpenGLView {
private var renderTimer: Timer?
private var ready = false
private var pixelWidth: Int32 = 1
@@ -0,0 +1,13 @@
import AppKit
import QuartzCore
import RaylibBridge
import SwiftUI
/// Render view for SwiftUI
struct RenderView: NSViewRepresentable {
func makeNSView(context: Context) -> RenderGLView {
RenderGLView(frame: .zero)
}
func updateNSView(_ nsView: RenderGLView, context: Context) {}
}
+1 -1
View File
@@ -9,7 +9,7 @@ struct RootView: View {
var body: some View {
ZStack {
RaylibGLView()
RenderView()
.ignoresSafeArea()
VStack(spacing: 16) {