浏览代码

run int render thread

/siyaoH-1.17-PlatformMessage
siyao 4 年前
当前提交
71e9e3cd
共有 2 个文件被更改,包括 19 次插入19 次删除
  1. 6
      Samples/UIWidgetsSamples_2019_4/Assets/ANT.cs
  2. 32
      engine/src/shell/platform/unity/android/unity_surface_manager.cc

6
Samples/UIWidgetsSamples_2019_4/Assets/ANT.cs


var texEx = Texture2D.CreateExternalTexture(width, height, TextureFormat.BGRA32, false, true, ptr);
GetComponent<Renderer>().material.mainTexture = texEx;
}
GL.IssuePluginEvent(GetRenderEventFunc(), 1);
// GL.IssuePluginEvent(GetRenderEventFunc(), 1);
// #endif
}

// Wait until all frame rendering is done
yield return new WaitForEndOfFrame();
#if !UNITY_EDITOR
// GL.IssuePluginEvent(GetRenderEventFunc(), 1);
draw_xxx();
GL.IssuePluginEvent(GetRenderEventFunc(), 1);
// draw_xxx();
#endif
}
}

32
engine/src/shell/platform/unity/android/unity_surface_manager.cc


egl_context_s_old = eglGetCurrentContext(); //????? for get context
egl_context_s = eglCreateContext(egl_display_s, egl_config_s, egl_context_s_old, attributes);
auto read = eglGetCurrentSurface(EGL_READ);
auto draw = eglGetCurrentSurface(EGL_DRAW);
auto state = eglMakeCurrent(egl_display_s, EGL_NO_SURFACE, EGL_NO_SURFACE, egl_context_s) == GL_TRUE;
unsigned int texture;
glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D, texture);
int rowPitch = wi * 4;
unsigned char *data = new unsigned char[rowPitch * he];
// auto read = eglGetCurrentSurface(EGL_READ);
// auto draw = eglGetCurrentSurface(EGL_DRAW);
// auto state = eglMakeCurrent(egl_display_s, EGL_NO_SURFACE, EGL_NO_SURFACE, egl_context_s) == GL_TRUE;
// unsigned int texture;
// glGenTextures(1, &texture);
// glBindTexture(GL_TEXTURE_2D, texture);
// int rowPitch = wi * 4;
// unsigned char *data = new unsigned char[rowPitch * he];
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, wi, he, 0, GL_RGB, GL_UNSIGNED_BYTE, data);
state = glGetError();
// glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, wi, he, 0, GL_RGB, GL_UNSIGNED_BYTE, data);
// state = glGetError();
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
state = glGetError();
state = eglMakeCurrent(egl_display_s, draw, read, egl_context_s_old) == GL_TRUE;
// glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
// state = glGetError();
// state = eglMakeCurrent(egl_display_s, draw, read, egl_context_s_old) == GL_TRUE;
}
void UnitySurfaceManager::drawxxx()
{

dst += rowPitch;
}
GLuint gltex = (GLuint)(size_t)(g_TextureHandle);
// auto read = eglGetCurrentSurface(EGL_READ);
// auto draw = eglGetCurrentSurface(EGL_DRAW);
auto read = eglGetCurrentSurface(EGL_READ);
auto draw = eglGetCurrentSurface(EGL_DRAW);
auto state = eglMakeCurrent(egl_display_s, EGL_NO_SURFACE, EGL_NO_SURFACE, egl_context_s) == GL_TRUE;
glBindTexture(GL_TEXTURE_2D, gltex);

state = eglMakeCurrent(egl_display_s, EGL_NO_SURFACE, EGL_NO_SURFACE, egl_context_s_old) == GL_TRUE;
state = eglMakeCurrent(egl_display_s, draw, read, egl_context_s_old) == GL_TRUE;
delete[](unsigned char *) data;
}
正在加载...
取消
保存