Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Map Mode: Map tiles are incorrectly drawn on screen #2

Bertram25 opened this Issue · 3 comments

1 participant

Yohann Ferreira
Yohann Ferreira

This is happening with smooth and normal rendering, and is thus a problem in the position computation of the tiles.

Note that:

  • The VideoManager is handling left center/right top/center/bottom auto placement of graphical objects and that could come in the way
  • The map layer coordinate algorithm (UpdateMapLayer) is using a custom pixel-perfect coord computation which might be in cause.
  • The view used in the map mode is quite different from all the other modes (32 x 24 vs 1024x768).
  • Map tiles should also be rendered on some buffer image without any smoothing before being rendering on screen using a potential smoothing method to avoid yet other graphical tile glitches.

Video showing the bug, kindly made by qubodup:

Yohann Ferreira

Additional notes:

  • it appeared that setting the coord system to top,left alignement seems to fix the problem on Win XP at least, but not on linux, for instance.
  • I also noticed that the wood floor tiles were not misplaced but in fact the texture part drawn is shifted one pixel up from the middle tile y line to the end. Moving the character is indeed changing the tiles present there, making the bug visible. I look into the quad drawing routine (void ImageDescriptor::_DrawTexture(const Color* draw_color) const) , but I'd take some help here: The bug might come from the system used to compute the textures or the vertices array.
Yohann Ferreira

As the map mode is being rewritten to use the standard coord system (0-1024 - 0-768), the pixel size should be less proeminent after that rewrite.
The actual solution to close this issue is to use a FBO if possible and draw all the tiles without smoothing there), and then draw the FBO smoothed on screen.

Yohann Ferreira

I have found that the code of VideoEngine::SetViewport() is very weird for a simple operation.
I'll try simplifying it and look at what it does under linux.
Note to self:
Replace it by this for the test:

void VideoEngine::SetViewport(float left, float right, float bottom, float top)
    int32 l = 0;
    int32 b = 0;
    int32 r = _screen_width;
    int32 t = _screen_height;

    _current_context.viewport = ScreenRect(l, b, r, t);
    glViewport(l, b, r, t);
Yohann Ferreira Bertram25 closed this issue from a commit
Yohann Ferreira Finally ... Fixed certain tiles not correctly drawn in the map mode.
Found an off-by-one offset in the glViewport() calls.
I also reduced the glTranslate() calls offset to make it more compliant
with the actual pixel size in that mode.

I might not be perfect but at least the floor problem seen in the video
is gone both on Windows and on Linux, as for me, at least.

Closes #2
Yohann Ferreira Bertram25 closed this in 47f394d
Nik N IkarusDowned referenced this issue from a commit in IkarusDowned/ValyriaTear
Nik N IkarusDowned passive effects from equipment applied
equipment now gives "passive" application of status to your character!
An easy way to try this out is to simply add a extreme strength modifier
to the Arbalest, and watch Kayla do some SERIOUS damage!
endoalir endoalir referenced this issue from a commit in endoalir/ValyriaTear
endoalir endoalir Fixed indexing issues with battle items 788e685
endoalir endoalir referenced this issue from a commit in endoalir/ValyriaTear
endoalir endoalir Fixed indexing issues with battle items b25745b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.