Here is how I set it up for my project using SFML, GLEW, and openGL.
I made a folder in C:, which I called usr. Inside that folder I made a folder called include, and a folder called lib. Just a place to put libs and header files.
I downloaded SFML, and copied the folder called SFML which holds the SFML headers into C:/usr/include. I copied all of SFML's lib files into C:/usr/lib.
Then I downloaded GLEW, and I put the header files in C:/usr/include/GL, and libs in C:/usr/lib).
I chose C:/usr/include, and C:/user/lib, because linux has locations with similar names. There may be a better place in windows to put this stuff, I don't know.
Also on windows you need to put dll's provided by SFML and GLEW in the same location as your executable. I guess in your code blocks project folder in bin/Debug, and bin/Release.
Then in code blocks, in project->build options, select your whole project on the left, not just debug or release, and then click on linker settings. Add
glew32s
opengl32
glu32
sfm-graphics
sfml-window
sfml-system |
, and any other sfml libs you want under Link Libraries. Then in search directories, I added c:/usr/lib under Linker, and c:/usr/include and my code::blocks project folder under compiler.
In compiler options I also selected have gcc follow C++11 or something like that.
My main.cpp looks something like this,
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
#include <windows.h>
#define GLEW_STATIC
#include <GL/glew.h>
#include <SFML/OpenGL.hpp>
#include <SFML/Window.hpp>
//#include various standard libraries
//some constants
int main() {
sf::Window window(sf::VideoMode(WIDTH, HEIGHT),
"SFML OpenGL",
sf::Style::Default,
sf::ContextSettings(24, 8, 4, 4, 0));
//last two parameters of cont. set. are openGL major and minor versions,
//in this case, OpenGL 4.0
glewExperimental = true;
if (glewInit() != GLEW_OK)
return -1;
bool quite = false;
while (! quit) {
sf::Event event;
while(window.pollEvent(event)) {
if (event.type == sf::Event::Closed)
quit = true;
}
//use sfml keyboard and mouse input stuff
//use sfml clock stuff for timer
//game.update(/*..*/);
//game.render(/*..*/);
window.display();
}
return 0;
}
|
Basically the same thing will work on any IDE, you just have a different GUI for specifying the libs you want to link, and the compiler and linker search directories, and other options.