openGL program stopped working on new machine

I am currently working on a simple 3D wireframe renderer using openGL.
I working on Windows 10 using Visual Studio. I use glfw to manage openGL windows, glad to load the latest version of openGL and glm for various mathematical stuff. The way I integrate these libraries with Visual Studio is with vcpkg and it worked well. I was working on my wireframe renderer program and it was going well.

Recently, my previous PC stopped working though. So I had to migrate the whole project (I backed it up) to a new PC. I installed Visual Studio, used vcpkg to integrate glfw, glad and glm and got it running. However, I realized, that nothing was being rendered in the window, despite not having changed anything in the code from the last version that was running just fine on the older PC.

I rolled the project back to a version where it was much simpler and was basically just rendering a single triangle, and back on the old machine it was working, but now on the new PC, it is not working at all. I am very confused since I am not even getting any errors, the program itself runs just fine, but simply nothing is rendered.

What could be the cause of this?

Here is the code of the simple version (1 file only) of the program, on which the more complex 3D wireframe rendere was built up on. This code worked on the old PC, but now is rendering nothing on my new PC.


#include <GLFW/glfw3.h>
#include <glad/glad.h>

#include <stdio.h>

void error_callback(int error, const char* description);
void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods);
int main()
	if (!glfwInit())
		perror("glfw init failed");
		return -1;
	puts("glfw initialized");


	GLFWwindow* window = glfwCreateWindow(640, 480, "Renderer", NULL, NULL);
	if (!window)
		perror("Window creation failed");
		return -1;

	glfwSetKeyCallback(window, key_callback);

	GLuint VAOID;
	glGenVertexArrays(1, &VAOID);

	//Create some vertices for a triangle
	GLfloat objectVertices[] =
		-1.0f, -1.0f, 0.0f,
		1.0f, -1.0f, 0.0f,
		0.0f, 1.0f, 0.0f

	GLuint VBOID;
	glGenBuffers(1, &VBOID);

	glBufferData(GL_ARRAY_BUFFER, sizeof(objectVertices), objectVertices, GL_STATIC_DRAW);
	//Tell openGL how our data is formatted
		3, //Each vertex is described by 3 values
		GL_FLOAT, //data type of each value



	//The program keeps running until the hint flag for termination is set
	while (!glfwWindowShouldClose(window))
		glDrawArrays(GL_TRIANGLES, 0, 3);


	return 0;

* This function is called when an error occurs
void error_callback(int error, const char* description)
	fprintf(stderr, "Error: %s\n", description);

* This function is called when a keyboard key is pressed
void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)

	//Esc key pressed: set the flag to tell the program to terminate
	if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS)
		glfwSetWindowShouldClose(window, GLFW_TRUE);

I made sure to update my Nvidia drivers prior to setting up anything in the environment of Visual Studio (both PCs had nvidia graphics cards)

Is there any reason, why this code shouldn’t work? It worked on the previous machine.

Check for GL Errors.

Also, query and print the values of GL_VERSION, GL_RENDERER and GL_VENDOR. It might give you some clues (e.g. glGetString( GL_VERSION )).

Is there a chance this is related to shaders?

I don’t see any reference for shaders in the code you shared, so I assume the project is using the fixed pipeline instead. From what I remember, this was deprecated in OpenGL 2.0 and removed on OpenGL 3.0+. Maybe your new hardware cannot emulate versions before OpenGL 3.0? That would explain why you don’t get any error and nothing is drawn on the screen.

I’m still learning OpenGL myself, so this is just an idea, not sure if something else might be going on.

1 Like

tomtsagk has a good point. It does seem odd that you aren’t setting up either fixed-function shaders or custom shaders.

Is it your intent to target fixed-function shaders (and a compatibility profile context), or custom shaders (with either a compatibility or core profile context)? In either case, you need more than this.

I am completely new to openGL myself and didn’t really get into shaders yet. I also didn’t know that there was something like a fixed pipeline (which was also deprecated). I simply downgraded the openGL version to 3.0 and the program started working again (The doc said that 3.0 was the last version that supported this deprecated semantic). I still have to learn how to properly do shading though.
Thank you for your help.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.