static void load_gpm_library(SCREEN *sp) { sp->_mouse_gpm_found = FALSE; if ((sp->_dlopen_gpm = dlopen(LIBGPM_SONAME, my_RTLD)) != 0) { if (GET_DLSYM(gpm_fd) == 0 || GET_DLSYM(Gpm_Open) == 0 || GET_DLSYM(Gpm_Close) == 0 || GET_DLSYM(Gpm_GetEvent) == 0) { T(("GPM initialization failed: %s", dlerror())); unload_gpm_library(sp); } else { sp->_mouse_gpm_found = TRUE; sp->_mouse_gpm_loaded = TRUE; } } }
ContextInfo *eglContextFromConfig(EGLDisplay *dpy, EGLConfig config) { EGLSurface surface = getDummyWindowSurface(dpy, config); EGLint contextAttrs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE }; EGLContext context = eglCreateContext(dpy, config, NULL, contextAttrs); if (context == EGL_NO_CONTEXT) { fprintf(stderr, "eglCreateContext() failed - %d\n", eglGetError()); return 0; } if (!eglMakeCurrent(dpy, surface, surface, context)) { fprintf(stderr, "eglMakeCurrent failed - %d\n", eglGetError()); return 0; } ContextInfo *ctxInfo = NULL; /* Note: We are only storing the string information of a driver. Assuming a system with a single or homogeneous GPUs. For the case of heterogeneous GPUs system the string information will need to move to GLContext class. */ /* allocate the structure */ ctxInfo = (ContextInfo *) malloc(sizeof(ContextInfo)); if (ctxInfo == NULL) { fprintf(stderr, "nInitialize: Failed in malloc\n"); return 0; } /* initialize the structure */ initializeCtxInfo(ctxInfo); const char *glVersion = (char *)glGetString(GL_VERSION); const char *glVendor = (char *)glGetString(GL_VENDOR); const char *glRenderer = (char *)glGetString(GL_RENDERER); // Make a copy, at least one platform does not preserve the string beyond the call. char *glExtensions = strdup((char *)glGetString(GL_EXTENSIONS)); char *eglExtensions = strdup((char *)eglQueryString(dpy, EGL_EXTENSIONS)); /* find out the version, major and minor version number */ char *tmpVersionStr = strdup(glVersion); int versionNumbers[2]; extractVersionInfo(tmpVersionStr, versionNumbers); free(tmpVersionStr); ctxInfo->versionStr = strdup(glVersion); ctxInfo->vendorStr = strdup(glVendor); ctxInfo->rendererStr = strdup(glRenderer); ctxInfo->glExtensionStr = strdup(glExtensions); ctxInfo->glxExtensionStr = strdup(eglExtensions); ctxInfo->versionNumbers[0] = versionNumbers[0]; ctxInfo->versionNumbers[1] = versionNumbers[1]; ctxInfo->display = getNativeDisplayType(); ctxInfo->context = context; ctxInfo->egldisplay = dpy; // cleanup free(glExtensions); free(eglExtensions); // from the wrapped_egl.c void *handle = getLibGLEShandle(); /* set function pointers */ ctxInfo->glActiveTexture = (PFNGLACTIVETEXTUREPROC) GET_DLSYM(handle, "glActiveTexture"); ctxInfo->glAttachShader = (PFNGLATTACHSHADERPROC) GET_DLSYM(handle, "glAttachShader"); ctxInfo->glBindAttribLocation = (PFNGLBINDATTRIBLOCATIONPROC) GET_DLSYM(handle, "glBindAttribLocation"); ctxInfo->glBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC) GET_DLSYM(handle, "glBindFramebuffer"); ctxInfo->glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC) GET_DLSYM(handle, "glBindRenderbuffer"); ctxInfo->glCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSPROC) GET_DLSYM(handle, "glCheckFramebufferStatus"); ctxInfo->glCreateProgram = (PFNGLCREATEPROGRAMPROC) GET_DLSYM(handle, "glCreateProgram"); ctxInfo->glCreateShader = (PFNGLCREATESHADERPROC) GET_DLSYM(handle, "glCreateShader"); ctxInfo->glCompileShader = (PFNGLCOMPILESHADERPROC) GET_DLSYM(handle, "glCompileShader"); ctxInfo->glDeleteBuffers = (PFNGLDELETEBUFFERSPROC) GET_DLSYM(handle, "glDeleteBuffers"); ctxInfo->glDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC) GET_DLSYM(handle, "glDeleteFramebuffers"); ctxInfo->glDeleteProgram = (PFNGLDELETEPROGRAMPROC) GET_DLSYM(handle, "glDeleteProgram"); ctxInfo->glDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC) GET_DLSYM(handle, "glDeleteRenderbuffers"); ctxInfo->glDeleteShader = (PFNGLDELETESHADERPROC) GET_DLSYM(handle, "glDeleteShader"); ctxInfo->glDetachShader = (PFNGLDETACHSHADERPROC) GET_DLSYM(handle, "glDetachShader"); ctxInfo->glDisableVertexAttribArray = (PFNGLDISABLEVERTEXATTRIBARRAYPROC) GET_DLSYM(handle, "glDisableVertexAttribArray"); ctxInfo->glEnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC) GET_DLSYM(handle, "glEnableVertexAttribArray"); ctxInfo->glFramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC) GET_DLSYM(handle, "glFramebufferRenderbuffer"); ctxInfo->glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC) GET_DLSYM(handle, "glFramebufferTexture2D"); ctxInfo->glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC) GET_DLSYM(handle, "glGenFramebuffers"); ctxInfo->glGenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC) GET_DLSYM(handle, "glGenRenderbuffers"); ctxInfo->glGetProgramiv = (PFNGLGETPROGRAMIVPROC) GET_DLSYM(handle, "glGetProgramiv"); ctxInfo->glGetShaderiv = (PFNGLGETSHADERIVPROC) GET_DLSYM(handle, "glGetShaderiv"); ctxInfo->glGetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC) GET_DLSYM(handle, "glGetUniformLocation"); ctxInfo->glLinkProgram = (PFNGLLINKPROGRAMPROC) GET_DLSYM(handle, "glLinkProgram"); ctxInfo->glRenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC) GET_DLSYM(handle, "glRenderbufferStorage"); ctxInfo->glShaderSource = (PFNGLSHADERSOURCEPROC) GET_DLSYM(handle, "glShaderSource"); ctxInfo->glUniform1f = (PFNGLUNIFORM1FPROC) GET_DLSYM(handle, "glUniform1f"); ctxInfo->glUniform2f = (PFNGLUNIFORM2FPROC) GET_DLSYM(handle, "glUniform2f"); ctxInfo->glUniform3f = (PFNGLUNIFORM3FPROC) GET_DLSYM(handle, "glUniform3f"); ctxInfo->glUniform4f = (PFNGLUNIFORM4FPROC) GET_DLSYM(handle, "glUniform4f"); ctxInfo->glUniform4fv = (PFNGLUNIFORM4FVPROC) GET_DLSYM(handle, "glUniform4fv"); ctxInfo->glUniform1i = (PFNGLUNIFORM1IPROC) GET_DLSYM(handle, "glUniform1i"); ctxInfo->glUniform2i = (PFNGLUNIFORM2IPROC) GET_DLSYM(handle, "glUniform2i"); ctxInfo->glUniform3i = (PFNGLUNIFORM3IPROC) GET_DLSYM(handle, "glUniform3i"); ctxInfo->glUniform4i = (PFNGLUNIFORM4IPROC) GET_DLSYM(handle, "glUniform4i"); ctxInfo->glUniform4iv = (PFNGLUNIFORM4IVPROC) GET_DLSYM(handle, "glUniform4iv"); ctxInfo->glUniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVPROC) GET_DLSYM(handle, "glUniformMatrix4fv"); ctxInfo->glUseProgram = (PFNGLUSEPROGRAMPROC) GET_DLSYM(handle, "glUseProgram"); ctxInfo->glValidateProgram = (PFNGLVALIDATEPROGRAMPROC) GET_DLSYM(handle, "glValidateProgram"); ctxInfo->glVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC) GET_DLSYM(handle, "glVertexAttribPointer"); ctxInfo->glGenBuffers = (PFNGLGENBUFFERSPROC) GET_DLSYM(handle, "glGenBuffers"); ctxInfo->glBindBuffer = (PFNGLBINDBUFFERPROC) GET_DLSYM(handle, "glBindBuffer"); ctxInfo->glBufferData = (PFNGLBUFFERDATAPROC) GET_DLSYM(handle, "glBufferData"); ctxInfo->glBufferSubData = (PFNGLBUFFERSUBDATAPROC) GET_DLSYM(handle, "glBufferSubData"); ctxInfo->glGetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC) GET_DLSYM(handle, "glGetShaderInfoLog"); ctxInfo->glGetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC) GET_DLSYM(handle, "glGetProgramInfoLog"); ctxInfo->glTexImage2DMultisample = (PFNGLTEXIMAGE2DMULTISAMPLEPROC) GET_DLSYM(handle, "glTexImage2DMultisample"); ctxInfo->glRenderbufferStorageMultisample = (PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) GET_DLSYM(handle, "glRenderbufferStorageMultisample"); ctxInfo->glBlitFramebuffer = (PFNGLBLITFRAMEBUFFERPROC) GET_DLSYM(handle, "glBlitFramebuffer"); initState(ctxInfo); /* Releasing native resources */ eglMakeCurrent(ctxInfo->egldisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); //eglDestroySurface(ctxInfo->egldisplay, surface); return ctxInfo; }