eglCreateWindowSurface return error 0x300B

We are trying to use EmbeddedWizard GUI platform with the iMX6DL. We have a problem while creating windows surface.
eglCreateWindowSurface function returns with error code 0x300B (BAD NATIVE WINDOWS).

I think, it is about the version of libEGL. I tried it with following images of toradex

Colibri-iMX6_Console-Image-Tezi_3.0b4.25

Colibri-iMX6_LXDE-Image-Tezi_2.8b6.184

Then I use Yocto to create two different images from the Index of /toradex-bsp-platform.git -b LinuxImage3.0 with the below changes in the local.conf file

First one:

DISTRO_FEATURES_remove = "x11 directfb wayland"
ACCEPT_FSL_EULA = "1"
IMAGE_INSTALL_append_mx6 = "eglinfo-fb"
IMAGE_FEATURES += "tools-debug tools-sdk"
CORE_IMAGE_EXTRA_INSTALL += "openssh openssh-sftp-server"
CORE_IMAGE_EXTRA_INSTALL += "dhcp-server dhcp-client "

Second one:

DISTRO_FEATURES_remove = "x11 wayland"
ACCEPT_FSL_EULA = "1"
IMAGE_INSTALL_append_mx6 = "eglinfo-fb"
IMAGE_FEATURES += "tools-debug tools-sdk"
CORE_IMAGE_EXTRA_INSTALL += "openssh openssh-sftp-server"
CORE_IMAGE_EXTRA_INSTALL += "dhcp-server dhcp-client "

As I understood, the problem occurs from EGL library. It has different modes, like framebuffer, directfb and X11. Is configuration correct for the framebuffer mode? Or do we need to make any changes?

This is the method of creating window surface.

eglDisplay = eglGetDisplay( EGL_DEFAULT_DISPLAY );  // no error occured after this
eglInitialize( eglDisplay,&EglVer0, &EglVer1 ); // no error occured after this
eglBindAPI( EGL_OPENGL_ES_API ); // no error occured after this
eglChooseConfig( eglDisplay, configAttribs, &eglConfig, 1, &num_configs ); // no error occured after this
eglSurface = eglCreateWindowSurface( eglDisplay, eglConfig, 0, 0 ); // BAD_NATIVE_WINDOWS error occures after this.

Hi @gnz and welcome to the Toradex Community!

Did you check this community thread about a similar topic? You basically have to make sure that you don’t have x11 or wayland in your DISTRO_FEATURES and that you add eglinfo-fb to the configuration. For this adding DISTRO_FEATURES_remove = "x11 " to your conf/local.conf is enough, since the Colibri iMX6 uses the tdx-x11 distro configuration which is on x11 and removes wayland by default. Also add eglinfo-fb with IMAGE_INSTALL_append_mx6 = " eglinfo-fb". In total:

 DISTRO_FEATURES_remove = "x11"
 ACCEPT_FSL_EULA = "1"
 IMAGE_INSTALL_append_mx6 = " eglinfo-fb"
 IMAGE_FEATURES += "tools-debug tools-sdk"
 CORE_IMAGE_EXTRA_INSTALL += "openssh openssh-sftp-server"
 CORE_IMAGE_EXTRA_INSTALL += "dhcp-server dhcp-client "

Additionally, you have to make sure to remove all buildoutput when you change the DISTRO_FEATURES variable.

rm -rf build/tmp-glibc/* sstate-cache/*

With that, I had the eglinfo-fb on my target. Did you check if your build was successful and if you can run eglinfo-fb on the target?

If it is still not working, would you have the full sample code with a proper Makefile to be able to reproduce the issue?

Best regards
Diego

Hi @diego_b.tx ,
Yes I have the eglinfo-fb on the target

EGL information:
    API version:    1.5
    vendor string:  Vivante Corporation
    version string: 1.5
    client APIs:    OpenGL_ES OpenVG
    extensions:
      EGL_KHR_fence_sync
      EGL_KHR_reusable_sync
      EGL_KHR_wait_sync
      EGL_KHR_image
      EGL_KHR_image_base
      EGL_KHR_image_pixmap
      EGL_KHR_gl_texture_2D_image
      EGL_KHR_gl_texture_cubemap_image
      EGL_KHR_gl_renderbuffer_image
      EGL_EXT_image_dma_buf_import
      EGL_EXT_image_dma_buf_import_modifiers
      EGL_KHR_lock_surface
      EGL_KHR_create_context
      EGL_KHR_surfaceless_context
      EGL_EXT_buffer_age
      EGL_ANDROID_native_fence_sync
      EGL_KHR_partial_update
   number of configurations: 60

win = window      (c) = conformant             slow      = slow config               gl      = Desktop OpenGL
pb  = pbuffer     (n) = non-conformant         nonconfmt = non-conformant config     es1,es2 = OpenGL ES 1.x/2.x
pix = pixmap                                                                         vg      = OpenVG

      #      ID  LEVEL  COLORBUFFER..........  DEPTH  STENCIL  MULTISAMPLE....  VISUAL.......  SURFACES..  RENDERABLES......................  TRANSPARENT..  CAVEAT...
                        type size  r  g  b  a  size   size     samples buffers  type   id                  apis                       native  type  r  g  b
      0       1      0  rgb    12  4  4  4  0     0      0           0       0  0x3038 0x0000  win,pb      es1(c),es2(c)              no      none -1 -1 -1  none
      1       2      0  rgb    12  4  4  4  0     0      8           0       0  0x3038 0x0000  win,pb      es1(c),es2(c)              no      none -1 -1 -1  none
      2       3      0  rgb    12  4  4  4  0    16      0           0       0  0x3038 0x0000  win,pb      es1(c),es2(c)              no      none -1 -1 -1  none
      3       4      0  rgb    12  4  4  4  0    24      0           0       0  0x3038 0x0000  win,pb      es1(c),es2(c)              no      none -1 -1 -1  none
      4       5      0  rgb    12  4  4  4  0    24      8           0       0  0x3038 0x0000  win,pb      es1(c),es2(c)              no      none -1 -1 -1  none
      5       6      0  rgb    12  4  4  4  0     0      0           4       1  0x3038 0x0000  win,pb      es1(c),es2(c)              no      none -1 -1 -1  none
      6       7      0  rgb    12  4  4  4  0     0      8           4       1  0x3038 0x0000  win,pb      es1(c),es2(c)              no      none -1 -1 -1  none
      7       8      0  rgb    12  4  4  4  0    16      0           4       1  0x3038 0x0000  win,pb      es1(c),es2(c)              no      none -1 -1 -1  none
      8       9      0  rgb    12  4  4  4  0    24      0           4       1  0x3038 0x0000  win,pb      es1(c),es2(c)              no      none -1 -1 -1  none
      9      10      0  rgb    12  4  4  4  0    24      8           4       1  0x3038 0x0000  win,pb      es1(c),es2(c)              no      none -1 -1 -1  none
     10      11      0  rgb    15  5  5  5  0     0      0           0       0  0x3038 0x0000  win,pb      es1(c),es2(c)              no      none -1 -1 -1  none
     11      12      0  rgb    15  5  5  5  0     0      8           0       0  0x3038 0x0000  win,pb      es1(c),es2(c)              no      none -1 -1 -1  none
     12      13      0  rgb    15  5  5  5  0    16      0           0       0  0x3038 0x0000  win,pb      es1(c),es2(c)              no      none -1 -1 -1  none
     13      14      0  rgb    15  5  5  5  0    24      0           0       0  0x3038 0x0000  win,pb      es1(c),es2(c)              no      none -1 -1 -1  none
     14      15      0  rgb    15  5  5  5  0    24      8           0       0  0x3038 0x0000  win,pb      es1(c),es2(c)              no      none -1 -1 -1  none
     15      16      0  rgb    15  5  5  5  0     0      0           4       1  0x3038 0x0000  win,pb      es1(c),es2(c)              no      none -1 -1 -1  none
     16      17      0  rgb    15  5  5  5  0     0      8           4       1  0x3038 0x0000  win,pb      es1(c),es2(c)              no      none -1 -1 -1  none
     17      18      0  rgb    15  5  5  5  0    16      0           4       1  0x3038 0x0000  win,pb      es1(c),es2(c)              no      none -1 -1 -1  none
     18      19      0  rgb    15  5  5  5  0    24      0           4       1  0x3038 0x0000  win,pb      es1(c),es2(c)              no      none -1 -1 -1  none
     19      20      0  rgb    15  5  5  5  0    24      8           4       1  0x3038 0x0000  win,pb      es1(c),es2(c)              no      none -1 -1 -1  none
     20      21      0  rgb    16  4  4  4  4     0      0           0       0  0x3038 0x0000  win,pb      es1(c),es2(c)              no      none -1 -1 -1  none
     21      22      0  rgb    16  5  6  5  0     0      0           0       0  0x0010 0x0000  win,pb,pix  es1(c),es2(c)              yes     none -1 -1 -1  none
     22      23      0  rgb    16  4  4  4  4     0      8           0       0  0x3038 0x0000  win,pb      es1(c),es2(c)              no      none -1 -1 -1  none
     23      24      0  rgb    16  5  6  5  0     0      8           0       0  0x0010 0x0000  win,pb,pix  es1(c),es2(c)              yes     none -1 -1 -1  none
     24      25      0  rgb    16  4  4  4  4    16      0           0       0  0x3038 0x0000  win,pb      es1(c),es2(c)              no      none -1 -1 -1  none
     25      26      0  rgb    16  5  6  5  0    16      0           0       0  0x0010 0x0000  win,pb,pix  es1(c),es2(c),vg(n)        yes     none -1 -1 -1  none
     26      27      0  rgb    16  4  4  4  4    24      0           0       0  0x3038 0x0000  win,pb      es1(c),es2(c)              no      none -1 -1 -1  none
     27      28      0  rgb    16  5  6  5  0    24      0           0       0  0x0010 0x0000  win,pb,pix  es1(c),es2(c)              yes     none -1 -1 -1  none
     28      29      0  rgb    16  4  4  4  4    24      8           0       0  0x3038 0x0000  win,pb      es1(c),es2(c)              no      none -1 -1 -1  none
     29      30      0  rgb    16  5  6  5  0    24      8           0       0  0x0010 0x0000  win,pb,pix  es1(c),es2(c)              yes     none -1 -1 -1  none
     30      31      0  rgb    16  4  4  4  4     0      0           4       1  0x3038 0x0000  win,pb      es1(c),es2(c)              no      none -1 -1 -1  none
     31      32      0  rgb    16  5  6  5  0     0      0           4       1  0x0010 0x0000  win,pb,pix  es1(c),es2(c)              yes     none -1 -1 -1  none
     32      33      0  rgb    16  4  4  4  4     0      8           4       1  0x3038 0x0000  win,pb      es1(c),es2(c)              no      none -1 -1 -1  none
     33      34      0  rgb    16  5  6  5  0     0      8           4       1  0x0010 0x0000  win,pb,pix  es1(c),es2(c)              yes     none -1 -1 -1  none
     34      35      0  rgb    16  4  4  4  4    16      0           4       1  0x3038 0x0000  win,pb      es1(c),es2(c)              no      none -1 -1 -1  none
     35      36      0  rgb    16  5  6  5  0    16      0           4       1  0x0010 0x0000  win,pb,pix  es1(c),es2(c),vg(c)        yes     none -1 -1 -1  none
     36      37      0  rgb    16  4  4  4  4    24      0           4       1  0x3038 0x0000  win,pb      es1(c),es2(c)              no      none -1 -1 -1  none
     37      38      0  rgb    16  5  6  5  0    24      0           4       1  0x0010 0x0000  win,pb,pix  es1(c),es2(c)              yes     none -1 -1 -1  none
     38      39      0  rgb    16  4  4  4  4    24      8           4       1  0x3038 0x0000  win,pb      es1(c),es2(c)              no      none -1 -1 -1  none
     39      40      0  rgb    16  5  6  5  0    24      8           4       1  0x0010 0x0000  win,pb,pix  es1(c),es2(c)              yes     none -1 -1 -1  none
     40      41      0  rgb    24  8  8  8  0     0      0           0       0  0x0020 0x0000  win,pb,pix  es1(c),es2(c)              yes     none -1 -1 -1  none
     41      42      0  rgb    24  8  8  8  0     0      8           0       0  0x0020 0x0000  win,pb,pix  es1(c),es2(c)              yes     none -1 -1 -1  none
     42      43      0  rgb    24  8  8  8  0    16      0           0       0  0x0020 0x0000  win,pb,pix  es1(c),es2(c),vg(n)        yes     none -1 -1 -1  none
     43      44      0  rgb    24  8  8  8  0    24      0           0       0  0x0020 0x0000  win,pb,pix  es1(c),es2(c)              yes     none -1 -1 -1  none
     44      45      0  rgb    24  8  8  8  0    24      8           0       0  0x0020 0x0000  win,pb,pix  es1(c),es2(c)              yes     none -1 -1 -1  none
     45      46      0  rgb    24  8  8  8  0     0      0           4       1  0x0020 0x0000  win,pb,pix  es1(c),es2(c)              yes     none -1 -1 -1  none
     46      47      0  rgb    24  8  8  8  0     0      8           4       1  0x0020 0x0000  win,pb,pix  es1(c),es2(c)              yes     none -1 -1 -1  none
     47      48      0  rgb    24  8  8  8  0    16      0           4       1  0x0020 0x0000  win,pb,pix  es1(c),es2(c),vg(c)        yes     none -1 -1 -1  none
     48      49      0  rgb    24  8  8  8  0    24      0           4       1  0x0020 0x0000  win,pb,pix  es1(c),es2(c)              yes     none -1 -1 -1  none
     49      50      0  rgb    24  8  8  8  0    24      8           4       1  0x0020 0x0000  win,pb,pix  es1(c),es2(c)              yes     none -1 -1 -1  none
     50      51      0  rgb    32  8  8  8  8     0      0           0       0  0x0020 0x0000  win,pb,pix  es1(c),es2(c)              yes     none -1 -1 -1  none
     51      52      0  rgb    32  8  8  8  8     0      8           0       0  0x0020 0x0000  win,pb,pix  es1(c),es2(c)              yes     none -1 -1 -1  none
     52      53      0  rgb    32  8  8  8  8    16      0           0       0  0x0020 0x0000  win,pb,pix  es1(c),es2(c),vg(n)        yes     none -1 -1 -1  none
     53      54      0  rgb    32  8  8  8  8    24      0           0       0  0x0020 0x0000  win,pb,pix  es1(c),es2(c)              yes     none -1 -1 -1  none
     54      55      0  rgb    32  8  8  8  8    24      8           0       0  0x0020 0x0000  win,pb,pix  es1(c),es2(c)              yes     none -1 -1 -1  none
     55      56      0  rgb    32  8  8  8  8     0      0           4       1  0x0020 0x0000  win,pb,pix  es1(c),es2(c)              yes     none -1 -1 -1  none
     56      57      0  rgb    32  8  8  8  8     0      8           4       1  0x0020 0x0000  win,pb,pix  es1(c),es2(c)              yes     none -1 -1 -1  none
     57      58      0  rgb    32  8  8  8  8    16      0           4       1  0x0020 0x0000  win,pb,pix  es1(c),es2(c),vg(n)        yes     none -1 -1 -1  none
     58      59      0  rgb    32  8  8  8  8    24      0           4       1  0x0020 0x0000  win,pb,pix  es1(c),es2(c)              yes     none -1 -1 -1  none
     59      60      0  rgb    32  8  8  8  8    24      8           4       1  0x0020 0x0000  win,pb,pix  es1(c),es2(c)              yes     none -1 -1 -1  none

No valid context: EGL failed to allocate resources for the requested operation.
eglMakeCurrent() failed: Arguments are inconsistent (for example, a valid context requires buffers not supplied by a valid surface).

OpenGL ES 2 information:
    version string:  OpenGL ES 3.0 V6.2.4.p4.190076
    renderer string: Vivante GC880
    extensions:
      GL_OES_vertex_type_10_10_10_2
      GL_OES_vertex_half_float
      GL_OES_element_index_uint
      GL_OES_mapbuffer
      GL_OES_vertex_array_object
      GL_OES_compressed_ETC1_RGB8_texture
      GL_OES_compressed_paletted_texture
      GL_OES_texture_npot
      GL_OES_rgb8_rgba8
      GL_OES_depth_texture
      GL_OES_depth_texture_cube_map
      GL_OES_depth24
      GL_OES_depth32
      GL_OES_packed_depth_stencil
      GL_OES_fbo_render_mipmap
      GL_OES_get_program_binary
      GL_OES_fragment_precision_high
      GL_OES_standard_derivatives
      GL_OES_EGL_image
      GL_OES_EGL_sync
      GL_OES_required_internalformat
      GL_OES_surfaceless_context
      GL_OES_texture_half_float
      GL_OES_texture_float
      GL_EXT_texture_type_2_10_10_10_REV
      GL_EXT_texture_filter_anisotropic
      GL_EXT_texture_compression_dxt1
      GL_EXT_texture_format_BGRA8888
      GL_EXT_texture_compression_s3tc
      GL_EXT_read_format_bgra
      GL_EXT_multi_draw_arrays
      GL_EXT_frag_depth
      GL_EXT_discard_framebuffer
      GL_EXT_blend_minmax
      GL_EXT_multisampled_render_to_texture
      GL_EXT_robustness
      GL_EXT_texture_sRGB_decode
      GL_EXT_texture_rg
      GL_EXT_sRGB
      GL_VIV_direct_texture
  main stats:
    max texture size:                 8192
    max cubemap texture size:         8192
    max texture image units:          8
    max renderbuffer size:            8064
    max combined texture image units: 20
    num compressed texture formats:   25
    aliased line width range:         1 - 16
    aliased point size range:         1 - 128
    implementation color read format: RGB
    implementation color read type:   unsigned byte
    max viewport dimensions:          8192 x 8192
    subpixel bits:                    4
    supported compressed texture formats:
      0x9270
      0x9271
      0x9272
      0x9273
      0x9274
      0x9275
      0x9276
      0x9277
      0x9278
      0x9279
      ETC1_RGB8
      PALETTE4_RGBA4_OES
      PALETTE4_RGB5_A1_OES
      PALETTE4_R5_G6_B5_OES
      PALETTE4_RGB8_OES
      PALETTE4_RGBA8_OES
      PALETTE8_RGBA4_OES
      PALETTE8_RGB5_A1_OES
      PALETTE8_R5_G6_B5_OES
      PALETTE8_RGB8_OES
      PALETTE8_RGBA8_OES
      COMPRESSED_RGB_S3TC_DXT1_EXT
      COMPRESSED_RGBA_S3TC_DXT1_EXT
      COMPRESSED_RGBA_S3TC_DXT3_ANGLE
      COMPRESSED_RGBA_S3TC_DXT5_ANGLE
  shader specific stats:
    max vertex attribs:             16
    max vertex texture image units: 4
    num program binary formats:     0
    num shader binary formats:      1
    max varying vectors:            11
    max vertex uniform vectors:     256
    max fragment uniform vectors:   256
    shader compiler:                yes
    supported shader binary formats:
      SHADER_BINARY_VIV

OpenVG information:
    vendor string:   Vivante Corporation
    version string:  1.1
    renderer string: Vivante GC880
    extensions:
      VG_KHR_EGL_image
  stats:
    max scissor rects:          256
    max dash count:             256
    max kernel size:            7
    max separable kernel size:  15
    max color ramp stops:       256
    max image width:            8192
    max image height:           8192
    max image pixels:           67108864
    max image bytes:            268435456
    max gaussian std deviation: 16
    image format acceleration:
      image format   accelerated
        sRGBX_8888           no
        sRGBA_8888           no
    sRGBA_8888_PRE           no
          sRGB_565           no
        sRGBA_5551           no
        sRGBA_4444           no
              sL_8           no
        lRGBX_8888           no
        lRGBA_8888           no
    lRGBA_8888_PRE           no
              lL_8           no
               A_8           no
              BW_1           no
        sXRGB_8888           no
        sARGB_8888           no
    sARGB_8888_PRE           no
        sARGB_1555           no
        sARGB_4444           no
        lXRGB_8888           no
        lARGB_8888           no
    lARGB_8888_PRE           no
        sBGRX_8888           no
        sBGRA_8888           no
    sBGRA_8888_PRE           no
          sBGR_565           no
        sBGRA_5551           no
        sBGRA_4444           no
        lBGRX_8888           no
        lBGRA_8888           no
    lBGRA_8888_PRE           no
        sXBGR_8888           no
        sABGR_8888           no
    sABGR_8888_PRE           no
        sABGR_1555           no
        sABGR_4444           no
        lXBGR_8888           no
        lABGR_8888           no
    lABGR_8888_PRE           no
    path datatype acceleration:
       s8  s16  s32    f
      yes  yes  yes  yes

I’ve attached the source codes and the makefile for my project. I am new to Linux and OpenGL. Do we need vivante-fb.so for using OpenGL or not?

link text

The problem was solved. Problem was my code. To use EGL with iMx6 frame buffer, NativeDisplayWindows needs to be changed like this.

GnzNativeDisplay = fbGetDisplayByIndex(0);
GnzNativeWindow = fbCreateWindow(GnzNativeDisplay,0,0,0,0);
eglDisplay = eglGetDisplay(GnzNativeDisplay);
eglInitialize( eglDisplay, 0, 0 );
eglBindAPI( EGL_OPENGL_ES_API );
eglChooseConfig( eglDisplay, configAttribs, &eglConfig, 1, &num_configs );
eglSurface = eglCreateWindowSurface( eglDisplay, eglConfig, GnzNativeWindow, 0 );

Hi @gnz

I am happy to hear that! Thank you for the notification.

Best regards
Diego