如何转换的Open GL ES 2.0应用程序,以一个动态壁纸? [英] How to convert an Open GL ES 2.0 application to a Live Wallpaper?

查看:250
本文介绍了如何转换的Open GL ES 2.0应用程序,以一个动态壁纸?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个实现GLSurfaceView.Renderer和使用的Open GL ES 2.0和完美的作品作为一个标准的应用程序的类。

I have a class which implements GLSurfaceView.Renderer and uses Open GL ES 2.0, and works perfectly as a standard application.

不过,我想扩大这个如此,它的一个活的壁纸。 Naturyally我有这exteds WallPaperservice一个服务类,进而延伸WallpaperService.Engine一个引擎类。

However I'd like to expand this so that its a live wallpaper. Naturyally I've got a service class which exteds WallPaperservice, and in turn a engine class which extends WallpaperService.Engine.

在的code我可以做普通版

In the normal version of the code I can just do

mGLSView = new GLSurfaceView(this); // in the engine this becomes 'new GLSurfaceView(getBaseContext());'
mGLSView.setEGLContextClientVersion(2);
mGLSView.setRenderer(new myRenderer());
setContentView(mGLSView);

然而,在引擎你不能叫的setContentView。 presumably我需要的表面传递到GLSurfaceView不知怎么的,但我真的无法看到。我发现每一个例子或教程使用OpenGL 1,因为我很新的这个我不能完全弄清楚如何去适应他们的2.0。

However in the 'Engine' you cannot call setContentView. Presumably I need to pass the surface into the GLSurfaceView somehow, but I really cant see how. Every example or tutorial that I've found uses OpenGL 1, and because I'm quite new to this I cant quite figure out how to adapt them for 2.0.

因此​​,没有人知道使用OpenGL ES 2.0的一个活的壁纸的一个简单的例子吗?或者在哪里电文读出了良好的指针?

So does anyone know of a simple example of a live wallpaper using OpenGL ES 2.0? Or a good pointer on where to readup?

谢谢

推荐答案

好了,心动不如行动!如果从 http://www.rbgrn.net使用的源/内容/ 354-glsurfaceview适应-3D-活壁纸(谢谢你的非常的太多罗伯特·格林这个!)

Ok, got it! If you use the source from http://www.rbgrn.net/content/354-glsurfaceview-adapted-3d-live-wallpapers (And thank you very much to Robert Green for this!!)

无论出于何种原因,我不得不修正了一些语法错误,我怀疑这是有Eclipse的较新版本或什么,因为原来是写。

For whatever reason I had to fix a few syntax errors, I suspect this is from having a newer version of Eclipse or whatever since the original was written.

要启用OpenGL ES 2.0,虽然,你需要进行两个更改。在ComponentSizeChooser的构造函数中添加

To enable OpenGL ES 2.0 though, you need to make two changes. In the constructor of ComponentSizeChooser add

EGL10.EGL_RENDERABLE_TYPE, 4, 

要超通话。此外,在中的createContext与DefaultContextFactory更换空

To the super call. Also in createContext in DefaultContextFactory replace the null with

new int[] { 0x3098, 2, EGL10.EGL_NONE }

这应该有你启用GL ES 2.0。

And that should have you enabled for GL ES 2.0.

此外,此外,在他的网页上,他有setRenderMode(RENDERMODE_WHEN_DIRTY);我猜想大多数人会想这是'setRenderMode(RENDERMODE_CONTINUOUSLY);

Also, additionally, on his webpage, he has 'setRenderMode(RENDERMODE_WHEN_DIRTY);' I suspect most will want this to be 'setRenderMode(RENDERMODE_CONTINUOUSLY);'

全部code可这里

这篇关于如何转换的Open GL ES 2.0应用程序,以一个动态壁纸?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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