Reputation: 33
I find that whenever I'm creating a live wallpaper, things begin to lag. For example, when switching between the screens, the animation lags. In many other wallpapers I've seen, ones with much more demanding graphics, there is literally no lag. From what I can see, OpenGL seems to be able to render graphics much faster than the Canvas can.
I want to draw solely in 2D. So I think it goes something like this in the onDrawFrame method. thanks to http://basic4gl.wikispaces.com/2D+Drawing+in+OpenGL
public void onDrawFrame(GL10 gl)
{
gl.glMatrixMode(GL10.GL_PROJECTION);
gl.glLoadIdentity();
gl.glOrthox(0, w, h, 0, 0, 1);
gl.glMatrixMode(GL10.GL_MODELVIEW);
gl.glTranslatef(.375f, .375f, 0);
gl.glDisable(GL10.GL_DEPTH_TEST);
gl.glClearColorx(162,205,239, 255);//In place of gl.glClear() because I want a differently colored background
}
But after this, I have no idea how to draw bitmaps or lines, which are essentially all I need for my current project. Can someone please tell me how to do these simple tasks? Also, if I'm completely off, can someone tell me what I'm doing wrong?
Upvotes: 1
Views: 1588
Reputation: 10738
George is right, if you aren't already, you should definitely be using https://github.com/markfguerra/GLWallpaperService for your GL/wallpaper backend.
Also, you shouldn't be setting up your projections in onDraw (which happens every frame), you should do that in onSurfaceChanged() (since you only need to do it when your view changes), which may be causing the lag you're seeing. Check out this tutorial series to get your feet wet.
Upvotes: 1
Reputation: 2260
You need to use a supplemental package to work with OpenGL within live wallpaper. Two obvious candidates are:
GLWallpaperService (https://github.com/markfguerra/GLWallpaperService)
AndEngine (http://code.google.com/p/andenginelivewallpaperextension/)
Upvotes: 1