GL
- Begin
- ClearWithSkybox
- Clear
- Color
- End
- InvalidateState
- LINES
- LoadIdentity
- LoadOrtho
- LoadPixelMatrix
- LoadProjectionMatrix
- modelview
- MultiTexCoord2
- MultiTexCoord3
- MultiTexCoord
- MultMatrix
- PopMatrix
- PushMatrix
- QUADS
- SetRevertBackfacing
- TexCoord2
- TexCoord3
- TexCoord
- TRIANGLE_STRIP
- TRIANGLES
- Vertex3
- Vertex
- Viewport
GL.PushMatrix 压入矩阵
static function PushMatrix () : void
Description描述
Saves both projection and modelview matrices to the matrix stack.
把投影视图矩阵和模型视图矩阵压入堆栈保存。
Changing modelview or projection matrices overrides current camera's parameters. These matrices can be saved and restored using GL.PushMatrix and GL.PopMatrix.
改变模型视图矩阵和投影矩阵会覆盖当前的camera' 的参数,许多情况下你需要用到GL.PushMatrix 和GL.PopMatrix矩阵函数.来保存和恢复。
参见:PopMatrix 函数
using UnityEngine;
using System.Collections;
public class example : MonoBehaviour {
public Material mat;
void OnPostRender() {
if (!mat) {
Debug.LogError("Please Assign a material on the inspector");
return;
}
GL.PushMatrix();
mat.SetPass(0);
GL.LoadPixelMatrix();
GL.Color(Color.yellow);
GL.Begin(GL.LINES);
GL.Vertex3(0, 0, 0);
GL.Vertex3(Screen.width, Screen.height, 0);
GL.End();
GL.PopMatrix();
}
}
// Draw a yellow line from the botton left to the
// top right of the screen
//从屏幕左下角到右上角,绘制一条黄色的线
var mat : Material;
function OnPostRender() {
if (!mat) {
Debug.LogError("Please Assign a material on the inspector");
return;
}
GL.PushMatrix(); // Save the current state 保存当前的状态
mat.SetPass(0);
GL.LoadPixelMatrix();
GL.Color(Color.yellow);
GL.Begin(GL.LINES);
GL.Vertex3(0,0,0);
GL.Vertex3(Screen.width, Screen.height,0);
GL.End();
GL.PopMatrix(); // Pop changes. 弹出改变
}
最后修改:2011年3月22日 Tuesday 14:05