As you may have known, OpenGL is now deprecated in the latest MacOS Mojave (10.14). 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 got black screen.
I read a lot of same issues with black screen on OpenGL after Mojave update in StackOverflow. But as of now, only few of them actually have accepted answer and the answers don’t work on me. So, when I run sometimes it renders, and sometimes it’s just black screen. What I have tried :
[ol]
[li]Change glFlush() into glutSwapBuffers() to flush without a call
[/li][li]Change glClear(GL_COLOR_BUFFER_BIT) into glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); (this one causing even more warning). Also I tried to set the color into glClearColor(255,255,255,0) (white), but after clear color buffer, only black screen. So the glClear isn’t working.
[/li][li] Try to resize the window using reshape.
[/li][li] update Xcode compiler for terminal to the latest version (Beta)
[/li][/ol]
This is my main loop :
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();
}
Any suggestion ?
[UPDATE]
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’ 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 usingHide glutFullScreen(); my screen is rendered, as of now the frame transition is not smooth and I’m still working on it.
[ATTACH=CONFIG]2870[/ATTACH]
Also, I set my fps into 60fps and print them out on terminal. 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). So, still need suggestion here, or other solution rather than resize.