mhm, it doesn't work, at least not as I expected it to do.
I will explain what's the problem:
The window is a RenderWindow embedded in a wxControl.
First I just tried to draw on it, but it looked like this:
I expected that it looks like this, because the RenderWindow is created(with the Tutorialcode for wxGTK) before wxWidgets adjusts the size of the window(It's in a wxSizer).
So I thought I would have to resize the VideoMode(which was probably wrong) so I asked and tried the following Code:
87 void MappingTool::resizeSFWindow(bool force)
88 {
89 static int width(0), height(0);
90 if(width != GetSize().GetWidth() || height != GetSize().GetHeight() || force)
91 GetDefaultView().SetHalfSize(GetSize().GetWidth()/2.0, GetSize().GetHeight()/2.0);
92 width = GetSize().GetWidth();
93 height = GetSize().GetHeight();
94 }
But now it's looking like this:
(a few pixelrows are cut, but that doesn't matter, but it IS smaller than the first Image)
The first Image shows the upper left corner of the desired image, the second one is extremly shrinked.
So what could it be? How can I show the Image how it should be?
I don't think that you need it, but
here's the DrawingCode:
52 wxPaintDC dc(this);
53
54 sf::Sprite tileset;
55 if(map)
56 {
57
58 if(currentTileset == MainTileset)
59 tileset = ImageList::GetInstance()->GetSpriteByImage(map->GetMainTileset().GetImage());
60 else if(currentTileset >= 0)
61 tileset = ImageList::GetInstance()->GetSpriteByImage(map->GetSideTileset(currentTileset).GetImage());
62 }
63 sf::Shape rectangle(sf::Shape::Rectangle(0, 0, tileset.GetSize().x, tileset.GetSize().y, sf::Color(255, 255, 255, 255)));
64 Draw(rectangle);
65
66 if(map)
67 Draw(tileset);
68
69 Display();
And this is there Code where the Sprite comes from:
201 const sf::Sprite& ImageList::GetSpriteByImage(SFImageID id)
202 {
203 if(spriteIDs[id] == -1)
204 {
205 sf::Sprite sprite(sfImages[id]);
206 sfSprites[id] = sprite;
207 spriteIDs[id] = sfSprites.size() - 1;
208 }
209
210 return sfSprites[id];
211 }
and sfImages[id] is set up here:
65 SpriteID ImageList::addSFImage(bf::path imagePath, std::string subDir)
66 {
67 bf::path ImageDir(copyImageToDirectory(imagePath, subDir));
68
69 std::string filePath((ImageDir/imagePath.leaf()).native_file_string());
70 sf::Image image;
71 image.LoadFromFile(filePath);
72
73 sfImages.push_back(image);
74 spriteIDs[sfImages.size() - 1] = -1;
75
76 return sfImages.size() - 1;
77 }