glfw: Potential sRGB bug on Mac

I believe I may have found a potential bug related to using a sRGB framebuffer on Mac. I am using the latest version of GLFW (3.2.1) My OS is MacOS Sierra 10.12.3 - current hardware is the new 2016 touchbar MacBook Pro 13"

When using a sRGB enabled framebuffer I have an issue when in fullscreen. For an unknown reason when switching away from then back to the fullscreen window, upon arrival the window gets a red overlay that encompasses the entire viewport. This red overlay the begins to quickly flash repeatedly.

If I move my cursor to expose the toolbar at the top of the screen the red flashing goes away.

Related to this, when I create an open file dialog box, if the box overlaps with the window the area under the box will have the same issue whether is it in fullscreen or not.

I have narrowed this down to being related to sRGB because if I remove the code:

glfwWindowHint( GLFW_SRGB_CAPABLE, GLFW_TRUE );

and

glEnable(GL_FRAMEBUFFER_SRGB);

The issue goes away.

I am not sure if it is an issue related to my code, glfw itself, my drivers, or something else entirely. Assistance with this would be greatly appreciated.

EDIT: Upon further testing, this issue seems to arise because of the retina display on my laptop. I created a very similar window using SDL as the library and the same issue arises. However I have now learned that if I disable retina scaling the issue goes away. I know this because I was able to test the application on a non retina iMac and there was no issue. Because only applications I have been developing have been having this issue I have to believe that there is something with GLFW that can be done to fix the issue.

Here is a link to a video of the issue: https://youtu.be/OUOE4t9tYxU Apologies for the quality of the video, for some reason when I try to record my screen using quicktime the flashing red overlay does not show up.

Here is the Code that results in the issue:

int main () {

	GLFWwindow* window_ptr;
	int window_width, window_height;
	int gl_viewport_width, gl_viewport_height;

	if ( glfwInit() ) {
		glfwWindowHint( GLFW_CONTEXT_VERSION_MAJOR, 3 );
		glfwWindowHint( GLFW_CONTEXT_VERSION_MINOR, 3 );
		glfwWindowHint( GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE );
		glfwWindowHint( GLFW_OPENGL_FORWARD_COMPAT, GLFW_TRUE );
		glfwWindowHint( GLFW_RESIZABLE, GLFW_TRUE );
		glfwWindowHint( GLFW_SRGB_CAPABLE, GLFW_TRUE );

		window_ptr = glfwCreateWindow( DEFAULT_WINDOW_WIDTH, DEFAULT_WINDOW_HEIGHT, "GLFW Window", 0, 0 );
		
		if ( !window_ptr ) {
			glfwTerminate();
			return -1;
		} else {
			glfwMakeContextCurrent( window_ptr );
			glfwGetWindowSize( window_ptr, &window_width, &window_height );
			glfwGetFramebufferSize( window_ptr, &gl_viewport_width, &gl_viewport_height );	

			glfwSwapInterval( 1 );

			glViewport( 0, 0, gl_viewport_width, gl_viewport_height );
			glEnable( GL_DEPTH_TEST );
			glCullFace( GL_BACK );
			glEnable( GL_CULL_FACE );
			glEnable(GL_BLEND);
			glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
			
			glEnable(GL_FRAMEBUFFER_SRGB);
			
			glClearColor( 0.5f, 0.5f, 0.5f, 1.0f );	
		}
	}

	if ( window_ptr ) {
		while ( !glfwWindowShouldClose( window_ptr ) ) { 
			glfwPollEvents();
			glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
			glfwSwapBuffers( window_ptr );
		}
		glfwTerminate();
	}

	return 0;
}

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 16 (5 by maintainers)

Most upvoted comments

I just factory reset by laptop (2016 MacBook Pro) and the issue no longer seems to be there. It appears that there must of been something going wrong behind the scenes that is now fixed.

Thanks for the help!

Here is a link to a dropbox folder. Included is a .app with both written and video instruction for how to reproduce the bug

Is it possible to provide something I can build from source? I’d prefer to be able to do that. The video and text files are helpful.

I would like to know if the issue is related to my machine alone. (2016 MacBook Pro 13" w/ touch-bar) If there is anyone with the same machine that can test to see if they have the same issue it would be greatly appreciated.

Would it be helpful to know if someone with a different Mac (e.g., a Late 2011 15" MacBook Pro) has the same issue? Or is it already known not to affect other models?

(I don’t have a retina screen, but I can still use a HiDPI resolution, which I think should behave the same.)