简体   繁体   中英

OpenGL ES 2.0 several scenes

How to implement transition between several scenes that use opengl?

I have 2 different scenes. each create its frame and render buffers and bind it. But then I try to switch between these scenes - nothing happens... I tried to delete all buffers when swithing but it's doesn't work. The First scene is still visible..

Well, in my experience you may need to dispose of the textures for the first scene's visuals. A quick idea is using psm studio's approach to OpenGLES.

public TitleScene ()
{
  this.Camera.SetViewFromViewport();
  _texture = new Texture2D("Application/images/title.png",false);
  _ti = new TextureInfo(_texture);
  SpriteUV titleScreen = new SpriteUV(_ti);
  titleScreen.Scale = _ti.TextureSizef;
  titleScreen.Pivot = new Vector2(0.5f,0.5f);
  titleScreen.Position = new Vector2(Director.Instance.GL.Context.GetViewport().Width/2,
      Director.Instance.GL.Context.GetViewport().Height/2);
  this.AddChild(titleScreen);
  public override void Update (float dt)
  {
    base.Update (dt);
    var touches = Touch.GetData(0).ToArray();
    if((touches.Length >0 && touches[0].Status == TouchStatus.Down) || Input2.GamePad0.Cross.Press)
    {
      Director.Instance.ReplaceScene(new MenuScene());
    }
  }

  ~TitleScene()
  {
    _texture.Dispose();
    _ti.Dispose ();
  }
}

I hope this will give you some help on what you are missing.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM