diff --git a/common/gal/graphics_abstraction_layer.cpp b/common/gal/graphics_abstraction_layer.cpp index 13d79fd09c..ddcb76309f 100644 --- a/common/gal/graphics_abstraction_layer.cpp +++ b/common/gal/graphics_abstraction_layer.cpp @@ -230,18 +230,10 @@ void GAL::DrawGrid() // Correct the index, else some lines are not correctly painted gridStartY -= std::abs( gridOrigin.y / gridSize.y ) + 1; - gridEndY += std::abs( gridOrigin.y / gridSize.y ) + 1; + gridEndY -= std::abs( gridOrigin.y / gridSize.y ) - 1; - if( gridStartX <= gridEndX ) - { - gridStartX -= std::abs( gridOrigin.x / gridSize.x ) + 1; - gridEndX += std::abs( gridOrigin.x / gridSize.x ) + 1; - } - else - { - gridStartX += std::abs( gridOrigin.x / gridSize.x ) + 1; - gridEndX -= std::abs( gridOrigin.x / gridSize.x ) + 1; - } + gridStartX -= std::abs( gridOrigin.x / gridSize.x ) + 1; + gridEndX -= std::abs( gridOrigin.x / gridSize.x ) - 1; int dirX = gridEndX >= gridStartX ? 1 : -1; int dirY = gridEndY >= gridStartY ? 1 : -1; @@ -273,8 +265,8 @@ void GAL::DrawGrid() if( ( j % gridTick == 0 && gridScreenSizeCoarse > gridThreshold ) || gridScreenSizeDense > gridThreshold ) { - drawGridLine( VECTOR2D( gridStartX * gridSize.x, y ), - VECTOR2D( gridEndX * gridSize.x, y ) ); + drawGridLine( VECTOR2D( gridStartX * gridSize.x + gridOrigin.x, y ), + VECTOR2D( gridEndX * gridSize.x + gridOrigin.x, y ) ); } } @@ -294,8 +286,8 @@ void GAL::DrawGrid() if( ( i % gridTick == 0 && gridScreenSizeCoarse > gridThreshold ) || gridScreenSizeDense > gridThreshold ) { - drawGridLine( VECTOR2D( x, gridStartY * gridSize.y ), - VECTOR2D( x, gridEndY * gridSize.y ) ); + drawGridLine( VECTOR2D( x, gridStartY * gridSize.y + gridOrigin.y ), + VECTOR2D( x, gridEndY * gridSize.y + gridOrigin.y ) ); } } } diff --git a/common/gal/opengl/opengl_gal.cpp b/common/gal/opengl/opengl_gal.cpp index f48794f4ec..a9cda632a9 100644 --- a/common/gal/opengl/opengl_gal.cpp +++ b/common/gal/opengl/opengl_gal.cpp @@ -988,18 +988,10 @@ void OPENGL_GAL::DrawGrid() // Correct the index, else some lines are not correctly painted gridStartY -= std::abs( gridOrigin.y / gridSize.y ) + 1; - gridEndY += std::abs( gridOrigin.y / gridSize.y ) + 1; + gridEndY -= std::abs( gridOrigin.y / gridSize.y ) - 1; - if( gridStartX <= gridEndX ) - { - gridStartX -= std::abs( gridOrigin.x / gridSize.x ) + 1; - gridEndX += std::abs( gridOrigin.x / gridSize.x ) + 1; - } - else - { - gridStartX += std::abs( gridOrigin.x / gridSize.x ) + 1; - gridEndX -= std::abs( gridOrigin.x / gridSize.x ) + 1; - } + gridStartX -= std::abs( gridOrigin.x / gridSize.x ) + 1; + gridEndX -= std::abs( gridOrigin.x / gridSize.x ) - 1; int dirX = gridStartX >= gridEndX ? -1 : 1; int dirY = gridStartY >= gridEndY ? -1 : 1; @@ -1074,8 +1066,8 @@ void OPENGL_GAL::DrawGrid() || gridScreenSizeDense > gridThreshold ) { glBegin( GL_LINES ); - glVertex2d( gridStartX * gridSize.x, y ); - glVertex2d( gridEndX * gridSize.x, y ); + glVertex2d( gridStartX * gridSize.x + gridOrigin.x, y ); + glVertex2d( gridEndX * gridSize.x + gridOrigin.x, y ); glEnd(); } } @@ -1104,8 +1096,8 @@ void OPENGL_GAL::DrawGrid() || gridScreenSizeDense > gridThreshold ) { glBegin( GL_LINES ); - glVertex2d( i * gridSize.x + gridOrigin.x, gridStartY * gridSize.y ); - glVertex2d( i * gridSize.x + gridOrigin.x, gridEndY * gridSize.y ); + glVertex2d( x, gridStartY * gridSize.y + gridOrigin.y ); + glVertex2d( x, gridEndY * gridSize.y + gridOrigin.y ); glEnd(); } }