PDA

View Full Version : glArrayElement is chucking access violation at me.



Sythe Dragon
01-26-2010, 07:06 AM
Hello forum,
I'm an absolute beginner and OpenGL is giving me issues with array element 0 of one of my (very simple) Vertex Arrays.
The relevant (or what i believe to be relevant) code is this:


void ground()
{
//create the vertex array
triple groundVertex[4] = {{45.0, 0.0, 45} , {45.0, 0.0, -45.0} ,{-45.0,0.0,-45} , {-45.0,0.0,45.0}
};

glVertexPointer(3,GL_FLOAT, 0, groundVertex);

glBegin(GL_QUADS);
glArrayElement(0);
glArrayElement(1);
glArrayElement(2);
glArrayElement(3);
glEnd();

}


When I compile it seems to throw this error at me.

"Unhandled exception at 0x692eada6 in wk7.exe: 0xC0000005: Access violation reading location 0x00000004."

And when i break it seems to point to Array Element 0.
I cannot think of what it could be.

Abdallah DIB
01-26-2010, 08:45 AM
did u enable vertex arrays ? befrore specifying the vertex pointer ?
if no, put this line
glEnableClientState(GL_VERTEX_ARRAY);
before :
glVertexPointer(3,GL_FLOAT, 0, groundVertex);

Sythe Dragon
01-26-2010, 09:33 AM
Yes i did, in my initialize function. Does it need to be done elsewhere??

Abdallah DIB
01-26-2010, 12:33 PM
check ur call stack functions to see which function is throwing this exception