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.


Messages - pallen@fgcu.edu

Pages: [1]
1
General / Visual Studio 17 Black RenderWindow
« on: March 03, 2022, 10:18:03 pm »
I'm trying to get a sample project working for the University C++ courses I teach.  I've used SFML in my courses before. It's just supposed to open a window with white background, and then draw a blue circle in the middle.  I have it working fine on Windows with MinGW64 and CLion using binaries downloaded from sfml-dev.org. I have it working on MacOS with CLion using command line cmake.  I can't get it to work on Windows with Visual Studio 17, I only get a black window.  I'm using the same cpp file.  I've tried binaries with static and non-static linking.  I've built the libraries using cmake-gui and VS 17 and tried static linking.  Same results.  Any ideas?

Here's my code:

#include <SFML/Graphics.hpp>

// Global Defines
// --------------------------------------------------------
const int WINDOW_WIDTH = 640;
const int WINDOW_HEIGHT = 480;

const sf::Color WINDOW_COLOR = sf::Color::White;
const sf::Color BALL_COLOR = sf::Color::Blue;

int main() {

    // create a 2d graphics window
    sf::RenderWindow window(sf::VideoMode(WINDOW_WIDTH, WINDOW_HEIGHT), "Hello SFML");
    window.clear(WINDOW_COLOR);

    sf::CircleShape ball;
    ball.setRadius(20);
    ball.setOrigin(10.0, 10.0);
    ball.setPosition(WINDOW_WIDTH / 2.0, WINDOW_HEIGHT / 2.0);
    ball.setFillColor(BALL_COLOR);

    while (window.isOpen())
    {
        // Process user input
        // ------------------------------------------------
        sf::Event event;
        while (window.pollEvent(event))
        {
            // "close requested" event: we close the window
            if (event.type == sf::Event::Closed)
                window.close();
        }

        // Render drawing objects
        // ------------------------------------------------
        window.clear(WINDOW_COLOR);
        window.draw(ball);
        window.display();
    }
    return 0;
}
 

Pages: [1]
anything