Mark
Mark

Reputation: 1170

Android - Use opengl to create animated background for app

I'm working on an app that is mostly textviews and buttons, nothing real exciting to look at. I would like to create an animated background with 3D objects moving around, changing colors, etc. What is a good way implement this? I know some simple opengl, like creating shapes and doing all of that. Is there a view that I can add to my xml layout and set this to my animation? Any help would be appreciated.

Upvotes: 3

Views: 2298

Answers (1)

James Coote
James Coote

Reputation: 1973

Here is the guide to android and opengl-es. Basically you have

    <android.opengl.GLSurfaceView 
        android:id="@+id/graphics_glsurfaceview1" 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent">
    </android.opengl.GLSurfaceView>

and then in your onCreate, you give it your implementation of a Renderer:

public class GraphicsRenderer implements Renderer {

    // implement Renderer. This is where all the openGL stuff goes

}

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);   

    setContentView(R.layout.main);

    GLSurfaceView mGLView = (GLSurfaceView) findViewById(R.id.graphics_glsurfaceview1);
    mGLView.setEGLConfigChooser(true);         
    mGLView.setRenderer(graphicsRenderer);

}

Upvotes: 2

Related Questions