14后处理opengl黑屏

14后处理opengl黑屏

本文介绍了如何在更新到macos mojave 10.14后处理opengl黑屏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如您所知,OpenGL现已在最新的MacOS Mojave(10.14)中弃用。我正在使用OpenGL + GLUT(我知道这是旧的,但我只需要一个简单的程序)并在终端上运行(不使用Xcode)。使用在Sierra中完美运行的相同程序,我在Mojave中获得了如此多的OpenGL弃用警告并设法使用-Wno-deprecated-declarations抑制所有警告,但现在我只有黑屏。



在StackOverflow中进行Mojave更新后,我在OpenGL上阅读了很多与黑屏相同的问题。但截至目前,只有少数人真正接受了答案,答案对我不起作用。所以,当我有时候运行渲染时,有时它只是黑屏。



这是我的主循环:



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.

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();
}





我的尝试:



我尝试了什么:



1.将glFlush()更改为glutSwapBuffers()以在不通电的情况下刷新

2.将glClear(GL_COLOR_BUFFER_BIT)更改为glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); (这个引起更多警告)

3.尝试调整屏幕大小。还有黑屏

4.更新终端的Xcode编译器



[更新]



上面的步骤3:尝试使用重塑来调整窗口大小。



这个似乎在我改变之后有点工作全屏显示,按照调整大小窗口到其他维度而不是初始大小。当我设置为另一个尺寸(更小/更大)时失败,但是当我使用



What I have tried:

What I have tried :

1. Change glFlush() into glutSwapBuffers() to flush without a call
2. Change glClear(GL_COLOR_BUFFER_BIT) into glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); (this one causing even more warning)
3. Try to resize the screen. Still got black screen
4. update Xcode compiler for terminal

[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 using

glutFullScreen();

设置为全屏时,我的屏幕被渲染,截至目前帧过渡是不顺利,我还在努力。



另外,我将我的fps设置为60fps并打印出来。虽然我的Mac刷新率只有90Hz,但在这次黑客攻击之后我在这里得到了100-200 fps的随机fps。这是因为resize命令,当我注释掉调整大小命令时,我得到了黑屏,但终端中打印的fps是正确的(大约60fps)。所以,仍然需要在这里提出建议,或者其他解决方案,而不是调整大小。



仍然是黑屏。有什么建议吗?

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 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.

Still the black screen. Any suggestion ?

推荐答案


这篇关于如何在更新到macos mojave 10.14后处理opengl黑屏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 16:50