OpenGL.exe has stopped working

I made an OpenGL program(by following youtube videos and it worked for the youtuber) and its giving me an error OpenGL.exe has stopped working after the window has been opened;

Heres the code were i think that the issue is:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <GL/glew.h>
#include "OpenGLWindow.h"

void OpenGLWindow::initializeGL()
{
	glewExperimental = GL_TRUE; 
	glewInit();

	GLfloat verts[] = 
	{
		+0.0f, +0.0f, 
		+1.0f, +1.0f, 
		-1.0f, +1.0f, 
		-1.0f, -1.0f,  
		+1.0f, -1.0f, 
	};

	GLuint vertexBufferID;
	glGenBuffers(1, &vertexBufferID);
	glBindBuffer(GL_ARRAY_BUFFER, vertexBufferID);
	glBufferData(GL_ARRAY_BUFFER, sizeof(verts), verts, GL_STATIC_DRAW);
	glEnableVertexAttribArray(0);
	glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, 0);

	GLushort indicies[] = { 0, 1, 2, 0, 3, 4 }; 
	GLuint indexBufferID;
	glGenBuffers(1, &indexBufferID);
	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBufferID);
	glBufferData(GL_TRIANGLES, sizeof(indicies), indicies, GL_STATIC_DRAW);
} 

void OpenGLWindow::paintGL()
{
	glViewport(0, 0, width(), height());
	glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0);
}


im sorry if this is a noob question

Thanks
Last edited on
Topic archived. No new replies allowed.