创建osmesa(屏幕外mesa)上下文后,glewInit()崩溃(segfault) [英] glewInit() crashing (segfault) after creating osmesa (off-screen mesa) context

查看:486
本文介绍了创建osmesa(屏幕外mesa)上下文后,glewInit()崩溃(segfault)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在远程计算集群上运行opengl应用程序.我正在使用osmesa,因为我打算执行屏幕外软件渲染(不进行x11转发等).我想使用glew(使生活更轻松地处理着色器和其他与扩展相关的调用),而且我似乎已经建立并关联了台面和glew.

I'm trying to run an opengl application on a remote computing cluster. I'm using osmesa as I intend to execute off-screen software rendering (no x11 forwarding etc). I want to use glew (to make life dealing with shaders and other extension related calls easier), and I seem to have built and linked both mesa and glew fine.

当我调用mesa-create-context时,glewinit给出了OPENGL版本不可用的输出,这可能意味着尚未创建上下文.当我调用glGetString(GL_EXTENSIONS)时,我没有得到任何输出,这证实了这一点.这也表明毛刺本身可以正常工作. (其他glew命令(例如glew版本等)也可以使用.

When I call mesa-create-context, glewinit gives a OPENGL Version not available output, which probably means the context has not been created. When I call glGetString(GL_EXTENSIONS) i dont get any output, which confirms this. This also shows that glew is working fine on its own. (Other glew commands like glew version etc also work).

现在,当我(如下所示)添加mesa-make-context-current函数时,glewinit会因段错误而崩溃.

Now when I (as shown below), add the mesa-make-context-current function, glewinit crashes with a segfault. Running glGetString(GL_EXTENSIONS) gives me a list of extensions now however (which means context creation is successful!)

我花了数小时试图弄清楚这一点,尝试修补,但无济于事.将不胜感激对此的任何帮助.也许你们当中有些人以前经历过类似的事情??再次感谢!

I've spent hours trying to figure this out, tried tinkering but nothing works. Would greatly appreciate any help on this. Maybe some of you has experienced something similar before?? Thanks again!

int Height = 1; int Width = 1;
OSMesaContext ctx; void *buffer; 
ctx = OSMesaCreateContext( OSMESA_RGBA, NULL );
buffer = malloc( Width * Height * 4 * sizeof(GLfloat) );

if (!OSMesaMakeCurrent( ctx, buffer, GL_UNSIGNED_BYTE, Width, Height )) {
printf("OSMesaMakeCurrent failed!\n");
return 0;
 }
-- glewinit() crashes after this.

仅添加一下,osmesa和glew最初并没有编译.由于glew在最后一行中未定义GLAPI,并且由于osmesa将不再包含gl.h,因此GLAPI仍未定义,并导致osmesa.h错误(119).我通过向GLAPI添加extern来解决此问题,但不确定是否与此相关.

Just to add, osmesa and glew actually did not compile initially. Because glew undefines GLAPI in it's last line and since osmesa will not include gl.h again, GLAPI remains undefined and causes an error in osmesa.h (119). I got around this by adding an extern to GLAPI, not sure if this is relevant though.

推荐答案

在glew.c中查看glewInit的源代码,如果glewContextInit成功,它将返回GLEW_OK,GLEW_OK定义为0,在Linux系统上,它将始终调用glxewContextInit它调用glX函数,在OSMesa的情况下可能无法使用.这将导致段错误(如我所见),不幸的是,glewInit函数无法在不修补C源代码和重新编译库的情况下处理这种情况.

Looking at the source to glewInit in glew.c if glewContextInit succeeds it returns GLEW_OK, GLEW_OK is defined to 0, and so on Linux systems it will always call glxewContextInit which calls glX functions that in the case of OSMesa will likely not be ready for use. This will cause a segfault (as I see), and it seems that the glewInit function has no capability to handle this case unfortunately without patching the C source and recompiling the library.

如果其他人已经解决了这个问题,我会很感兴趣,我已经看到了glew.c源程序的一些修补版本,可以解决此问题.尚不清楚GLEW社区中是否有任何能量来合并针对该用例的更改.

If others have already solved this I would be interested, I have seen some patched versions of the glew.c sources that workaround this. It isn't clear if there is any energy in the GLEW community to merge changes in that address this use case.

这篇关于创建osmesa(屏幕外mesa)上下文后,glewInit()崩溃(segfault)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆