Guest User

Untitled

a guest
Jan 29th, 2012
1,541
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <unistd.h>
  4.  
  5. // adjustments to paths might be needed
  6. #include <EGL/egl.h>
  7. #include <EGL/eglplatform.h>
  8. #include <GLES2/gl2.h>
  9.  
  10. static EGLint const attribute_list[] = {
  11.     EGL_RED_SIZE, 1,
  12.     EGL_GREEN_SIZE, 1,
  13.     EGL_BLUE_SIZE, 1,
  14.     EGL_NONE
  15. };
  16.  
  17. static EGLint const context_attribute_list[] = {
  18.     EGL_CONTEXT_CLIENT_VERSION, 2,
  19.     EGL_NONE
  20. };
  21.  
  22. struct gl_limit {
  23.     GLint name;
  24.     char *string;
  25.     int num_args;
  26. };
  27. #define EXPAND(x) x, #x
  28. struct gl_limit limits[] = {
  29.     {EXPAND(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS), 1},
  30.     {EXPAND(GL_MAX_CUBE_MAP_TEXTURE_SIZE), 1},
  31.     {EXPAND(GL_MAX_FRAGMENT_UNIFORM_VECTORS), 1},
  32.     {EXPAND(GL_MAX_RENDERBUFFER_SIZE), 1},
  33.     {EXPAND(GL_MAX_TEXTURE_IMAGE_UNITS), 1},
  34.     {EXPAND(GL_MAX_TEXTURE_SIZE), 1},
  35.     {EXPAND(GL_MAX_VARYING_VECTORS), 1},
  36.     {EXPAND(GL_MAX_VERTEX_ATTRIBS), 1},
  37.     {EXPAND(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS), 1},
  38.     {EXPAND(GL_MAX_VERTEX_UNIFORM_VECTORS), 1},
  39.     {EXPAND(GL_MAX_VIEWPORT_DIMS), 2},
  40.     {0, NULL}
  41. };
  42.  
  43. int main(int argc, char ** argv)
  44. {
  45.     EGLDisplay display;
  46.     EGLConfig config;
  47.     EGLContext context;
  48.     EGLSurface surface;
  49.     EGLint num_config;
  50.  
  51.     // create a pbuffer-based surface, and use it
  52.     display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
  53.     eglInitialize(display, NULL, NULL);
  54.     eglChooseConfig(display, attribute_list, &config, 1, &num_config);
  55.     context = eglCreateContext(display, config, EGL_NO_CONTEXT,
  56.             context_attribute_list);
  57.     surface = eglCreatePbufferSurface(display, config, NULL);
  58.     eglMakeCurrent(display, surface, surface, context);
  59.  
  60.     // query egl-specific strings
  61.     char *egl_vendor = (char *)eglQueryString(display, EGL_VENDOR);
  62.     char *egl_version = (char *)eglQueryString(display, EGL_VERSION);
  63.     char *egl_apis = (char *)eglQueryString(display, EGL_CLIENT_APIS);
  64.     char *egl_exts = (char *)eglQueryString(display, EGL_EXTENSIONS);
  65.  
  66.     printf("EGL\n");
  67.     printf("  Vendor: %s\n", egl_vendor);
  68.     printf("  Version: %s\n", egl_version);
  69.     printf("  Client APIs: %s\n", egl_apis);
  70.     printf("  Extensions: %s\n", egl_exts);
  71.  
  72.     // query strings
  73.     char *vendor = (char *)glGetString(GL_VENDOR);
  74.     char *renderer = (char *)glGetString(GL_RENDERER);
  75.     char *version = (char *)glGetString(GL_VERSION);
  76.     char *glsl_version = (char *)glGetString(GL_SHADING_LANGUAGE_VERSION);
  77.     char *exts = (char *)glGetString(GL_EXTENSIONS);
  78.  
  79.     printf("OpenGL ES\n");
  80.     printf("  Vendor: %s\n", vendor);
  81.     printf("  Renderer: %s\n", renderer);
  82.     printf("  Version: %s\n", version);
  83.     printf("  GLSL version: %s\n", glsl_version);
  84.     printf("  Extensions: %s\n", exts);
  85.     printf("  Implementation limits:\n");
  86.  
  87.     // query limits
  88.     int i = 0;
  89.     for (i = 0; limits[i].name != 0; i++) {
  90.         int param[2] = {0, 0};
  91.         glGetIntegerv(limits[i].name, param);
  92.         if (limits[i].num_args == 1)
  93.             printf("    %s = %d\n", limits[i].string, param[0]);
  94.         else
  95.             printf("    %s = %d, %d\n", limits[i].string, param[0], param[1]);
  96.  
  97.     }
  98.  
  99.     return EXIT_SUCCESS;
  100. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×