Esempio n. 1
0
/**
 * Recreates and selects the surface for the newly created window, or selects a dummy buffer when there's no window.
 */
static void GLimp_Android_UpdateWindowSurface( void )
{
	ANativeWindow *window = glw_state.window;

	if( glw_state.surface != EGL_NO_SURFACE )
	{
		qeglDestroySurface( glw_state.display, glw_state.surface );
		glw_state.surface = EGL_NO_SURFACE;
	}

	if( !window )
	{
		qeglMakeCurrent( glw_state.display, glw_state.pbufferSurface, glw_state.pbufferSurface, glw_state.context );
		return;
	}

	ANativeWindow_setBuffersGeometry( window, glConfig.width, glConfig.height, glw_state.format );

	if( glConfig.stereoEnabled )
	{
		const char *extensions = qglGetGLWExtensionsString();
		if( extensions && strstr( extensions, "EGL_EXT_multiview_window" ) )
		{
			int attribs[] = { EGL_MULTIVIEW_VIEW_COUNT_EXT, 2, EGL_NONE };
			glw_state.surface = qeglCreateWindowSurface( glw_state.display, glw_state.config, glw_state.window, attribs );
		}
	}

	if( glw_state.surface == EGL_NO_SURFACE ) // Try to create a non-stereo surface.
	{
		glConfig.stereoEnabled = false;
		glw_state.surface = qeglCreateWindowSurface( glw_state.display, glw_state.config, glw_state.window, NULL );
	}

	if( glw_state.surface == EGL_NO_SURFACE )
	{
		ri.Com_Printf( "GLimp_Android_UpdateWindowSurface() - GLimp_Android_CreateWindowSurface failed\n" );
		return;
	}

	if( !qeglMakeCurrent( glw_state.display, glw_state.surface, glw_state.surface, glw_state.context ) )
	{
		ri.Com_Printf( "GLimp_Android_UpdateWindowSurface() - eglMakeCurrent failed\n" );
		qeglDestroySurface( glw_state.display, glw_state.surface );
		glw_state.surface = EGL_NO_SURFACE;
		return;
	}

	qeglSwapInterval( glw_state.display, glw_state.swapInterval );
}
Esempio n. 2
0
/**
 * Recreates and selects the surface for the newly created window, or selects a dummy buffer when there's no window.
 */
static void GLimp_EGL_UpdateWindowSurface( void )
{
    EGLNativeWindowType window = glw_state.window;
    EGLContext context = qeglGetCurrentContext();

    if( context == EGL_NO_CONTEXT )
        return;

    if( glw_state.surface != EGL_NO_SURFACE )
    {
        qeglMakeCurrent( glw_state.display, glw_state.noWindowPbuffer, glw_state.noWindowPbuffer, context );
        qeglDestroySurface( glw_state.display, glw_state.surface );
        glw_state.surface = EGL_NO_SURFACE;
    }

    if( !window )
        return;

#ifdef __ANDROID__
    ANativeWindow_setBuffersGeometry( window, glConfig.width, glConfig.height, glw_state.format );
#endif

    glw_state.surface = qeglCreateWindowSurface( glw_state.display, glw_state.config, window, NULL );
    if( glw_state.surface == EGL_NO_SURFACE )
    {
        ri.Com_Printf( "GLimp_EGL_UpdateWindowSurface() - GLimp_EGL_CreateWindowSurface failed\n" );
        return;
    }

    qeglMakeCurrent( glw_state.display, glw_state.surface, glw_state.surface, context );
    qeglSwapInterval( glw_state.display, glw_state.swapInterval );
}