Reputation: 217
I'm looking to set a static image from my drawable resource folder as a background for my OpenGL animation. As the animation sits on a GLSurfaceView
I tried setting the GLSurfaceView
's background to the drawable resource but this doesn't work.
<android.opengl.GLSurfaceView
android:id="@+id/graphics_glsurfaceview1"
android:layout_width="fill_parent"
android:layout_height="500dp"
android:background="@drawable/background" />
Any ideas how I would go about setting a background image for my OpenGL animation. I have onSurfaceCreated
, onDrawFrame
, onSurfaceChanged
methods for my GLSurfaceView
class so maybe somewhere in there?
Upvotes: 0
Views: 1071
Reputation: 5364
This won't work. You will need to make it this way:
GLSurfaceView
This way you will see your background.
You can see example of this in Android API Demos, take a look at TranslucentGLSurfaceViewActivity
. To see it, launch API Demos application and select Graphics->OpenGL ES->Translucent GLSurfaceView.
However, I will strongly suggest to draw background not this way but with OpenGL means - load texture and draw it.
Upvotes: 1