Hi I am trying to get started using Metal CPP after viewing the documentation and defining the constants below:
#ifndef MTL_PRIVATE_IMPLEMENTATION
#define NS_PRIVATE_IMPLEMENTATION
#define MTL_PRIVATE_IMPLEMENTATION
//#define MTK_PRIVATE_IMPLEMENTATION
#define CA_PRIVATE_IMPLEMENTATION
#endif
I commented out the MTK macro since it was not in the getting started video although it was in the fundamentals projects for metal cpp. I am defining this in a Objective C++ header along with including:
#import <Foundation/Foundation.hpp>
#import <Metal/Metal.hpp>
#import <QuartzCore/QuartzCore.hpp>
#import <MetalKit/MetalKit.h>
#import <simd/simd.h>
I get the error:
redeclaration of 'NSPOSIXErrorDomain' with a different type: 'const NSErrorDomain _Nonnull __strong' (aka 'NSString *const __strong') vs 'const NS::ErrorDomain' (aka 'NS::String *const')
along with other errors similar to that one. These errors all seem to do with <Foundation/Foundation.h>. I can see that the NS prefix is being declared rather than the C++ version of NS:: but I am sure I implemented this correctly. I have a header set up in Objective C for this file along with things being @implementation rather than pure C++:
#pragma once
#include "../../../src/state/config.h"
#ifdef __PEN_IOS__
//#import <cassert>
#ifndef MTL_PRIVATE_IMPLEMENTATION
#define NS_PRIVATE_IMPLEMENTATION
#define MTL_PRIVATE_IMPLEMENTATION
//#define MTK_PRIVATE_IMPLEMENTATION
#define CA_PRIVATE_IMPLEMENTATION
#endif
#ifdef TARGET_IPHONE_SIMULATOR
//#import <UIKit/UIKit.h>
#elifdef TARGET_OS_IPHONE
//#import <UIKit/UIKit.hpp>
#elifdef TARGET_OS_IOS
//#import <UIKit/UIKit.hpp>
#elifdef TARGET_OS_MAC
//#import <AppKit/AppKit.hpp>
#endif
#import <Foundation/Foundation.hpp>
#import <Metal/Metal.hpp>
//#import <CoreFoundation/CoreFoundation.h>
#import <QuartzCore/QuartzCore.hpp>
#import <MetalKit/MetalKit.h>
#import <simd/simd.h>
#import "ios_cpp_objective_c_mapping.h"
@class IOSState;
@interface IOSState : NSObject
@property MTK::View* iosMtkView;
@property MTL::Device* iosDevice;
@property MTL::CommandQueue* iosCommandQueue;
@property MTL::RenderPipelineState* iosPipelineState;
@property NS::Notification* iosLaunchNotification;
@property MTL::ArgumentEncoder* iosArgEncoder;
@property MTL::DepthStencilState* iosDepthStencilState;
@property MTL::Texture* iosPixelBuffer;
@property MTL::Buffer* iosUniformBuffer;
@property MTL::Buffer* iosInstanceBuffer;
@property MTL::RenderCommandEncoder* iosCommandEncoder;
@property MTL::CommandBuffer* iosCommandBuffer;
@property NS::AutoreleasePool* iosAutoReleasePool;
@property dispatch_semaphore_t dispatchSemaphore;
+ (IOSState*) Get;
+ (void) Destroy;
@end
#endif
I include this file in multiple places although the headers should be able to be included more than once.