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

Pages: [1]
1
Ofcourse...

I somehow automatically thought NULL would be a no event value.

Thank you!

2
Hello all

I have done everything mentioned in the "read this before posting". I'm not able to find an explanation to this problem.

The problem is that if I open a new window, unless my mouse is on top of that window, it immediately gets sent a "sf::Event::Closed" event, even though it has just been created ! If however my mouse cursor happens to be on top of where the window opens, the event is not sent.

And, as I am polling for this event to close the window, the result is that the window gets closed immediately after it has been created - unless the mouse cursor is in the area of the window when it appears.

My environment is SFML 2.1 with MinGW.

Below is the code to reproduce the problem:

main.cpp
#include "problem.h"

int main()
{
    test_SFML();
    while (1)
    {
        pollEsc();
    }

}

problem.cpp
#include "problem.h"

using namespace sf;

sf::RenderWindow simWindow;
sf::View simScreen(sf::FloatRect(0, 0, 320, 240));
sf::Color col0(250, 250, 250); // background
sf::Event simEvent;

void test_SFML(void)
{
    simWindow.create(sf::VideoMode(320, 240), "test");
    simScreen.setViewport(sf::FloatRect(0, 0, 1, 1));
    simWindow.setView(simScreen);
    simWindow.clear(col0);
    simWindow.display();
}

int pollEsc() {
simWindow.pollEvent(simEvent);
    if(simEvent.type == sf::Event::Closed) {
       simWindow.close();
       return -1;
    }
return 0;
}
 

problem.h
#ifndef PROBLEM_H
#define PROBLEM_H

#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>

extern void test_SFML();
extern int pollEsc();

#endif // PROBLEM_H

 

Pages: [1]