I just started working with openGL a few days ago, but my first foray into using VBOs has encountered a strange error that I haven’t found searching the forums or the internet yet, the code below throws an error when I try to run it, “Unhandled exception at 0x7732BDA1 in Project6.exe: 0xC0000005: Access violation executing location 0x00000000.”
#include <glew.h>
#include <freeglut.h>
#include <iostream>
using namespace std;
#define GLEW_STATIC
void init (int argc, char** argv)
{
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize (1920,1080);
glutCreateWindow ("OpenGL happens here.");
glClearColor (0.0, 0.0, 0.0, 0.0);
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
glOrtho (-1 * (1920/2), 1920/2, -540, 540, -1.0, 1.0);
}
int main (int argc, char** argv)
{
glutInit (&argc, argv);
glewInit();
wglGetProcAddress;
static const GLsizeiptr PositionSize = 6 * 2 * sizeof(GLfloat);
static const GLfloat PositionData[] =
{
-100.0,-100.0,
100.0,-100.0,
100.0,100.0,
100.0,100.0,
-100.0,100.0,
-100.0,-100.0
};
static const GLsizeiptr ColorSize = 6 * 3 * sizeof(GLubyte);
static const GLubyte ColorData[] =
{
255,0,0,
255,255,0,
0,255,0,
0,255,255,
0,255,0,
255,255,0
};
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize (1920,1080);
GLuint vboid;
glGenBuffers(1, &vboid);
init(argc, argv);
}