【发布时间】:2018-05-04 08:29:47
【问题描述】:
我正在使用 opengles 在 Android 上创建自己的显示器。 我有一个显示器,我想在上面显示两个表面(第一个是 Android,第二个是我自己的显示器)。
注意:显示器分辨率为 (1920x1080)
为此,我能够在左侧 (1280x1080) 为我的 Android 系统 UI 设置自定义大小。所以我现在在右侧(840x1080)有一个可用空间供其他显示器使用。 我能够用这个分辨率(840x1080)创建一个绿色表面,问题是它在左边,所以它隐藏了 Android 系统。我想在其上应用 1280 像素的翻译,使其位于右侧。
这是我的代码:
const EGLint attribs[] = {
EGL_RED_SIZE, 8,
EGL_GREEN_SIZE, 8,
EGL_BLUE_SIZE, 8,
EGL_DEPTH_SIZE, 0,
EGL_NONE
};
EGLint w, h;
EGLint numConfigs;
EGLConfig config;
EGLSurface surface;
EGLContext context;
EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
eglInitialize(display, NULL, NULL);
eglChooseConfig(display, attribs, &config, 1, &numConfigs);
if ((surface = eglCreateWindowSurface(display, config, s.get(), NULL)) == EGL_NO_SURFACE) {
ALOGD("initSurface() eglCreateWindowSurface failed");
return;
}
context = eglCreateContext(display, config, NULL, NULL);
eglQuerySurface(display, surface, EGL_WIDTH, &w);
eglQuerySurface(display, surface, EGL_HEIGHT, &h);
ALOGD("Surface size is w = %d h = %d", w, h);
if (eglMakeCurrent(display, surface, surface, context) == EGL_FALSE) {
ALOGD("initSurface() eglMakeCurrent failed");
return ;
}
glShadeModel(GL_FLAT);
glDisable(GL_DITHER);
glDisable(GL_SCISSOR_TEST);
glClearColor(0, 1, 0, 1);
glClear(GL_COLOR_BUFFER_BIT);
eglSwapBuffers(display, surface);
使用 opengles 应用此翻译需要什么功能?
【问题讨论】:
标签: android opengl-es opengl-es-2.0 surface egl