EGLDisplay对GBM [英] EGLDisplay on GBM
问题描述
我想通过创建一个EGL OpenGL上下文。正如我不会实际绘制,我想结合使用与pbuffer而使GBM的平台。这是code(C99):
I want to create an OpenGL context through EGL. As I won't actually draw, I want to use Pbuffers in conjunction with the GBM platform. This is the code (C99):
#include <stdlib.h>
#include <assert.h>
#include <fcntl.h>
#include <unistd.h>
#include <EGL/egl.h>
#include <EGL/eglext.h>
#include <gbm.h>
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;
}
它失败,出现以下错误:
It fails with the following error:
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);
<一个href=\"http://virtuousgeek.org/blog/index.php/jbarnes/2011/10/31/writing_stanalone_programs_with_egl_and_\">This是我把为例页面。
我很惊讶,因为我建梅萨与 - 与东瀛平台= DRM,韦兰,X11
,而且,即使它说的这里的 EGL_DEFAULT_DISPLAY
映射到指定的第一个平台,它是一个别名 _XDisplay *
我的系统上。
I'm surprised, because I built Mesa with --with-egl-platforms=drm,wayland,x11
, and, even though it is stated here that EGL_DEFAULT_DISPLAY
maps to the first platform specified, it is an alias for _XDisplay *
on my system.
--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.
据我所知,韦斯顿创建在裸KMS借鉴GBM之上的EGLDisplay。我看着它的code,我已经grepped相关的系统头寻找一个解决方案,但它似乎并不存在。
AFAIK, Weston creates an EGLDisplay on top of GBM for drawing on bare KMS. I've looked at its code, and I've grepped the pertinent system headers looking for a solution, but it seems to not be there.
FWIW,我使用梅萨10.0上的Radeon HD 3200,Linux的3.12.6,GCC 4.8.2。
FWIW, I'm using Mesa 10.0 on a Radeon HD 3200, Linux 3.12.6, GCC 4.8.2.
推荐答案
您说
我想结合使用与pbuffer而使GBM的平台。
I want to use Pbuffers in conjunction with the GBM platform.
EGL / GBM不支持pbuffer而使。它不支持像素图无论是。
EGL/GBM does not support Pbuffers. It doesn't support Pixmaps either.
要创建EGL / GBM一个屏幕外表面,你必须通过一个gbm_surface到eglCreateWindowSurface。 窗口是用词不当。没有真正的窗口被创建。得到的缓冲区将保持屏幕外,除非你使用内核的KMS的API将其发布到显示器上。
To create an offscreen surface with EGL/GBM, you must pass a gbm_surface to eglCreateWindowSurface. "Window" is a misnomer. No real "window" gets created. The resultant buffer will remain offscreen unless you use the kernel's KMS APIs to post it to the display.
可是......为什么你的程序编译失败,这不是。当调用eglGetDisplay和eglCreateWindowSurface,必须转换是这样的:
But... that's not why your program fails to compile. When calling eglGetDisplay and eglCreateWindowSurface, you must cast like this:
eglGetDisplay((EGLNativeDisplayType)my_gbm_device);
eglCreateWindowSurface(egl_dpy, egl_config,
(EGLNativeWindowType)my_gbm_surface, NULL);
如果您正在使用包含提交<一台面href=\"http://cgit.freedesktop.org/mesa/mesa/commit/src/egl/main?id=468cc866b4b308cee40470f06b31002c6c56da96\"相对=nofollow> 468cc86 ,那么你就可以通过,而不是使用eglGetPlatformDisplayEXT和eglCreatePlatformWindowSurface这样避免了铸造:
If you are using a Mesa that contains commit 468cc86, then you may avoid the casting by instead using eglGetPlatformDisplayEXT and eglCreatePlatformWindowSurface like this:
eglGetPlatformDisplayEXT(EGL_PLATFORM_GBM_MESA, my_gbm_device, NULL);
eglCreatePlatformWindowSurfaceEXT(egl_dpy, egl_config, my_gbm_surface, NULL);
无论您选择使用香草EGL功能或较新的平台功能EGL,你应该参考的例子code中的 EGL_MESA_platform_gbm 规范为指导。
这篇关于EGLDisplay对GBM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!