Please help me understand CVAs

I guess the other part of the forum was for hardware and games, not programming

I can use CVAs to a point, but not to their fullest.

I have a function that removes any shared vertices from my vertex array, and all the other arrays like colors, normals, and uv coords; the problem is that if I do that, my normal, color, and texture array elements aren’t aligned any more. How can I fix that? For now I have nPolygons*3 worth of all arrays. It’s really slow .

Here’s my drawing routine:

void rmdata: [img]http://www.opengl.org/discussion_boards/ubb/biggrin.gif[/img]raw(rmdescriptor* Descriptor, GLuint* TextureNames, bool UseSN)
{
	if(!Descriptor)
	{
		return;
	}

	GLuint ColorOld=512, ColorNew=0;

	glEnableClientState(GL_VERTEX_ARRAY);
	glVertexPointer(3, GL_FLOAT, 0, Vertices);

	if(Descriptor->States & RM_NORMAL_ARRAY)
	{
		glEnableClientState(GL_NORMAL_ARRAY);
		glNormalPointer(GL_FLOAT, 0, Normals);
	}
	else
	{
		glDisableClientState(GL_NORMAL_ARRAY);
	}

	if(Descriptor->States & RM_TEXTURE_COORD_ARRAY)
	{
		glEnableClientState(GL_TEXTURE_COORD_ARRAY);
		glTexCoordPointer(2, GL_FLOAT, 0, Descriptor->UVcoords);
	}
	else
	{
		glDisableClientState(GL_TEXTURE_COORD_ARRAY);
	}
	
	if(Descriptor->States & RM_COLOR_ARRAY)
	{
		glEnableClientState(GL_COLOR_ARRAY);
		glColorPointer(3, GL_FLOAT, 0, Descriptor->Colors);
	}	
	else
	{
		glDisableClientState(GL_COLOR_ARRAY);
	}

	if(glLockArraysEXT)
		glLockArraysEXT(0, nVertices);

	rmPolygonCount+=Descriptor->nPolygons;

	for(GLuint i=0; i<Descriptor->nPolygons; i++)
	{
		if(Descriptor->States & RM_TEXTURE_COORD_ARRAY && Descriptor->TextureNames[i] != 255)
		{
			ColorNew=TextureNames[Descriptor->TextureNames[i]];
		}
		else
		{
			ColorNew=0;
		}

		if(ColorOld!=ColorNew && UseSN)
		{
			glBindTexture(GL_TEXTURE_2D, ColorNew);
			ColorOld=ColorNew;
		}

		glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_INT, Descriptor->VertexIndices[i]);
		//glDrawArrays(GL_TRIANGLES, 0, 1);
	}
	//glDrawArrays(GL_TRIANGLES, 0, Descriptor->nPolygons*3);

	if(glUnlockArraysEXT)
		glUnlockArraysEXT();

}

Please help me. I’ve asked about this questions here and there a million times, but no one has the answers. I’ve read documents, tutorials, I even have the Red Book…still I don’t get it . Also, can you explain in english what glLockArraysEXT(); and glUnlockArraysEXT(); does? If I could make sence of some of this I could get started making a better model library.

You can’t. To remove duplicates, you have to
consider all elements (vertex, normal, color)
and only treat an index as duplicate if all
three are the same (could be more than three
depending on what arrays you use).

And WRT glLockArraysEXT, this allows a driver
to assume that you won’t change the data
pointed at by the array pointer, so it can
go ahead and pre-compute transforms for the
array, DMA it onto the card, or whatever else
might make using the arrays faster.

However, I would expect the big win from
glLockArraysEXT to come if you’re re-using
geometry, i e drawing the same array with a
bunch of different textures (light maps,
shadow maps, detail maps, what have you).

I have a CVA example on my website.
Pretty big explanation of how they should be used in the top of the source file too.
www.nutty.org

  • Nutty

Thank you! I get it now! I’ll have to modify my source code to remove any shared elements instead of individual things.

I understand the CVAs now, to. I think. So, if I want to do something like multitextureing, CVAs would make it possible to not translate the same vertex more than once? Is there any other way to speed things up besides that? I heard about register combiners; is that just another name for CVAs, or is it something else that also speeds up multitexturing?

Thank you generous hosts

Register Combiners have nothing to do with CVA’s. They’re a kind of pixel shader, that operates in hardware, on the per pixel level on Geforce and upwards cards.

  • Nutty

Are there any tutorials on how to do register combiners anywhere? I’d like to check that out .