Metal with SwiftUI 1: Hello Triangle!

  Переглядів 18,493

GetIntoGameDev

GetIntoGameDev

2 роки тому

#gamedev #gamedevelopment #programming
code: github.com/amengede/getIntoMe...
playlist: • MacOS Metal
Discord: / discord
Patreon: patreon.com/user?u=58955910

КОМЕНТАРІ: 29
@tiIIus
@tiIIus Рік тому
I just wanted to say that this UKposts channel is completely underrated! Thank you for all those great videos!
@GetIntoGameDev
@GetIntoGameDev Рік тому
You're welcome!
@2etime
@2etime 11 місяців тому
Looks great man! I want to do a tutorial on swift ui development with metal too. Once you have the views setup, it is just metal dev really lol! Def subscribing! :)
@arkemal
@arkemal Рік тому
Excellent introduction to Metal. Thank you!
@richwickerman
@richwickerman Рік тому
Been looking for series like this
@EeroafHeurlin
@EeroafHeurlin Рік тому
Thank you for the excellent series, something that took me way too long to figure out however is: Don't put your shader structs in the bridging header, make a separate header ("shaderdata.h" or something) and import that in the bridging header and import the "shaderdata.h" in your .metal file. Because if you ever need to include anything else in the bridging header (say ) you will get *really* weird errors about incompatible architectures when the shaders are being compiled.
@GetIntoGameDev
@GetIntoGameDev Рік тому
Thankyou! I was not aware so I’m sure you’ve saved me a lot of future pain
@diegotrazzi
@diegotrazzi Рік тому
Beautiful triangle!
@willisplummer
@willisplummer 9 місяців тому
for anyone following along a year later, to get the teal background to compile I had to change the type signature of makeUIView to `func makeUIView(context: UIViewRepresentableContext) -> UIView` instead of MTLView
@samator1236
@samator1236 Рік тому
this is amazing thank you
@Ryan_Wiseman
@Ryan_Wiseman 3 місяці тому
Swift is like the C# of C. It works far better than you'd expect. This has been a lot more easier to work with than VulkanSDK via VSCode (which while it works perfectly with Xcode, I do like the project management aesthetic of VSCode). Curious, would you ever do videos on implementing Metal with game development? There is a lot on developing games with Swift, but less involving Metal and Swift (and the ones that exist I'm sure are a bit dated)
@FunFradd
@FunFradd 2 роки тому
Author, thanks you please make more videos about Metal
@GetIntoGameDev
@GetIntoGameDev 2 роки тому
It’s on my roster!
@lancehui6526
@lancehui6526 2 місяці тому
Thinks for your videos!
@dmitryskripkin7417
@dmitryskripkin7417 2 роки тому
Wait-wait, I'm sure there were more videos about Metal just a few days ago! About sphere and snowman, did you just deleted older videos? A relaunch? Great work, it's pretty hard to find tutorials about Metal. Especially with latest Swift and SwiftUI. Official Apple examples suck, Obj-C is not what I want to learn today. I'm not an gamedev guy, just some amateur newbie generative artist. Thanks for your work.
@GetIntoGameDev
@GetIntoGameDev 2 роки тому
Yes, you’re right, I’m redoing the series. Don’t worry, Metal is very much on my radar, I’m fascinated with it. Thanks! Yeah it’s really tough finding info on it. Especially, as you say, the modern swiftui approach. I’m glad you’re getting something out of the series!
@dmitryskripkin7417
@dmitryskripkin7417 2 роки тому
@@GetIntoGameDev somehow I'm not able to debug Metal with SwiftUI (with boilerplate from your videos). Basic Obj-C examples works fine. I'm digging deeper to find reason for that. If you have any ideas that would be a great help. P.S. Metal debugger is killer feature for me.
@dmitryskripkin7417
@dmitryskripkin7417 2 роки тому
However it works with MacOS target and NSView instead of UIView. Wasted hours on googling it with no success. Lucky me I tried replacing the view class. No idea why it work only this way.
@GetIntoGameDev
@GetIntoGameDev 2 роки тому
@@dmitryskripkin7417 Interesting, so it can build MacOS but not ios. Maybe installing command line tools for xcode would help with that? Can your installation of xcode build other ios apps?
@monfera
@monfera Рік тому
From 12:00 - why is it OK to call `metalDevice.makeCommandQueue()` in row 22? It's not inside the `if let`. So `metalDevice` may be nil. There's no ? or !, it's just a straight method call. Also, it's an `if let` rather than a `guard`, so it won't exit the scope if `metalDevice` is nil. Sorry for the noob question :-)
@GetIntoGameDev
@GetIntoGameDev Рік тому
Hi Robert, great questions! So this puzzled me a bit too when I first saw it, it would appear the makeCommandQueue is returning a regular object and there's not need to unwrap. I guess the Metal API has a lot of faith in itself in this one case. And as for the if-let stuff, yes a guard statement is technically better, I guess I'm just so used to reading error messages for my debugging...
@roygalaasen
@roygalaasen Рік тому
This is how they do it in the documentation: guard let device = MTLCreateSystemDefaultDevice() else { fatalError( "Failed to get the system's default Metal device." ) } So it can fail, and with a declaration of the variable with an exclamation mark, it will crash your app if it fails. Edit: so in this example it will crash either way, and perhaps the philosophy is that if this call fails, it is better to crash early, since it won’t run your application the way you want anyway?
@LamNguyen-zg1ft
@LamNguyen-zg1ft 10 місяців тому
great video, man. but if i want to custom .metal file on my own. Where I must start from?
@GetIntoGameDev
@GetIntoGameDev 10 місяців тому
Hi, I’m not quite sure what that means. By .metal file, do you mean shaders?
@LamNguyen-zg1ft
@LamNguyen-zg1ft 9 місяців тому
@@GetIntoGameDev yep, it's hard for me to understand Metal Shading Language.
@miguelsaldana5768
@miguelsaldana5768 Рік тому
why didn't you used UIKit? still is a MTKView hmmm amazing videos
@GetIntoGameDev
@GetIntoGameDev Рік тому
Thanks! I wanted to focus on SwiftUI as it's a newer framework and I haven't seen a lot of material around on SwiftUI x Metal.
@roger7341
@roger7341 Рік тому
This is ridiculous. Why doesn't Apple just provide plug-and-play modules that work right out of the box? It takes all that work just to get a single triangle on the screen? And you have to learn another programming language to boot? All I want is to animate a few simple objects and program in C++ if I have to. How about a program that reads in some .obj files and lets me write some code in C++ that will move those objects around on the screen?
@GetIntoGameDev
@GetIntoGameDev Рік тому
Yeah it’s pretty messed up but the support isn’t there right now. I don’t know, maybe they’re too busy changing the m1 to an m2 on their marketing material. I hope it improves in the near future.
MacOS Metal with SwiftUI 2: Transformations
44:49
GetIntoGameDev
Переглядів 4,5 тис.
ISSEI funny story😂😂😂Strange World | Magic Lips💋
00:36
ISSEI / いっせい
Переглядів 109 млн
🔥 Україна виходить у ФІНАЛ ЄВРОБАЧЕННЯ-2024! Реакція alyona alyona та Jerry Heil #eurovision2024
00:10
Євробачення Україна | Eurovision Ukraine official
Переглядів 321 тис.
OpenAI "SHOCKED" Everyone! Voice, Vision, & Free?!
8:58
Theoretically Media
Переглядів 12 тис.
Георгий Остроброд - Введение в Apple Metal
1:11:48
How My Desktop CNC Made Over $500,000 in 2 Years
11:34
Cutting It Close
Переглядів 1,6 млн
Beginning Metal - Getting Started
13:05
Kodeco
Переглядів 34 тис.
An introduction to Shader Art Coding
22:40
kishimisu
Переглядів 887 тис.
Giving Personality to Procedural Animations using Math
15:30
t3ssel8r
Переглядів 2,3 млн
Beginning Metal - Learning Metal for iOS from the Ground Up
6:44
Introducing Inferno: Metal shaders for SwiftUI
6:37
Paul Hudson
Переглядів 11 тис.
Samsung UE40D5520RU перезагружается, замена nand памяти
0:46
Слава 100пудово!
Переглядів 3,8 млн