Я пытаюсь создать подкласс из UTexture2D
, чтобы он работал с CVPixelBufferRef
от Apple. Я использую AppleARKitTextures.h
в качестве примера и просто заменил UTexture
на UTexture2D
.
Когда я пытаюсь скомпилировать мой модуль, я получаю эту ошибку:
CompilerResultsLog: [3/6] Compile Module.MyCameraModule.gen.cpp
CompilerResultsLog: [1/6] Compile MyCameraModule.cpp
CompilerResultsLog: [2/6] Compile Module.MyCameraModule.cpp
CompilerResultsLog: [4/6] Link UE4Editor-MyCameraModule-0031.dylib
CompilerResultsLog: Undefined symbols for architecture x86_64:
CompilerResultsLog: "UTexture2D::PreSave(ITargetPlatform const*)", referenced from:
CompilerResultsLog: vtable for UAppleCameraTexture in Module.MyCameraModule.cpp.o
CompilerResultsLog: "UTexture2D::PostLoad()", referenced from:
CompilerResultsLog: vtable for UAppleCameraTexture in Module.MyCameraModule.cpp.o
...
CompilerResultsLog: "UTexture2D::CalcTextureMemorySizeEnum(ETextureMipCount) const", referenced from:
CompilerResultsLog: vtable for UAppleCameraTexture in Module.MyCameraModule.cpp.o
CompilerResultsLog: "UTexture2D::Serialize(FArchive&)", referenced from:
CompilerResultsLog: vtable for UAppleCameraTexture in Module.MyCameraModule.cpp.o
CompilerResultsLog: "vtable for UTexture2D", referenced from:
CompilerResultsLog: UAppleCameraTexture::UAppleCameraTexture(FObjectInitializer const&) in Module.MyCameraModule.cpp.o
CompilerResultsLog: UAppleCameraTexture::~UAppleCameraTexture() in Module.MyCameraModule.cpp.o
CompilerResultsLog: UAppleCameraTexture::UAppleCameraTexture(FVTableHelper&) in Module.MyCameraModule.gen.cpp.o
CompilerResultsLog: NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
CompilerResultsLog: "FRenderAssetUpdate::Release() const", referenced from:
CompilerResultsLog: UAppleCameraTexture::UAppleCameraTexture(FObjectInitializer const&) in Module.MyCameraModule.cpp.o
CompilerResultsLog: UAppleCameraTexture::~UAppleCameraTexture() in Module.MyCameraModule.cpp.o
CompilerResultsLog: UAppleCameraTexture::UAppleCameraTexture(FVTableHelper&) in Module.MyCameraModule.gen.cpp.o
CompilerResultsLog: ld: symbol(s) not found for architecture x86_64
CompilerResultsLog: clang: error: linker command failed with exit code 1 (use -v to see invocation)
С UTexture
он компилируется нормально. Мне нужно использовать UTexture2D
, потому что я планирую использовать эту текстуру в пользовательском интерфейсе.
Исходный код:
UCLASS( MinimalAPI, BlueprintType )
class UAppleCameraTexture : public UTexture2D, public IAppleImageInterface
{
GENERATED_UCLASS_BODY()
public:
// UTexture interface implementation
virtual void BeginDestroy() override;
virtual FTextureResource* CreateResource() override;
virtual EMaterialValueType GetMaterialType() const override { return MCT_Texture2D; }
virtual float GetSurfaceWidth() const override { return Size.X; }
virtual float GetSurfaceHeight() const override { return Size.Y; }
// End UTexture interface
#if PLATFORM_MAC || PLATFORM_IOS
/** Sets any initialization data */
virtual void Init(float InTimestamp, CVPixelBufferRef InCameraImage);
/** Queues the conversion on the render thread */
virtual void Init_RenderThread();
/** Store off the camera image for a later resource update */
void EnqueueNewCameraImage(CVPixelBufferRef InCameraImage);
#endif
virtual EAppleTextureType GetTextureType() const override { return EAppleTextureType::PixelBuffer; }
#if PLATFORM_MAC || PLATFORM_IOS
/** Returns the cached camera image. You must retain this if you hold onto it */
CVPixelBufferRef GetCameraImage() const { return CameraImage; }
// IAppleImageInterface interface implementation
virtual CVPixelBufferRef GetPixelBuffer() const override { return CameraImage; }
// End IAppleImageInterface interface
#endif
private:
float Timestamp;
FGuid ExternalTextureGuid;
FVector2D Size;
#if PLATFORM_MAC || PLATFORM_IOS
/** The Apple specific representation of the ar camera image */
CVPixelBufferRef CameraImage;
CVPixelBufferRef NewCameraImage;
FCriticalSection PendingImageLock;
#endif
};