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

  • 相关阅读:
    REST接口设计规范总结
    Linux 下建立 Git 与 GitHub 的连接
    Linux centos修改防火墙为iptables
    一些开源软件的国内镜像源
    centOS7下安装GUI图形界面
    mysql使用锁的分析
    php后台添加默认图片
    php执行时间
    递归获取所有分类下面子分类的id
    php laravel左连接leftJoin多条where语句
  • 原文地址:https://www.cnblogs.com/wantnon/p/5066203.html
Copyright © 2011-2022 走看看