Open GLES, 2D/3D split screen?

Discussion in 'iOS Programming' started by BananaDuffle, Apr 27, 2009.

  1. BananaDuffle macrumors member

    Mar 29, 2009
    Hi guys, I've just started iphone development. I've managed to get 2D graphics working in open gl along with rudimentary 3D graphics.

    The effect I'm after is getting 50/50(top/bottom) split screen with 2D graphics in one view and a 3D view in the other... Imagine like a DS game where you get, say, a map on the bottom screen and the game view in the top (for example only, obviously thats not a great use of iphone screen-space).

    Unfortunately my experience with 3D and Open GL is pretty limited so i'm not even sure what techniques or methods I should be googling for to achieve this.

  2. lazydog macrumors 6502a

    Sep 3, 2005
    Cramlington, UK

    Are you using OpenGL for 2D and 3D? If so you could achieve your split view quite easily by using glViewport() twice, once for each of your views. After defining a view/viewport using glViewport() set up your perspective and viewing transformations as normal for your view type, ie 2D or 3D. A couple of things to be aware of though:

    glClear() clears the whole context and not the viewport so you can't use it to clear your split views independently. If your views have different colour backgrounds then use a coloured quad or something similar.

    According to the docs it's possible that some drawing operations might bleed outside the viewport. I haven't seen this happen but if you do run into this then it's easily fixed, set up a clipping rectangle around your viewport using glScissors().

    ß e n
  3. BananaDuffle thread starter macrumors member

    Mar 29, 2009
    Thank you :)
    Yes i'm doing my 2D on OGLES... I wasn't expecting the answer to be so easy, thank you very much.

Share This Page