Vanilla Vertex Arrays Crash For No Reason.
Hi all,
FYI, im running XPSP2, VC2003.NET, Radeon 9500 Pro, Cat 4.9. and im using C++ and nVidia's Cg 1.2
so here's the problem:
when i load my terrain data as triangles it crashes when i render. the error is to the tune of "Access Violation 0x0000005 when attempting to read location 0x00000000"
now the obvious thing there is to check that i'm not passing in any null pointers, i did. i disabled everything but vertex arrays and rendered, still got the problem.
next thing i checked was that verticies and tc's etc were valid, they were. then i checked that all my indices were in range... and they are.
odd stuff:
there are around 7900 polygons, so ~23000 verts.. but when i render LESS than 5913 verticies ie. glDrawElements( GL_TRIANGLES, 5912, ... ) it renders without crashing.
i check the index values for indicies past 5912, they are all valid.
if you need code, i can supply, i can't really describe the problem any more than that until anyone wants some specifics.
Thanks in Advance,
Danu
To make things interesting....
if i break the glDrawElements call into a loop
ie. instead of
WTF.
if i break the glDrawElements call into a loop
ie. instead of
glDrawElements( GL_TRIANGLES, mesh.polyCount * 3, GL_UNSIGNED_INT, &mesh.polys[0] );
i do this:for(int i=0; i<mesh.polyCount; i++) glDrawElements( GL_TRIANGLES, 3, GL_UNSIGNED_INT, &mesh.polys);
it works.WTF.
It's not a vanilla vertex array if you're using a vector to store the data. I'm kinda wondering WHY you're doing that in the first place...
Try putting it all into a simple array:
eg:
Polygon *polys;
and somewhere in your init routines:
polys = new Polygon[polyCount];
And then just calling:
glDrawElements(GL_TRIANGLES, mesh.polyCount * 3, GL_UNSIGNED_INT, mesh.polys);
Betcha it'll work.
Try putting it all into a simple array:
eg:
Polygon *polys;
and somewhere in your init routines:
polys = new Polygon[polyCount];
And then just calling:
glDrawElements(GL_TRIANGLES, mesh.polyCount * 3, GL_UNSIGNED_INT, mesh.polys);
Betcha it'll work.
Quote:Original post by overflowed_Vector is guaranteed by the standard to provide contiguous memory, betcha it won't make a difference.
It's not a vanilla vertex array if you're using a vector to store the data. I'm kinda wondering WHY you're doing that in the first place...
Try putting it all into a simple array:
eg:
Polygon *polys;
and somewhere in your init routines:
polys = new Polygon[polyCount];
And then just calling:
glDrawElements(GL_TRIANGLES, mesh.polyCount * 3, GL_UNSIGNED_INT, mesh.polys);
Betcha it'll work.
PS. i will try it any way!
did element-by-element copy into a plane jane array, still crashed in the same place. here's the exact message
/continues to search..
Unhandled exception at 0x692ae676 in Ignite.exe: 0xC0000005: Access violation reading location 0x00000000.
looks like a good 'ol NULL pointer exception, but i dunno where.. as i said all the data looks valid./continues to search..
Try setting up some breakpoints ahead of the code you think is causing the problem, then put some watches on any possible pointers near the problem section.
Also, if you can post the entire vertex array section (everything for this particular render), there might be something as simple as a typo causing a problem.
Also, if you can post the entire vertex array section (everything for this particular render), there might be something as simple as a typo causing a problem.
try this
glDisableClientState( GL_VERTEX_ARRAY );
glDisableClientState( GL_NORMAL_ARRAY );
glDisableClientState( GL_COLOR_ARRAY );
glClientActiveTexture( GL_TEXTURE0 );
glDisableClientState( GL_TEXTURE_COORD_ARRAY );
glClientActiveTexture( GL_TEXTURE1 );
glDisableClientState( GL_TEXTURE_COORD_ARRAY );
and then draw it
u wont see anythihng but hopefully it wont crash, then comment out
glDisableClientState( GL_VERTEX_ARRAY ); + run it again etc
glDisableClientState( GL_VERTEX_ARRAY );
glDisableClientState( GL_NORMAL_ARRAY );
glDisableClientState( GL_COLOR_ARRAY );
glClientActiveTexture( GL_TEXTURE0 );
glDisableClientState( GL_TEXTURE_COORD_ARRAY );
glClientActiveTexture( GL_TEXTURE1 );
glDisableClientState( GL_TEXTURE_COORD_ARRAY );
and then draw it
u wont see anythihng but hopefully it wont crash, then comment out
glDisableClientState( GL_VERTEX_ARRAY ); + run it again etc
Quote:Original post by overflowed_its crashing INSIDE the OpenGL driver, not in my code. ie. exception comes from
Try setting up some breakpoints ahead of the code you think is causing the problem, then put some watches on any possible pointers near the problem section.
Also, if you can post the entire vertex array section (everything for this particular render), there might be something as simple as a typo causing a problem.
atioglxx.dll!692ae676()
i disabled everything but vertex arrays, still crashes, but when i disable everything, its fine. (nothing on the screen though :p)
my renderer flush function if anyone cares:
void RRenderer::flush() { CVector3 *ve = 0; int r = 0; int i = 0; int normArrayActive = 0; // reset client states for(int i=0; i<8; i++) { glClientActiveTextureARB(GL_TEXTURE0_ARB+i); glActiveTexture( GL_TEXTURE0_ARB+i); glDisable( GL_TEXTURE_2D ); glDisableClientState( GL_TEXTURE_COORD_ARRAY ); } glEnableClientState( GL_TEXTURE_COORD_ARRAY ); glEnableClientState( GL_VERTEX_ARRAY ); glEnableClientState( GL_NORMAL_ARRAY ); glEnableClientState( GL_COLOR_ARRAY ); glCullFace( GL_FRONT ); glEnable( GL_CULL_FACE ); glMatrixMode( GL_MODELVIEW ); glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); RCgInfo& cgc = CgContext; //iterate through rendering objects for( uint o=0; o<objects.size(); o++ ) { RObject *co = &objects[o]; //iterate through meshes of current object for( uint m=0; m<co->meshes.size(); m++ ) { RMesh *cm = &co->meshes[m]; RPolygon* p = cm->polybuffer.get(0); //returns polybuffer.polys[0] RVertexBuffer& vb = cm->vertbuffer; RShader *sh = getShader( cm->shader ); if( sh == NULL && (Renderer.settings & GENERATION_GL15) ) //some kind of error continue; glPushMatrix(); if( cm->transfomMat != NULL ) glMultMatrixf( cm->transfomMat->entries ); if( sh != NULL ) { //bind the decal texture glClientActiveTextureARB(GL_TEXTURE0_ARB); glActiveTexture( GL_TEXTURE0_ARB); // bind the texture coordinates glEnableClientState( GL_TEXTURE_COORD_ARRAY ); glTexCoordPointer( 2, GL_FLOAT, 0, (GLvoid*) vb.getTc( RVertexBuffer::TEXCOORD0, 0) ); } if( Renderer.settings & GENERATION_GL15 ) bindShader(cm->shader); if( vb.get(RVertexBuffer::NORMAL, 0) ) { glEnableClientState( GL_NORMAL_ARRAY ); normArrayActive = 1; glNormalPointer( GL_FLOAT, 0, (GLvoid*) vb.get(RVertexBuffer::NORMAL, 0) ); } if( vb.get(RVertexBuffer::TANGENT, 0) && dx9 ) { //send the tangent data through the color arrays glColorPointer( 3, GL_FLOAT, 0, (GLvoid*) vb.get(RVertexBuffer::TANGENT, 0) ); } else { glDisableClientState( GL_COLOR_ARRAY ); } glPushAttrib( GL_LIGHTING_BIT ); if( cm->flags & RMesh::MESH_NOLIGHT ) { glDisable( GL_LIGHTING ); } int numElems = cm->polybuffer.polycount * 3; CVector3 *pVerts = vb.get(RVertexBuffer::VERTEX, 0); glVertexPointer( 3, GL_FLOAT, 0, (GLvoid*) pVerts ); glDrawElements( GL_TRIANGLES, numElems, GL_UNSIGNED_INT, (GLvoid*) p); // crashes here for no reason. glPopAttrib(); glPopMatrix(); unbindShader(cm->shader); } } glDepthFunc( GL_LEQUAL );}
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement