c/c++语言开发共享EGLD上的EGLD显示

我想通过EGL创建一个OpenGL上下文。 由于我实际上不会绘制,我想将Pbuffers与GBM平台结合使用。 这是代码(C99):

#include  #include  #include  #include  #include  #include  #include  int main( void ) { assert( eglBindAPI( EGL_OPENGL_API ) == EGL_TRUE ); int fd = open("/dev/dri/card0", O_RDWR); struct gbm_device * gbm = gbm_create_device( fd ); EGLDisplay dpy = eglGetDisplay( gbm ); eglInitialize( dpy , NULL , NULL ); EGLConfig config; EGLint n_of_configs; assert( eglGetConfigs( dpy , &config , 1 , &n_of_configs ) == EGL_TRUE ); EGLSurface srf = eglCreatePbufferSurface( dpy , config , NULL ); assert( srf != EGL_NO_SURFACE ); EGLContext ctx = eglCreateContext( dpy , config , EGL_NO_CONTEXT , NULL ); assert( ctx != EGL_NO_CONTEXT ); assert( eglMakeCurrent( dpy , srf , srf , ctx ) == EGL_TRUE ); eglDestroySurface( dpy , srf ); eglDestroyContext( dpy , ctx ); eglTerminate( dpy ); gbm_device_destroy( gbm ); close( fd ); return EXIT_SUCCESS; } 

它失败并出现以下错误:

 test.c: In function 'main': test.c:20:2: error: passing argument 1 of 'eglGetDisplay' from incompatible pointer type [-Werror] EGLDisplay dpy = eglGetDisplay( gbm ); ^ In file included from test.c:7:0: /usr/include/EGL/egl.h:251:31: note: expected 'EGLNativeDisplayType' but argument is of type 'struct gbm_device *' EGLAPI EGLDisplay EGLAPIENTRY eglGetDisplay(EGLNativeDisplayType display_id); 

这是我作为例子的页面。

我很惊讶,因为我使用--with-egl-platforms=drm,wayland,x11构建了Mesa,即使这里说EGL_DEFAULT_DISPLAY映射到指定的第一个平台,它也是我的_XDisplay *的别名系统。

 --with-egl-platforms List the platforms (window systems) to support. Its argument is a comma seprated string such as --with-egl-platforms=x11,drm. It decides the platforms a driver may support. The first listed platform is also used by the main library to decide the native platform: the platform the EGL native types such as EGLNativeDisplayType or EGLNativeWindowType defined for. 

AFAIK,Weston在GBM上创建了一个EGLDisplay,用于绘制裸KMS。 我已经查看了它的代码,并且我已经找到了相关的系统头,寻找解决方案,但似乎并不存在。

FWIW,我在Radeon HD 3200,Linux 3.12.6,GCC 4.8.2上使用Mesa 10.0。

    你说

    我想将Pbuffers与GBM平台结合使用。

    EGL / GBM不支持Pbuffers。 它也不支持Pixmaps。

    要使用EGL / GBM创建屏幕外表面,必须将gbm_surface传递给eglCreateWindowSurface。 “窗口”是用词不当。 没有真正的“窗口”被创建。 除非您使用内核的KMS API将其发布到显示器,否则生成的缓冲区将保持在屏幕外。

    但是……这不是你的程序无法编译的原因。 调用eglGetDisplay和eglCreateWindowSurface时,必须像这样进行转换:

     eglGetDisplay((EGLNativeDisplayType)my_gbm_device); eglCreateWindowSurface(egl_dpy, egl_config, (EGLNativeWindowType)my_gbm_surface, NULL); 

    如果您使用的是包含提交468cc86的Mesa,那么您可以通过使用eglGetPlatformDisplayEXT和eglCreatePlatformWindowSurface来避免强制转换,如下所示:

     eglGetPlatformDisplayEXT(EGL_PLATFORM_GBM_MESA, my_gbm_device, NULL); eglCreatePlatformWindowSurfaceEXT(egl_dpy, egl_config, my_gbm_surface, NULL); 

    无论您选择使用vanilla EGL函数还是更新的平台EGL函数,都应该参考EGL_MESA_platform_gbm规范中的示例代码作为指导。

      以上就是c/c++开发分享EGLD上的EGLD显示相关内容,想了解更多C/C++开发(异常处理)及C/C++游戏开发关注计算机技术网(www.ctvol.com)!)。

      本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。

      ctvol管理联系方式QQ:251552304

      本文章地址:https://www.ctvol.com/c-cdevelopment/545050.html

      (0)
      上一篇 2021年1月10日
      下一篇 2021年1月10日

      精彩推荐