PDA

View Full Version : driver problem?



george
06-04-2012, 04:54 AM
hello all

I have a very easy to describe problem
the following code executes without problems and does what i expect to do in an old laptop of mine, runing win xp

When i run it in my new desktop pc (i7 win7 64bit 8Gb ram) with a NVIDIA Quadro FX 580 graphics card,
when executing glDrawArrays, i get
"0xC0000005: Access violation reading location 0x00000000."

code:
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);

glBindTexture(GL_TEXTURE_2D,quadTexture);
glVertexPointer(3,GL_FLOAT,0,&quadVertexesArray[0]);
glNormalPointer(3,0,&quadNormalsArray[0]);
glTexCoordPointer(2,GL_FLOAT,0,&quadTexCoordArray[0]);
glDrawArrays(GL_QUADS,0,noOfQuads*4);//0xC0000005: Access violation reading location 0x00000000.

glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY);


the pointers where initialised using:
quadNormalsArray =(GLfloat *) malloc(sizeof(GLfloat)*quads.count()*3);
quadVertexesArray=(GLfloat *) malloc(sizeof(GLfloat)*quads.count()*3*4);
quadTexCoordArray=(GLfloat *) malloc(sizeof(GLfloat)*quads.count()*2*4);
and
quadNormalsArray=new GLfloat[quads.count()*3];
quadVertexesArray=new GLfloat[quads.count()*3*4];
quadTexCoordArray=new GLfloat[quads.count()*2*4];
with the same result (0xC0000005: Access violation reading location 0x00000000.)

i suspect a driver problem
i have downloaded the latest driver but i get the same....
any idea of what to look for?

i use the latest Qt library and the a QGLWidget (if this is relevant in any way)

thank you for your time
george

CatDog
06-04-2012, 06:40 AM
glNormalPointer(3,0,&quadNormalsArray[0]);

Check the first parameter:

http://www.opengl.org/sdk/docs/man/xhtml/glNormalPointer.xml

CatDog

Dan Bartlett
06-04-2012, 06:51 AM
Normals should be specified per-vertex instead of per-quad, even if the value is repeated over the whole quad, so instead of:

quadNormalsArray =(GLfloat *) malloc(sizeof(GLfloat)*quads.count()*3);
you should have:

quadNormalsArray =(GLfloat *) malloc(sizeof(GLfloat)*quads.count()*3*4);

And driver problems are fairly rare unless you're using brand new functionality, or an infrequently used part of OpenGL.

If you use glGetError after the glNormalPointer it should be returning GL_INVALID_ENUM, because as CatDog said, "3" isn't a valid value (you probably want to use GL_FLOAT instead)

mhagain
06-04-2012, 07:52 AM
If there's a driver problem here then it's on the old XP machine as this code should not have ran without problems - the behaviour you're getting on the Windows 7 machine is actually correct (you told it to crash and it crashed).

george
06-05-2012, 12:38 AM
the problem was solved
thank you all for your time

george