AnsweredAssumed Answered

fb-based OpenGL ES2.0 application for i.MX6 crashing on glClear() call

Question asked by Scott Vander Weide on Aug 8, 2016
Latest reply on Aug 24, 2016 by Scott Vander Weide

I am attempting to write an fb-based OpenGL ES2.0 application for i.MX6 (specifically the BD Nitrogen6x). No matter what I try the application always crashes on the first glClear() call. I know this probably means the GL Context isn't current, but I don't know, beyond what I've already done, to make it current. Here is my sample application:

 

#include <GLES2/gl2.h>

#include <GLES2/gl2ext.h>

 

 

#include <EGL/egl.h>

#include <EGL/eglvivante.h>

 

 

#include <stdio.h>

#include <assert.h>

#include <stdlib.h>

#include <cstring>

#include <unistd.h>

 

 

//Configure window size here

#define WIDTH 1920

#define HEIGHT 1080

 

 

NativeDisplayType display;

NativeWindowType window;

 

 

EGLDisplay _eglDisplay;

EGLSurface _eglSurface;

EGLContext _eglContext;

 

 

EGLint numConfigs = 0;

EGLConfig eglConfig;

 

 

void init_egl()

{

    // setup attribs

    static const EGLint configAttribs[] =

    {

        EGL_SAMPLES,         0,

        EGL_RED_SIZE,        8,

        EGL_GREEN_SIZE,      8,

        EGL_BLUE_SIZE,       8,

        EGL_ALPHA_SIZE,      0,

        EGL_DEPTH_SIZE,      24,

        EGL_SURFACE_TYPE,    EGL_WINDOW_BIT,

        EGL_NONE

    };

 

 

    // create a context

    EGLint contextAttribs[] =

    {

        EGL_CONTEXT_CLIENT_VERSION, 2,

        EGL_NONE

    };

 

 

    display = fbGetDisplayByIndex( 0 );

    assert( display );

 

 

    _eglDisplay = eglGetDisplay( display );

    assert( EGL_SUCCESS == eglGetError() );

    assert( 0 != _eglDisplay );

 

 

    eglInitialize( _eglDisplay, NULL, NULL );

    assert( EGL_SUCCESS == eglGetError() );

 

 

    eglBindAPI(EGL_OPENGL_ES_API);

 

 

    eglChooseConfig( _eglDisplay, configAttribs, &eglConfig, 1, &numConfigs );

    assert( EGL_SUCCESS == eglGetError() );

    assert( 1 == numConfigs );

 

 

    window = fbCreateWindow( display, 0, 0, WIDTH, HEIGHT );

    assert( window );

 

 

    _eglSurface = eglCreateWindowSurface( _eglDisplay, eglConfig, window, configAttribs );

    assert( EGL_SUCCESS == eglGetError() );

 

 

    _eglContext = eglCreateContext( _eglDisplay, eglConfig, NULL, contextAttribs );

    assert( EGL_SUCCESS == eglGetError() );

 

 

    eglMakeCurrent( _eglDisplay, _eglSurface, _eglSurface, _eglContext );

    assert( EGL_SUCCESS == eglGetError() );

 

 

    eglSwapInterval( _eglDisplay, 1 );

}

 

 

int main(int argc,char *argv[])

{

    init_egl();

 

 

    int ret = 0;

    while( running && ret != -1 )

    {

        glViewport( 0, 0, WIDTH, HEIGHT );

        glClearColor( 1.0, 1.0, 0.0, 1.0 );

        glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

        eglSwapBuffers( _eglDisplay, _eglSurface );

    }

 

 

    return 0;

}

 

Any help is very much appreciated.

Outcomes