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

Author Topic: Porting SFML 1.2 Makefile project glgalaxy to windows Code::Blocks  (Read 1289 times)

0 Members and 1 Guest are viewing this topic.

phusg

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
I'm relatively new to SFML and even C++ but am highly motivated to learn the ropes via this great project I've found: https://github.com/dustyco/glgalaxy (basically a beautified version of the classic xscreensaver galaxy)

The .cpp files have #include <GL/gl.h> so I'm assuming it's a SFML 1.2 project. I've set up SFML 1.6 with the Dwarf2 version of GCC 4.4.1 in Code::Blocks 10.05 and have built and run my first SFML executable.

After a lot of googling I'm still not any further as to how to port the Makefile based glgalaxy code (which I assume was made in Linux) to my windows Code::Blocks project, hence my cry for help! The makefile is pretty simple as they go:

all: gljitter

gldemo: gldemo.cpp
        g++ -O3 -o gldemo gldemo.cpp -lsfml-system -lsfml-window -lGL

gltexture: gltexture.cpp
        g++ -O3 -o gltexture gltexture.cpp -lsfml-system -lsfml-window -lGL

gljitter: gljitter.cpp
        g++ -O3 -o gljitter gljitter.cpp -lsfml-system -lsfml-window -lGL

gl3d: gl3d.cpp
        g++ -O3 -o gl3d gl3d.cpp -lsfml-system -lsfml-window -lGL

Any pointers or hints are much appreciated! What I still don't get at the moment is why there isn't a main.cpp and why only the lodepng has a header file (yes I have a lot to learn, please help me on my way).

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10993
    • View Profile
    • development blog
    • Email
Re: Porting SFML 1.2 Makefile project glgalaxy to windows Code::Blocks
« Reply #1 on: April 11, 2013, 10:59:17 pm »
If you're new to SFML and even more to C++, then you don't want to start with an OpenGL project, but you should start with some small games, e.g. Pong, Snake, Tetris, etc. until you got some more experience. Besides that you should get a good book on C++, since it's not a trivial language and without a good basis it's very hard to advance further.

There's not really much to do with the make file. It just compiles 4 different source files into 4 different executable and links them with SFML system and window and OpenGL.
Again I really don't suggest to start working on a project directly with OpenGL, but to get a Code::Blocks project file, you could create four empty projects with one workbench and add to all of the the one related source file and then change the settings (according to the official tutorial on SFML) to link against the system and window module and add OpenGL as well.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

phusg

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
Re: Porting SFML 1.2 Makefile project glgalaxy to windows Code::Blocks
« Reply #2 on: May 12, 2013, 12:26:50 pm »
First off: Thanks very much for your reply eXpl0it3r!

You're right that C++/OpenGL no stroll in the park and so I'm now practising doing other stuff to get me to the point where I can further develop this glgalaxy code.

Still it would be nice if I could just get this code running on my machine so I also have an idea of how computationaly intensive it is. This is how far I've got:

> you could create four empty projects with one workbench and add to all of the the one related source file

I've done this, assuming you mean matrix.cpp is the related source file of each project, as each of the 4 .cpps in the Makefile includes matrix.cpp, and 3 of them build to give an executable. (BTW, to link against OpenGL on windows I found out I needed the -lopengl32 switch instead of the linux only -lGL.)

The one that doesn't build is gltexture. That one is slighly more complicated as it also includes lodepng.cpp (which also needs lodepng.h). Building the gltexture project results in almost 300 multiple definition errors along the lines of

/lodepng.cpp:1811: multiple definition of `LodeZlib_read32bitInt(unsigned char const*)'

Is there an incompatibility between this LodePNG version 20110417 and SFML 1.6? As I said glgalaxy seems to have been written in SFML 1.2, but unfortunately that has now been taken offline. Or should I be looking elsewhere?

I'm still not entirely sure what I should make of the all: gljitter line from the Makefile. Does that mean gljitter.cpp is a dependency of each of the other 3 projects too?

Any help, suggestions, tips much appreciated!