I’ve been trying to implement VBO on my computer and I ran into a segmentation fault:
Unhandled exception at 0x00000000 in attocube.exe: 0xC0000005: Access violation
The error is at the line where I call glBindBuffer(GL_ARRAY_BUFFER, ID); in void init().
I’ve used the code of the following question: How to get VBO working
#include <windows.h>
#include <iostream>
#include <GL/glew.h>
#include <GL/freeglut.h>
#pragma comment(lib,"glew32.lib")
GLuint ID;
void init(){
glewInit();
glClearColor(1.0f, 1.0f, 1.0f, 0.0f);
glShadeModel(GL_FLAT);
glEnableClientState(GL_VERTEX_ARRAY);
float data[][2] = {{50,50},{100,50},{75,100}};
glGenBuffers(1,&ID);
glBindBuffer(GL_ARRAY_BUFFER, ID);
glBufferData(GL_ARRAY_BUFFER, sizeof(data), data, GL_STATIC_DRAW);
}
void reshape(int w, int h){
glViewport(0,0, (GLsizei) w, (GLsizei) h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0f, (GLdouble) w, 0.0f, (GLdouble) h);
}
void display(){
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(0.0f,0.0f,0.0f);
glBindBuffer(GL_ARRAY_BUFFER, ID);
glVertexPointer(2, GL_FLOAT, 2*sizeof(float), 0);
glDrawArrays(GL_TRIANGLES,0,3);
glFlush();
}
int main(int argc, char **argv){
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(500,500);
glutInitWindowPosition(300,300);
glutCreateWindow(argv[0]);
init();
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutMainLoop();
return 0;
}
My configuration is the following:
Windows 7 / Geforce GTX 570 / glew 1.9.0
I am working on the workstation with Remote Desktop Connection. I’ve just tried running the code directly on the machine and it works. VBO doesn’t work with RDC. I’m feeling really stupid. Thank you very much for the help.