Пример #1
0
EGLAPI EGLBoolean EGLAPIENTRY eglSaneChooseConfigBRCM(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config)
{
   return choose_config(dpy, attrib_list, configs, config_size, num_config, true);
}
Пример #2
0
int QNX_InitGL(void)
{
    int usage = SCREEN_USAGE_OPENGL_ES1;
	int transp = SCREEN_TRANSPARENCY_NONE;
	EGLint interval = 1;
	int size[2] = { -1, -1 };
	int pos[2] = { 0, 0 };
	int nbuffers = 2;
	int format;
	EGLConfig config;
    EGLint           err;

    config = choose_config(eglDisplay, "rgb565");
    if (config == (EGLConfig)0) {
        Com_Printf( "Demo Thread Init: failed to find config!" );
        return FALSE;
	}

    // Create EGL rendering context
    eglContext = eglCreateContext( eglDisplay, config, EGL_NO_CONTEXT, NULL );
    err = eglGetError( );
    if ( eglContext == EGL_NO_CONTEXT ) {
        Com_Printf( "Demo Thread Init: can't create gles2 context!" );
        PrintEglError( err );
		return FALSE;
    }

    err = screen_create_context(&screen_ctx, 0);
	if (err) {
		Com_Printf("screen_create_context");
		return FALSE;
	}

    err = screen_create_window(&screen_win, screen_ctx);
	if (err) {
		Com_Printf("screen_create_window");
		return FALSE;
	}

	format = choose_format(eglDisplay, config);
	err = screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_FORMAT, &format);
	if (err) {
		Com_Printf("screen_set_window_property_iv(SCREEN_PROPERTY_FORMAT)");
		return FALSE;
	}



	err = screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_USAGE, &usage);
	if (err) {
		Com_Printf("screen_set_window_property_iv(SCREEN_PROPERTY_USAGE)");
		return FALSE;
	}

	size[0]=1024;
	size[1]=768;

	err = screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, size);
	if (err) {
		Com_Printf("screen_set_window_property_iv(screen_set_window_property_iv)");
		return FALSE;
	}

	if (size[0] > 0 && size[1] > 0) {
		err = screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_SIZE, size);
		if (err) {
			Com_Printf("screen_set_window_property_iv(SCREEN_PROPERTY_SIZE)");
			return FALSE;
		}
	} else {
		err = screen_get_window_property_iv(screen_win, SCREEN_PROPERTY_SIZE, size);
		if (err) {
			Com_Printf("screen_get_window_property_iv(SCREEN_PROPERTY_SIZE)");
			return FALSE;
		}
	}

	glConfig.vidWidth = size[0];
	glConfig.vidHeight = size[1];

	InitControls();

	bz[0] = size[0];
	bz[1] = size[1];

	if (pos[0] != 0 || pos[1] != 0) {
		err = screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_POSITION, pos);
		if (err) {
			Com_Printf("screen_set_window_property_iv(SCREEN_PROPERTY_POSITION)");
			return FALSE;
		}
	}

	err = screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_TRANSPARENCY, &transp);
	if (err) {
		Com_Printf("screen_set_window_property_iv(SCREEN_PROPERTY_TRANSPARENCY)");
		return FALSE;
	}

	err = screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_SWAP_INTERVAL, &interval);
	if (err) {
		Com_Printf("screen_set_window_property_iv(SCREEN_PROPERTY_SWAP_INTERVAL)");
		return FALSE;
	}

	err = screen_create_window_buffers(screen_win, nbuffers);
	if (err) {
		Com_Printf("screen_create_window_buffers");
		return FALSE;
	}

	size[0] = 1024;
	size[1] = 600;
	err = screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_SIZE, size);
	if (err) {
		Com_Printf("screen_set_window_property_iv(SCREEN_PROPERTY_SIZE)");
		return FALSE;
	}

	err = screen_create_event(&screen_ev);
	if (err) {
		Com_Printf("screen_create_event");
		return FALSE;
	}

	eglSurface = eglCreateWindowSurface(eglDisplay, config, screen_win, NULL);
	if (eglSurface == EGL_NO_SURFACE) {
        Com_Printf( "Demo Thread Init: can't create surface!" );
        PrintEglError( err );
        return FALSE;
	}

	err = eglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext);
	if (err != EGL_TRUE) {
        Com_Printf( "Demo Thread Init: can't make current!" );
		return FALSE;
	}

	pps_decoder_init(&decoder, NULL, 0);
	ppsfd = open("/pps/services/navigator/control", O_RDWR);
	if (ppsfd == -1) {
		Com_Printf("warning: failed to open PPS\n");
	}
    return TRUE;
}
Пример #3
0
int egl_initialize(EGLDisplay *dpy, EGLConfig *config, EGLContext *context)
{
    EGLint major, minor;
    int fd;

    fd = get_service("DISPLAY");
    if(fd == 0)
        return -1;

    gbm = gbm_create_device(fd);
    if( gbm == NULL)
    {
        DBG("failed to initialize GBM device\n");
        goto err_0;
    };

    *dpy = eglGetDisplay(gbm);

    if (!eglInitialize(*dpy, &major, &minor))
    {
        DBG("failed to initialize EGL display\n");
        goto err_1;
    };

    DBG("EGL_VERSION = %s\n", eglQueryString(*dpy, EGL_VERSION));
    DBG("EGL_VENDOR = %s\n", eglQueryString(*dpy, EGL_VENDOR));
    DBG("EGL_EXTENSIONS = %s\n", eglQueryString(*dpy, EGL_EXTENSIONS));
    DBG("EGL_CLIENT_APIS = %s\n", eglQueryString(*dpy, EGL_CLIENT_APIS));

    *config = choose_config(*dpy);
    if( *config == NULL)
    {
        DBG("failed to choose a config\n");
        goto err_2;
    };

    eglBindAPI(EGL_OPENGL_API);
    *context = eglCreateContext(*dpy, *config, EGL_NO_CONTEXT, NULL);
    if (context == NULL)
    {
        DBG("failed to create context\n");
        goto err_2;
    };

    if (!eglMakeCurrent(*dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, *context))
    {
        DBG("failed to make context current");
        goto err_3;
    };

    return 0;

err_3:
    eglDestroyContext(*dpy, *context);
err_2:
    eglTerminate(*dpy);
err_1:
    gbm_device_destroy(gbm);
err_0:
    return -1;
};