Search Unity

OpenGL primitives rendered twice

Discussion in 'Immediate Mode GUI (IMGUI)' started by broksigar, May 16, 2015.

  1. broksigar

    broksigar

    Joined:
    May 16, 2015
    Posts:
    4
    Hello :)

    I want to create health bar for my game using openGL primitives (I'm new in Unity, but have great experience in openGL). I used this code :

    void OnGUI()
    {
    GL.Begin(GL.TRIANGLE_STRIP);
    GL.Color(new Color(1, 1, 0, 1.0F));
    GL.Vertex3(10, 10, 0);
    GL.Vertex3(50, 10, 0);
    GL.Vertex3(10, 50, 0);
    //GL.Vertex3(500, 500, 0);
    GL.End();
    }

    in player class. It display me TWO yellow triangles (look at posted picture). However, wanted to make screenshot I discovered that, when I turn off Canvas (or everything in Canvas) it display everything correctly (another thing that when everything is turned off, lightning affect my poor triangle). I could stay in that point, but in nearby future I need to add more GUI elements.

    I'm writing again, I'm new to Unity, so I could done something wrong.

    Thanks for reading this post and I please all of you for help :)
     

    Attached Files:

    • to.png
      to.png
      File size:
      11.6 KB
      Views:
      828