SFML community forums

Help => Graphics => Topic started by: Rytif on August 11, 2010, 09:41:13 pm

Title: [Solved] Sprite Rendering Problem
Post by: Rytif on August 11, 2010, 09:41:13 pm
Hello, I'm loading a 1024x1024 tilemap that is divided into 16x16 tiles. Each tile is drawn with the sf::Sprite using a subrect of the tilemap. All tiles are being retrieved correctly, but the quality of the tiles are very low. Here is the difference between the sfml (left) and c# gdi+ (right) versions:

(http://img683.imageshack.us/img683/4798/renderingproblem.png)

It looks like maybe the tiles are being stretched or it could be something with my window settings.

Code: [Select]


         tile->sprite.SetImage(tileMap->GetTexture());
 
         sf::IntRect rect;

/* Set position */
tile->sprite.SetPosition((float)(tile->column * tileWidth), (float)(tile->row * tileHeight));

/* Grab the tile definition from the tilemap */
int tileRow = tile->index / tilesPerRow;
int tileColumn = tile->index % tilesPerRow;

rect.Left = tileColumn * tileWidth;
rect.Right = (tileColumn * tileWidth) + tileWidth;
rect.Top = tileRow * tileHeight;
rect.Bottom = (tileRow * tileHeight) + tileHeight;

tile->sprite.SetSubRect(rect);


Code: [Select]


/* Initialize window */
sf::WindowSettings settings;
settings.DepthBits         = 24; // Request a 24 bits depth buffer
settings.StencilBits       = 16;  // Request a 8 bits stencil buffer
settings.AntialiasingLevel = 2;  // Request 2 levels of antialiasing

window = new RenderWindow(
VideoMode(Globals::ScreenWidth,
Globals::ScreenHeight, 32), "Game Window",
sf::Style::Close, settings);



I'd appreciate any help on this.

Thanks
Title: [Solved] Sprite Rendering Problem
Post by: panithadrum on August 11, 2010, 09:54:51 pm
Your problem is that sf::Image::SetSmooth(bool) is true by default.

Write tileMap->GetTexture().SetSmooth(false).
Title: [Solved] Sprite Rendering Problem
Post by: Rytif on August 11, 2010, 10:11:46 pm
Quote from: "panithadrum"
Your problem is that sf::Image::SetSmooth(bool) is true by default.

Write tileMap->GetTexture().SetSmooth(false).


That was the problem, thanks!