I have a problem in openGL when using buffer object to store vertex array . when I run the code , a window appears that display message " access violation reading location 0x000000000 " and when I move the cursor to arrow beside glGenBuufers function I see description: this is the next statement to execute when this thread returns from current function.
Code:
int frame=0;
void display();
void datasource();
GLuint vbo;
void datasource()
{
GLfloat vertex1[]={-1.000000 ,0.500000 ,-0.700000 ,0.500000 ,-1.000000 ,0.800000 ,-0.700000 ,0.800000 ,-0.400000 ,0.500000 ,-0.100000 ,0.500000 ,-0.400000 ,0.800000 ,-0.100000 ,0.200000 ,0.500000 ,0.500000 ,0.500000 ,0.200000 ,0.800000 ,0.500000,0.800000 ,0.800000 ,0.800000 ,0.500000 ,1.100000 ,0.500000 ,0.800000 ,0.800000 ,1.100000,0.800000 };
glGenBuffers(1,&vbo);
glBindBuffer(GL_ARRAY_BUFFER,vbo);
glBufferData(GL_ARRAY_BUFFER,sizeof(vertex1),vertex1,GL_STATIC_DRAW);
}
void init(int arc,char **arch)
{
glutInit(&arc,arch);
glutInitWindowSize(800,800);
glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
glutCreateWindow("chess");
glClearColor(0.0,0.0,0.0,0.0);
glutDisplayFunc(display);
}
int main(int arc,char **arch)
{
init(arc,arch);
datasource();
glutMainLoop();
return 0;
}
void display()
{
frame++;
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glDrawArrays(GL_TRIANGLE_STRIP,0,8);
glutSwapBuffers();
glutPostRedisplay();
}
What did I do wrong?