コード例 #1
0
 def initialize(self, width, height):
     gbm_format = egl.EGLint()
     if not egl.eglGetConfigAttrib(self.egl_dpy, self.egl_config,
                                   egl.EGL_NATIVE_VISUAL_ID,
                                   pointer(gbm_format)):
         return False
     self.gbm_surf = libgbm.gbm_surface_create(self.gbm_dev, width, height,
                                               gbm_format,
                                               libgbm.GBM_BO_USE_RENDERING)
     if not self.gbm_surf:
         self.gbm_surf = None
         return False
     self.egl_surface = egl.eglCreateWindowSurface(self.egl_dpy,
                                                   self.egl_config,
                                                   self.gbm_surf, None)
     if self.egl_surface == egl.EGL_NO_SURFACE:
         self.egl_surface = None
         self.release()
         return False
     return True
コード例 #2
0
    def gl_get_attr(self, attr, pvalue):
        """This function may be used to check that OpenGL attributes where
        successfully set to the rendering window after the VidExt_SetVideoMode
        function call.
        PROTOTYPE:
         m64p_error VidExt_GL_GetAttribute(m64p_GLattr Attr, int *pValue)"""
        log.debug(
            f"Vidext: gl_get_attr(attr:{wrp_dt.m64p_GLattr(attr).name}, pvalue:{str(pvalue.contents.value)})"
        )

        pointer = c.pointer(c.c_int())
        if attr == wrp_dt.m64p_GLattr.M64P_GL_DOUBLEBUFFER.value:
            #value = ogl.glGetIntegerv(ogl.GL_DOUBLEBUFFER, pointer)
            value = egl.eglQueryContext(self.egl_display, self.egl_context,
                                        egl.EGL_RENDER_BUFFER, pointer)
        elif attr == wrp_dt.m64p_GLattr.M64P_GL_BUFFER_SIZE.value:
            value = egl.eglGetConfigAttrib(self.egl_display,
                                           self.egl_config[0],
                                           egl.EGL_BUFFER_SIZE, pointer)
        elif attr == wrp_dt.m64p_GLattr.M64P_GL_DEPTH_SIZE.value:
            value = egl.eglGetConfigAttrib(self.egl_display,
                                           self.egl_config[0],
                                           egl.EGL_DEPTH_SIZE, pointer)
        elif attr == wrp_dt.m64p_GLattr.M64P_GL_RED_SIZE.value:
            value = egl.eglGetConfigAttrib(self.egl_display,
                                           self.egl_config[0],
                                           egl.EGL_RED_SIZE, pointer)
        elif attr == wrp_dt.m64p_GLattr.M64P_GL_GREEN_SIZE.value:
            value = egl.eglGetConfigAttrib(self.egl_display,
                                           self.egl_config[0],
                                           egl.EGL_GREEN_SIZE, pointer)
        elif attr == wrp_dt.m64p_GLattr.M64P_GL_BLUE_SIZE.value:
            value = egl.eglGetConfigAttrib(self.egl_display,
                                           self.egl_config[0],
                                           egl.EGL_BLUE_SIZE, pointer)
        elif attr == wrp_dt.m64p_GLattr.M64P_GL_ALPHA_SIZE.value:
            value = egl.eglGetConfigAttrib(self.egl_display,
                                           self.egl_config[0],
                                           egl.EGL_ALPHA_SIZE, pointer)
        elif attr == wrp_dt.m64p_GLattr.M64P_GL_SWAP_CONTROL.value:
            # TODO: Is this attribute the right one?
            value = egl.eglGetConfigAttrib(self.egl_display,
                                           self.egl_config[0],
                                           egl.EGL_MIN_SWAP_INTERVAL, pointer)
        elif attr == wrp_dt.m64p_GLattr.M64P_GL_MULTISAMPLEBUFFERS.value:
            value = egl.eglGetConfigAttrib(self.egl_display,
                                           self.egl_config[0],
                                           egl.EGL_SAMPLE_BUFFERS, pointer)
        elif attr == wrp_dt.m64p_GLattr.M64P_GL_MULTISAMPLESAMPLES.value:
            value = egl.eglGetConfigAttrib(self.egl_display,
                                           self.egl_config[0], egl.EGL_SAMPLES,
                                           pointer)
        elif attr == wrp_dt.m64p_GLattr.M64P_GL_CONTEXT_MAJOR_VERSION.value:
            try:
                value = ogl.glGetIntegerv(ogl.GL_MAJOR_VERSION, pointer)
            except:
                # OGL 2.1 or less is not compatible with glGetIntegerv
                value = c.pointer(c.c_int(2))
            #egl.eglQueryContext(self.egl_display, self.egl_context, egl.EGL_CONTEXT_MAJOR_VERSION, pointer)
        elif attr == wrp_dt.m64p_GLattr.M64P_GL_CONTEXT_MINOR_VERSION.value:
            try:
                value = ogl.glGetIntegerv(ogl.GL_MINOR_VERSION, pointer)
            except:
                # OGL 2.1 or less is not compatible with glGetIntegerv
                value = c.pointer(c.c_int(0))
        elif attr == wrp_dt.m64p_GLattr.M64P_GL_CONTEXT_PROFILE_MASK.value:
            # OpenGL context profile is introduced in 3.2
            try:
                if self.context_major >= 3 and self.context_minor >= 2:
                    # TODO: How to get the exact version of the context profile?
                    value = ogl.glGetIntegerv(ogl.GL_CONTEXT_PROFILE_MASK,
                                              pointer)
                    #egl.eglQueryContext(self.egl_display, self.egl_context, egl.EGL_CONTEXT_MAJOR_VERSION, pointer)
                else:
                    # TODO: What's the value in case the gfx plugin doesn't support OGL 3.2+? Zero?
                    value = pvalue.contents.value
            except AttributeError as e:
                log.error(
                    f"Vidext: gl_get_attr() has reported M64ERR_SYSTEM_FAIL, unable to get attribute {wrp_dt.m64p_GLattr(attr).name}. \n > {e}"
                )

        else:
            log.warning(
                "gom64p doesn't know how to handle {wrp_dt.m64p_GLattr(attr).name}"
            )

        query = pointer.contents.value
        if query == pvalue.contents.value:
            return wrp_dt.m64p_error.M64ERR_SUCCESS.value
        else:
            log.error(
                f"Vidext: gl_get_attr() has reported M64ERR_SYSTEM_FAIL, for {wrp_dt.m64p_GLattr(attr).name} was expected {pvalue.contents.value} but it returned {query}"
            )
            return wrp_dt.m64p_error.M64ERR_INVALID_STATE.value