1

I am building a VR application for VR glasses. Basically, I want to split the screen in two, and have two GLSurfaceViews (one in each side) showing the same in each one of them.

While investigating a bit, I read in some posts that it is not possible to have more than one GLSurfaceViews in one activity (For example: How can I use Multiple GLSurfaceView components in the same Layout?), but I also read (in that same question) that it is indeed possible, so I didn't get a clear picture.

Anyway, I tried to do it by myself. So, in my code, if I just create one instance of GLSurfaceView, everything works fine. However, if I create 2 instances of a GLSurfaceView, I realised that the renderer is created only once (I don't know why). Thus, since I actually want to draw the same in both surfaces I thought I could just use the same renderer for both surfaceViews. I basically tried to use the first created renderer and use setRenderer() method in the second instance of GLSurfaceView, but this would crash my app.

So, can someone help me to implement two GLSurfaceViews showing the same in the same acitvity (in case this is possible)?

Community
  • 1
  • 1
Jorge S
  • 81
  • 1
  • 9
  • 1
    You can have multiple GLSurfaceViews in an activity. Define a layout that contains two of them, and it will work just fine. You'll want to create s separate renderer for each. It's easiest if you create a class that derives from `GLSurfaceView`, and create the renderer in the constructor of this view. – Reto Koradi Jan 02 '16 at 00:28
  • @Reto Koradi In my code, I actually have a class that extends GLSurfaceView, and the renderer is created in the constructor. However, when I tried to create 2 instances of my own GLSurfaceView class, only one renderer is created ( I can see this easily by placing a log in the constructor of the renderer ). So, that is not something tht worked for me :/ – Jorge S Jan 03 '16 at 09:51
  • 1
    @JorgeS did you ever solve this? – StainlessSteelRat Feb 25 '21 at 21:10
  • Did you manage to have 2 GLSurfaceViews in the same activity ? Thanks. – toto_tata May 10 '22 at 09:14

0 Answers0