返回介绍

GL.TRIANGLES 三角形

发布于 2019-12-18 15:37:44 字数 2011 浏览 1224 评论 0 收藏 0

JavaScript => public static var TRIANGLES: int;
C# => public static int TRIANGLES;

Description 描述

Mode for Begin: draw triangles.

从Begin模式开始后,然后绘制三角形。

If you want to draw something 2D in screen space then probably you will want to use GL.LoadOrtho or GL.LoadPixelMatrix.
If you want something in “3D”, then probably you should consider using GL.LoadIdentity followed by GL.MultMatrix with the actual 3D transform you want your stuff to be in.

如果在场景中画2D对象,你可能要用到GL.LoadOrtho 或 GL.LoadPixelMatrix函数。
如果在场景中画3D对象,你可能要用到GL.LoadIdentity 或 GL.MultMatrix函数进行3D变换。

See Also: GL.Begin, GL.End.

JavaScript:

	// Draws a triangle that covers the middle of the screen
	var mat : Material;
 
	function OnPostRender() {
		if (!mat) {
			Debug.LogError("Please Assign a material on the inspector");
			return;
		}
		GL.PushMatrix();
		mat.SetPass(0);
		GL.LoadOrtho();
		GL.Begin(GL.TRIANGLES);
		GL.Vertex3(0,0,0);
		GL.Vertex3(1,1,0);
		GL.Vertex3(0,1,0);
		GL.End();
		GL.PopMatrix();
	}

C#:

using UnityEngine;
using System.Collections;
 
public class ExampleClass : MonoBehaviour {
    public Material mat;
    void OnPostRender() {
        if (!mat) {
            Debug.LogError("Please Assign a material on the inspector");
            return;
        }
        GL.PushMatrix();
        mat.SetPass(0);
        GL.LoadOrtho();
        GL.Begin(GL.TRIANGLES);
        GL.Vertex3(0, 0, 0);
        GL.Vertex3(1, 1, 0);
        GL.Vertex3(0, 1, 0);
        GL.End();
        GL.PopMatrix();
    }
}

GL

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文