android - 使用 EGL 和 openGL 渲染到大型 ImageReader 表面,无法渲染出 GL_MAX_VIEWPORT_DIMS 范围
问题描述
我正在尝试在 Imagereader 的表面上使用 OpenGL ES 绘制一些东西。我为它创建了 EGL 上下文和表面。一切正常,当图像阅读器尺寸小于 GL_MAX_VIEWPORT_DIMS(我的设备上为 8192)时。我可以从它那里得到一张好照片。
但是当尺寸大于 8192 时,比如 8224,输出图像仍然留下一些填充无法绘制。这是输出图像。
即使我尝试使用 glViewport(0, 32, width, 8192),渲染结果也会向上偏移,但仍然不能超过 padding(8192~8224)。但是 glclear 命令可以使背景清晰到目标颜色(在我的例子中,它是红色)。
有没有办法在表面的填充部分绘制?
这是我的代码:
mImageReader = ImageReader.newInstance(
size.getWidth(),
size.getHeight(),
PixelFormat.RGBA_8888,
// PixelFormat.RGB_888,
// ImageFormat.JPEG,
1);
// mReaderSurface = new EglWindowSurface(core, mImageReader.getSurface(), null);
mReaderSurface = core.createWindowSurface2(mImageReader.getSurface());
public EGLSurface createWindowSurface2(Object surface) {
if (!(surface instanceof Surface) && !(surface instanceof SurfaceTexture)) {
throw new RuntimeException("invalid surface: " + surface);
}
// Create a window surface, and attach it to the Surface we received.
int[] surfaceAttribs = {
EGL14.EGL_NONE
};
int[] attribList = {
EGL14.EGL_RED_SIZE, 8,
EGL14.EGL_GREEN_SIZE, 8,
EGL14.EGL_BLUE_SIZE, 8,
EGL14.EGL_ALPHA_SIZE, 8,
EGL14.EGL_DEPTH_SIZE, 16,
EGL14.EGL_NONE
};
EGLConfig[] configs = new EGLConfig[1];
int[] numConfigs = new int[1];
if (!EGL14.eglChooseConfig(mEGLDisplay, attribList, 0, configs, 0, configs.length,
numConfigs, 0)) {
Log.e(TAG, "createWindowSurface2: ");
return null;
}
EGLSurface eglSurface = EGL14.eglCreateWindowSurface(mEGLDisplay, configs[0], surface,
surfaceAttribs, 0);
checkEglError("eglCreateWindowSurface");
if (eglSurface == null) {
throw new RuntimeException("surface was null");
}
return eglSurface;
}
解决方案
推荐阅读
- symfony - 无法运行简单迁移:指定的密钥太长错误
- excel - Excel - 在多个条件下查找和匹配值
- java - 如何使用 Maven 和 Eclipse 在 Java 主应用程序中运行 JUnit 测试类
- php - 检测嵌套匹配的 PCRE 模式
- spring-boot - 如果布尔表达式为 true,则 Spring Boot @RequestParam 默认值
- android - 如何使 AsyncTask 是静态的并与活动分开?
- python - 将熊猫数据框除以熊猫系列时仅获取整数
- javascript - fast-csv 同步读取多个文件
- azure - Cosmo Db sql Azure-并行读取唯一文档
- angular - 重定向后本地存储丢失