Guest User

Untitled

a guest
Jan 16th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.36 KB | None | 0 0
  1. #include <EGL/egl.h>
  2. #include <GL/gl.h>
  3. #include <iostream>
  4. using namespace std;
  5.  
  6. static EGLint const attribute_list[] = {
  7. EGL_RED_SIZE, 1,
  8. EGL_GREEN_SIZE, 1,
  9. EGL_BLUE_SIZE, 1,
  10. EGL_NONE
  11. };
  12.  
  13.  
  14. int main(){
  15.  
  16. EGLDisplay display;
  17. EGLConfig config;
  18. EGLContext context;
  19.  
  20. EGLint num_config;
  21.  
  22. display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
  23.  
  24. if(display == EGL_NO_DISPLAY){
  25. cout << "Error detecting display!" << endl;
  26. return 0;
  27. }
  28.  
  29. EGLint init = eglInitialize(display, NULL, NULL);
  30.  
  31. if(init == EGL_BAD_DISPLAY){
  32. cout << "Error! Display is not an EGL display connection." << endl;
  33. return 0;
  34. }
  35.  
  36. EGLBoolean cfg = eglChooseConfig(display, attribute_list, &config, 1, &num_config);
  37.  
  38. if(cfg == EGL_FALSE){
  39. cout << "Error setting configurations!" << endl;
  40. return 0;
  41. }
  42.  
  43. context = eglCreateContext(display, config, EGL_NO_CONTEXT, NULL);
  44. EGLint ctx = eglGetError();
  45.  
  46. if(context == EGL_NO_CONTEXT){
  47. cout << "Error! Creation of the context failed." << endl;
  48. }
  49.  
  50. if(ctx == EGL_BAD_MATCH){
  51. cout << "Error! The current rendering API is EGL_NONE or the server context state for share_context exists in an address space which cannot be shared with the newly created context!" << endl;
  52. return 0;
  53. }else if(ctx == EGL_BAD_DISPLAY){
  54. cout << "Error! Display is not an EGL display connection." << endl;
  55. return 0;
  56. }else if(ctx == EGL_NOT_INITIALIZED){
  57. cout << "Error! Display has not been initialized." << endl;
  58. return 0;
  59. }else if(ctx == EGL_BAD_CONFIG){
  60. cout << "Error! Config is not an EGL frame buffer configuration, or does not support the current rendering API." << endl;
  61. return 0;
  62. }else if(ctx == EGL_BAD_CONTEXT){
  63. cout << "Error! Share_context is not an EGL rendering context!" << endl;
  64. return 0;
  65. }else if(ctx == EGL_BAD_ATTRIBUTE){
  66. cout << "Error! Attrib_list contains an invalid context attribute or if an attribute is not recognized or out of range." << endl;
  67. return 0;
  68. }else if(ctx == EGL_BAD_ALLOC){
  69. cout << "Error! There are not enough resources to allocate the new context." << endl;
  70. return 0;
  71. }
  72.  
  73. EGLBoolean cpdy = eglMakeCurrent(display, NULL, NULL, context);
  74.  
  75. if(cpdy == EGL_FALSE){
  76. cout << "Fail make current" << endl;
  77. return 0;
  78. }
  79.  
  80. cout << glGetString(GL_VERSION) << endl;
  81.  
  82. return 0;
  83. }
Add Comment
Please, Sign In to add comment