[DF]
[Dragonfly]

Dragonfly with Visual Studio v14 (2015)

Home Engine Games Tutorial Docs Book Notes

This is a setup guide for configuring Microsoft Visual Studio to use and develop Dragonfly. This setup guide is good as of SFML version 2.5 and Microsoft Visual Studio version 14 (2015).

  1. Open Visual Studio.

  2. Create a new Win32 Project

    1. From the menu:

      "File" → "New" → "Project"
      "Templates" → "Visual C++" → "Win32"
      Select:
      "Win32 Project"
      Uncheck:
      "Create directory for solution"
    2. Fill out information:

      Name: "saucer-shoot"
      Location: "Wherever you want"
    3. Click "OK" and then Click "Next"

    4. Select:

      "Windows application"
      "Empty project"
      Note, if needed in the future, there are directions for Changing a Windows App to a Console App in Visual Studio

      Another note, to keep the console window open after the program ends, run with ctrl-F5 (instead of just F5). Other suggestions are available how-to-keep-the-console-window-open-in-visual-c++.

    5. Click "Finish"

  3. Set the compiler/linker settings for SFML:

    1. Menu (or press Alt-F7):

      "Project" → "(Project name) Properties"
      Select:
      "Configuration Properties"
      Set Configuration in the top drop-down to:
      "All Configurations"
    2. Select:

      "VC++ Directories"
      "Include Directories" → (Dropdown arrow) → "Edit"
      Click top line, then dropdown arrow. Use file browser to add:
      (Directory where extracted SFML)\include
      e.g.,..\..\SFML-2.5\include

      If linking in Dragonfly (versus developing Dragonfly), on the next line, also add:

      (Directory where extracted dragonfly)\include
      e.g., ..\..\dragonfly\include

      Click "OK"

    3. Select:

      "Library Directories" → (Dropdown arrow) → "Edit"
      Click top line, then dropdown arrow. Use file browser to add:
      (Directory where extracted SFML)\lib
      e.g., ..\..\SFML-2.5\lib

      If linking in Dragonfly (versus developing Dragonfly), on the next line, also add:

      (Directory where extracted dragonfly library)
      e.g., ..\..\dragonfly\lib

      Click "OK"

    4. Select:

      "Linker" → "Input" → "Additional Dependencies" → (Dropdown arrow) → "Edit"
      Add:
      sfml-system-d.lib
      sfml-window-d.lib
      sfml-graphics-d.lib
      sfml-main-d.lib
      sfml-audio-d.lib
      sfml-network-d.lib
      Winmm.lib
      Ws2_32.lib

      Note! Changing to "Release" requires different SFML libraries for linking. See: SFML and Visual studio for details.

      If linking in Dragonfly (versus developing Dragonfly), also add:

      libdragonfly-win32-debug.lib
      (Adjust the name to the version of the library appropriate for the build). Click "OK"
  4. Create program to build. Menu:

    "View" → "Solution Explorer"
    (Right click Project name) → "Add" → "New Item"
    Select:
    "Installed" → "Visual C++"
    "C++ File (.cpp)"
    Fill out information:
    Name: "game.cpp"
    Click "Add"

    Do ONE of the below options:

    1. If linking in Dragonfly (versus developing Dragonfly), paste in the below code:
      //
      // game.cpp
      // 
      
      // Engine includes.
      #include "GameManager.h"
      #include "LogManager.h"
      
      int main(int argc, char *argv[]) {
      
        // Start up game manager.
        df::GameManager &game_manager = df::GameManager::getInstance();
        if (game_manager.startUp())  {
          df::LogManager &log_manager = df::LogManager::getInstance();
          log_manager.writeLog("Error starting game manager!");
          game_manager.shutDown();
          return 0;
        }
      
        // Show splash screen.
        df::splash();
      
        // Shut everything down.
        game_manager.shutDown();
      }
      
    2. If developing Dragonfly (versus linking in Dragonfly), paste in the below code:
      #include <SFML/Graphics.hpp>
      
      int main()
      {
          sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
          sf::CircleShape shape(100.f);
          shape.setFillColor(sf::Color::Green);
      
          while (window.isOpen())
          {
              sf::Event event;
              while (window.pollEvent(event))
              {
                  if (event.type == sf::Event::Closed)
                      window.close();
              }
      
              window.clear();
              window.draw(shape);
              window.display();
          }
      
          return 0;
      }
      
  5. Build (press F7)

    Warnings about "PDB" files not found can be ignored

    If linking in Dragonfly (versus developing Dragonfly), copy "df-font.ttf" to the directory with the .exe just built (e.g., (Project name)\Debug)

  6. Ensure access to SFML DLLs. To do this, do ONE of the below options:

    1. Copy all DLL files:

      (Directory where extracted SFML)\bin\*.dll
      to the directory with the .exe just built (e.g., saucer-shoot\Debug).
    2. Go to project properties (press Alt+F7):

      "Configuration Properties" → "Debugging"
      "Environment" → (Dropdown arrow) → "Edit"
      Add:
      PATH=%PATH%;(Directory where extracted SFML)\bin;
      e.g., PATH=%PATH%;..\..\SFML-2.5\bin;

      Click "OK"

  7. (Optional) Change the working directory when running:

    Go to project properties (press Alt+F7):

    "Configuration Properties" → "Debugging"
    "Working Directory" → (Dropdown arrow) → "Browse"
    Use file browser to select the directory where the application .exe is (e.g., $(ProjectDir)\Debug)

    Click "OK"

  8. Run (press F5).

Home Engine Games Tutorial Docs Book Notes

Copyright ©2016-2019, Mark Claypool (claypool [at] cs.wpi.edu) and WPI. All rights reserved.