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

Closed
Bertram25 opened this Issue Jul 24, 2012 · 3 comments

1 participant

@Bertram25
Valyria Tear member

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:
http://www.youtube.com/watch?v=hH81ZmuX7AU
http://www.youtube.com/watch?v=hXrCiFoY8K4

@Bertram25
Valyria Tear member

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: https://github.com/Bertram25/ValyriaTear/blob/master/src/engine/video/image.cpp#L533 The bug might come from the system used to compute the textures or the vertices array.
@Bertram25
Valyria Tear member

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.

@Bertram25
Valyria Tear member

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);
}
@Bertram25 Bertram25 pushed a commit that closed this issue Nov 29, 2012
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
47f394d
@Bertram25 Bertram25 closed this in 47f394d Nov 29, 2012
@IkarusDowned IkarusDowned referenced this issue in IkarusDowned/ValyriaTear Mar 30, 2013
@IkarusDowned 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!
b7b92e6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment