Beispiel #1
0
    def _create_egl_context(self, share):
        if share:
            share_context = share.egl_context
        else:
            share_context = None

        egl.eglBindAPI(egl.EGL_OPENGL_API)
        return egl.eglCreateContext(
            self.config.canvas.display._display_connection,
            self.config._egl_config, share_context,
            self.config._context_attrib_array)
Beispiel #2
0
result = libegl.eglChooseConfig(display_connection, config_attrib_array,
                                egl_config, 1, num_configs)
assert result == 1, "Failed to choose Config"

# Create a surface:
pbufferwidth = 1
pbufferheight = 1
pbuffer_attribs = (EGL_WIDTH, pbufferwidth, EGL_HEIGHT, pbufferheight,
                   EGL_NONE)
pbuffer_attrib_array = (libegl.EGLint * len(pbuffer_attribs))(*pbuffer_attribs)
surface = libegl.eglCreatePbufferSurface(display_connection, egl_config,
                                         pbuffer_attrib_array)
print("Surface id: ", surface)

# Bind the API:
result = libegl.eglBindAPI(libegl.EGL_OPENGL_API)
assert result == 1, "Failed to bind EGL_OPENGL_API"

# Create a context:
context_attribs = (EGL_CONTEXT_MAJOR_VERSION, 2, EGL_NONE)
context_attrib_array = (libegl.EGLint * len(context_attribs))(*context_attribs)
context = libegl.eglCreateContext(display_connection, egl_config, None,
                                  context_attrib_array)
print("Context id: ", context)

# Make context current:
result = libegl.eglMakeCurrent(display_connection, surface, surface, context)
assert result == 1, "Failed to make context current"

error_code = libegl.eglGetError()
assert error_code == EGL_SUCCESS, "EGL Error code {} returned".format(