2D - 20000 Polylines - blinking

I have 20000 polylines to draw, when I make PAN, these redraw are blinking…

I use vector and glVertexPointer(3, GL_DOUBLE, 0, data());

What is the best way to do it?

I’m using glortho with gltranslated.

You probably are not double-buffering. How you enable it depends on your windowing system.

Use double buffering to reduce flicker as cireneikual said.

To increase performance make sure your data uses single-precision floats and change GL_DOUBLE to GL_SINGLE too, since most hardware will need to perform this conversion otherwise. If the data is static, or doesn’t change often then using VBOs can save re-submitting the same data to the GPU every time. Also, make sure your data() call isn’t doing more work than it needs to.

There isn’t a “GL_SINGLE”; for single-precision floats, use GL_FLOAT.

[QUOTE=Dan Bartlett;1251676]Use double buffering to reduce flicker as cireneikual said.

To increase performance make sure your data uses single-precision floats and change GL_DOUBLE to GL_SINGLE too, since most hardware will need to perform this conversion otherwise. If the data is static, or doesn’t change often then using VBOs can save re-submitting the same data to the GPU every time. Also, make sure your data() call isn’t doing more work than it needs to.[/QUOTE]

Hi Dan…

I’m using opengl with MFC, yes, is double buffered. I change double to float, but doesn’t makes diference…

How to use VBO with opengl 1.1? (MFC default)

This is my aproximetely “structure”.


struct POINT
{
double x;
double y;
double z;
}
vector <POINT> test;

//include a lot of vertex

glVertexPointer(3, GL_DOUBLE, 0, test.data());
glDrawArrays(GL_LINE_STRIP,0,test.size());


How to use VBO with opengl 1.1? (MFC default)

MFC has nothing to do with OpenGL. How are you initializing OpenGL? You can use any version of OpenGL your driver supports inside MFC.

You will need to load the OpenGL functions used for buffer objects either yourself or using a loading library (recommended). There are quite a few tutorials out there for using buffer objects especially vertex buffer objects (VBOs).

A good tutorial on modern OpenGL usage is here, with the page introducing buffer objects here. Another tutorial can be found here, with the page about buffer objects here.

If you’re not ready for modern OpenGL (as shaders/VAOs/generic attributes/ etc. all need to be understood before you can start drawing triangles), here’s a couple of older tutorials from Google: OpenGL Vertex Buffer Object (VBO) oZone3D.Net Tutorials - Vertex Buffer Objects - OpenGL VBO - Demo - GL_STREAM_DRAW GL_STATIC_DRAW GL_DYNAMIC_DRAW

A simple adaptation of your code to use VBOs would look something like this (untested):

struct POINT
{
GLfloat x;
GLfloat y;
GLfloat z;
}
vector <POINT> test;
...
// create a single VBO + load data to it
GLuint vbo1;
glGenBuffers(1, &vbo1);
glBindBuffer(GL_ARRAY_BUFFER, vbo1);
glBufferData(GL_ARRAY_BUFFER, test.size() * sizeof(POINT), data(), GL_STATIC_DRAW);

// the combination of the buffer object currently bound to GL_ARRAY_BUFFER & glVertexPointer tells OpenGL
// that the vertex data should be retrieved from offset 0 in vbo1, rather than from a client-side vertex array.
glBindBuffer(GL_ARRAY_BUFFER, vbo1);
glVertexPointer(3, GL_FLOAT, sizeof(POINT), BUFFER_OFFSET(0));
//glColorPointer(...);
//glNormalPointer(...)

glEnableClientState(GL_VERTEX_ARRAY);
glDrawArrays(GL_LINE_STRIP, 0, test.size());

// unbind/disable
glBindBuffer(GL_ARRAY_BUFFER, 0);
glDisableClientState(GL_VERTEX_ARRAY);