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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - new-sfml-developer

Pages: [1]
1
Graphics / 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.

Pages: [1]
anything