sfml
ウィンドウの基本
サーチ…
備考
sf::RectangleShape
やsf::Sprite
など、SFMLで提供される描画プリミティブを使用する場合は、 sf::Window
ではなくsf::RenderWindow
を使用する必要があります。
OpenGLウィンドウの作成
SFMLのWindowsは、次の2つのクラスのいずれかで表されます。
-
sf::Window
は、OpenGLのレンダリングコンテキストを含む、オペレーティングシステムによって提供される汎用ウィンドウです。 -
sf::RenderWindow
はsf::Window
特殊なバージョンで、sf::RenderTarget
としても機能し、SFMLのプリミティブをレンダリングすることができます。
どちらの場合も基本的な使い方は同じです。
#include <SFML/Window.hpp>
int main(int argc, char *argv) {
// Create and initialize a window object
sf::Window window(sf::VideoMode(640, 480), "My SFML Window");
// Repeat this as long as the window is open
while (window.isOpen()) {
// Handle window events ("event loop")
sf::Event event;
while (window.pollEvent(event)) {
switch(event.type) {
case sf::Event::Closed: // User tries to close the window
window.close(); // Actually close the window
break;
}
}
// Render logic would be placed here
// Swap buffers and update the window
window.display();
}
return 0;
}
Modified text is an extract of the original Stack Overflow Documentation
ライセンスを受けた CC BY-SA 3.0
所属していない Stack Overflow