|
Dragonfly with Visual Studio v16 (2019) |
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.6.* and Microsoft Visual Studio version 16 (2019).
Open Visual Studio.
Create a new Project
From the menu:
"File" → "New" → "Project"
"Empty Project"
Fill out information:
Name: "Whatever you want"
Location: "Wherever you want"
Solution: "Create new solution"
Solution name: "Whatever you want"
Click "Create"
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++.
Click "Finish"
Set the compiler/linker settings for SFML:
Menu:
"Project" → "Properties"Select:
"Configuration Properties"Set Configuration in the top left drop-down to:
"All Configurations"Set Platform in the top center drop-down to:
"All Platforms"
Select:
"VC++ Directories"Click top line, then "..." button on right. Use file browser to add:
"Include Directories" → (Dropdown arrow) → "Edit"
(Directory where extracted SFML)\includee.g.,
..\..\SFML-2.6\include
If linking in Dragonfly (versus developing Dragonfly), on the next line, also add:
(Directory where extracted dragonfly)\includee.g.,
..\..\dragonfly\include
Click "OK"
Set Configuration in the top left drop-down to:
"Debug"
Select:
"Library Directories" → (Dropdown arrow) → "Edit"Click top line, then "..." button on right. Use file browser to add:
(Directory where extracted SFML)\libe.g.,
..\..\SFML-2.6\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"
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
If linking in Dragonfly (versus developing Dragonfly), also add:
libdragonfly-x64-debug.lib(Adjust the name to the version of the library appropriate for the build). Click "OK"
Note! Changing from "Debug" to "Release" requires different SFML
libraries for linking.
See: SFML
and Visual studio for details.
Create program to build. Menu:
"View" → "Solution Explorer"Select:
(Expand Project name)
Right click "Source Files" → "Add" → "New Item"
"Installed" → "Visual C++"Fill out information:
"C++ File (.cpp)"
Name: "game.cpp"Click "Add"
Location: (leave as-is)
Do ONE of the below options:
// // 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(); }
#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; }
Build (ctrl-shift-B)
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
)
Ensure access to SFML DLLs. To do this, do ONE of the below options:
Copy all DLL files:
(Directory where extracted SFML)\bin\*.dllto the directory with the .exe just built (e.g.,
saucer-shoot\Debug
).
Go to project properties:
"Menu" → "Project" → "Properties"Then:
"Configuration Properties" → "Debugging"Add:
"Environment" → (Dropdown arrow) → "Edit"
PATH=%PATH%;(Directory where extracted SFML)\bin;e.g.,
PATH=%PATH%;..\..\SFML-2.6\bin;
Click "OK"
(Optional) Change the working directory when running:
Go to project properties:
"Menu" → "Project" → "Properties"Then:
"Configuration Properties" → "Debugging"Use file browser to select the directory where the application .exe is (e.g.,
"Working Directory" → (Dropdown arrow) → "Browse"
$(ProjectDir)\x64\Debug
)Click "OK"
Compile via:
"Build" → "Build Solution"If compilation works fine, proceed to the next step.
But, if you get a compiler error in an SFML file called
"Rect.inl" that is similar to '(': illegal error on right side
of token '::')
, fix it by adding a preprocessing directive.
Go to project properties:
"Menu" → "Project" → "Properties"Then:
"C/C++" → "Preprocessor" → "Preprocessor Definitions" → (Dropdown arrow) → "Edit"Add:
NOMINMAX
Run (press F5).
Home | Engine | Games | Tutorial | Docs | Book | Notes |