Lesson%201%3A%20Hello%20Metal/2.%20Hello%20Triangle/ #4
Replies: 5 comments 6 replies
-
|
Great Tutorial so far, but... Maybe I forgot to import some Library or something, but "simd::float3" is marked as an undeclared identifier in triangleVertexBuffer = metalDevice->newBuffer(&triangleVertices, wich is in located in mtl_engine.mm in my case. Kind of stuck here... Regards, Roman |
Beta Was this translation helpful? Give feedback.
-
|
With regards to the objective-c code needed in MTLEngine, you can abstract them away so that MTLEngine and main can be .cpp instead of .mm First, replace @autoreleasepool in the run() function with NS::AutoReleasePool* pPool
Note that you can make this change in main.cpp as well Next, declare in MTLEngine.hpp
and add these lines in the init() function. Don't compile yet because there will still be errors.
Thirdly,
then go ahead and include
Note that you should still keep #include <GLFW/glfw3.h> in MTLEngine Lastly, this final step is based on what is found on stack overflow: https://stackoverflow.com/questions/76776751/how-to-use-metal-cpp-with-glfw I named my file GLFWBridge.h/.mm
Back in MTLEngine.mm Go ahead and add this
and this line in init() after layer->setDrawableSize(CGSizeMake(width, height));
After all these, you can go ahead and switch MTLEngine.mm to MTLEngine.cpp, as well as main.mm to main.cpp. |
Beta Was this translation helpful? Give feedback.
-
|
Shouldn't we have released vertex and fragment shader objects because they were created using function with the |
Beta Was this translation helpful? Give feedback.
-
|
you forgot to release vertexShader and fragmentShader? |
Beta Was this translation helpful? Give feedback.
-
|
For anyone who might be interested in pure C++ implementation of this tutorial: |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Lesson%201%3A%20Hello%20Metal/2.%20Hello%20Triangle/
https://metaltutorial.com/Lesson%201%3A%20Hello%20Metal/2.%20Hello%20Triangle/
Beta Was this translation helpful? Give feedback.
All reactions