I have been having this problem for a while and I cant for the love of me find a solution.
I want to render a simple triangle. But i keep getting this output in visual studio when compiling the program.
NOTE> I do not belive it is not a linking problem but something else. I have checked my linker countless times and everything is there!
LINK: https://pastebin.com/xeTDd0Qu
main
static const GLfloat g_vertex_buffer_data[] = {
100.0f, 100.0f, 0.0f,
150.0f, 100.0f, 0.0f,
100.0f, 150.0f, 0.0f,
};
GLFWwindow* window;
window = initWindow(640, 480, "Title");
GLuint VertexArrayID;
glGenVertexArrays(1, &VertexArrayID);
glBindVertexArray(VertexArrayID);
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);
while (!glfwWindowShouldClose(window)) {
glViewport(0, 0, 640, 480);
glClearColor(0, 0, 0, 0);
glClear(GL_COLOR_BUFFER_BIT);
glEnableVertexAttribArray(0);
glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, (void*)0);
glDrawArrays(GL_TRIANGLES, 0, 3);
glDisableVertexAttribArray(0);
glFlush();
glfwSwapBuffers(window);
glfwPollEvents();
}
glfwTerminate();
return 0;
initWindow()
GLFWwindow* initWindow(int a_width, int a_height, const char* title) {
glewExperimental = GL_TRUE;
int err = glewInit();
if (!err) {
exit(-1);
}
if (!glfwInit()) {
printf("glfwInit() failed!");
return nullptr;
}
GLFWwindow* window = glfwCreateWindow(640, 480, "My Title", NULL, NULL);
if (!window) {
glfwTerminate();
return nullptr;
}
return window;
}
Thanks!
EDIT: Exception message i get: Exception thrown at 0x00000000 in ConvexHullVisualiser.exe: 0xC0000005: Access violation executing location 0x00000000.