Ignore offscreen segments.
This commit is contained in:
parent
efb0f93062
commit
c27055f8d0
1 changed files with 15 additions and 9 deletions
|
@ -112,24 +112,30 @@ namespace cloonel {
|
|||
LineBase scaledLine(*this);
|
||||
scaledLine += static_cast<short2>(parPos);
|
||||
scaledLine *= parScaling;
|
||||
const short2 wh(static_cast<short2>(m_sdlmain->WidthHeight()));
|
||||
{
|
||||
SDL_Rect screen;
|
||||
screen.x = screen.y = 0;
|
||||
const short2 wh(static_cast<short2>(m_sdlmain->WidthHeight()));
|
||||
screen.w = wh.x();
|
||||
screen.h = wh.y();
|
||||
|
||||
ClipLine(screen, scaledLine);
|
||||
}
|
||||
const int16_t h = static_cast<int16_t>(m_sdlmain->WidthHeight().y());
|
||||
|
||||
if (scaledLine[0] != scaledLine[1]) {
|
||||
SDL_RenderDrawLine(
|
||||
m_sdlmain->GetRenderer(),
|
||||
scaledLine[0].x(),
|
||||
h - scaledLine[0].y(),
|
||||
scaledLine[1].x(),
|
||||
h - scaledLine[1].y()
|
||||
);
|
||||
const bool isOnScreen = scaledLine[0] >= short2(0) and scaledLine[0] < wh and
|
||||
scaledLine[1] >= short2(0) and scaledLine[1] < wh;
|
||||
|
||||
if (isOnScreen) {
|
||||
const int16_t h = static_cast<int16_t>(m_sdlmain->WidthHeight().y());
|
||||
SDL_RenderDrawLine(
|
||||
m_sdlmain->GetRenderer(),
|
||||
scaledLine[0].x(),
|
||||
h - scaledLine[0].y(),
|
||||
scaledLine[1].x(),
|
||||
h - scaledLine[1].y()
|
||||
);
|
||||
}
|
||||
}
|
||||
//Returns 0 on success or a negative error code on failure; call SDL_GetError() for more information.
|
||||
//http://www.ginkgobitter.org/sdl/?SDL_RenderDrawLine
|
||||
|
|
Loading…
Reference in a new issue