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

Pages: [1]
1
General / Re: Update CircleShape color in other thread
« on: May 25, 2017, 03:48:49 am »
I reduced the code to just basics. The app basically draw a sprite and a circle shape showing the state of a usb card-reader connected to the pc. When the card-reader is plugged in changes the circleshape color, then it do some stuff, like giving format to the card-reader, copy some files to,..., and then finally do a safe-remove.

every state is coded with a color and it handles as max usb ports as u have to plug in card-readers, so the second thread is intended to Format drive, copy files,..., safe-remove, without stopping the main thread who is listening windows events, drawing, and creating threads for every card-reader.

if i just call a function i will be calling a function from the second thread, so i suppose is the same.

what i'm doing is creating a win32 app, starting a windows, subscribing it to the WM_DEVICECHANGE windows event and hiding it. What i discover from unhide that window is when the win32 window is onfocus or active i don't have the problem to move the mouse or press a key to update the rendering.

why it happens idk. That is why i asked here https://en.sfml-dev.org/forums/index.php?topic=22016.0 if there is a way to subscribe the render window to the WM_DEVICECHANGE windows event directly with out creating the Win32 window.

or can i create a sf::view or a sf::renderwindow inside the win32 window?

Thanks anyway.

2
Is there a way to do that?

I know how to do it in a win32 application.

Any help will be appreciated.

thanks!

3
General / Re: Update CircleShape color in other thread
« on: May 25, 2017, 01:15:06 am »
This is the Main Loop:

void Manager::Run()
{
while (m_window->m_renderWindow.isOpen())
    {
        sf::Event evnt;
        while (m_window->m_renderWindow.pollEvent(evnt));
        {
            if (evnt.type == sf::Event::Closed)
                m_window->CloseWindowes();
        }

        m_window->MessagePump();
        ProcessMessages();
        Update();
        Draw();
    }
}

This is the Draw funtion:

void Manager::Draw()
{
    m_window->m_renderWindow.clear(sf::Color::Black);
    //Drive container.second only has a pointer to class EgClass*
    DriveContainer::iterator itr = m_DriveContainer.begin();
    for (; itr != m_DriveContainer.end(); )
    {
        itr->second->Draw(m_window->m_renderWindow);
        ++itr;
    }

    m_window->m_renderWindow.display();
}

this is the draw function of the instance:

void EgClass::Draw(sf::RenderWindow& renderWindow)
{
    renderWindow.draw(m_spriteSD);
    renderWindow.draw(m_circleShape);
    renderWindow.draw(m_text);
}

and this is a thread launched when i create the instance

void EgClass::Run()
{
    m_circleShape.setFillColor(sf::Color::Blue);

    while (m_state != L"Done")
    {
        m_state = L"Done";

        sf::sleep(sf::seconds(15));
    }
    m_circleShape.setFillColor(sf::Color::Green);
}

4
General / Update CircleShape color in other thread
« on: May 25, 2017, 12:58:07 am »
Hello guys i'm trying to do what the title says, i'm not doing any multi-threading rendering, its just a thread that updates the color of a CircleShape, it works fine excepts that i only see the new color when i move the mouse or press any key, it means on any event.

i cant find something similar on the forum or google.

i appreciate any clue about what is happening.

thanks!

Pages: [1]
anything