Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Empty window after porting from SFML 1.6 to 2.0 [Solved]  (Read 1865 times)

0 Members and 1 Guest are viewing this topic.

Pfeffer

  • Newbie
  • *
  • Posts: 4
    • View Profile
Empty window after porting from SFML 1.6 to 2.0 [Solved]
« on: May 31, 2013, 12:18:07 am »
Hello guys,

I have a big problem after updating a big project to SFML 2.0 from 1.6. The program seems to run fine (no errors) and the window is shown, but it is always empty (transparent, i see what was before the window appeared). I can move the mouse cursor, but that's it. The program worked fine before updaing to 2.0. I needed to compile SFML 2.0 by myself, since I had to update my mingw-gcc compiler for this update (precompiled libs didn't work with mingw-gcc 4.7.2).

While porting I already paid attention to this list of differences between 1.6 and 2.0:
http://en.sfml-dev.org/forums/index.php?topic=5343.0
  • I removed the SFML_DYNAMIC definition from linkage (I already used dynamic libs before).
  • Replaced Input class with used correspoding class.
  • Changed to pollEvent() function, not waitEvent.
  • Added OpenGL context values, which I used before (OpenGL 3.3)

Facts until now (will be updated):
  • No infinite calculations are done, since the program responds to the "LostFocus" and "GainedFocus" events. (I stop my game timers when loosing focus and resuming them when gaining focus again).
  • (Added) The program is stuck in an infinite loop of pollEvents(), until it looses focus. Then the program seem to run fine again (even renders). But after regaining focus, it is stuck in the loop again.
  • (Added, Problem) The event which doesn't seem to stop is the MouseMoved event. It only stops, after loosing focus of the window.
  • The display()-method of my Window instance is used (checked it in debugger)
  • The libraries seem to work fine now, since the precompiled ones didn't before and the program crashed everytime.
  • No OpenGL errors, exceptions or anything else occurs.

Code of the handleEvents function:
void
InteractionHandler::handleEvents() {
    sf::Event Event;
    while (windowInstance->pollEvent(Event)) {
        switch (Event.type) {
        case sf::Event::Closed:
            appContext->App->close();
            exit(0);
            break;
        case sf::Event::GainedFocus:
            appContext->hasFocus = true;
            break;
        case sf::Event::LostFocus:
            appContext->hasFocus = false;
            break;
            break;
        case sf::Event::MouseMoved:
            onMouseMovement(Event.mouseMove.x, Event.mouseMove.y);
            break;
        }
    }
}


Project Description:
The project is a little game which only uses 2 dynamic libs of SFML: libsfml-system and libsfml-window. It uses OpenGL (3.3) using also GLEW 1.6.0 (1.9.0 didn't work). I've put the glew include into the SFML OpenGL header (SFML/Window/OpenGL.cpp), before the GL headers and after the windows.h. My program is structured like the OpenGL example, but a little more complex:
http://www.sfml-dev.org/tutorials/2.0/window-opengl.php
I only use one window and only one thread. Expect for GLEW  my only other library I use is FreeImage to load some textures. Rendering is done via Shaders (Vertex, Geometry and Fragment Shaders), also using VBOs and VAOs for the vertex data. Input is only done with keyboard and mouse.

Compilation of SFML 2.0:
I used the CMake-GUI tool. Selected the directory of the extracted SFML 2.0 sources, configured the project (BUILD_SHARED_LIBS = TRUE, CMAKE_BUILD_TYPE = Release) and then generated the Makefile. I targeted a Makefile project with the MinGW-GCC compiler (default compiler). Then I opened a console and used mingw32-make to compile SFML 2.0 with the generated Makefile. I followed this instructions without knowing: http://www.sfml-dev.org/tutorials/2.0/compile-with-cmake.php

Hard- & Software:
I am using Windows 7 Prof. 64bit on a 5 year old notebook hardware:
Intel 2 Duo P8600 - 2.4Ghz
Nvidia Geforce 9600M GT
4GB RAM

Situation before updating:
Project used SFML 1.6. Program used OpenGL 3.3 with GLEW. No OpenGL errors were printed and the game ran fine.

I've already paid attention to the "Read before posting"-thread (http://en.sfml-dev.org/forums/index.php?topic=5559.0) and cleaned and recompiled the project several times.

I will try to post a very reduced version of my program, if no one has a clue.

Thanks for your help.
« Last Edit: May 31, 2013, 01:02:40 am by Pfeffer »

Pfeffer

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Empty window after porting from SFML 1.6 to 2.0 [Solved]
« Reply #1 on: May 31, 2013, 01:05:25 am »
So the problem really was the update to SFML 2.0: A buggy pollEvents function which always returns a MouseMoved event, when no other events are available.

But it is not completly solved, since I can't change the pollEvents() function. I will create a bug report on this.

Update: Nailed it (https://github.com/SFML/SFML/issues/399).
« Last Edit: May 31, 2013, 03:03:26 am by Pfeffer »