Displaylists

I’ve got a strange Problem with using Displaylists:

This piece of Code works (lets call it manuell-index-picking)

if(Nyx.drawstyle.mode == DRAWSTYLE_MODE_POINTS)
{
	for(int i = 0; i < indexLIST->lenght; i++)
	{

		unsigned short index = indexLIST->indexlist[i];

		glBegin(GL_POINTS);

		glVertex3f(vtxLIST->ArrayPOSITION[index].x,
				   vtxLIST->ArrayPOSITION[index].y,
				   vtxLIST->ArrayPOSITION[index].z);

		glEnd();
		
	}
}

But Dislaylists just display strange Coordinates… Its ****ed up.

if(Nyx.drawstyle.mode == DRAWSTYLE_MODE_DISPLAYLISTS)
{
	glVertexPointer(3, 
					GL_FLOAT, 
					sizeof(float)*3, // irrelevant, da highly packed. kann auch 0 sein
					(const GLvoid*) &vtxLIST->ArrayPOSITION);

	glEnableClientState(GL_VERTEX_ARRAY);
	
	glDrawElements(GL_POINTS, 
				   indexLIST->lenght,
				   GL_UNSIGNED_SHORT,
				   indexLIST->indexlist);

	glDisableClientState(GL_VERTEX_ARRAY);
}

VEKTOR is a structure with 3 coordinates, indexlist is an unsigned short* containing the indeces…

plz help, id relly need this up to tomorow morning!

greetings,
Matthias Markowski

What you are using here is called vertex arrays, not display lists.

I think the vertex pointer you give is invalid. vtxLIST->ArrayPOSITION should be enough (no need to place the & before).

You mean vertex arrays, not display lists?

Try (const GLvoid*) &(vtxLIST->ArrayPOSITION[0].x).

Assert that the stride is really what you think:
assert(sizeof(float) * 3 == (char *) &(vtxLIST->ArrayPOSITION[1].x) - (char *) &(vtxLIST->ArrayPOSITION[0].x));

Performance tip: Move the glBegin(GL_POINTS) glEnd() outside the for loop and use the vector version glVertex3fv if the xyz are tightly packed anyway.

(Double post :slight_smile: )