WhatEver
02-15-2001, 03:44 PM
*I guess the other part of the forum was for hardware and games, not programming http://www.opengl.org/discussion_boards/ubb/wink.gif*
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 http://www.opengl.org/discussion_boards/ubb/frown.gif.
Here's my drawing routine:
void rmdata: http://www.opengl.org/discussion_boards/ubb/biggrin.gifraw(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 http://www.opengl.org/discussion_boards/ubb/frown.gif. 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.
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 http://www.opengl.org/discussion_boards/ubb/frown.gif.
Here's my drawing routine:
void rmdata: http://www.opengl.org/discussion_boards/ubb/biggrin.gifraw(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 http://www.opengl.org/discussion_boards/ubb/frown.gif. 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.