【问题标题】:SFML 2.3 Window doesn't display anythingSFML 2.3 窗口不显示任何内容
【发布时间】:2015-06-24 16:45:01
【问题描述】:

我刚刚使用 sfml 网站上的官方教程设置了我的 SFML 2.3 项目。一切都运行,但窗口不显示那个绿色圆圈。下图清楚地描述了这个问题。窗口就是这样。

我使用了他们网站上 sfml 教程中的代码。它来自 Learn -> SFML 2.3 -> SFML with Visual Studio。 http://www.sfml-dev.org/tutorials/2.3/start-vc.php

#include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
    sf::CircleShape shape(100.f);
    shape.setFillColor(sf::Color::Green);

    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }

        window.clear();
        window.draw(shape);
        window.display();
    }

    return 0;
}

我尝试使用 SFML 2.1,效果很好。会是什么呢?我的显卡是 Intel GMA 3150,它支持最高 1.4 的 OpenGL。我的 buid 在 32 位 Windows 7 上运行。

【问题讨论】:

  • 我们可以看看你的代码吗?看起来您的事件处理/渲染循环不正确。
  • 我使用了他们网站上 sfml 教程中的代码。它来自 Learn -> SFML 2.3 -> SFML with Visual Studio。

标签: window render sfml


【解决方案1】:

SFML 2.3 增加了对 OpenGL 3 的支持。SFML 可能默认为 OpenGL 2 或 3。SFML Changelog 2.3

【讨论】:

  • 我当时的GPU不支持OGL 3.0或更高版本,所以一定是这样。 SFML 没有回退到受支持的版本,所以发生了奇怪的事情。我放弃了在那台机器上的工作并买了一台新的。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-12-24
  • 2022-07-31
  • 1970-01-01
  • 2020-05-22
  • 1970-01-01
  • 2021-03-01
相关资源
最近更新 更多