Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Running into errors with using SFML on WSL  (Read 1504 times)

0 Members and 2 Guests are viewing this topic.

new-sfml-developer

  • Newbie
  • *
  • Posts: 3
    • View Profile
Running into errors with using SFML on WSL
« on: February 08, 2024, 10:03:00 pm »
Hi! I'm running into some pretty major issues trying to start using sfml in a new project. I'm trying to render a rectangle to a window and cannot get it to work. I'm able to change the color of the window with the clear() method, but drawing doesn't seem to work. I've included <SFML/Graphics.hpp> in the header. Here's the code:

int main() {
    sf::RenderWindow window(sf::VideoMode(1280, 720), "SFML works!");
    sf::RectangleShape shape;
    shape.setPosition(590, 310); // Adjusted position to fit within the window
    shape.setSize(sf::Vector2f(100, 100));
    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(sf::Color::White);
        window.draw(shape);
        window.display();
    }

    return 0;
}
 

I've followed tons of forum posts and asked ChatGPT what it thinks, and so far I haven't been able to find a solution. The window that appears when the draw line is not commented out is black as well. Some things I've tried: Fixing CMakeLists.txt files (I can post snippits from here too if it would help) Debugging and tracing through call stack (it seems to get mad at glXSwapBuffers) Installing dependencies manually with sudo Changing shapes, sprites, etc. to try and render something Following CMake tutorial in the tutorial section.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Running into errors with using SFML on WSL
« Reply #1 on: February 09, 2024, 08:45:12 am »
What do you get when you run wsl --version?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

new-sfml-developer

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Running into errors with using SFML on WSL
« Reply #2 on: February 09, 2024, 01:47:47 pm »
Thanks for your reply!  I get this in my powershell
WSL version: 2.0.14.0
Kernel version: 5.15.133.1-1
WSLg version: 1.0.59
MSRDC version: 1.2.4677
Direct3D version: 1.611.1-81528511
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.19045.3930
 

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Running into errors with using SFML on WSL
« Reply #3 on: February 12, 2024, 08:41:02 am »
Hmm odd. It works fine for me, but I'm also on Windows 11 and not 10

Any specific reason you want to develop under WSL2 with SFML?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

new-sfml-developer

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Running into errors with using SFML on WSL
« Reply #4 on: February 12, 2024, 03:50:28 pm »
Ok well at least now I know it may be in the setup  :( but I want to use WSL2 and SFML to develop a C++ app that's essentially a balance game using force plates, but I've only really worked with mac/linux in the past and so when I initially set up my development environment I opted for WSL for the smoother starting process.  I was thinking of maybe trying to restart in windows but I'm not sure if that'll even work.