I accidentally updated my Mac, and OpenGL is now deprecated in the latest MacOS Mojave. I'm using OpenGL + GLUT (I know this is old, but I just need a simple program) and run on terminal (not using Xcode). With the same program that has been working perfectly in Sierra, I got so many OpenGL deprecated warnings in Mojave and managed to suppress all the warning using -Wno-deprecated-declarations
, but now I only get black screen.
I read a lot of same issues with black screen on OpenGL after Mojave update, like Black screen on OpenGL , and Mac Mojave + opengl Ask Question. But as of now, none of them have accepted answer and the provided answers don't work on me.
This is my main loop :
Code :
static void mainLoop(void)
{ glClearColor(0,0,0,0);
glClear(GL_COLOR_BUFFER_BIT);
//glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glEnable(GL_FRAMEBUFFER_SRGB);
argDrawMode2D(vp); //draw to the screen
char string[256];
glColor3f(1,1,1);
sprintf(string, "Some strings", string1 );
argDrawStringsByIdealPos( string, 10.0, 25.0 );
argSwapBuffers(); //clear the buffer
glFlush();
}
I have 2 questions :
Do you have any suggestion how to solve the black screen problem ? What I have tried but still got black screen :
Change
glFlush()
intoglutSwapBuffers()
to flush without a callChange glClear
(GL_COLOR_BUFFER_BIT)
intoglClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
(this one causing even more warning). Also I tried to set the color intoglClearColor(255,255,255,0)
(white), but after clear color buffer, only black screen. So the glClear isn't working.Try to resize the window using reshape.
Update Xcode compiler for terminal to the latest version (Beta)
I'm using Gamma Correction from OpenGL with with
glEnable(GL_FRAMEBUFFER_SRGB)
, and after Mojave I'm facing this"Assertion failed: (value >= 0.0f && value <= 1.0f), function LinearToSRGB"
Does the openGL gamma correction doesn't work anymore ?
Any Suggestion ?
[UPDATE 1]
Step 3 above : Try to resize the window using reshape.
This one seems to work a little bit after I changed into full screen, following this Mojave 'hack' from The University of Bath, to resize your window to other dimension than the initial size. It failed when I set to another size (smaller/bigger), but when I set into fullscreen using glutFullScreen();
, my screen is rendered, as of now the frame transition is not smooth and I'm still working on it.
Also, I set my fps into 60fps and print them out. And after this hack I got random fps from 100-200 fps here, despite my Mac refresh rate only 90Hz. It is because the resize command, when I commented out the resize command I got black screen but the printed fps in terminal is correct (around 60fps). I realize this hack is also not reliable in the future. So, still need suggestion here, or other solution rather than resize.
[UPDATE 2]
I tried to changed my whole project using GLFW. Still the same black screen issue even with GLFW. Therefore this is not API issue.
[UPDATE 3]
Tried to clean uninstall XCode 10 (which comes with Mojave update). Then install XCode 9.41 (Sierra) and Command Tools 9.41 as well. As of now, the GLFW works, and the GLUT still doesn't work.