zoukankan      html  css  js  c++  java
  • unity, unity中GL.MultMatrix的一个超级bug

    GL.MultMatrix与OpenGL固定管线的glMultMatrix函数行为并不一致,不是累乘,而是覆盖。

    例如下面例子,本来预期是在(100,100)处画一个方块,而实际效果却是在(0,0)处画一个方块:

    GL.PushMatrix();
      GL.LoadPixelMatrix();
      {
       //mult matrix
       Matrix4x4 mat1 = Matrix4x4.TRS(new Vector3(100,100,0),Quaternion.identity,Vector3.one);
       GL.MultMatrix (mat1);
       //mult matrix
       Matrix4x4 mat2 = Matrix4x4.identity;
       GL.MultMatrix (mat2); 
       //draw quad
       {
        float m_left = -20;
        float m_top = -20;
        float m_right = 20;
        float m_bottom = 20;
        Vector2 LU = new Vector2 (m_left, m_top);
        Vector2 LD = new Vector2 (m_left, m_bottom);
        Vector2 RU = new Vector2 (m_right, m_top);
        Vector2 RD = new Vector2 (m_right, m_bottom);
        uiMat.getInstance ().m_dftUIMat.SetPass (0);
        GL.Begin (GL.QUADS);
        GL.Color (Color.red);
        GL.Vertex (new Vector3 (LU.x, LU.y, 0));
        GL.Vertex (new Vector3 (LD.x, LD.y, 0));
        GL.Vertex (new Vector3 (RD.x, RD.y, 0));
        GL.Vertex (new Vector3 (RU.x, RU.y, 0));
        GL.End ();
       }
      }
      GL.PopMatrix();

    参考:http://answers.unity3d.com/answers/1115934/view.html

  • 相关阅读:
    学习数据结构基础
    epoll
    pthread_create
    设置套接字选项
    5中I/O模型
    数据仓库一些整理(列式数据库)
    mysql分区方案的研究
    订单表的分库分表方案设计(大数据)
    从源码角度理清memcache缓存服务
    性能,不是不重要,而是,它没有可维护性重要
  • 原文地址:https://www.cnblogs.com/wantnon/p/5066203.html
Copyright © 2011-2022 走看看