28 unsigned int fmt,
int dmafd) :
29 Width(width), Height(height), Display(display)
37 case V4L2_PIX_FMT_YUYV: drm_fmt = DRM_FORMAT_YUYV;
break;
38 case V4L2_PIX_FMT_RGB32: drm_fmt = DRM_FORMAT_XBGR8888;
break;
39 case V4L2_PIX_FMT_RGB565: drm_fmt = DRM_FORMAT_RGB565;
break;
40 case V4L2_PIX_FMT_BGR24: drm_fmt = DRM_FORMAT_RGB888;
break;
41 case V4L2_PIX_FMT_RGB24: drm_fmt = DRM_FORMAT_BGR888;
break;
42 case V4L2_PIX_FMT_UYVY: drm_fmt = DRM_FORMAT_UYVY;
break;
49 case V4L2_PIX_FMT_NV12:
50 case V4L2_PIX_FMT_YUV444:
53 case V4L2_PIX_FMT_SRGGB8:
54 case V4L2_PIX_FMT_SBGGR16:
55 case V4L2_PIX_FMT_SGRBG16:
56 case V4L2_PIX_FMT_MJPEG:
62 EGLint attrib_list[] =
66 EGL_LINUX_DRM_FOURCC_EXT, drm_fmt,
67 EGL_DMA_BUF_PLANE0_FD_EXT, dmafd,
68 EGL_DMA_BUF_PLANE0_OFFSET_EXT, 0,
75 Image = eglCreateImageKHR(display, EGL_NO_CONTEXT, EGL_LINUX_DMA_BUF_EXT, NULL, attrib_list);
76 if (
Image == EGL_NO_IMAGE_KHR)
LFATAL(
"eglCreateImageKHR() failed");
78 glBindTexture(GL_TEXTURE_EXTERNAL_OES,
Id);
79 GL_CHECK(glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_NEAREST));
80 GL_CHECK(glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, GL_NEAREST));
81 GL_CHECK(glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE));
82 GL_CHECK(glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE));
83 glEGLImageTargetTexture2DOES(GL_TEXTURE_EXTERNAL_OES,
Image);
84 glBindTexture(GL_TEXTURE_EXTERNAL_OES, 0);
86 LDEBUG(
"Created " << width <<
'x' << height <<
" texture (id=" <<
Id <<
", dmafd=" << dmafd <<
')');
GPUtextureDmaBuf(EGLDisplay display, GLsizei width, GLsizei height, unsigned int fmt, int dmafd)
Constructor.
~GPUtextureDmaBuf()
Destructor, frees the texture in OpenGL.