/* ** GLimp_InitGL */ static bool GLimp_InitGL( void ) { int format; EGLConfig config; const int pbufferAttribs[] = { EGL_WIDTH, 1, EGL_HEIGHT, 1, EGL_NONE }; const int contextAttribs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE }; EGLSurface surface; glw_state.display = qeglGetDisplay( EGL_DEFAULT_DISPLAY ); if( glw_state.display == EGL_NO_DISPLAY ) { ri.Com_Printf( "GLimp_InitGL() - eglGetDisplay failed\n" ); return false; } if( !qeglInitialize( glw_state.display, NULL, NULL ) ) { ri.Com_Printf( "GLimp_InitGL() - eglInitialize failed\n" ); return false; } GLimp_Android_ChooseConfig(); if( !glw_state.config ) { ri.Com_Printf( "GLimp_InitGL() - GLimp_Android_ChooseConfig failed\n" ); return false; } if ( !qeglGetConfigAttrib( glw_state.display, glw_state.config, EGL_NATIVE_VISUAL_ID, &glw_state.format ) ) { ri.Com_Printf( "GLimp_InitGL() - eglGetConfigAttrib failed\n" ); return false; } glw_state.pbufferSurface = qeglCreatePbufferSurface( glw_state.display, glw_state.config, pbufferAttribs ); if( glw_state.pbufferSurface == EGL_NO_SURFACE ) { ri.Com_Printf( "GLimp_InitGL() - eglCreatePbufferSurface failed\n" ); return false; } glw_state.context = qeglCreateContext( glw_state.display, glw_state.config, EGL_NO_CONTEXT, contextAttribs ); if( glw_state.context == EGL_NO_CONTEXT ) { ri.Com_Printf( "GLimp_InitGL() - eglCreateContext failed\n" ); return false; } glw_state.swapInterval = 1; GLimp_Android_UpdateWindowSurface(); return true; }
/* ** GLimp_SharedContext_Create */ bool GLimp_SharedContext_Create( void **context, void **surface ) { const int pbufferAttribs[] = { EGL_WIDTH, 1, EGL_HEIGHT, 1, EGL_NONE }; const int contextAttribs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE }; EGLSurface pbuffer; EGLContext ctx; pbuffer = qeglCreatePbufferSurface( glw_state.display, glw_state.config, pbufferAttribs ); if( pbuffer == EGL_NO_SURFACE ) return false; ctx = qeglCreateContext( glw_state.display, glw_state.config, glw_state.context, contextAttribs ); if( !ctx ) { qeglDestroySurface( glw_state.display, pbuffer ); return false; } *context = ctx; *surface = pbuffer; return true; }
/** * Creates a 1x1 pbuffer surface for contexts that don't use the main surface. * * @return 1x1 pbuffer surface */ static EGLSurface GLimp_EGL_CreatePbufferSurface( void ) { const int pbufferAttribs[] = { EGL_WIDTH, 1, EGL_HEIGHT, 1, EGL_NONE }; return qeglCreatePbufferSurface( glw_state.display, glw_state.config, pbufferAttribs ); }