Hi, I'm new at this (java and opengl) so please bear with me if the answer to the question is simple. :)
I'm trying to get a camera preview screen with the ability to display 3d objects simultaneously. Having gone through the samples at the api demos, I thought combining the code for the the examples at the api demo would suffice. But somehow its not working. The forces me to shut down upon startup and the error is mentioned as null pointer exception. Could someone share with me where did I go wrong and how to proceed from there. How I did the combination for the code is as shown below:
myoverview.xml
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<android.opengl.GLSurfaceView
android:id="@+id/cubes"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
<SurfaceView
android:id="@+id/camera"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
</FrameLayout>
myoverview.java
import android.app.Activity;
import android.os.Bundle;
import android.view.SurfaceView;
import android.view.Window;
public class MyOverView extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Hide the window title.
requestWindowFeature(Window.FEATURE_NO_TITLE);
// camera view as the background
SurfaceView cameraView = (SurfaceView) findViewById(R.id.camera);
cameraView = new CameraView(this);
// visual of both cubes
GLSurfaceView cubesView = (GLSurfaceView) findViewById(R.id.cubes);
cubesView = new GLSurfaceView(this);
cubesView.setRenderer(new CubeRenderer(false));
// set view
setContentView(R.layout.myoverview);
}
}
GLSurfaceView.java
import android.content.Context;
class GLSurfaceView extends android.opengl.GLSurfaceView {
public GLSurfaceView(Context context) {
super(context);
}
}
NOTE :
I didnt list the rest of the files as they are just copies of the api demos. The cameraView refers to the camerapreview.java example and the CubeRenderer refers to the CubeRenderer.java and Cube.java example. Any help would be appreciated as I've been stuck at this for a couple of days :p Thanks
Sorry, didnt realise that the coding was out of place due to formatting mistakes. :p