我用的是M1 MacBook,如果这能改变什么的话。我也在使用SFML 2. 5. 1。下面是代码的样子:
// Include important libraries here
#include <SFML/Graphics.hpp>
// Make code easier to type with "using namespace"
using namespace sf;
// This is where our game starts from
int main()
{
// Create a video mode object
VideoMode vm(1920, 1080);
// Create and open a window for the game
RenderWindow window(vm, "Timber!!!", Style::Fullscreen);
while (window.isOpen())
{
// Handle the players input
if (Keyboard::isKeyPressed(Keyboard::Escape))
{
window.close();
}
// Update the scene
// Draw the scene
// Clear everything from the last scene
window.clear();
// Draw our game scene here
// Show everything we just drew
window.display();
}
return 0;
}
然而,当我运行这个时,没有窗口打开,我得到多个警告。现在我不知道这些警告是否与窗口没有打开有关,但我想我会包括那个细节。
我收到的警告如下:
/Users/charlescreighton/Desktop/stuff/xcode_projects/External Libraries/SFML/include/SFML/Window/Keyboard.hpp:161:41: Declaration is marked with '\deprecated' command but does not have a deprecation attribute
/Users/charlescreighton/Desktop/stuff/xcode_projects/Timber/Timber/main.cpp:9:10: in file included from /Users/charlescreighton/Desktop/stuff/xcode_projects/Timber/Timber/main.cpp:9:
/Users/charlescreighton/Desktop/stuff/xcode_projects/External Libraries/SFML/include/SFML/Graphics.hpp:32:10: in file included from /Users/charlescreighton/Desktop/stuff/xcode_projects/External Libraries/SFML/include/SFML/Graphics.hpp:32:
/Users/charlescreighton/Desktop/stuff/xcode_projects/External Libraries/SFML/include/SFML/Window.hpp:37:10: in file included from /Users/charlescreighton/Desktop/stuff/xcode_projects/External Libraries/SFML/include/SFML/Window.hpp:37:
/Users/charlescreighton/Desktop/stuff/xcode_projects/External Libraries/SFML/include/SFML/Window/Event.hpp:33:10: in file included from /Users/charlescreighton/Desktop/stuff/xcode_projects/External Libraries/SFML/include/SFML/Window/Event.hpp:33:
/Users/charlescreighton/Desktop/stuff/xcode_projects/External Libraries/SFML/include/SFML/Window/Event.hpp:105:10: Declaration is marked with '\deprecated' command but does not have a deprecation attribute
/Users/charlescreighton/Desktop/stuff/xcode_projects/Timber/Timber/main.cpp:9:10: in file included from /Users/charlescreighton/Desktop/stuff/xcode_projects/Timber/Timber/main.cpp:9:
/Users/charlescreighton/Desktop/stuff/xcode_projects/External Libraries/SFML/include/SFML/Graphics.hpp:32:10: in file included from /Users/charlescreighton/Desktop/stuff/xcode_projects/External Libraries/SFML/include/SFML/Graphics.hpp:32:
/Users/charlescreighton/Desktop/stuff/xcode_projects/External Libraries/SFML/include/SFML/Window.hpp:37:10: in file included from /Users/charlescreighton/Desktop/stuff/xcode_projects/External Libraries/SFML/include/SFML/Window.hpp:37:
/Users/charlescreighton/Desktop/stuff/xcode_projects/External Libraries/SFML/include/SFML/Graphics/PrimitiveType.hpp:52:43: Declaration is marked with '\deprecated' command but does not have a deprecation attribute
/Users/charlescreighton/Desktop/stuff/xcode_projects/Timber/Timber/main.cpp:9:10: in file included from /Users/charlescreighton/Desktop/stuff/xcode_projects/Timber/Timber/main.cpp:9:
/Users/charlescreighton/Desktop/stuff/xcode_projects/External Libraries/SFML/include/SFML/Graphics.hpp:34:10: in file included from /Users/charlescreighton/Desktop/stuff/xcode_projects/External Libraries/SFML/include/SFML/Graphics.hpp:34:
/Users/charlescreighton/Desktop/stuff/xcode_projects/External Libraries/SFML/include/SFML/Graphics/CircleShape.hpp:32:10: in file included from /Users/charlescreighton/Desktop/stuff/xcode_projects/External Libraries/SFML/include/SFML/Graphics/CircleShape.hpp:32:
/Users/charlescreighton/Desktop/stuff/xcode_projects/External Libraries/SFML/include/SFML/Graphics/Shape.hpp:34:10: in file included from /Users/charlescreighton/Desktop/stuff/xcode_projects/External Libraries/SFML/include/SFML/Graphics/Shape.hpp:34:
/Users/charlescreighton/Desktop/stuff/xcode_projects/External Libraries/SFML/include/SFML/Graphics/VertexArray.hpp:33:10: in file included from /Users/charlescreighton/Desktop/stuff/xcode_projects/External Libraries/SFML/include/SFML/Graphics/VertexArray.hpp:33:
如果这让人感到困惑,这里有一张警告的图片:
当我单击3个警告以查看它们出现的位置时,它显示如下:
第一个警告位置:
第二个警告位置:
第三个警告位置:
1条答案
按热度按时间iyr7buue1#
我假设这个问题与你如何管理你的窗口事件处理系统有关!你处理事件的方式是使用sf::键盘!而不是使用正确的方式与sf::事件!如果你不使用sf::事件来处理窗口事件,那么窗口将冻结在windows操作系统上。也许在mac上窗口将不会被创建!
创建窗口的正确方法是