I’m new to openGL and I need to directly use it for debuging perpose can anyone please tell me why in this code glDrawArray should throw exception (trying to access memory at 0x00000000)
glEnableClientState(GL_VERTEX_ARRAY);
float data[8];
data[0] = 10;
data[1] = 10;
data[2] = 10;
data[3] = 20;
data[4] = 20;
data[5] = 20;
data[6] = 20;
data[7] = 10;
glVertexPointer(2,GL_FLOAT,0,data);
glDrawArrays(GL_LINE_LOOP,0,4);
glDisableClientState(GL_VERTEX_ARRAY);
Perhaps you have enabled another array with
glEnableClientStateat another point in your program and didn’t disable it. SoglDrawArraystries to read from another array that causes the problem.EDIT:: It could also be, that the code you showed us is not the real code and you call
glVertexPointerat a completely different place thanglDrawArrays. When givingdataas vertex pointer, you only tell it to take the vertices fromdata, whenglDrawArraysis called. The vertex data is not copied, sodatahas to still exist whenglDrawArraysis called (at the moment it’s a local variable, but with the code snippet you gave us it should work).EDIT: I also suppose you are not using any buffer objects, as that could also be a problem, if a vertex buffer is bound when you call
glVertexPointer.