Not logged inGosu Forums
Forum back to libgosu.org Help Search Register Login
Up Topic Gosu / Gosu Exchange / Isometric tile map rendering problem
- - By siondream Date 2011-11-20 23:03
Hello everyone.

I'm creating a little isometric arcade game and I'm having problem zooming my map in/out because some weird lines appear bordering each tile. You can look at the attached pictures for details on the problem [1] [2].

Here you have my code:

Level construction:

// Load tileset
Gosu::imagesFromTiledBitmap(graphics(),  Gosu::sharedResourcePrefix() + L"data/" + Gosu::utf8ToWstring(tilesetName),  _tileWidth,  _tileHeight, true, _tiles);


Level drawing:


// Drap map
int x, y;
int offsetX = (_screenWidth - _tileWidth * _mapWidth) / 2.0f;
int offsetY = _screenHeight / 2.0f;

for (int i = 0; i < _mapHeight; ++i) {
  for(int j = _mapWidth - 1; j >= 0; --j) {
    x = offsetX + ((j * _tileWidth / 2.0f) + (i * _tileWidth / 2.0f)) * _zoom;
    y = offsetY + ((i * _tileHeight / 2.0f) - (j * _tileHeight / 2.0f)) * _zoom;
    _tiles[_map[i * _mapHeight + j]]->draw(x, y, 0, _zoom, _zoom);
  }
}


Do you know what's wrong with the rendering? I have already tried playing with the blending mode.

Thanks!

[1] http://i1194.photobucket.com/albums/aa368/siondream/isometric-1.png
[2] http://i1194.photobucket.com/albums/aa368/siondream/isometric-2.png
Parent - - By jlnr (dev) Date 2011-11-20 23:41
I guess this is because the bilinear interpolation applied by OpenGL bleeds some black into the tiles. The easiest solution is to make the tiles a bit bigger than they have to be. The CptnRuby.rb example does the same (the C++ version is available as CptnCpp on Github).

If you are after a retro style anyway, you can disable bilinear filtering with this hack, (There will be a proper option to do this later.)

namespace Gosu {
    // Call this function before creating any Image
    void enableUndocumentedRetrofication() { extern bool undocumentedRetrofication; undocumentedRetrofication = true; }
}
Parent - - By siondream Date 2011-11-20 23:47
I have added:

Gosu::enableUndocumentedRetrofication();

Apparently the function doesn't exists, it's weird because I have #include <Gosu/Gosu.hpp> but it's not in the docs either.
Parent - - By jlnr (dev) Date 2011-11-20 23:59
You are have to copy the snippet above into your code. It's not an official feature yet.
Parent - - By siondream Date 2011-11-21 00:09
Sorry, that was stupid of me. About the black pixels problem, it's not fixed yet...

http://i1194.photobucket.com/albums/aa368/siondream/isometric-3.png
Parent - - By Spooner Date 2011-11-21 00:51
I am making an isometric game with retrofication right now too, though in Ruby/Gosu. You need to ensure that you have a regular zoom level or you will get artifacts like that. I just move through 0.25, 0.5, 1.0, 2.0, 4.0 zoom as the mouse wheel is turned and there are never artefacts of that kind, but there are at irregular zooms.
Parent - By siondream Date 2011-11-21 00:56
It worked, thanks!
Up Topic Gosu / Gosu Exchange / Isometric tile map rendering problem

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill