AnsweredAssumed Answered

i.mx6q sabresd OpenGL ES API Segmentation fault

Question asked by Gary Yin on Oct 3, 2016
Latest reply on Nov 2, 2016 by Gary Yin

i.mx6q      linux 3.14.28

 

#include <unistd.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/wait.h>
#include <sys/mman.h>
#include <sys/mount.h>
#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <errno.h>

#include <EGL/egl.h>
#include <GLES/gl.h>
#include <math.h>
#include <time.h>

 

int main(int argc, char** argv)
{
   int fb;
   GLint maj, min;
   EGLDisplay m_eglDisplay;

 

   printf("OpenGL ES 1.1 DEMO\n");

 

   fb = open("/dev/fb0", O_RDWR);

   if(fb < 0)
   {
      printf("device fb0 open failed[%d : %d]!\n", fb, errno);
      goto exit0;
   }

 

   m_eglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);

   if(EGL_NO_DISPLAY == m_eglDisplay)
   {
      printf("error: eglGetDisplay returns EGL_NO_DISPLAY\n");
      goto exit1;
   }

 

   printf("eglGetDisplay() success\n");

 

   if(EGL_FALSE == eglInitialize(m_eglDisplay, &maj, &min))
   {
      printf("error: eglInitialize() returns EGL_FALSE\n");
      goto exit1;
   }

 

   printf("eglInitialize() success[%d.%d]\n", maj, min);

 

... ...

}

 

Compile options:

CFLAGS += -DLINUX -DEGL_API_FB

LIBS += -lGLESv1_CM -lGAL -lEGL -lVSC -lGAL_egl -lX11
LIBS += -lXdamage -lXfixes -lXext -lxcb -lXau -lXdmcp

 

Run the app:
root@imx6qsabresd:~# ./gles_demo 
OpenGL ES 1.1 DEMO
eglGetDisplay() success
Segmentation fault

 

So the API call "eglInitialize(m_eglDisplay, &maj, &min)" causes the Segmentation fault. Why?

Outcomes