Simple OpenGL example crashes

0

I've just copy & pasted my first OpenGL project from a tutroial (yay!). The code is super simple:

#include "freeglut.h"


void displayMe(void)
{
  glClear(GL_COLOR_BUFFER_BIT);
  glFlush();
}

int main(int argc, char** argv)
{
  glutInit(&argc, argv);

  glutInitDisplayMode(GLUT_SINGLE);
  glutInitWindowSize(300, 300);
  glutInitWindowPosition(500, 500);
  glutCreateWindow("Test");          /// CRASHES HERE!
  glutDisplayFunc(displayMe);
  glutMainLoop();

  return 0;
}

I use the latest versions of:

  • Visual Studio (2017)
  • Freeglut x86 (3.0.0)
  • GLEW x86 (2.0.0)
  • NVIDIA driver for my Geforce 1070

But my applicaion (built as x86) crashes immediately with the following exception:

Exception thrown at 0x6907EE5F (nvoglv32.dll) in MyTest.exe: 0xC0000005: Access violation reading location 0x00000250.

EDIT: The crash occurs at this line:

glutCreateWindow("Test");

EDIT 2 I just tried a different framework. Now I use GLFW instead of freeGLUT. The application crashes, too, when creating the window :-(

#include <glfw3.h>

int main(void)
{
  GLFWwindow* window;

  /* Initialize the library */
  if (!glfwInit())
    return -1;

  /* Create a windowed mode window and its OpenGL context */
  window = glfwCreateWindow(640, 480, "Hello World", NULL, NULL); // CRASH HERE
  if (!window)
  {
    glfwTerminate();
    return -1;
  }

  /* Make the window's context current */
  glfwMakeContextCurrent(window);

  /* Loop until the user closes the window */
  while (!glfwWindowShouldClose(window))
  {
    /* Render here */
    glClear(GL_COLOR_BUFFER_BIT);

    /* Swap front and back buffers */
    glfwSwapBuffers(window);

    /* Poll for and process events */
    glfwPollEvents();
  }

  glfwTerminate();
  return 0;
}
c++
visual-studio
opengl
glut
glew
asked on Stack Overflow Apr 30, 2017 by Boris • edited May 1, 2017 by Boris

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0