'Is there any way to draw line by it's center in OpenGL?

I'm making a class that draws axis for a graph. And the result should look like this:

enter image description here

And I want to draw lines which represents scale by only passing the coords of their centers, length and orientation (vertical or hoisontal) to vertex shader by calling glDrawArrays(). Is the any way to do this?

enter image description here

I have been searching for hours, but only way of drawing lines I found is to call glDrawArrays() with GL_LINES and pass an array of lines begin and end coords.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source