在背景渲染资源的应用程序运行Android的OpenGL? [英] Run Android OpenGL in Background as Rendering Resource for App?

查看:183
本文介绍了在背景渲染资源的应用程序运行Android的OpenGL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的应用程序,为应用程序提供动态的图形资源(位图等)的后台运行一个Android的OpenGL-ES表面。 OpenGL的GLSurfaceView是不是我的应用程序的可视屏幕;它只是用来作为渲染工厂由主活动制造图形以供使用。

I want to run an Android OpenGL-ES surface in the background of my app to provide dynamic graphical resources (bitmaps, etc.) for the application. The OpenGl GLSurfaceView is not the visible screen of my app; it is only used as a rendering factory to manufacture graphics for use by the main activity.

有谁知道如何使一个机器人GLSurfaceView运行时,它不是一个积极的看法?谷歌Android文档是清楚的是,当GLSurfaceView失去作为主视图它的状态,该表面连同其所有资源破坏。

Does anyone know how to make an Android GLSurfaceView run when it is not an active view? The Google Android documentation is clear that when a GLSurfaceView loses its status as a primary view, the surface is destroyed along with all of its resources.

有没有什么办法让一个GLSurfaceView及其相关GLSurfaceView.Renderer正常运行时,它不是(决不是)应用程序的主视图?

Is there any way to keep a GLSurfaceView and its associated GLSurfaceView.Renderer running normally when it is not (and never is) the application's primary view?

推荐答案

有关你想做什么,你应该跳过GLSurfaceView完全。既然你只想做一些OpenGL的离屏渲染,你可以使用一个EGL像素缓冲区,并将其转换为位图。请参阅<一href="http://www.anddev.org/android-2d-3d-graphics-opengl-tutorials-f2/possible-to-do-opengl-off-screen-rendering-in-android-t13232.html#wrap">this线程anddev 寻求解决方案。我在我的几个应用程序的使用非常成功。

For what you're trying to do, you should skip the GLSurfaceView entirely. Since you just want to do some OpenGL offscreen rendering, you can make use of an EGL pixel buffer and convert it to a bitmap. See this thread on anddev for a solution. I've used it very successfully in a few of my apps.

实现这一线底部的实施是一个有点马车,因为它做一些很简单的EGL选择。我建议实施一个更强大的选择器,你可以在罗伯特·格林找到<一href="https://github.com/markfguerra/GLWallpaperService/blob/master/GLWallpaperService/src/net/rbgrn/android/glwallpaperservice/GLWallpaperService.java">GLWallpaperService,如果你愿意的话。

The implementation towards the bottom of that thread is a bit buggy, since it does some very simple EGL choosing. I'd recommend implementing a more robust chooser, which you can find in Robert Green's GLWallpaperService, if you'd like.

另外一个改变我最终作出了删除垂直像素镜像。我刚刚结束了翻转我在onSurfaceCreate视窗,而不是手动翻转写入位图时呈现像素。

Another change I ended up making was to remove the vertical pixel mirroring. I just ended up flipping my viewport in onSurfaceCreate, rather than manually flip rendered pixels when writing to the bitmap.

祝你好运!

这篇关于在背景渲染资源的应用程序运行Android的OpenGL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆