|
|
|
|
|
|
// gr_context_.get(), m_backendTex, kBottomLeft_GrSurfaceOrigin, 1,
|
|
|
|
// kRGBA_8888_SkColorType, nullptr, nullptr);
|
|
|
|
} |
|
|
|
|
|
|
|
static EGLSurface surfaces; |
|
|
|
static EGLContext egl_context_s_old; |
|
|
|
static bool inited = false; |
|
|
|
static EGLSurface read_s; |
|
|
|
static EGLSurface draw_s; |
|
|
|
|
|
|
|
void *UnitySurfaceManager::SetTextureFromUnity(void *tex, int w, int h) |
|
|
|
{ |
|
|
|
|
|
|
return nullptr; |
|
|
|
} |
|
|
|
static void StoreOldCurrent(){ |
|
|
|
read_s = eglGetCurrentSurface(EGL_READ); |
|
|
|
draw_s = eglGetCurrentSurface(EGL_DRAW); |
|
|
|
egl_display_s = eglGetCurrentDisplay(); |
|
|
|
egl_context_s_old = eglGetCurrentContext(); //????? for get context
|
|
|
|
} |
|
|
|
static bool RestoreOldCurrent() { |
|
|
|
return eglMakeCurrent(egl_display_s, draw_s, read_s, egl_context_s_old) == GL_TRUE; |
|
|
|
} |
|
|
|
StoreOldCurrent(); |
|
|
|
auto read_s = eglGetCurrentSurface(EGL_READ); |
|
|
|
auto draw_s = eglGetCurrentSurface(EGL_DRAW); |
|
|
|
egl_display_s = eglGetCurrentDisplay(); |
|
|
|
auto egl_context_s_old = eglGetCurrentContext(); |
|
|
|
// egl_display_s = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
|
|
|
// FML_CHECK(egl_display_s != EGL_NO_DISPLAY)
|
|
|
|
// << "Renderer type is invalid";
|
|
|
|
|
|
|
|
// // Initialize the display connection.
|
|
|
|
// FML_CHECK(eglInitialize(egl_display_s, nullptr, nullptr) == EGL_TRUE)
|
|
|
|
// << "Renderer type is invalid";
|
|
|
|
|
|
|
|
// FML_CHECK(success) << "Could not choose an EGL configuration.";
|
|
|
|
// auto state = eglMakeCurrent(egl_display_s, EGL_NO_SURFACE, EGL_NO_SURFACE, egl_config_s) == GL_TRUE;
|
|
|
|
// int texture;
|
|
|
|
// glGenTextures()
|
|
|
|
|
|
|
|
// state = eglMakeCurrent(egl_display_s, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT) == 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();
|
|
|
|
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, |
|
|
|
gltex, 0); |
|
|
|
FML_CHECK(glCheckFramebufferStatus(GL_FRAMEBUFFER) == |
|
|
|
GL_FRAMEBUFFER_COMPLETE); |
|
|
|
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, gltex, 0); |
|
|
|
FML_CHECK(glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE); |
|
|
|
// glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, gltex, 0);
|
|
|
|
state = glGetError(); |
|
|
|
RestoreOldCurrent(); |
|
|
|
// return nullptr;
|
|
|
|
eglMakeCurrent(egl_display_s, draw_s, read_s, egl_context_s_old); |
|
|
|
// static void createContext()
|
|
|
|
// {
|
|
|
|
// if (egl_display_s != nullptr)
|
|
|
|
// {
|
|
|
|
// return;
|
|
|
|
// }
|
|
|
|
// egl_display_s = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
|
|
|
// FML_CHECK(egl_display_s != EGL_NO_DISPLAY)
|
|
|
|
// << "Renderer type is invalid";
|
|
|
|
|
|
|
|
// // Initialize the display connection.
|
|
|
|
// FML_CHECK(eglInitialize(egl_display_s, nullptr, nullptr) == EGL_TRUE)
|
|
|
|
// << "Renderer type is invalid";
|
|
|
|
static int siyao = 0; |
|
|
|
// bool success = false;
|
|
|
|
|
|
|
|
// std::tie(success, egl_config_s) = ChooseEGLConfiguration(egl_display_s);
|
|
|
|
// FML_CHECK(success) << "Could not choose an EGL configuration.";
|
|
|
|
|
|
|
|
// EGLint attributes[] = {EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE};
|
|
|
|
// egl_context_s_old = eglGetCurrentContext(); //????? for get context
|
|
|
|
|
|
|
|
// egl_context_s = eglCreateContext(egl_display_s, egl_config_s, egl_context_s_old, attributes);
|
|
|
|
// }
|
|
|
|
static int siyao= 0; |
|
|
|
// createContext();
|
|
|
|
int width = wi; |
|
|
|
int height = he; |
|
|
|
|
|
|
|
|
|
|
unsigned char *ptr = dst; |
|
|
|
for (int x = 0; x < width; ++x) |
|
|
|
{ |
|
|
|
// Simple "plasma effect": several combined sine waves
|
|
|
|
int vv = (244 + siyao )%244; |
|
|
|
int vv = (244 + siyao) % 244; |
|
|
|
|
|
|
|
// Write the texture pixel
|
|
|
|
ptr[0] = vv; |
|
|
|
|
|
|
|
|
|
|
// To next pixel (our pixels are 4 bpp)
|
|
|
|
// To next image row
|
|
|
|
auto read = eglGetCurrentSurface(EGL_READ); |
|
|
|
auto draw = eglGetCurrentSurface(EGL_DRAW); |
|
|
|
auto dis = eglGetCurrentDisplay(); |
|
|
|
auto ctx = eglGetCurrentContext(); |
|
|
|
// glBegin(GL_LINES);
|
|
|
|
// glVertex2f(.25,0.25);
|
|
|
|
// glVertex2f(.75,.75);
|
|
|
|
// glEnd();
|
|
|
|
// glClearColor(1.0, 0, 0, 1.0);
|
|
|
|
// glClearColor(1.0, 0, 1.0, 1.0);
|
|
|
|
state = eglMakeCurrent(dis, draw, read, ctx) == GL_TRUE; |
|
|
|
// state = eglMakeCurrent(EGL_NO_DISPLAY, EGL_NO_DISPLAY, EGL_NO_DISPLAY, EGL_NO_CONTEXT) == GL_TRUE;
|
|
|
|
// state = eglMakeCurrent(egl_display_s, draw_s, read_s, egl_context_s_old) == GL_TRUE;
|
|
|
|
|
|
|
|
// state = eglMakeCurrent(egl_display_s, EGL_NO_DISPLAY, EGL_NO_DISPLAY, egl_context_s_old) == GL_TRUE;
|
|
|
|
// state = eglMakeCurrent(egl_display_s, draw, read, egl_context_s_old) == GL_TRUE;
|
|
|
|
|
|
|
|
eglMakeCurrent(egl_display_s, EGL_NO_DISPLAY, EGL_NO_DISPLAY, EGL_NO_CONTEXT); |
|
|
|
delete[](unsigned char *) data; |
|
|
|
} |
|
|
|
|