Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <EGL/egl.h>
- #include <GL/gl.h>
- #include <iostream>
- using namespace std;
- static EGLint const attribute_list[] = {
- EGL_RED_SIZE, 1,
- EGL_GREEN_SIZE, 1,
- EGL_BLUE_SIZE, 1,
- EGL_NONE
- };
- int main(){
- EGLDisplay display;
- EGLConfig config;
- EGLContext context;
- EGLint num_config;
- display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
- if(display == EGL_NO_DISPLAY){
- cout << "Error detecting display!" << endl;
- return 0;
- }
- EGLint init = eglInitialize(display, NULL, NULL);
- if(init == EGL_BAD_DISPLAY){
- cout << "Error! Display is not an EGL display connection." << endl;
- return 0;
- }
- EGLBoolean cfg = eglChooseConfig(display, attribute_list, &config, 1, &num_config);
- if(cfg == EGL_FALSE){
- cout << "Error setting configurations!" << endl;
- return 0;
- }
- context = eglCreateContext(display, config, EGL_NO_CONTEXT, NULL);
- EGLint ctx = eglGetError();
- if(context == EGL_NO_CONTEXT){
- cout << "Error! Creation of the context failed." << endl;
- }
- if(ctx == EGL_BAD_MATCH){
- 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;
- return 0;
- }else if(ctx == EGL_BAD_DISPLAY){
- cout << "Error! Display is not an EGL display connection." << endl;
- return 0;
- }else if(ctx == EGL_NOT_INITIALIZED){
- cout << "Error! Display has not been initialized." << endl;
- return 0;
- }else if(ctx == EGL_BAD_CONFIG){
- cout << "Error! Config is not an EGL frame buffer configuration, or does not support the current rendering API." << endl;
- return 0;
- }else if(ctx == EGL_BAD_CONTEXT){
- cout << "Error! Share_context is not an EGL rendering context!" << endl;
- return 0;
- }else if(ctx == EGL_BAD_ATTRIBUTE){
- cout << "Error! Attrib_list contains an invalid context attribute or if an attribute is not recognized or out of range." << endl;
- return 0;
- }else if(ctx == EGL_BAD_ALLOC){
- cout << "Error! There are not enough resources to allocate the new context." << endl;
- return 0;
- }
- EGLBoolean cpdy = eglMakeCurrent(display, NULL, NULL, context);
- if(cpdy == EGL_FALSE){
- cout << "Fail make current" << endl;
- return 0;
- }
- cout << glGetString(GL_VERSION) << endl;
- return 0;
- }
Add Comment
Please, Sign In to add comment