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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Trijames

Pages: [1]
1
General / Problems with linking SFML2 static
« on: May 10, 2011, 04:51:48 pm »
Quote from: "Laurent"
Quote
I set CMake like this and have tried doing everything from scratch with and without FORCE_STATIC_VCRT: http://i.imgur.com/LFbt5.jpg

The variable that controls static/dynamic builds is BUILD_SHARED_LIBS, not FORCE_STATIC_VCRT.
If you think it's not clear enough in the tutorial, let me know how I could improve it ;)


 :oops: I understood it while re-reading the tutorial and was going to delete my post.

I think the tutorial is clear enough with this line:
Quote
This boolean option controls whether you build the dynamic (shared) libraries of SFML, or the static ones.

it was just me being careless. thanks :oops:

one thing I could add is that in the 2.0 documentation there is the doc for GetEvent but in reality it's called in another way (PoolEvent I think?)

2
General / Problems with linking SFML2 static
« on: May 10, 2011, 04:43:26 pm »
Hi, I also have some problems with compiling SFML2 static libraries.

I hope to not be doing any confusion with terms, what I mean is that I used to link -s files with 1.6 because I didn't want to copy the DLLs in the exe dirs.

Anyway, here's my problem:

I've downloaded the SFML2 tarball from GitiHub then followed this tutorial to get Visual C++ 2010 solution files etc.

I set CMake like this and have tried doing everything from scratch with and without FORCE_STATIC_VCRT: http://i.imgur.com/LFbt5.jpg (Actually I did build the examples)

In the output directory there are only the following files:
Quote
sfml-*-d-2.dll
sfml-*-d.lib

sfml-*-d.exp
sfml-*-d-2.ilk
sfml-*-d-2.pdb

(and the same as above without -d for Release)

Now, unless I'm mistaken the un-bolded ones are garbage from the compiler and can be ignored.

The problem is that I'm not getting any *-s files to be linked in my projects. If I link normal DLLs the code gets compiled but when I open the executable I get a missing DLL error. Also I have defined SFML_STATIC in my code.

3
Graphics / Can't get the map tiles' image to draw
« on: May 07, 2011, 04:28:03 pm »
Quote from: "Laurent"
Why don't you use the class member directly? You don't need to create another sf::Image instance.

Code: [Select]
  if (!Image.LoadFromFile("../img.png")) {
      std::cout << "Could not load file: ../img.png" << std::endl;
      return false;
   }


Ehrrr. I feel so stupid for not having thought of that :lol: works great, thanks. Au revoir!

4
Graphics / Can't get the map tiles' image to draw
« on: May 07, 2011, 03:49:12 pm »
You're right, I think that is because I used the same name for both the objects, do you think that doing this makes sense?

Code: [Select]
// in Load()
sf::Image Img;
if (!Img.LoadFromFile("../img.png")) {
std::cout << "Could not load file: ../img.png" << std::endl;
return false;
}
//set the class member Image to the newly declared Img
Image = Img;
// destroy Img after this


This works, but I'm not sure if it makes sense to do something like this. i'm sure there is something I'm missing.

5
Graphics / Can't get the map tiles' image to draw
« on: May 07, 2011, 03:27:57 pm »
Quote from: "Laurent"
The sf::Image instance that you use doesn't exist anymore when the sprites are drawn, that's why it doesn't show.

You must keep the image as a member of your class, so that it's kept alive as long as the sprites use it.

Thanks for the quick reply,
I'm not sure to get what you mean.

I do have a declaration of the Image object in my class header file:
Code: [Select]
class Map {
   //....
   private:
         //...
         sf::Image Image;
         //...
}


So the sf::Image object should be stored as a member of the class and available when it's drawn later... or not?

Hope this makes sense.

**** Disregard that, I set the Image object as static in my Load() function and the images are displaying now :D .

6
Graphics / Can't get the map tiles' image to draw
« on: May 07, 2011, 03:03:23 pm »
Hi there,
I'm a hobbyist programmer and SFML beginner, I've done some easy project in the past like pong, now I'm trying to write a map system for more advanced games.
I'm just started with it but have already encountered a problem: apparently the tile sprites are drawn but not the image I set to them.

I have a Load() function which works like a constructor for my Map class, basically it should fill the "tiles" vector with stuff for testing since I haven't done a map reading/writing system yet. In this function I have an Image var and I set it with Image.LoadFromFile() like this:
Code: [Select]
sf::Image Image;
if (!Image.LoadFromFile("../img.png")) {
std::cout << "Could not load file: ../img.png" << std::endl;
return false;
}


then I have the loop which "creates" the sprites and sets them to the tiles vector, like this:
Code: [Select]
for (int i = 0; i < 255; i++) {
sf::Sprite Sprite;
Sprite.SetImage(Image);
Sprite.SetPosition(x * tileWidth, y * tileHeight);
Sprite.SetColor(sf::Color(200,100,100,255));

tiles.push_back(Sprite);
}


I have this which I call in the main loop between RenderWindow.Clear() and RenderWindow.Display() to draw stuff on screen:
Code: [Select]
void Map::Draw(sf::RenderWindow &window) {
for (int tile = 0; tile < tiles.size(); tile++) {
window.Draw(tiles[tile]);
}
}


For some reason the tiles are displayed as pink-ish squares (the 200,100,100 RGB color I set in the code) but the image is not displayed.

I'm using Microsoft Visual C++ 2010 and have read this thread but it seems not to be my case.

What am I doing wrong and can anyone reccomend me any kind of reference for a project like this? Thank you.

Pages: [1]
anything