用户工具

站点工具


侧边栏

script:unityengine:classes:gl:gl.loadpixelmatrix

GL.LoadPixelMatrix 加载像素矩阵

JavaScript ⇒ public static function LoadPixelMatrix(): void;
C# ⇒ public static void LoadPixelMatrix();

Description 描述

Setup a matrix for pixel-correct rendering.

设置一个矩阵用于像素矫正渲染。

This sets up modelview and projection matrices so that X, Y coordinates map directly to pixels. The (0,0) is at the bottom left corner of current camera's viewport. The Z coordinate goes from -1 to +1.

这设置模型视图和投影矩阵,为了使坐标X,Y映射为屏幕上的像素点。(0,0)对应视点的左下角。Z坐标值从-1到+1.

This function overrides current camera's parameters, so most often you want to save and restore matrices using GL.PushMatrix and GL.PopMatrix.

这个函数会覆盖当前camera的参数,许多情况下你需要用到GL.PushMatrix 和GL.PopMatrix矩阵函数来保存和恢复。

JavaScript:

	// Draws a red triangle using pixels as coordinates to paint on.
	var mat : Material;
 
	function OnPostRender() {
		if (!mat) {
			Debug.LogError("Please Assign a material on the inspector");
			return;
		}
		GL.PushMatrix();
		mat.SetPass(0);
		GL.LoadPixelMatrix();
		GL.Color(Color.red);
		GL.Begin(GL.TRIANGLES);
		GL.Vertex3(0,0,0);
		GL.Vertex3(0,Screen.height/2,0);
		GL.Vertex3(Screen.width/2,Screen.height/2,0);
		GL.End();
		GL.PopMatrix();
	}

C#:

using UnityEngine;

                                    
script/unityengine/classes/gl/gl.loadpixelmatrix.txt · 最后更改: 2016/08/02 05:24 (外部编辑)