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

Pages: [1]
1
Window / Re: sf::Mouse::getPosition lags behind the mouse curser
« on: September 03, 2016, 09:26:09 pm »
Ok, thanks for your answers.

2
Window / sf::Mouse::getPosition lags behind the mouse curser
« on: September 02, 2016, 05:45:10 pm »
Hello,

i'm using a sf::Sprite instead of the normal windows mouse curser. I have set the mouse curser invisible through

Code: [Select]
sf::Window::setMouseCursorVisible(false).
Then I set the mouse sprite at the mouse position:

Code: [Select]
setPosition(sf::Vector2f(window.mapPixelToCoords(sf::Mouse::getPosition(window))));
I call this function every frame.
The problem is now that the mouse "lags" behind the real mouse curser position. I can see this when I set the mouse curser visible (with sf::Window::setMouseCursorVisible(true)) and move the mouse around. The mouse sprite is always a bit behind the windows curser, it feels like a few frames.
Why is it so? Can I somehow fix this?

3
Graphics / Re: Why does multi-threaded drawing work?
« on: August 22, 2016, 05:08:49 pm »
Ok, thanks  :) .

4
Graphics / Re: Why does multi-threaded drawing work?
« on: August 13, 2016, 02:01:16 pm »
Thank you for your answer.
I already know this about thread safety, i think maybe my first post was misleading. Maybe this question is better:

In the SFML tutorial it looks like it is ok to have no mutex or so. Therefore we would risking that two threads access the same data at the same time. Is this correct? If so, why should we do this, wouldn't it be possible that we will see not "the right things" on the screen the most time when this program is running?
Or is the programmer supposed to add mutexes / locks to prevent this?

5
Graphics / Why does multi-threaded drawing work?
« on: August 12, 2016, 05:50:27 pm »
Hello,

in the SFML tutorial "Drawing 2D stuff" is at the end a section "Drawing from threads", which explains that you can handle all drawing in a seperate thread.
I don't understand why this is working:
I draw for example a sf::Sprite in the rendering thread
Code: [Select]
window.draw(sprite);
which calls sf::RenderTarget::draw and then sf::Sprite::draw. In this draw function I'm accessing the sprites data members m_origin, m_position, m_rotation and so on through the call to sf::Transformable::getTransform().
At the same time i can access this data members from the "main game loop" in another thread through calls like sf::Transformable::setPosition(), sf::Transformable::setRotation() and so on.
Aren't I'm accessing the data members then from different threads at the same time? I have nowhere seen a mutex or so, why does this work?

6
Window / Re: sf::RenderWindow doesn't work
« on: July 09, 2016, 03:12:47 pm »
I tried it now with the GCC 4.9.2 MinGW compiler and everything work fine. So probably i made a mistake with the compiler settings.

7
Window / Re: sf::RenderWindow doesn't work
« on: July 09, 2016, 12:15:25 pm »
Has nobody an idea? I could post some screenshots of my compiler settings or something else if this would help.

8
Window / sf::RenderWindow doesn't work
« on: July 03, 2016, 12:05:59 pm »
Hello,

i've used sfml with Visual Studio now for a while. Now i wanted to use sfml with Code::Blocks.
I installed everything and followed the SFML and Code::Blocks (MinGW) tutorial. I installed the GCC 4.8.1 TDM (SJLJ) - 64-bit sfml version and the TDM 4.8.1 (64-bit) compiler linked on the sfml download page.

I compiled the example from the SFML and Code::Blocks (MinGW) tutorial and there were no errors. But when i start the programm it doesn't work. The sfml window pops up with a white screen and the correct text but there come directly a windows window which say that the program doesn't work any longer (the exact text in german: Testing.exe funktioniert nicht mehr).
Here is the code i compiled (i just copied it from the tutorial):

Code: [Select]
#include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
    sf::CircleShape shape(100.f);
    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();
        window.draw(shape);
        window.display();
    }

    return 0;
}

If i now compile this code:

Code: [Select]
#include <SFML/Graphics.hpp>

int main()
{
    sf::Vector2f vec;
    vec.x = 8;
    std::cout << vec.x << std::endl;

    return 0;
}

everything works and the "8" is showing up in the console window.
I also just compiled this:

Code: [Select]
#include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");

    return 0;
}

the same "Testing.exe doesn't work any longer" window pops up when i start the program (there were again no errors when i compiled it).

It seems that the problem is the sf::RenderWindow, but what exactly is wrong here?

Pages: [1]