Fix texture sharing between GPUs

This commit is contained in:
2018-09-22 14:54:39 +02:00
parent db8564e12b
commit b1febba24e
5 changed files with 30 additions and 10 deletions

View File

@@ -143,7 +143,7 @@ void init_gl(gl_ctx* ctx, int w, int h)
ctx->h = h;
ctx->is_fullscreen = 0;
bool bContextCreated = create_context(EGL_DEFAULT_DISPLAY, ctx->x_window, egl_config_attribs, egl_context_attribs, egl_surface_attribs, &ctx->egl_display, &ctx->egl_context, &ctx->egl_surface);
bool bContextCreated = create_context(EGL_PLATFORM_X11_KHR, EGL_DEFAULT_DISPLAY, ctx->x_window, egl_config_attribs, egl_context_attribs, egl_surface_attribs, &ctx->egl_display, &ctx->egl_context, &ctx->egl_surface);
if(!bContextCreated || ctx->egl_context == EGL_NO_CONTEXT)
{
@@ -289,14 +289,19 @@ GLuint compile_shader(const char* vertex, const char* fragment)
return programShader;
}
void create_fbo(int eye_width, int eye_height, GLuint* fbo, GLuint* color_tex, GLuint* depth_tex)
void create_fbo(int eye_width, int eye_height, GLuint* fbo, GLuint* color_tex, GLuint* depth_tex, EGLImage image)
{
glGenTextures(1, color_tex);
glGenTextures(1, depth_tex);
glGenFramebuffers(1, fbo);
glBindTexture(GL_TEXTURE_2D, *color_tex);
#if 0
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, eye_width, eye_height, 0, GL_RGBA, GL_UNSIGNED_INT, NULL);
#else
PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glEGLImageTargetTexture2DOES = (PFNGLEGLIMAGETARGETTEXTURE2DOESPROC) eglGetProcAddress ("glEGLImageTargetTexture2DOES");
glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image);
#endif // 0
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);