SFML community forums

Help => General => Topic started by: arcticstrat on February 05, 2010, 03:39:12 am

Title: First project
Post by: arcticstrat on February 05, 2010, 03:39:12 am
I'm creating a project for school using SFML. I moved all the necessary files for SFML. Modified the project settings and everything. I followed the tutorial. The code compiles but nothing is happening even when I try to just do a simple cout. I'm using Visual Studios C++ 2008. Any ideas as to why it's not working right would greatly help.
Title: First project
Post by: OniLinkPlus on February 05, 2010, 03:41:12 am
Please show the source code you are using so that we can find the source of the problem.
Title: First project
Post by: arcticstrat on February 05, 2010, 03:26:01 pm
Code: [Select]
#include "stdafx.h"
#include <SFML/System.hpp>
#include <iostream>

int main()
{
    sf::Clock Clock;
    while (Clock.GetElapsedTime() < 5.f)
    {
        std::cout << Clock.GetElapsedTime() << std::endl;
        sf::Sleep(0.5f);
    }

    return 0;
}

Its from the tutorial
Title: First project
Post by: Laurent on February 05, 2010, 03:43:34 pm
Are you sure that your project is a "console application", not a "Win32 application"?
Title: First project
Post by: arcticstrat on February 05, 2010, 03:54:32 pm
The only console apps are Win32 console app and CLR console app for c++
Title: First project
Post by: Laurent on February 05, 2010, 04:01:06 pm
Yes, it should be "Win32 console app". You can also set it in the project settings, under linker --> System --> SubSystem.
Title: First project
Post by: arcticstrat on February 05, 2010, 04:03:58 pm
Ok. I've been using Win32 Console App. I checked the subsystem and its Console
Title: First project
Post by: Laurent on February 05, 2010, 04:07:10 pm
Can you see the console when you launch your application? If you put a breakpoint on the "return 0" line and run the debugger (F5), is it hit?
Title: First project
Post by: arcticstrat on February 05, 2010, 04:12:43 pm
The console shows up and says "Press any key to continue..." Here's what shows up when I put in the breakpoint:
Code: [Select]
'regf.exe': Loaded 'C:\Documents and Settings\Sonya G. Aguilar\My Documents\Visual Studio 2008\Projects\regf\Debug\regf.exe', Symbols loaded.
'regf.exe': Loaded 'C:\WINDOWS\system32\ntdll.dll'
'regf.exe': Loaded 'C:\WINDOWS\system32\kernel32.dll'
'regf.exe': Loaded 'C:\WINDOWS\system32\EntAPI.dll'
'regf.exe': Loaded 'C:\WINDOWS\system32\advapi32.dll'
'regf.exe': Loaded 'C:\WINDOWS\system32\rpcrt4.dll'
'regf.exe': Loaded 'C:\WINDOWS\system32\msvcrt.dll'
'regf.exe': Loaded 'C:\WINDOWS\system32\user32.dll'
'regf.exe': Loaded 'C:\WINDOWS\system32\gdi32.dll'
'regf.exe': Loaded 'C:\WINDOWS\system32\psapi.dll'
'regf.exe': Loaded 'C:\WINDOWS\system32\netapi32.dll'
'regf.exe': Loaded 'C:\WINDOWS\system32\imm32.dll'
'regf.exe': Unloaded 'C:\WINDOWS\system32\EntAPI.dll'
'regf.exe': Unloaded 'C:\WINDOWS\system32\netapi32.dll'
'regf.exe': Unloaded 'C:\WINDOWS\system32\psapi.dll'
'regf.exe': Unloaded 'C:\WINDOWS\system32\msvcrt.dll'
Debugger:: An unhandled non-continuable STATUS_DLL_NOT_FOUND exception was thrown during process load
The program '[2820] regf.exe: Native' has exited with code -1073741515 (0xc0000135).
Title: First project
Post by: Laurent on February 05, 2010, 04:16:32 pm
Quote
An unhandled non-continuable STATUS_DLL_NOT_FOUND exception was thrown during process load

It seems that a DLL is not found, maybe sfml-system.dll? It's weird that you never got an error dialog box from the OS, if it's really that.
Title: First project
Post by: arcticstrat on February 05, 2010, 04:33:05 pm
Wow. I put the dll's in the wrong folder. Thanks. I got a new problem though. When I display a window, there's a bunch of black spots in the window. Any ideas why. Here's the code:
Code: [Select]
#include "stdafx.h"
#include <SFML/Window.hpp>

int main()
{
    // Create the main window
    sf::Window App(sf::VideoMode(800, 600, 16), "SFML Events");

    // Get a reference to the input manager associated to our window, and store it for later use
    const sf::Input& Input = App.GetInput();

    // Start main loop
    while (App.IsOpened())
    {
        // Process events
        sf::Event Event;
        while (App.GetEvent(Event))
        {
            // Close window : exit
            if (Event.Type == sf::Event::Closed)
                App.Close();

            // Escape key : exit
            if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))
                App.Close();
        }

        // Get some useless input states, just to illustrate the tutorial
        bool         LeftKeyDown     = Input.IsKeyDown(sf::Key::Left);
        bool         RightButtonDown = Input.IsMouseButtonDown(sf::Mouse::Right);
        bool         JoyButton1Down  = Input.IsJoystickButtonDown(0, 1);
        unsigned int MouseX          = Input.GetMouseX();
        unsigned int MouseY          = Input.GetMouseY();

        // Display window on screen
        App.Display();
    }

    return EXIT_SUCCESS;
}
Title: First project
Post by: Laurent on February 05, 2010, 04:36:03 pm
That's because you don't draw anything into the window, so the you always see the initial garbage (what was in video memory when you started your app).
Title: First project
Post by: arcticstrat on February 05, 2010, 04:48:07 pm
I think I got everything down now. Thanks a lot Laurent