c++ - SFML 在 xcode 中打开图像文件?
问题描述
我试图在 xCode 中将 .gif 文件加载到 SFML 中的纹理中,但我不知道如何打开它。
float radius = 2.50e+11;
CelestialBody sun(0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 1.9890e+30, "sun.gif", radius);
sf::RenderWindow window(sf::VideoMode((radius/600000000.0)*2,(radius/600000000.0)*2), "test");
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
window.clear();
sun.draw(window,sf::RenderStates::Default);
window.display();
}
return 0;
}
当我运行此代码时,它构建得很好,并且显示了一个窗口,但是其中没有图像,当我查看控制台时,我有一个错误提示“无法加载图像”sun.gif“。原因:无法打开文件”
该文件与我的 .cpp 和 .hpp 文件位于同一文件夹中,我认为它会在那里查找图像,但现在我不确定将图像放在哪里以便 xcode 能够找到它。
解决方案
推荐阅读
- php - Laravel 会话在页面刷新时被破坏
- c# - Chrome 开发工具协议 - Chrome 在 30 秒不活动后终止 websocket
- java - Java 流中的 null 和 NullPointerexception
- ruby - 如何通过参数
- android - ADB 命令打开 Chrome 设置
- jquery - 将共享点左侧导航中的文本设为超链接
- mysql - 如何在 MySQL 中使用完全联接?
- highcharts - 您可以在旭日形图中显示/隐藏系列吗?
- angular - 如何在Angular 7中使用Typescript获取具有空构造函数的类的属性
- css - 造型 PrimeNG p-tabView