Android动态壁纸——OpenGL vs Canvas [英] Android Live Wallpapers -- OpenGL vs Canvas

查看:42
本文介绍了Android动态壁纸——OpenGL vs Canvas的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一个相当新手"的 Android 开发人员,我希望我的第一个项目之一是动态壁纸,但是对于我应该专注于 Canvas 还是 OpenGL,我感到很矛盾.作为新手,我知道我应该首先掌握 Canvas,因为它更易于使用,但我更喜欢从我感兴趣的现实世界项目中学习,即使有时有点落后.

I am a fairly "newb" Android developer, and I would like one of my first projects to be a live wallpaper, however I am conflicted on whether I should be focusing on Canvas or OpenGL for it. Being new to this I know I should master Canvas first since it is easier to use, but I prefer to learn from real world projects that I have an interest in, even if it's a little backwards at times.

我以前以非常基本的方式使用过这两种方法,我了解它们的一般概念,但我不确定它们是如何转移到动态壁纸领域的.我认为动态壁纸不需要 OpenGL 的全速运行,因为以最大 FPS 运行它只会消耗更多的电池电量,但同时我担心使用 Canvas 会导致延迟和更改主屏幕等操作时卡顿.

I have used both before in very basic ways, and I understand the general concepts to them, but I am not sure how they transfer over to the realm of live wallpapers. I figure that the full blown speed of OpenGL isn't required on a live wallpaper, since running it at max FPS would just run down the battery more than it necessary, but at the same time I am worried that using Canvas would cause lags and stutters when doing things like changing home screens.

我一直倾向于使用 OpenGL ES 2.0,一方面是为了保持最佳性能,另一方面是因为我最初对壁纸的想法涉及很多我不确定 Canvas 是否能够做到的分层,但我希望有经验更丰富的开发人员关于使用 OpenGL 所涉及的所有额外工作(尤其是与动态壁纸相关的工作,根据我所阅读的内容)是否值得的意见.

I have been leaning towards using OpenGL ES 2.0, both to keep performance optimal and because my initial ideas for the wallpaper involve a lot of layering that I am not sure Canvas is capable of, but I'd like a more experienced developers opinion on whether or not all of the extra work involved in using OpenGL (especially in relation to live wallpapers, from what I've read) is worth it.

推荐答案

如果您可以摆脱只在画布上绘图(例如 SDK 中的立方体示例),那就少了很多工作.由于动画的简单性(无位图),立方体能够毫无困难地实现高帧率.

If you can get away with just drawing to a canvas (e.g. cube example in SDK), that's much less work. Because of the simplicity of the animation (no bitmaps), the cube is able to achieve a high frame rate without difficulty.

如果要使用 OpenGL,则需要使用补充包,例如 GLWallpaperService、AndEngine 或 RenderScript.

If you want to use OpenGL, you will need to use a supplemental package, such as GLWallpaperService, AndEngine, or RenderScript.

http://www.rbgrn.net/content/354-glsurfaceview-adapted-3d-live-wallpapers

http://www.andengine.org/forums/tutorials/live-wallpaper-template-t258.html

浏览 Android 源代码,了解如何使用 RenderScript 实现库存壁纸(例如 Grass、Galaxy).此链接可能有效,但不能保证:http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android-apps/4.1.1_r1/com/android/wallpaper/(然后向下滚动到壁纸)

Browse the Android source code to see how the stock wallpapers (e.g. Grass, Galaxy) are implemented using RenderScript. This link may work, but no guarantees: http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android-apps/4.1.1_r1/com/android/wallpaper/ (then scroll down to the wallpapers)

Moonblink 已经停止了他的项目,但如果你真的很感兴趣,你可以尝试从这里开始研究他的工作(Substrate):http://code.google.com/p/moonblink/source/browse/wiki/Setup.wiki

Moonblink has discontinued his project, but if you're really keen, you can try researching his work (Substrate) starting here: http://code.google.com/p/moonblink/source/browse/wiki/Setup.wiki

这篇关于Android动态壁纸——OpenGL vs Canvas的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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