Guest User

EGL context

a guest
Nov 5th, 2015
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.20 KB | None | 0 0
  1.     EGLDisplay display;
  2.     EGLConfig config;
  3.     EGLContext context;
  4.     EGLint num_config;
  5.     EGLSurface surface;
  6.     EGLNativeWindowType native_window;
  7.     Display *x_display;
  8.  
  9.     // get an EGL display connection
  10.     display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
  11.  
  12.     // initialize the EGL display connection
  13.     eglInitialize(display, NULL, NULL);
  14.     eglBindAPI(EGL_OPENGL_ES_API);
  15.  
  16.     // get an appropriate EGL frame buffer configuration
  17.     EGLint attribute_list[] = {
  18.         EGL_RED_SIZE, 8,
  19.         EGL_GREEN_SIZE, 8,
  20.         EGL_BLUE_SIZE, 8,
  21.         EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
  22.         EGL_NONE
  23.     };
  24.     eglChooseConfig(display, attribute_list, &config, 1, &num_config);
  25.     if(num_config != 1)
  26.     {
  27.         LOGE("Number of suitable EGL configs found = %d.\n", num_config);
  28.         exit(1);
  29.     }
  30.  
  31.     // create an EGL rendering context
  32.     EGLint ContextAttributes[] = {
  33.         EGL_CONTEXT_CLIENT_VERSION, 2,      // selects OpenGL ES 2.0
  34.         EGL_NONE
  35.     };
  36.     context = eglCreateContext(display, config, EGL_NO_CONTEXT, ContextAttributes);
  37.     if(context == EGL_NO_CONTEXT)
  38.     {
  39.         LOGE("EGL Context creation failed\n");
  40.         exit(1);
  41.     }
Advertisement
Add Comment
Please, Sign In to add comment