Below is my opengl code, it might not do something meaningful. I used freeglut library in the code. Below is the all of the code:
#include <glload/gll.h>
#include <glload/gl_3_0.h>
#include <GL/glut.h>
#include "glfw3.h"
void ChangeSize(int w, int h)
{
glViewport(0, 0, w, h);
}
void RenderScene(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
glLoadIdentity();
glLineWidth(1);
glColor3f(1.0f, 0.0f, 0.0f);
glBegin(GL_LINE);
glVertex3f(0.0f, 0.0f, 0.5f);
glVertex3f(0.0f, 1.0f, 0.5f);
glVertex3f(1.0f, 1.0f, 0.5f);
glEnd();
glMatrixMode(GL_PROJECTION);
glOrtho(-2.0,2.0,-2.0,2.0,-1.0,1.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
int main (int argc, char** argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH | GLUT_STENCIL);
glutInitWindowSize(800, 600);
glutCreateWindow("Triangle");
// glClearColor(1.0f, 1.0f, 1.0f, 0.0f);
// glShadeModel(GL_SMOOTH);
glutReshapeFunc(ChangeSize);
glutDisplayFunc(RenderScene);
glutMainLoop();
return 0;
}
Here is the error message:
Unhandled exception at 0x00000000 in HelloGL5.exe: 0xC0000005: Access violation.
Please notice that I commented out two lines of code and this I am not getting this error. Why am I getting this error when I add one of those two lines to the code?