Answer the question
In order to leave comments, you need to log in
Why is an exception thrown???
There will be no retreats, straight to the point
Here is the code:
#define GLEW_STATIC
#include <D:\Games\Include\GLEW\glew.h>
#include <D:\Games\Include\GLFW\glfw3.h>
#include<D:\Games\Include\GLUT\glut.h>
void draw()
{
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glDrawArrays(GL_POINTS, 0, 1);
glClear(GL_COLOR_BUFFER_BIT);
glutSwapBuffers();
}
int main(int argc, char *argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA);
glutInitWindowSize(1024, 768);
glutInitWindowPosition(100, 100);
glutCreateWindow("Tutorial 01");
GLfloat vertices[] = {
0.0f,0.0f,0.0f
};
GLuint VBO;
glGenBuffers(1, &VBO);
glBindBuffer(GL_ARRAY_BUFFER, VBO);
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
glEnableVertexAttribArray(0);
glBindBuffer(GL_ARRAY_BUFFER, VBO);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
glutDisplayFunc(draw);
glutMainLoop();
glfwTerminate();
return 0;
}
Answer the question
In order to leave comments, you need to log in
You don't initialize an OpenGL context, so your program crashes the first time you use an OpenGL function. For initialization you need to use GLEW.
It's also not clear why you are connecting GLUT and GLFW at the same time...
Check out this OpenGL tutorial . There is code at the end of the article that does just what you need.
PS An exception, as written, is thrown when a program dereferences (uses) a pointer that points to memory outside of the application's address space. For example, an uninitialized pointer.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question