用户工具

站点工具


侧边栏

script:unityengine:classes:gl:gl.vertex

GL.Vertex 顶点

JavaScript ⇒ public static function Vertex(v: Vector3): void;
C# ⇒ public static void Vertex(Vector3 v);

Description 描述

Submit a vertex.

绘制一个顶点。

In OpenGL this matches glVertex3f(v.x,v.y,v.z); on other graphics APIs the same functionality is emulated.

这个函数和OpenGL中的glVertex3f(v.x,v.y,v.z)函数一样。其它的图形API也有对应的功能。

This function can only be called between GL.Begin and GL.End functions.

这个函数只能在GL.Begin 和GL.End 之间使用。

JavaScript:

	// Draws a line from the bottom right
	// to the top left of the Screen
	// Using GL.Vertex
	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.LINES);
		GL.Vertex(Vector3(1,0,0));
		GL.Vertex(Vector3(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.LINES);
        GL.Vertex(new Vector3(1, 0, 0));
        GL.Vertex(new Vector3(0, 1, 0));
        GL.End();
        GL.PopMatrix();
    }
}

GL

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