コード例 #1
0
EGLAPI EGLSurface EGLAPIENTRY eglCreatePbufferSurface(EGLDisplay dpy,
				EGLConfig config, const EGLint *attrib_list)
{
	uint32_t configID = (uint32_t)config;

	if (!fglEGLValidateDisplay(dpy)) {
		setError(EGL_BAD_DISPLAY);
		return EGL_NO_SURFACE;
	}

	EGLint surfaceType;
	if (!fglGetConfigAttrib(configID, EGL_SURFACE_TYPE, &surfaceType))
		return EGL_NO_SURFACE;

	if (!(surfaceType & EGL_PBUFFER_BIT)) {
		setError(EGL_BAD_MATCH);
		return EGL_NO_SURFACE;
	}

	uint32_t depthFormat;
	uint32_t pixelFormat;
	if (!fglGetConfigFormatInfo(configID, &pixelFormat, &depthFormat)) {
		setError(EGL_BAD_MATCH);
		return EGL_NO_SURFACE;
	}

	if (unlikely(!attrib_list))
		attrib_list = &dummyAttribList;

	int32_t width = 0;
	int32_t height = 0;
	while (attrib_list[0] != EGL_NONE) {
		if (attrib_list[0] == EGL_WIDTH)
			width = attrib_list[1];

		if (attrib_list[0] == EGL_HEIGHT)
			height = attrib_list[1];

		attrib_list += 2;
	}

	if (width <= 0 || height <= 0) {
		setError(EGL_BAD_PARAMETER);
		return EGL_NO_SURFACE;
	}

	FGLRenderSurface *surface = new FGLPbufferSurface(dpy,
			configID, pixelFormat, depthFormat, width, height);
	if (!surface || !surface->initCheck()) {
		if (!surface)
			setError(EGL_BAD_ALLOC);
		/* otherwise constructor should have set error value for us */
		delete surface;
		return EGL_NO_SURFACE;
	}

	return (EGLSurface)surface;
}
コード例 #2
0
EGLAPI EGLSurface EGLAPIENTRY eglCreateWindowSurface(EGLDisplay dpy,
	EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list)
{
	uint32_t configID = (uint32_t)config;

	if (!fglEGLValidateDisplay(dpy)) {
		setError(EGL_BAD_DISPLAY);
		return EGL_NO_SURFACE;
	}

	if (win == 0) {
		setError(EGL_BAD_MATCH);
		return EGL_NO_SURFACE;
	}

	EGLint surfaceType;
	if (!fglGetConfigAttrib(configID, EGL_SURFACE_TYPE, &surfaceType))
		return EGL_NO_SURFACE;

	if (!(surfaceType & EGL_WINDOW_BIT)) {
		setError(EGL_BAD_MATCH);
		return EGL_NO_SURFACE;
	}

	uint32_t depthFormat;
	uint32_t pixelFormat;
	if (!fglGetConfigFormatInfo(configID, &pixelFormat, &depthFormat)) {
		setError(EGL_BAD_MATCH);
		return EGL_NO_SURFACE;
	}

	FGLRenderSurface *surface = platformCreateWindowSurface(dpy,
				configID, pixelFormat, depthFormat, win);
	if (!surface || !surface->initCheck()) {
		if (!surface)
			setError(EGL_BAD_ALLOC);
		/* otherwise platform code should have set error value for us */
		delete surface;
		return EGL_NO_SURFACE;
	}

	return (EGLSurface)surface;
}