OpenGL program keeps crashing?

nvidia drivers
opengl driver
glfwpollevents crash

This code returns 3 errors (literally all the errors) GLEW init failed; GLFW init failed; Window creation failed:

#include "GL/glew.h"
#include "GLFW/glfw3.h"

#include <iostream>

//Window dimensions
const GLint SCREEN_WIDTH = 800, SCREEN_HEIGHT = 600;

int main() {
    //Initialize GLFW
    if (glfwInit() != GLEW_OK) { 
        std::cout << "GLFW init failed\n"; 

    //Setup GLFW window properties
    //OpenGL version
    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); //Large version
    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); //Small version 
    glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); //Detects any old OpenGL code, this will throw an error
    glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); //Allows forward compatibility (between differnt OS) 

    //Creating window
    GLFWwindow* window; 
    window = glfwCreateWindow(SCREEN_WIDTH, SCREEN_HEIGHT, "OpenGL Test Window", NULL, NULL);
    if (window == NULL) {
        std::cout << "GLFW window creation failed!\n";

    //Get buffer size information
    glfwGetFramebufferSize(window, &BUFFER_WIDTH, &BUFFER_HEIGHT);

    //Set context for GLEW to use (can change between which window)

    //Allow modern extension features
    glewExperimental = GL_TRUE;

    if (glfwInit() != GLEW_OK) {
        std::cout << "Glew init failed!\n";

    //Setup viewport size
    glViewport(0, 0, BUFFER_WIDTH, BUFFER_HEIGHT);

    //Main game loop
    while (!glfwWindowShouldClose(window)) {
        //Get + Handle user input events

        //Clear window
        glClearColor(1.f, 0.f, 0.f, 1.f);


Try this , you need to initialize Glew.

GLenum GlewInitResult;
GlewInitResult = glewInit();
if ( GLEW_OK != GlewInitResult) 
    return -1;

All Programs Using OpenGL Crashing, New LG OLED C9 + DEEP COLOR + ONKYO TX-NR656 Receiver- WON'T DO 4K 60HZ HDR! Forces 1080p DVI ! 1 18. 1. GreenleafBAS 2. GeForce Graphics� Strictly speaking, “OpenGL” cannot crash a computer, but your graphics drivers can. Graphics drivers are an implementation of OpenGL created by NVidia, AMD/ATI, Intel etc. Depending on the quality of graphics drivers, they can cause problems, and result in the operating system to reboot.

This is wrong:

if (glfwInit() != GLEW_OK) { 
   std::cout << "GLFW init failed\n"; 

GLEW_OK is defined as 0 (See

So this is evaluated as follows: if (glfwInit() != 0) which will only be true if GLFW did initialize properly.

So change that part to:

if (glfwInit() == 0) { 
    std::cout << "GLFW init failed\n"; 

OpenGL application crashing, This OpenGL program is written to draw a triangle and it got crashed. Basically a set of triangle vertices is define as array named coordinate, then this array is� Hi, We are developing an application based on OSGEarth, this application crash on the following setup : Microsoft Surface Pro 4 with Windows 10, GPU : Intel HD Graphics 520 (drivers 154516.4627) Application displayed on a deported screen using a Display link adapter (HP USB Graphics Adapter NL571AA, drivers 8.2 M1).

There are 2 issues.

glfwInit returns GLFW_TRUE if it succeeds (GLFW_TRUE is 1). So it has to be:

if (glfwInit() != GLFW_TRUE) { 
    std::cout << "GLFW init failed\n"; 

(Note, if GLFW failed to initialize, then there is no need to call glfwTerminate())

If you want to install GLEW, then you've to call glewInit rather than glfwInit. glewInit returns GLEW_OK, if it succeeds (see Initializing GLEW). GLEW_OK is 0. So it has to be:

if (glewInit() != GLEW_OK) {

    std::cout << "Glew init failed!\n";

OPENGL BASED GAMES CRASH!!, Hi there, I have recently bought a system which is P4 2.8GHz, 800MHz FSB, HTT etc, PALIT Daytona Geforce FX 5600, I have windows XP, DX� Occasionally, OpenGL works, but 90% of the time it just crashes the program. This issue is repeatable in Cinema 4D, Cinebench, OpenGL Extension Viewer (when trying the rendering tests), browsers when OpenGL is being used, and various other 3D applications.

[SOLVED]Game keeps crashing (OpenGL fixed it!), Just enter cd, followed by a space, followed by the folder name. For me, that's cd Kerbal Space Program Then hit enter. Step 5: As explained� GeForce - OpenGL problem - OpenGL crash ATI - Graphic Card - Fix openGL - Crash Fix Counter strike - minecraft - the walking dead low specs - low end - game crash - pc games.

Fix OpenGL crash on NVIDIA 100% [Tested], OpenGl - Fix - DirectX - Nvidia - crash. Optical flares - element 3d - after effects GeForce Duration: 3:18 Posted: 03-Jan-2015 OpenGL program keeps crashing around glDrawArrays() Ask Question Asked 7 years ago. Active 6 years, 10 months ago. Viewed 404 times 0. I am trying to

FIX Premiere Pro Crashing - NVIDIA OpenGL Error Code: 3, How to fix Adobe Premiere Pro crashing with NVIDIA OpenGL Error. If you have a Nvidia Duration: 0:47 Posted: 15-May-2019 I understand that the game crashes. We will assist you to resolve the issue. This issue may arise se due to compatibility issues. I suggest you to run the game in compatible mode and check if it helps to resolve the issue. Run the program in Compatibility mode, please follow the below steps: Right click on the Program; Click on Properties

  • The only error of relevance is the glfwInit(); call, since you failed to exit your application once that error appears.
  • @PaulMcKenzie Sorry? "...failed to exit your application once that error appears"? What do you mean by that? I did glfwTerminate(); for both events.
  • No, a C++ main function has not returned. Your code calls glfwTerminate(), but that has nothing to do with main returning -- it is just a function call. To terminate an application, you either return from main, or you call exit(). That's why you see the other error messages -- you failed to bail out on the first error and your program kept going. Also, think logically about it -- what if I want to end the gl engine in the middle of my application, but keep my app going? Will glfwTerminate() end my entire application? Of course not.
  • I think OP meant glfwInit() != GLFW_TRUE and just used the wrong constant.