Reputation: 1053
I am new to google cardboard and trying to implement a very simple demo. I have tried with VrVideowidget & panowidget separately but failed to implement it with GvrView. My work with code and output is given below.
I have added a GvrView which provide split screen automatically, after that i want to add same image/video into each screen so that it can appear well on google cardboard . The view I am adding via addView() appear single instead of two on both screen. I have added it on onDrawEye(). Please help me to reslove.
My final aim is to create a very basic demo of image/video on Google Cardboard with required feature.
MainActivity.java
public class MainActivity extends GvrActivity implements GvrView.StereoRenderer {
GvrView gvrView;
private ImageView imageView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
imageView = new ImageView(this);
gvrView = new GvrView(this);
gvrView.setRenderer(this);
setContentView(gvrView);
}
@Override
public void onDrawEye(Eye eye) {
imageView.setImageResource(R.drawable.ic_launcher);
// gvrView.addView(imageView);
gvrView.addView(imageView,400,400);
}
}
Upvotes: 2
Views: 1436
Reputation: 462
I am not an expert but my understanding is that you use onDrawEye to render images specific to the individual eyes, while you use onNewFrame() for non-eye specific rendering. So moving
imageView.setImageResource(R.drawable.ic_launcher);
// gvrView.addView(imageView);
gvrView.addView(imageView,400,400);
to onNewFrame() should be enough.
Upvotes: 0
Reputation: 491
Use VrPanoramaView instead, code sample is as follow:
import com.google.vr.sdk.widgets.pano.VrPanoramaView;
VrPanoramaView panoWidgetView = (VrPanoramaView) findViewById(R.id.pano_view);
panoWidgetView.loadImageFromBitmap(img,null);
panoWidgetView.resumeRendering();
Upvotes: 1