Log in or register to post comments

How

November 2, 2010 - 1:31am #1

When the tracker get the trackable in the frame ,i want to display a video instead of the teapot .
I start the project from the ImageTargets .I have hacked the ImageTargets.cpp , removed all the render code from renderFrame method and only return the trackable's name.It works well.

For playing a video ,I need add a SurfaceView Overlay on the GLSurfaceView.There is a SurfaceView Overlay example in the Android 2.2 APIDemo.I have studied the code and successfully played a video on the GLSurfaceView.

The following is our layout/main.xml file.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">

    <!-- Here is where we put the SurfaceView, in a frame so that we can
         stack other views on top of it. -->
    <FrameLayout
            android:layout_width="fill_parent"
            android:layout_height="0px"
            android:layout_weight="1">

        <android.opengl.GLSurfaceView android:id="@+id/mGLSurfaceview"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent" />

        <LinearLayout android:id="@+id/hidecontainer"
                android:orientation="vertical"
                android:visibility="gone"
                android:background="@drawable/transparent_background"
                android:gravity="center"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent">
           
  			<SurfaceView
    			android:id="@+id/mSurface"
    			android:layout_width="176px " 
    			android:layout_height="144px"> 
  			</SurfaceView>
                    
        </LinearLayout>    
    </FrameLayout>

</LinearLayout>

I create the GLSurfaceView with the following code
mGlView = (QCARSampleGLView) findViewById(R.id.mGLSurfaceview);

if i setContentView(R.layout.main) on the onCreate method,it got the following errors

11-02 15:56:07.431: ERROR/AndroidRuntime(3949): FATAL EXCEPTION: main
11-02 15:56:07.431: ERROR/AndroidRuntime(3949): java.lang.NullPointerException
11-02 15:56:07.431: ERROR/AndroidRuntime(3949):     at android.opengl.GLSurfaceView.surfaceCreated(GLSurfaceView.java:471)
11-02 15:56:07.431: ERROR/AndroidRuntime(3949):     at android.view.SurfaceView.updateWindow(SurfaceView.java:532)
11-02 15:56:07.431: ERROR/AndroidRuntime(3949):     at android.view.SurfaceView.dispatchDraw(SurfaceView.java:339)
11-02 15:56:07.431: ERROR/AndroidRuntime(3949):     at android.view.ViewGroup.drawChild(ViewGroup.java:1638)
11-02 15:56:07.431: ERROR/AndroidRuntime(3949):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
11-02 15:56:07.431: ERROR/AndroidRuntime(3949):     at android.view.ViewGroup.drawChild(ViewGroup.java:1638)
11-02 15:56:07.431: ERROR/AndroidRuntime(3949):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
11-02 15:56:07.431: ERROR/AndroidRuntime(3949):     at android.view.ViewGroup.drawChild(ViewGroup.java:1638)
11-02 15:56:07.431: ERROR/AndroidRuntime(3949):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
11-02 15:56:07.431: ERROR/AndroidRuntime(3949):     at android.view.ViewGroup.drawChild(ViewGroup.java:1638)
11-02 15:56:07.431: ERROR/AndroidRuntime(3949):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
11-02 15:56:07.431: ERROR/AndroidRuntime(3949):     at android.view.View.draw(View.java:6743)
11-02 15:56:07.431: ERROR/AndroidRuntime(3949):     at android.widget.FrameLayout.draw(FrameLayout.java:352)
11-02 15:56:07.431: ERROR/AndroidRuntime(3949):     at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1842)
11-02 15:56:07.431: ERROR/AndroidRuntime(3949):     at android.view.ViewRoot.draw(ViewRoot.java:1407)
11-02 15:56:07.431: ERROR/AndroidRuntime(3949):     at android.view.ViewRoot.performTraversals(ViewRoot.java:1163)
11-02 15:56:07.431: ERROR/AndroidRuntime(3949):     at android.view.ViewRoot.handleMessage(ViewRoot.java:1727)
11-02 15:56:07.431: ERROR/AndroidRuntime(3949):     at android.os.Handler.dispatchMessage(Handler.java:99)
11-02 15:56:07.431: ERROR/AndroidRuntime(3949):     at android.os.Looper.loop(Looper.java:123)
11-02 15:56:07.431: ERROR/AndroidRuntime(3949):     at android.app.ActivityThread.main(ActivityThread.java:4627)
11-02 15:56:07.431: ERROR/AndroidRuntime(3949):     at java.lang.reflect.Method.invokeNative(Native Method)
11-02 15:56:07.431: ERROR/AndroidRuntime(3949):     at java.lang.reflect.Method.invoke(Method.java:521)
11-02 15:56:07.431: ERROR/AndroidRuntime(3949):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
11-02 15:56:07.431: ERROR/AndroidRuntime(3949):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
11-02 15:56:07.431: ERROR/AndroidRuntime(3949):     at dalvik.system.NativeStart.main(Native Method)

If i remove the setContentView code ,the program works well .Would you like give me some suggestion?Thank you!

Log in or register to post comments