Esempio n. 1
0
/* Return 1 if we were able to initialize PSPGL successfully. */
int PSP_GL_Init(_THIS)
{
	EGLint attribs[32];
	EGLDisplay display;
	EGLContext context;
	EGLSurface surface;
	EGLConfig config;
	EGLint num_configs;
	int i;

	/* EGL init taken from glutCreateWindow() in PSPGL's glut.c. */
	EGLCHK(display = eglGetDisplay(0));
	EGLCHK(eglInitialize(display, NULL, NULL));

	/* Setup the config based on SDL's current values. */
	i = 0;
	attribs[i++] = EGL_RED_SIZE;
	attribs[i++] = this->gl_config.red_size;
	attribs[i++] = EGL_GREEN_SIZE;
	attribs[i++] = this->gl_config.green_size;
	attribs[i++] = EGL_BLUE_SIZE;
	attribs[i++] = this->gl_config.blue_size;
	attribs[i++] = EGL_DEPTH_SIZE;
	attribs[i++] = this->gl_config.depth_size;

	if (this->gl_config.alpha_size)
	{
		attribs[i++] = EGL_ALPHA_SIZE;
		attribs[i++] = this->gl_config.alpha_size;
	}
	if (this->gl_config.stencil_size)
	{
		attribs[i++] = EGL_STENCIL_SIZE;
		attribs[i++] = this->gl_config.stencil_size;
	}

	attribs[i++] = EGL_NONE;
	EGLCHK(eglChooseConfig(display, attribs, &config, 1, &num_configs));

	if (num_configs == 0)
	{
		SDL_SetError("No valid EGL configs for requested mode");
		return 0;
	}

	EGLCHK(context = eglCreateContext(display, config, NULL, NULL));
	EGLCHK(surface = eglCreateWindowSurface(display, config, 0, NULL));

	this->gl_data->display = display;
	this->gl_data->context = context;
	this->gl_data->surface = surface;
	return 1;
}
Esempio n. 2
0
int glutCreateWindow (const char *title)
{
    EGLConfig config;
    EGLint num_configs;

    atexit(cleanup);

    /* pass NativeDisplay=0, we only have one screen... */
    EGLCHK(dpy = eglGetDisplay(0));
    EGLCHK(eglInitialize(dpy, NULL, NULL));

    psp_log("EGL vendor \"%s\"\n", eglQueryString(dpy, EGL_VENDOR));
    psp_log("EGL version \"%s\"\n", eglQueryString(dpy, EGL_VERSION));
    psp_log("EGL extensions \"%s\"\n", eglQueryString(dpy, EGL_EXTENSIONS));

    if (glut_display_mode & GLUT_ALPHA)
        attrib_list[7] = 8;
    if (glut_display_mode & GLUT_STENCIL)
        attrib_list[9] = 8;
    if (glut_display_mode & GLUT_DEPTH)
        attrib_list[11] = 16;

    EGLCHK(eglChooseConfig(dpy, attrib_list, &config, 1, &num_configs));

    if (num_configs == 0) {
        __pspgl_log("glutCreateWindow: eglChooseConfig returned no configurations for display mode %x\n",
                    glut_display_mode);
        return 0;
    }

    psp_log("eglChooseConfig() returned config 0x%04x\n", (unsigned int) config);

    EGLCHK(eglGetConfigAttrib(dpy, config, EGL_WIDTH, &width));
    EGLCHK(eglGetConfigAttrib(dpy, config, EGL_HEIGHT, &height));

    EGLCHK(ctx = eglCreateContext(dpy, config, NULL, NULL));
    EGLCHK(surface = eglCreateWindowSurface(dpy, config, 0, NULL));
    EGLCHK(eglMakeCurrent(dpy, surface, surface, ctx));

    return 0;
}
SDL_GLContext
PSP_GL_CreateContext(_THIS, SDL_Window * window)
{

    SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata;

        EGLint attribs[32];
        EGLDisplay display;
        EGLContext context;
        EGLSurface surface;
        EGLConfig config;
        EGLint num_configs;
        int i;


    /* EGL init taken from glutCreateWindow() in PSPGL's glut.c. */
        EGLCHK(display = eglGetDisplay(0));
        EGLCHK(eglInitialize(display, NULL, NULL));
    wdata->uses_gles = SDL_TRUE;
        window->flags |= SDL_WINDOW_FULLSCREEN;

        /* Setup the config based on SDL's current values. */
        i = 0;
        attribs[i++] = EGL_RED_SIZE;
        attribs[i++] = _this->gl_config.red_size;
        attribs[i++] = EGL_GREEN_SIZE;
        attribs[i++] = _this->gl_config.green_size;
        attribs[i++] = EGL_BLUE_SIZE;
        attribs[i++] = _this->gl_config.blue_size;
        attribs[i++] = EGL_DEPTH_SIZE;
        attribs[i++] = _this->gl_config.depth_size;

        if (_this->gl_config.alpha_size)
        {
            attribs[i++] = EGL_ALPHA_SIZE;
            attribs[i++] = _this->gl_config.alpha_size;
        }
        if (_this->gl_config.stencil_size)
        {
            attribs[i++] = EGL_STENCIL_SIZE;
            attribs[i++] = _this->gl_config.stencil_size;
        }

        attribs[i++] = EGL_NONE;

        EGLCHK(eglChooseConfig(display, attribs, &config, 1, &num_configs));

        if (num_configs == 0)
        {
            SDL_SetError("No valid EGL configs for requested mode");
            return 0;
        }

        EGLCHK(eglGetConfigAttrib(display, config, EGL_WIDTH, &width));
        EGLCHK(eglGetConfigAttrib(display, config, EGL_HEIGHT, &height));

        EGLCHK(context = eglCreateContext(display, config, NULL, NULL));
        EGLCHK(surface = eglCreateWindowSurface(display, config, 0, NULL));
        EGLCHK(eglMakeCurrent(display, surface, surface, context));

        _this->gl_data->display = display;
        _this->gl_data->context = context;
        _this->gl_data->surface = surface;


    return context;
}
Esempio n. 4
0
static
void cleanup (void)
{
    EGLCHK(eglTerminate(dpy));
}
Esempio n. 5
0
void glutSwapBuffers(void)
{
    EGLCHK(eglSwapBuffers(dpy, surface));
}