I’m developing a small charting control that displays time series data using OpenGL. I’m programming in C++ in Visual Studio.
My control works great. I can zoom, and scroll data using glOrtho. The one problem I have is when I draw rectangles representing some
data every increment in the time series they are not evenly spaced which is not visually appealling (see pic).
I convert my data to floats and display using the following code. Should I use doubles or map my data to pixels using int?
Any suggestions or help is greatly appreciated, thanks.
// increment 't' to represent the next point in the time series
float TIMESHIFT = 0.2f;
glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
glBegin(GL_POLYGON);
/////////////////////////////////////
glVertex2f( t - TIMESHIFT, 0.0);
glVertex2f( t + TIMESHIFT, 0.0);
glVertex2f( t + TIMESHIFT, y);
glVertex2f( t - TIMESHIFT, y);
/////////////////////////////////////
glEnd();