egl_config_test.cpp 3.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <math.h>
  5. #include <time.h>
  6. #include <iostream>
  7. #include <assert.h>
  8. #include <EGL/egl.h>
  9. using namespace std;
  10. int main(void)
  11. {
  12. EGLDisplay display;
  13. // get an EGL display connection
  14. display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
  15. assert(display !=EGL_NO_DISPLAY);
  16. // now lets initialise EGL and get the versions
  17. int major;
  18. int minor;
  19. EGLBoolean result;
  20. result = eglInitialize(display, &major, &minor);
  21. assert(result != EGL_FALSE );
  22. std::cout<<"Major version "<<major<<" minor "<<minor<<"\n";
  23. EGLint numConfigs;
  24. // first we call getConfigs with a NULL to see how many configs we have
  25. result=eglGetConfigs(display,NULL,0,&numConfigs);
  26. assert(result != EGL_FALSE );
  27. std::cout<< "number of configs found "<<numConfigs<<"\n";
  28. // now we create a buffer to store all our configs
  29. EGLConfig *configs = new EGLConfig[numConfigs];
  30. // and copy them into our buffer (don't forget to delete once done)
  31. result=eglGetConfigs(display,configs,numConfigs,&numConfigs);
  32. assert(result != EGL_FALSE );
  33. int value = 0;
  34. for(int i=0; i<numConfigs; ++i)
  35. {
  36. std::cout<<"====================\nConfig #"<<i<<"\n";
  37. eglGetConfigAttrib(display,configs[i],EGL_BUFFER_SIZE,&value);
  38. std::cout<<"Buffer Size "<<value<<"\n";
  39. eglGetConfigAttrib(display,configs[i],EGL_RED_SIZE,&value);
  40. std::cout<<"Red Size "<<value<<"\n";
  41. eglGetConfigAttrib(display,configs[i],EGL_GREEN_SIZE,&value);
  42. std::cout<<"Green Size "<<value<<"\n";
  43. eglGetConfigAttrib(display,configs[i],EGL_BLUE_SIZE,&value);
  44. std::cout<<"Blue Size "<<value<<"\n";
  45. eglGetConfigAttrib(display,configs[i],EGL_ALPHA_SIZE,&value);
  46. std::cout<<"Alpha Size "<<value<<"\n";
  47. eglGetConfigAttrib(display,configs[i],EGL_CONFIG_CAVEAT,&value);
  48. switch(value)
  49. {
  50. case EGL_NONE : std::cout<<"EGL_CONFIG_CAVEAT EGL_NONE\n"; break;
  51. case EGL_SLOW_CONFIG : std::cout<<"EGL_CONFIG_CAVEAT EGL_SLOW_CONFIG\n"; break;
  52. }
  53. eglGetConfigAttrib(display,configs[i],EGL_CONFIG_ID,&value);
  54. std::cout<<"Config ID "<<value<<"\n";
  55. eglGetConfigAttrib(display,configs[i],EGL_DEPTH_SIZE,&value);
  56. std::cout<<"Depth size "<<value<<"\n";
  57. eglGetConfigAttrib(display,configs[i],EGL_MAX_PBUFFER_WIDTH,&value);
  58. std::cout<<"Max pbuffer width "<<value<<"\n";
  59. eglGetConfigAttrib(display,configs[i],EGL_MAX_PBUFFER_HEIGHT,&value);
  60. std::cout<<"Max pbuffer height "<<value<<"\n";
  61. eglGetConfigAttrib(display,configs[i],EGL_MAX_PBUFFER_PIXELS,&value);
  62. std::cout<<"Max pbuffer pixels "<<value<<"\n";
  63. eglGetConfigAttrib(display,configs[i],EGL_NATIVE_RENDERABLE,&value);
  64. std::cout<<"Native renderable "<<std::string(value ? "true" : "false")<<"\n";
  65. eglGetConfigAttrib(display,configs[i],EGL_NATIVE_VISUAL_ID,&value);
  66. std::cout<<"Native visual ID "<<value<<"\n";
  67. eglGetConfigAttrib(display,configs[i],EGL_NATIVE_VISUAL_TYPE,&value);
  68. std::cout<<"Native visual type "<<value<<"\n";
  69. eglGetConfigAttrib(display,configs[i],EGL_SAMPLE_BUFFERS,&value);
  70. std::cout<<"Sample Buffers "<<value<<"\n";
  71. eglGetConfigAttrib(display,configs[i],EGL_SAMPLES,&value);
  72. std::cout<<"Samples "<<value<<"\n";
  73. eglGetConfigAttrib(display,configs[i],EGL_SURFACE_TYPE,&value);
  74. std::cout<<"Surface type "<<value<<"\n";
  75. eglGetConfigAttrib(display,configs[i],EGL_TRANSPARENT_TYPE,&value);
  76. }
  77. // don't forget to delete once done
  78. delete [] configs;
  79. return 0;
  80. }