c++ - 在 C++ 上使用 Cocoa 创建一个简单的 OpenGL 应用程序
问题描述
我正在学习https://riptutorial.com/opengl/example/13875/creating-opengl-4-1-with-cplusplus-and-cocoa上的教程,但该项目无法构建。我可能猜想 XCode 混合了我的 Cpp 和 Obj-C 文件。在 Application.hpp 中,它建议用 Obj-C“类”替换“类”并添加分号,而在 MacApp.h 中它找不到要包含的内存。
我已经为此苦苦挣扎了一段时间,但找不到解决方案。
应用程序.hpp
#include <OpenGL/gl3.h>
class Application { // Suggests "Class" and a semicolon
private:
GLuint program;
GLuint vao;
public:
Application();
void update();
~Application();
};
MacApp.h
#import <Cocoa/Cocoa.h>
#import "Application.hpp"
#import <memory> // Error here
NSApplication* application;
@interface MacApp : NSWindow <NSApplicationDelegate>{
std::shared_ptr<Application> appInstance;
}
@property (nonatomic, retain) NSOpenGLView* glView;
-(void) drawLoop:(NSTimer*) timer;
@end
UPD:将 Cpp 标准库从 libstdc++ 更改为 libc++(LLVM...) 并将应用程序指针移动到 main.m 文件中解决了问题
解决方案
推荐阅读
- regex - 如何使用正则表达式查找具有特定起始字符串的所有匹配项?
- c - 在适当的位置添加一个节点(列表将按升序排列)
- typescript - 酶打字稿 - 无法设置在 Function.assign 中只有一个 getter 的 [object Event] 的属性目标
- javascript - 如何使用 JSDocs 描述具有默认值的可选对象参数
- types - Sagemath:为什么不等式没有转换为布尔值?
- python - CITE-Seq-Count 修剪 Fastq 文件/运行逗号分隔列表
- mobx-state-tree - 如何将自动运行与流操作一起使用?
- mysql - MySQL按彼此相隔X天的日期分组
- java - 我应该写下什么来避免 stackoverflow 错误?
- bash - 配置cowsay以在ansible中为每个主机输出不同颜色的方法?