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

Author Topic: Window is closing after a few seconds  (Read 5760 times)

0 Members and 4 Guests are viewing this topic.

niehoelzz

  • Newbie
  • *
  • Posts: 13
    • View Profile
Window is closing after a few seconds
« on: July 12, 2016, 12:30:40 am »
#include <SFML\Window.hpp>
#include <SFML\Graphics.hpp>
#include <iostream>


int main() {
        bool walkl = false, walkr = false;

        sf::RenderWindow mainwindow(sf::VideoMode(1920, 1080), "Mein Erstes Spiel", sf::Style::Default);
        // Adding Background
        sf::Texture background;
        background.loadFromFile("background.png");
        sf::Sprite backgroundsprite;
        backgroundsprite.setTexture(background);
       

        // As long as Window is open
        while (mainwindow.isOpen()) {
               
                // clear window
                mainwindow.clear();

                // Draw here
                mainwindow.draw(backgroundsprite);

                // end the current frame
                mainwindow.display();



                sf::Event event;
                while (mainwindow.pollEvent(event)) {
                        switch (event.type) {
                        case sf::Event::Closed:
                                mainwindow.close();
                                break;
                        case sf::Event::KeyPressed:
                                if (event.key.code == sf::Keyboard::D) {
                                        walkr = true;
                                }
                                else if (event.key.code == sf::Keyboard::A) {
                                        walkl = true;
                                }
                                break;
                        case sf::Event::KeyReleased:
                                walkr = false;
                                walkl = false;
                        }
                       
                       
                }

                if (walkr == true){
                        std::cout << "Bewege nach Rechts" << std::endl;
                }
                if (walkl == true) {
                        std::cout << "Bewege nach Links" << std::endl;
                }
        }


        return 0;
}

Why is my window closing after 5 - 10 seconds?  :-\

niehoelzz

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Window is closing after a few seconds
« Reply #1 on: July 12, 2016, 02:28:11 am »
The Message is

The Program "[9952] GameDevelopment.exe" was endet with the code -1073740777 (0xc0000417).
Help me please i dunno what to do  :'(

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11033
    • View Profile
    • development blog
    • Email
Re: Window is closing after a few seconds
« Reply #2 on: July 12, 2016, 03:11:32 am »
Run it through the debugger and figure out what goes wrong.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

niehoelzz

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Window is closing after a few seconds
« Reply #3 on: July 12, 2016, 12:14:54 pm »
Run it through the debugger and figure out what goes wrong.
I already did but it enters the loop for like thousands of times and that in under 1msec so it would take forever to get the error

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Window is closing after a few seconds
« Reply #4 on: July 12, 2016, 12:44:53 pm »
Don't run step by step. The debugger halts the execution automatically when the crash happens.
Laurent Gomila - SFML developer

niehoelzz

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Window is closing after a few seconds
« Reply #5 on: July 12, 2016, 03:43:28 pm »
Don't run step by step. The debugger halts the execution automatically when the crash happens.

Heres some Output:
The Thread 0x3308 has ended with the code -1073740777 (0xc0000417).
The Thread 0x36bc has ended with the code -1073740777 (0xc0000417).
The Thread 0x39e4 has ended with the code -1073740777 (0xc0000417).
The Thread 0x32c0 has ended with the code -1073740777 (0xc0000417).
The Thread 0x4ed8 has ended with the code -1073740777 (0xc0000417).
The Thread 0x1408 has ended with the code -1073740777 (0xc0000417).
The Thread 0x2988 has ended with the code -1073740777 (0xc0000417).
The Thread 0x1fb8 has ended with the code -1073740777 (0xc0000417).
The Thread 0x4708 has ended with the code -1073740777 (0xc0000417).
The Thread 0x3808 has ended with the code -1073740777 (0xc0000417).
The Thread 0x21f0 has ended with the code -1073740777 (0xc0000417).
The Thread 0x2620 has ended with the code -1073740777 (0xc0000417).
The Thread 0x135c has ended with the code -1073740777 (0xc0000417).
The Thread 0xca4 has ended with the code -1073740777 (0xc0000417).
The Thread 0x300c has ended with the code -1073740777 (0xc0000417).
The Thread 0x405c has ended with the code -1073740777 (0xc0000417).
The Thread 0xc84 has ended with the code -1073740777 (0xc0000417).
The program "[19804] GameDevelopment.exe" was closed with the code -1073741510 (0xc000013a).

I dont know if it helps...
Ill try to run the Debug mode later cuz im reinstalling the Visual Studio right now maybe that will solve the problem... hopefully

It even wont work if its only the window which is drawn but it works if i use 'sf::Window' instead of 'sf::RenderWindow'
« Last Edit: July 12, 2016, 03:45:21 pm by niehoelzz »

niehoelzz

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Window is closing after a few seconds
« Reply #6 on: July 12, 2016, 04:17:12 pm »
After some Testing i found out that this happens when im adding the
mainwindow.display();
line.

But why?

Rosme

  • Full Member
  • ***
  • Posts: 169
  • Proud member of the shoe club
    • View Profile
    • Code-Concept
Re: Window is closing after a few seconds
« Reply #7 on: July 12, 2016, 06:45:11 pm »
Are you linking correctly? Debug libraries with debug build? Release libraries with release build? You downloaded the correct library for your compiler?
GitHub
Code Concept
Twitter
Rosme on IRC/Discord

niehoelzz

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Window is closing after a few seconds
« Reply #8 on: July 12, 2016, 07:15:24 pm »
Are you linking correctly? Debug libraries with debug build? Release libraries with release build? You downloaded the correct library for your compiler?

Configuration Debug:
sfml-graphics-d.lib
sfml-window-d.lib
sfml-system-d.lib
sfml-network-d.lib
sfml-audio-d.lib

Configuration Release:
sfml-graphics.lib
sfml-window.lib
sfml-system.lib
sfml-network.lib
sfml-audio.lib

Visual Studio 2015        Sfml 14 (VS2015)

niehoelzz

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Window is closing after a few seconds
« Reply #9 on: July 12, 2016, 09:58:00 pm »
It has to do with my Visual Studio. It works neither with Allegro. The Allegro window is closing after some time too.
Ill try to do it with Code blocks

niehoelzz

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Window is closing after a few seconds
« Reply #10 on: July 12, 2016, 11:08:19 pm »
It works on my stupid laptop but i did exactly the same.

 

anything