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 - nestharus

Pages: [1]
1
hm.. I'm actually doing it in VS 2012.

including string stopped it from crashing when passing in a string. I just assumed that it included it within its own headers since the strings appeared to be working with the string header, but ok then ^)^.


I'd recompile it for VS 2012, but SFML 2 doesn't come with src atm : (.

2
When I run the below program, it initially works perfectly. The program just writes whatever you are typing to the window. I wrote it for a tryout. When I hit CTRL+ALT+DELETE (doing a full screen****), the whole thing bugs. The program will only redraw the window whenever it goes out of and back into focus. It stays this way permanently (until I close it and start a new instance).

I'm not sure if I did something wrong here or if this is a problem with SFML.

Again, I run the program, I hit CTRL+ALT+DELETE, I hit cancel. I click on the window, I type text. The text does not appear. I click somewhere to bring the window out of focus. I click back on the window. The text is now up. I have to continue to do this to bring the text up.

When I run the program and don't hit CTRL+ALT+DELETE (bring about a full screen window thing on top of SFML's window), the program runs just fine. I type and the text appears.

Details of program: type letters like regular chat to make them appear. Backspace to delete. Enter to clear.

Attached to the post is the program in question (so that you don't have to setup a project or anything). It uses
    libsndfile-1.dll
    openal32.dll
    sfml-audio-2.dll
    sfml-graphics-2.dll
    sfml-network-2.dll
    sfml-system-2.dll
    sfml-window-2.dll

off topic
also, passing the string directly into setText makes the program crash.. I have to convert it to a c_str. Not sure if it's me again or if it's SFML being buggy =).
end off topic

Thank you for taking the time to read this post.

#include <SFML\Graphics.hpp>

#include <chrono>
#include <thread>

int main()
{
    sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!", sf::Style::Close);
    sf::CircleShape shape(100.f);
    shape.setFillColor(sf::Color::Green);

    std::chrono::milliseconds interval(1000/32);

    window.setVerticalSyncEnabled(true);

    sf::Event event;
    sf::Text text("");
    text.setScale(.75, .75);
    text.setPosition(10, 80);
    text.setColor(sf::Color::White);

    std::string str = "";

    while (window.isOpen())
    {
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
                        else if (event.type == sf::Event::TextEntered) {
                                if (static_cast<char>(event.text.unicode) == '\r') {
                                        str = "";
                                        text.setString("");
                                } //if
                                else if (static_cast<char>(event.text.unicode) == '\b') {
                                        str = str.substr(0, str.length() - 1);
                                        text.setString(str.c_str());
                                } //else if
                                else {
                                        str += static_cast<char>(event.text.unicode);
                                        text.setString(str.c_str());
                                } //else
                        } //else if
        }

        window.clear();
        window.draw(shape);
        window.draw(text);
        window.display();

        std::this_thread::sleep_for(interval);
    }
       
    return 0;
}
 

[attachment deleted by admin]

Pages: [1]
anything