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