I am just learning openGL and I have just found out that I should use the programable pipeline instead of the fixed pipeline..
Therefore I started using VAOs in order to make an array of verticies. This means using functions such as:
glGenVertexArrays
, glBindVertexArray
and so on..
These functions are all a part of the glew library. And Ive come to the conclusion that something is wrong with glew library since non of the glew-methods work.
I get this error message:
Exception thrown at 0x00000000 in CUBE.exe: 0xC0000005: Access violation executing location 0x00000000.
I have read all forums regarding this error message and forums regarding disfunctional glew without any succes..
If tried using the trick to set glewExperimental = GL_TRUE
;
I have tried to create a context.
And ofc. checked whether the glew library was linked correctly.
I have also put glewInit()
before any glew related method calls.
And much more..
So its been a long day.. Here is my code for reference.
#include <stdio.h>
#include <GL\glew.h>
#include <GL\glut.h>
void display() {
glClear(GL_COLOR_BUFFER_BIT);
glFlush();
}
void Initialize() {
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
}
void init(void) {
glewInit();
GLuint arrayID;
glGenVertexArrays(1, &arrayID);
glBindVertexArray(arrayID);
static const GLfloat g_vertex_buffer_data[] = {
-1.0f,-1.0f,-1.0f, // triangle 1 : begin
-1.0f,-1.0f, 1.0f,
-1.0f, 1.0f, 1.0f, // triangle 1 : end
1.0f, 1.0f,-1.0f, // triangle 2 : begin
-1.0f,-1.0f,-1.0f,
-1.0f, 1.0f,-1.0f, // triangle 2 : end
1.0f,-1.0f, 1.0f,
-1.0f,-1.0f,-1.0f,
1.0f,-1.0f,-1.0f,
1.0f, 1.0f,-1.0f,
1.0f,-1.0f,-1.0f,
-1.0f,-1.0f,-1.0f,
-1.0f,-1.0f,-1.0f,
-1.0f, 1.0f, 1.0f,
-1.0f, 1.0f,-1.0f,
1.0f,-1.0f, 1.0f,
-1.0f,-1.0f, 1.0f,
-1.0f,-1.0f,-1.0f,
-1.0f, 1.0f, 1.0f,
-1.0f,-1.0f, 1.0f,
1.0f,-1.0f, 1.0f,
1.0f, 1.0f, 1.0f,
1.0f,-1.0f,-1.0f,
1.0f, 1.0f,-1.0f,
1.0f,-1.0f,-1.0f,
1.0f, 1.0f, 1.0f,
1.0f,-1.0f, 1.0f,
1.0f, 1.0f, 1.0f,
1.0f, 1.0f,-1.0f,
-1.0f, 1.0f,-1.0f,
1.0f, 1.0f, 1.0f,
-1.0f, 1.0f,-1.0f,
-1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f,
-1.0f, 1.0f, 1.0f,
1.0f,-1.0f, 1.0f
};
GLuint vertexBuffer;
glGenBuffers(1, &vertexBuffer);
glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer);
glBufferData(GL_ARRAY_BUFFER, sizeof(g_vertex_buffer_data),
g_vertex_buffer_data, GL_STATIC_DRAW);
glEnableVertexAttribArray(1);
glVertexAttribPointer(
1,
3,
GL_FLOAT,
GL_FALSE,
0,
(void*)0
);
glDrawArrays(GL_TRIANGLES, 0, 12 * 3);
}
int main(int iArgc, char** cppArgv) {
glutInit(&__argc,__argv);
glDrawArrays(GL_TRIANGLES, 0, 12 * 3);
glutInitDisplayMode(GLUT_RGBA);
glutInitWindowSize(950, 500);
glutInitWindowPosition(200, 200);
glutCreateWindow(__argv[0]);
wglCreateContext;
wglMakeCurrent;
glewExperimental = GL_TRUE;
Initialize();
init();
wglMakeCurrent;
glutDisplayFunc(display);
glutMainLoop();
return 0;
}
There are some incoherent stuff in my code (a result of a day full of different tries), but the essential thing is that my program will show a window if I clear out the glew stuff..
My version of OpenGL is 3.3 if is has any relevance.