by Anonymous » 01 Mar 2025, 14:23
Ich versuche mit der SFML -Bibliothek auf Ubuntu zusammenzuarbeiten und ich habe mit dem Tutorial begonnen. Aber ich stieß ein paar Probleme. Ich dachte, ich habe keine SFML -Dateien aufgenommen, aber ich habe es getan. Jetzt gegen Code schreiben: < /p>
Code: Select all
main.cpp: In function ‘int main()’:
main.cpp:12:60: error: no matching function for call to ‘sf::RenderWindow::pollEvent()’
12 | while (const std::optional event = window.pollEvent())
| ~~~~~~~~~~~~~~~~^~
In file included from /usr/include/SFML/Window/Window.hpp:33,
from /usr/include/SFML/Window.hpp:44,
from /usr/include/SFML/Graphics.hpp:32,
from main.cpp:1:
/usr/include/SFML/Window/WindowBase.hpp:170:10: note: candidate: ‘bool sf::WindowBase::pollEvent(sf::Event&)’
170 | bool pollEvent(Event& event);
| ^~~~~~~~~
/usr/include/SFML/Window/WindowBase.hpp:170:10: note: candidate expects 1 argument, 0 provided
main.cpp:14:46: error: expected primary-expression before ‘)’ token
14 | if (event->is())
|
< /code>
Mein Code: < /p>
#include
#include
int main()
{
sf::RenderWindow window(sf::VideoMode({200, 200}), "SFML works!");
sf::CircleShape shape(100.f);
shape.setFillColor(sf::Color::Green);
while (window.isOpen())
{
while (const std::optional event = window.pollEvent())
{
if (event->is())
window.close();
}
window.clear();
window.draw(shape);
window.display();
}
}```
I've tried to find solution, but I haven't. Also I haven't worked with c++ before, only with c, so can guess that it can be a [url=viewtopic.php?t=15738]problem[/url] with compiler or c++ version.
Ich versuche mit der SFML -Bibliothek auf Ubuntu zusammenzuarbeiten und ich habe mit dem Tutorial begonnen. Aber ich stieß ein paar Probleme. Ich dachte, ich habe keine SFML -Dateien aufgenommen, aber ich habe es getan. Jetzt gegen Code schreiben: < /p>
[code]main.cpp: In function ‘int main()’:
main.cpp:12:60: error: no matching function for call to ‘sf::RenderWindow::pollEvent()’
12 | while (const std::optional event = window.pollEvent())
| ~~~~~~~~~~~~~~~~^~
In file included from /usr/include/SFML/Window/Window.hpp:33,
from /usr/include/SFML/Window.hpp:44,
from /usr/include/SFML/Graphics.hpp:32,
from main.cpp:1:
/usr/include/SFML/Window/WindowBase.hpp:170:10: note: candidate: ‘bool sf::WindowBase::pollEvent(sf::Event&)’
170 | bool pollEvent(Event& event);
| ^~~~~~~~~
/usr/include/SFML/Window/WindowBase.hpp:170:10: note: candidate expects 1 argument, 0 provided
main.cpp:14:46: error: expected primary-expression before ‘)’ token
14 | if (event->is())
|
< /code>
Mein Code: < /p>
#include
#include
int main()
{
sf::RenderWindow window(sf::VideoMode({200, 200}), "SFML works!");
sf::CircleShape shape(100.f);
shape.setFillColor(sf::Color::Green);
while (window.isOpen())
{
while (const std::optional event = window.pollEvent())
{
if (event->is())
window.close();
}
window.clear();
window.draw(shape);
window.display();
}
}```
I've tried to find solution, but I haven't. Also I haven't worked with c++ before, only with c, so can guess that it can be a [url=viewtopic.php?t=15738]problem[/url] with compiler or c++ version.
[/code]