3

Screenshot This code compiles without errors or warning, but it can't run it, application crashing instantly.

#include <GL/glut.h>

int WinWidth  = 640,
 WinHeight = 480;
int WinFar   = 10;

void DrawPoint(float x, float y)
{
 glColor3f(1.0, 1.0, 1.0);
 glBegin(GL_POINTS);
  glVertex2f(x, y);
 glEnd();
}

void display()
{
 glClear(GL_COLOR_BUFFER_BIT);
 //Draws
 DrawPoint(0, 0);
 //
 glFlush();
}

int main(int argc, char** argv)
{
 glutInit(&argc, argv);
 glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
 glutInitWindowSize(WinWidth, WinHeight);
 glutInitWindowPosition(150, 150);
 glutCreateWindow("Lesson 01");
 glClearColor(0, 0, 0, 1.0);

 glOrtho(-WinWidth/2, WinWidth/2, WinHeight/2, -WinHeight/2, -WinFar/2, WinFar/2);
 glutDisplayFunc(display);

 glutMainLoop();
 return 0;
}

It's crashing with return value 3221225477. What I'm doing wrong?

Program received signal SIGEGV, Segmentation fault when I run it in debug mode

Nicol Bolas
  • 449,505
  • 63
  • 781
  • 982
  • 3
    Where does it crash when running in a debugger? – Quimby Jul 15 '19 at 16:33
  • more detaild about the crash, please – Nícolas Jul 15 '19 at 16:34
  • 1
    I had ran you program and it is working 'normally'. So the question is: which OS, compiler, library version and so on. – Amadeus Jul 15 '19 at 16:36
  • Windows 7, Ide - Devcpp, Freeglut 3.0.0 – Oleg Pustoslov Jul 15 '19 at 16:40
  • 1
    @OlegPustoslov openGL version is important too – Amadeus Jul 15 '19 at 16:40
  • It's crushing on glutCreateWindow function – Oleg Pustoslov Jul 15 '19 at 17:01
  • Segmentation fault means you are accessing memory that is not yours There are a number of reasons that can lead to this here few: 1. on Windows check if you have vendor gfx drivers instead of MS ones that are loaded by default and have not usable OpenGL implementation in it? If yes download and install correct drivers manually as automatic reinstall will get you wrong drivers (probably to promote DirectX). 2. Is your GLUT matching your apps target platform (32bit or 64bit executable) if not matching either use correct one or change your executable target in your compiler/linker settings. – Spektre Jul 16 '19 at 07:45
  • 3. what are the command line options your exe is called with? – Spektre Jul 16 '19 at 07:49

0 Answers0