render optimization question

Hi guys,

at the moment i have about 3000 Points in about 5500 triangles and my System (Athlon 2000, 64mb gfx card) slow down when my openGL window has to display them.
The big trouble is that i need to display alot of more points in the future

I have all Points and triangles stored in two vector.

When i render the scene i do the following:

std::vector<std::vector<double> > MyMeshPoints = controller->m_Datas.getMeshPoints();
std::vector<std::vector<double> > MyMeshTriangles = controller->m_Datas.getMeshTriangles();
int iAmountMeshTriangles = MyMeshTriangles.size();

	int l,m,n;
	glColor4f (0.0, 0.0, 0.4,0.5);
	glPolygonMode(GL_FRONT, GL_LINE);
	for (int k=0; k&lt;iAmountMeshTriangles; k++)
			l = MyMeshTriangles[k][0];
			m = MyMeshTriangles[k][1];
			n = MyMeshTriangles[k][2];
			GLfloat iPointx = convertRechengebietX_ToOpenGL(MyMeshPoints[l][1]);
			GLfloat iPointy = convertRechengebietY_ToOpenGL(MyMeshPoints[l][2]);
			iPointx = convertRechengebietX_ToOpenGL(MyMeshPoints[m][1]);
			iPointy = convertRechengebietY_ToOpenGL(MyMeshPoints[m][2]);

			iPointx = convertRechengebietX_ToOpenGL(MyMeshPoints[n][1]);
			iPointy = convertRechengebietY_ToOpenGL(MyMeshPoints[n][2]);


It would be nice if someone could give me some hints, what i could do to improve my code.

And a second simple question.
I have the possibility to zoom and scroll inside my openGL window.I do it by recalculating all points and redrawing the scene every time.
Is there a better solution?

thx in advance
daSickboy [daNoob]

Hi !

I don’t think the performance problem has much to do with OpenGL, first of all you should have a look at convertRechengebietX/Y_ToOpenGL(), is this an inline function ? does it do something complex ?

Try to preprocess your data in some way so that you don’t have to do it over and over again for each frame if you don’t need to.

To get faster OpenGL rendering you need to put your vertex data in memory that can be accessed by the GPU, use display lists or vertex buffers.

A few hundred thousands of vertices should not be a big problem to handle.



That´s my function to convert the point values for displaying.

float COpenGL::convertRechengebietX_ToOpenGL(double RechengebietX)
int offset = controller->iXOffset;
int zoom = controller->iZoom;
double width = controller->width;
float result = ( (( RechengebietX - offset) *iZoom) / (width)) *2 - 1.0;
return result;

Do you think it would help in this case to use a display list you mentioned?


also move the glBegin()…glEnd() out of the loop, you are calling them 5500 times, no wonder things are slowing down