I want to implement a timer viewer that allows the user to scale and smoothly pan.
I already did opengl instant mode, but now it is deprecated in favor of VBOs. In all VBOs examples, I can find the XYZ coordinates for storing each point.
I suspect that I need to save all my data in VRAM in order to get the frame rate during panning, which can be called “smooth”, but I only have Y data (dependent variable). X is an independent variable that can be calculated from the index, and Z is a constant. If I need to store X and Z, then my memory requirements (both the buffer size and the CPU-> GPU block transfer) will triple. And I have tens of millions of data points through which the user can pan, so memory usage will be non-trivial.
Is there any method for drawing a 1-D vertex array where the index is used as another coordinate or storing a 1-D array (possibly in a texture?) And using a shader program to generate XYZ? I get the impression that I need a simple shader anyway in the framework of the new model of the pipeline with fixed functionality in order to implement scaling and translation, so if I could combine the generation of X and Z coordinates and Y scaling / translation, which would be ideal .
Is it possible? Do you know any sample code that does this? Or can you at least give me some pseudo-code saying that GL is making the call in what order?
Thank!
EDIT: to make sure this is clear, here is the equivalent immediate mode code and the vertex array code:
glBegin(GL_LINE_STRIP);
for( int i = 0; i < N; ++i )
glVertex2(i, y[i]);
glEnd();
struct { float x, y; } v[N];
for( int i = 0; i < N; ++i ) {
v[i].x = i;
v[i].y = y[i];
}
glVertexPointer(2, GL_FLOAT, 0, v);
glDrawArrays(GL_LINE_STRIP, 0, N);
, v[] y[].