Каждый раз, когда я пытаюсь создать окно, оно создает два окна непосредственно друг над другом и выдает следующую ошибку при их перемещении:
CLIENT ERROR: TUINSRemoteViewController does not override -viewServiceDidTerminateWithError: and thus cannot react to catastrophic errors beyond logging them
Вот как выглядит мой код:
mtl_engine.mm
#include "mtl_engine.hpp"
void MTLEngine::init() {
initDevice();
initWindow();
}
void MTLEngine::run() {
while (!glfwWindowShouldClose(glfwWindow)) {
glfwPollEvents();
}
}
void MTLEngine::cleanup() {
glfwTerminate();
metalDevice->release();
}
void MTLEngine::initDevice() {
metalDevice = MTL::CreateSystemDefaultDevice();
}
void MTLEngine::initWindow() {
glfwInit();
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
glfwWindow = glfwCreateWindow(800, 600, "Metal Engine", NULL, NULL);
if (!glfwWindow) {
glfwTerminate();
exit(EXIT_FAILURE);
}
metalWindow = glfwGetCocoaWindow(glfwWindow);
metalLayer = [CAMetalLayer layer];
metalLayer.device = (__bridge id)metalDevice;
metalLayer.pixelFormat = MTLPixelFormatBGRA8Unorm;
metalWindow.contentView.layer = metalLayer;
metalWindow.contentView.wantsLayer = YES;
}
mtl_engine.hpp
#pragma once
#define GLFW_INCLUDE_NONE
#import
#define GLFW_EXPOSE_NATIVE_COCOA
#import
#include
#include
#include
#include
#include
class MTLEngine {
public:
void init();
void run();
void cleanup();
private:
void initDevice();
void initWindow();
MTL::Device* metalDevice;
GLFWwindow* glfwWindow;
NSWindow* metalWindow;
CAMetalLayer* metalLayer;
};
main.mm
#include "mtl_engine.hpp"
int main() {
MTLEngine engine;
engine.init();
engine.run();
engine.cleanup();
return 0;
}
mtl_implementation.cpp
#define NS_PRIVATE_IMPLEMENTATION
#define CA_PRIVATE_IMPLEMENTATION
#define MTL_PRIVATE_IMPLEMENTATION
#include
#include
#include
Подробнее здесь: https://stackoverflow.com/questions/790 ... wo-windows
При создании окна с помощью GLFW и Metal в macOS создается два окна? ⇐ C++
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение