I'm fairly new to OpenGL and my problem is when I do SetContentView("R.layout.main")
nothing happens, however when I do SetContentView("mGLView")
the game is displayed fine. My main.xml file contains an surface view and therefore I would of thought that it would be displayed, since main.xml has an surface view.
I suspect a way to fix this, will be done with addview or findviewbyid, however my implication of this have failed.
Relevent MainActivity Code:
public class OpenGLES20Activity extends Activity {
private GLSurfaceView mGLView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mGLView = new MyGLSurfaceView(this);
setContentView(R.layout.main);
main.xml code:
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout android:id="@+id/linearLayout1" android:layout_width="wrap_content"
android:layout_height="wrap_content">
<SurfaceView
android:id="@+id/SurfaceView"
android:layout_width="500dp"
android:layout_height="478dp">
</SurfaceView>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/Timer"
android:id="@+id/Timer"/>
</RelativeLayout>
</FrameLayout>
Any help is appreciated.
You need to set your extended
GLSurfaceView
instead of justSurfaceView
in the xml file so just changeSurfaceView
tocom.example.yourapp.MyGLSurfaceView
: