Reputation:
I am new in android. I need to use opengl in combination with View Class to draw something. How to do this. plz give me any hints or suggestions...
Upvotes: 2
Views: 1190
Reputation: 3996
You also have the option to combine "normal" android views (Button, ImageView, etc) in a layout with a GlSurfaceView. (i.e. FrameLayout)
By doing so you can combine normal android UI with openGL, you can also make a composite view where the openGL view is just part of the layout.
This is the way ads are usually displayed overlaying 3D aplications.
Be aware that this technique can produce quite weird results in low end devices when dealing with tranasparency.
Upvotes: 1
Reputation: 2462
You probably wanta GlSurfaceView. It's a View that allows you to use Opengl to draw to it.
Put it in a layout file for your app
<GLSurfaceView id="@+id/myView" android:layout_width="fill_parent" android:layout_height="fill_parent"/>
Then in your code
((GLSurfaceView)findViewById(R.id.myView)).setRenderer(new GlSurfaceView.Renderer() {
public void onSurfaceCreated(...)...
public void onSurfaceChanged(...)...
public void onDraw(GL10 gl)...
});
((GLSurfaceView)findViewById(R.id.myView)).setRenderMode(RENDERMODE_CONTINUOUSLY);
And then you draw in your onDraw with your gl calls.
This is the super-quick start answer to your question, if you drop the surfaceview in framelayout and know what your drawing it's pretty quick to get a basic setup running.
Upvotes: 0