Archived

This topic is now archived and is closed to further replies.

pacrugby

glDrawElements error

Recommended Posts

pacrugby    122
Ive been using vertex/index arrays and they have been working great. I have recently having a problem that I cannot find the solution for. info: V6.0C++ Win2000 I load my a large 3d array of points all spaced evenly apart and use the info I have to draw xy yz xz sections through my data. I can draw my xy planes with no problem. I have all my data stored in vectors. and I just set up a new index vector to draw my planes. Plane ex is drawn like this:
  
for(i= 0;i<30;i++)
{		
for(int j = 0;j<40;j++)
{
planedata.index.push_back(databox.Index[j+i*41]);
planedata.index.push_back(databox.Index[j+41+i*41]);		
planedata.index.push_back(databox.Index[j+1+41+i*41]);
planedata.index.push_back(databox.Index[j+1+i*41]);
		 }
	 }
  
I draw the xz plane like this.(same way different index)
  
 for(i= 0;i<30;i++)
	 {		
		 for(int j = 0;j<30;j++)
		 {
planedata2.index.push_back(databox.Index[i*41+j*1271]);
planedata2.index.push_back(databox.Index[i*41+41+j*1271]);
planedata2.index.push_back(databox.Index[i*41+41+1271+j*1271]);
planedata2.index.push_back(databox.Index[i*41+1271+j*1271]);
}
}
  
I the second plane fails when I call glDrawElements. I norrowed it down to failure drawing the 4th quad but I used "TRACE" to look at all the data and it is fine. The error I get is: First-chance exception in ExamineStereo3d.exe (WCGICD.DLL): 0xC0000005: Access Violation. Sorry about the long message, any help would be great! TIA

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
Hi,

glDrawElements causes me major headaches, but it now works for me fine.

Can you post your glDrawElements call pls?

Share this post


Link to post
Share on other sites
pacrugby    122
here are my calls:
  
void CMainFrame::BuildBox()
{
glNewList(DATABOX1,GL_COMPILE);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_INDEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, m_readdata.databox.COORD.begin () );
glIndexPointer(GL_UNSIGNED_INT,0,m_readdata.planedata.index.begin());
glTexCoordPointer(1,GL_FLOAT,0,m_readdata.databox.sig1.begin () );
glDrawElements(GL_QUADS,m_readdata.planedata.index.size(),GL_UNSIGNED_INT, m_readdata.planedata.index.begin());//this one works fine

glEndList();


glNewList(DATABOX2,GL_COMPILE);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_INDEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, m_readdata.databox.COORD.begin ());
glIndexPointer(GL_UNSIGNED_INT,0,m_readdata.planedata2.index.begin());
glTexCoordPointer(1,GL_FLOAT,0,m_readdata.databox.sig1.begin ());
glDrawElements(GL_QUADS,m_readdata.planedata2.index.size(),GL_UNSIGNED_INT, m_readdata.planedata2.index.begin());//it fails HERE!

glEndList();
}

Share this post


Link to post
Share on other sites