Ignore offscreen segments.

This commit is contained in:
King_DuckZ 2014-09-04 12:14:31 +02:00
parent efb0f93062
commit c27055f8d0

View file

@ -112,24 +112,30 @@ 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]) {
SDL_RenderDrawLine( const bool isOnScreen = scaledLine[0] >= short2(0) and scaledLine[0] < wh and
m_sdlmain->GetRenderer(), scaledLine[1] >= short2(0) and scaledLine[1] < wh;
scaledLine[0].x(),
h - scaledLine[0].y(), if (isOnScreen) {
scaledLine[1].x(), const int16_t h = static_cast<int16_t>(m_sdlmain->WidthHeight().y());
h - scaledLine[1].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. //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