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

Author Topic: [Solved] Sprite Rendering Problem  (Read 1954 times)

0 Members and 2 Guests are viewing this topic.

Rytif

  • Newbie
  • *
  • Posts: 2
    • View Profile
[Solved] Sprite Rendering Problem
« 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:



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

panithadrum

  • Sr. Member
  • ****
  • Posts: 304
    • View Profile
    • Skyrpex@Github
    • Email
[Solved] Sprite Rendering Problem
« Reply #1 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).

Rytif

  • Newbie
  • *
  • Posts: 2
    • View Profile
[Solved] Sprite Rendering Problem
« Reply #2 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!