Jump to content
  • Advertisement
Sign in to follow this  
  • entries
  • comments
  • views

Made a few decisions (Update)

Sign in to follow this  


Well so far I made a few decisions and was able to get some basic code up and running to test the environment.

The first decision I made was to use C++ over Python and other languages I know. The main reason for this decision is library support. When I look from the perspective of game development with Python there are libraries that exist and they are wrappers around C/C++ libs. This is not an issue but the issue does arise with the way they are wrapped in many cases using Cython. I do not know much about Cython but what I do know is you really need to pay attention to the compiler you use with Python and wrapped libraries otherwise you get tons of crashes. I really did not want to go with this hassle I would much rather bolt Python or Lua on top of my code before going through all the setup required.

Now that this is out of the way I also decided to go with SFML-2.1. This is really a no brainer due to my decision to use C++. This is a super clean library and there is very little to complain about. It handles many parts you do not want to handle and stays simple enough to not step on your toes where you do not want it.

As far as IDE's and Compilers go I really wanted to stay away from VC++. Do not get me wrong here it is a great compiler and IDE but I do not spend all my time on Windows anymore. The main reason I use windows is because it is required for school, however, after I graduate this summer this is not a deal breaker for me anymore and I am likely to go to Linux full time for the most part and just leave Windows laying around for cross platform testing purposes. Due to this I decided to go with QTCreator with mingw_w64 32bit. The version you get with QTCreator 2.8.1 uses GCC 4.8.1. This is really a very nice IDE so far I have only used it a small amount but it is really indeed slick to use.

Also from what I can see qmake is very powerful and well designed and not too difficult to figure out. Qmake is basically similar to something like CMake in the respect that it does not actually build the code but instead it is a makefile generator to create the makefile for you.

So with all this set up I was able to put together what I would consider the SFML Hello World application which they use in the documentation to demonstrate how to setup the library.

The purpose of the code is to create a colored circle on the window rendering surface which is quite simple.
#include int main(){ sf::RenderWindow window(sf::VideoMode(200, 200), "SFML Works!"); sf::CircleShape shape(100.0f); shape.setFillColor(sf::Color::Red); 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;}
Very simple. Create the window, add the circle of a particular radius, start the event handler, and exit when closed.

In order for this code to compile you obviously need to add the includes, and libraries to the project. QTCreator does this differently then most ide's as it is not done through the configuration ui it is actually done in the project file aka the .pro which just so happens to also be your QMake file as well. This is really cool :D

The other issue is I am dynamically linking to SFML instead of using static libs. So the dll files must be present. In my opinion the typical way of copying the dll files in place by hand is annoying. To automate the process is platform dependent and QMake again comes to the rescue by allowing to create a unix or a win32 block to cover platform dependence. With this I can manipulate the directories and pipe the information into cmd.exe to copy the dll files to the build directory. Really neat stuff.

Here is the .pro file for qmake with comments. The thing to note from a windows perspective this can only be run from the ide. The reason it cannot be run from the debug folder in this case is although I can copy over the appropriate runtime dll's for dwarf2 and pthreads; I cannot copy over libstdc++'s dll. I am not sure why I think the way the file is named causes the terminal copy command to croak. If anyone knows a better way please let me know as -static-libstdc++ seems to not be statically linking like it should.TEMPLATE = appCONFIG += consoleCONFIG -= app_bundleCONFIG -= qtINCLUDEPATH = c:/libs/SFML-2.1/includeLIBS += -Lc:/libs/SFML-2.1/lib -lsfml-graphics -lsfml-window -lsfml-systemSOURCES += main.cppwin32:debug { EXTRA_BINFILES += \ c:/libs/SFML-2.1/bin/sfml-graphics-2.dll \ c:/libs/SFML-2.1/bin/sfml-window-2.dll \ c:/libs/SFML-2.1/bin/sfml-system-2.dll EXTRA_BINFILES_WIN = $${EXTRA_BINFILES} EXTRA_BINFILES_WIN ~= s,/,\\,g # regex replace '/' with '\' in path list DESTDIR_WIN = ./debug DESTDIR_WIN ~= s,/,\\,g # regex replace '/' with '\' in the path # iterate through file list and copy to the build directors for (FILE, EXTRA_BINFILES_WIN) { QMAKE_POST_LINK += $$quote(cmd /c copy /y $${FILE} $${DESTDIR_WIN} $$escape_expand(\n\t)) }}
That is all for now hope you enjoy.
Sign in to follow this  


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!