Android - 使用OpenGL为应用创建动态背景

3

我正在开发一款主要由TextView和Button组成的应用程序,外观并不令人兴奋。我想创建一个动态背景,其中有3D对象移动、变色等特效。如何实现呢?我知道一些简单的OpenGL,比如创建形状等操作。是否有一个视图可以添加到我的xml布局中,并将其设置为我的动画?任何帮助将不胜感激。

1个回答

2
这里是安卓和OpenGL ES的指南。基本上,您需要使用 这个 来实现它们。请按照指南中提供的步骤进行操作。
    <android.opengl.GLSurfaceView 
        android:id="@+id/graphics_glsurfaceview1" 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent">
    </android.opengl.GLSurfaceView>

然后在你的onCreate方法中,你需要提供自己实现的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);

}

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接