わいえむねっと

Contents
Categories
Calendar
2014/09
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
Monthly Archives
~2000/01
Recent Entries
RSS1.0
Templates
Information
Processed: 0.058 sec
Chashed: -
2014/09/29 Mon
OpenGL ESメモ@Yocto


前提

  • Ubuntu 12.04
  • Yocto Project 1.6.1 - Daisy
  • qemuarm
  • core-image-x11
  • gcc
  • g++
  • libegl-mesa
  • libegl-mesa-dev
  • libgles2-mesa
  • libgles2-mesa-dev


テストコード


#include <stdlib.h>
#include <EGL/egl.h>

int main()
{
    Display* xdisp = XOpenDisplay(NULL);
    if(xdisp == NULL)
    {
        abort();
    }

    Window rootWin = DefaultRootWindow(xdisp);

    int screen = DefaultScreen(xdisp);
    unsigned long white = WhitePixel(xdisp, screen);
    unsigned long black = BlackPixel(xdisp, screen);

    Window window = XCreateSimpleWindow(
        xdisp, rootWin, 
        100, 100,
        640, 480,
        2,
        black, white);

#ifdef DEFAULT
    EGLDisplay eglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
#else
    EGLDisplay eglDisplay = eglGetDisplay((EGLNativeDisplayType)xdisp);
#endif
    if(eglDisplay == EGL_NO_DISPLAY)
    {
        abort();
    }
    if(!eglInitialize(eglDisplay, NULL, NULL))
    {
        abort();
    }

    EGLint attr[] = {
        EGL_BUFFER_SIZE, 16,
        EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
        EGL_NONE,
    };
    EGLConfig cfg;
    EGLint numConfigs;
    if(!eglChooseConfig(eglDisplay, attr, &cfg, 1, &numConfigs))
    {
        abort();
    }
    if(numConfigs != 1)
    {
        abort();
    }
    EGLSurface eglSurface = eglCreateWindowSurface(eglDisplay, cfg, window, NULL);
    if(eglSurface == EGL_NO_SURFACE)
    {
        abort();
    }
}


EGL_DEFAULT_DISPLAYで初期化

Native platform type: drm (build-time configuration)


# arm-poky-linux-gnueabi-g++ foo.cpp -lX11 -lEGL -DDEFAULT
# export EGL_LOG_LEVEL=debug
# ./a.out
libEGL debug: Native platform type: drm (build-time configuration)
libEGL debug: EGL search path is /usr/lib/egl
libEGL debug: added egl_dri2 to module array
libEGL debug: added egl_glx to module array
gbm_create_device: invalid fd: -1
libEGL warning: GLX: failed to load GLX
libEGL debug: EGL user error 0x3001 (EGL_NOT_INITIALIZED) in eglInitialize
Aborted

eglInitializeでEGL_NOT_INITIALIZED。


Native platform type: x11 (environment overwrite)


# export EGL_PLATFORM=x11
# ./a.out
libEGL debug: Native platform type: x11 (environment overwrite)
libEGL debug: EGL search path is /usr/lib/egl
libEGL debug: added egl_dri2 to module array
libEGL debug: added egl_glx to module array
libEGL warning: DRI2: failed to authenticate
libEGL debug: DRI2: dlopen(/usr/lib/dri/swrast_dri.so)
libEGL debug: DRI2: found extension `DRI_Core'
libEGL info: DRI2: found extension DRI_Core version 1
libEGL debug: DRI2: found extension `DRI_SWRast'
libEGL info: DRI2: found extension DRI_SWRast version 3
libEGL debug: DRI2: found extension `DRI_TexBuffer'
libEGL info: DRI2: found extension DRI_TexBuffer version 2
libEGL debug: the best driver is DRI2
libEGL debug: EGL user error 0x3003 (EGL_BAD_ALLOC) in xcb_get_geometry
Aborted

eglCreateWindowSurfaceでEGL_BAD_ALLOC。


X11のDisplayで初期化

Native platform type: x11 (autodetected)


# arm-poky-linux-gnueabi-g++ foo.cpp -lX11 -lEGL
# unset EGL_PLATFORM
# ./a.out
libEGL debug: Native platform type: x11 (autodetected)
libEGL debug: EGL search path is /usr/lib/egl
libEGL debug: added egl_dri2 to module array
libEGL debug: added egl_glx to module array
libEGL warning: DRI2: failed to authenticate
libEGL debug: DRI2: dlopen(/usr/lib/dri/swrast_dri.so)
libEGL debug: DRI2: found extension `DRI_Core'
libEGL info: DRI2: found extension DRI_Core version 1
libEGL debug: DRI2: found extension `DRI_SWRast'
libEGL info: DRI2: found extension DRI_SWRast version 3
libEGL debug: DRI2: found extension `DRI_TexBuffer'
libEGL info: DRI2: found extension DRI_TexBuffer version 2
libEGL debug: the best driver is DRI2
libEGL debug: Display 0x1b160 is destroyed with resources

正常終了。


Native platform type: drm (environment overwrite)


# export EGL_PLATFORM=drm
# ./a.out
libEGL debug: Native platform type: drm (environment overwrite)
libEGL debug: EGL search path is /usr/lib/egl
libEGL debug: added egl_dri2 to module array
libEGL debug: added egl_glx to module array
Segmentation fault

eglInitializeでSegmentation fault。


参考サイト

すらりん日記 ≫ Blog Archive ≫ Ubuntuで EGL使えるか?|No:3072|すらりん日記
http://blog.techl​ab-xe.net/archives/3072

Mesa EGL
http://www.mesa3d​.org/egl.html