Hi guys,
I am trying to draw an axis for a 2d-plot.
Specifically I am trying to draw the ticks on that axis.
Unfortunately I ran into some precision problems. As soon as the range between min and max exceeds single precision (32 bit float)
the ticks are fucked up or all drawn at the same position.
Example: m_NiceMin = 1.1111111 and m_NiceMax = 1.1111112
In double precision there is no problem, in single precision it is all 1.1111112 and therefore drawn in the same place.
Here is my code. Hope you can help me out.
// Set drawing area
_u32 AxisWidth = m_ControlRect.Width() - 2*BorderSize - YAxisWidth;
glViewport(BorderSize + YAxisWidth, // X0
BorderSize, // Y0
AxisWidth, // Width
m_BaseSize + AxisTitleSize // Height
);
glLoadIdentity();
glOrtho(m_NiceMin, m_NiceMax, 0, 1, -1, 1);
// Draw the ticks on the right side of the axis
double CurrentTick = m_NiceMin + m_TickSpacing;
for (_u32 i = 1; i < Ticks; i++)
{
// Draw tick line
glBegin(GL_LINE_STRIP);
glVertex2d(CurrentTick, 1);
glVertex2d(CurrentTick, 0.8);
glEnd();
CurrentTick += m_TickSpacing;
}