billyquith / GWork

Skinnable GUI with useful widget collection. Fork of GWEN.
https://billyquith.github.io/GWork/
Other
218 stars 30 forks source link

Gwork SDL2 Sample issues(screen is broken) #59

Closed wwforever closed 7 years ago

wwforever commented 7 years ago

I have built and run the GWork SDL2 sample, but the screen is broken like a snapshot. What have I missed? Is there a solution?

gwork_sdl2_sample

wwforever commented 7 years ago

The dll file associated with sdl2_image was copied and the texture was successfully loaded. But the controls do not look right. gwork_sdl2_sample2

billyquith commented 7 years ago

The dll file associated with sdl2_image was copied and the texture was successfully loaded.

The first image looks like it didn't find the skin texture, so I think think the default colour is red.

But the controls do not look right.

Second image shows a (potential) scissoring/clipping bug in SDL2. See #18.

If you have the latest SDL2 and latest Gwork (gwork branch) then this should be fixed and you should no longer see this problem.

wwforever commented 7 years ago

@billyquith Thank you for answer. I am using the latest SDL2 (2.0.5) and the latest GWork. I'll check it again.

wwforever commented 7 years ago
void SDL2::StartClip()
{
    return; //not clip
    const Gwk::Rect &rect = ClipRegion();

    int w, h;
    SDL_GetRendererOutputSize(SDL_GetRenderer(m_window), &w, &h);

    // Something wrong with clip rectangles in SDL2?
    // https://bugzilla.libsdl.org/show_bug.cgi?id=2700
    // =>   clip.y = screenHieght - clip.y - clip.h;
    const SDL_Rect clip = { rect.x, h - rect.y - rect.h, rect.w, rect.h };

    SDL_RenderSetClipRect(m_renderer, &clip);
}

void SDL2::EndClip()
{
    return; //not clip
    SDL_RenderSetClipRect(m_renderer, 0);
}

The source of the GWork I am using is the latest version. After temporarily blocking the clip processing by processing the return from StartClip and EndClip, I have confirmed that it works almost as close to normal. However, you can see that clipping is not working properly.

gwork_sdl2_clip_return

wwforever commented 7 years ago
void SDL2::StartClip()
{
    const Gwk::Rect &rect = ClipRegion();
    const SDL_Rect clip = { rect.x, rect.y, rect.w,rect.h };
    //const Gwk::Rect &rect = ClipRegion();

    //int w, h;
    //SDL_GetRendererOutputSize(SDL_GetRenderer(m_window), &w, &h);

    //// Something wrong with clip rectangles in SDL2?
    //// https://bugzilla.libsdl.org/show_bug.cgi?id=2700
    //// =>   clip.y = screenHieght - clip.y - clip.h;
    //const SDL_Rect clip = { rect.x, h - rect.y - rect.h, rect.w, rect.h };

    SDL_RenderSetClipRect(m_renderer, &clip);
}

I went back to the previous revision of the issue #18 and found that it works fine. It seems to have fixed a bug related to SDL_RenderSetClipRect in the latest version of SDL2 2.0.5.

gwork_sdl2_clip_ok

billyquith commented 7 years ago

Thanks for reporting this. It does indeed appear to not happen any more. I put in a test for versions of SDL2 pre 2.0.5.