diff options
author | chai <chaifix@163.com> | 2018-09-23 19:34:47 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2018-09-23 19:34:47 +0800 |
commit | e61e555361940b1b3c865520d78b203df03237c5 (patch) | |
tree | 60359aa163dbebbccb19017d643fadc46ad0a7f0 /Box2d/Assets/Program/Test/ApplicationMain.cs | |
parent | 146e343b49af2ade042dc416b983ef1f06cf712b (diff) |
*update
Diffstat (limited to 'Box2d/Assets/Program/Test/ApplicationMain.cs')
-rw-r--r-- | Box2d/Assets/Program/Test/ApplicationMain.cs | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/Box2d/Assets/Program/Test/ApplicationMain.cs b/Box2d/Assets/Program/Test/ApplicationMain.cs new file mode 100644 index 0000000..bec4540 --- /dev/null +++ b/Box2d/Assets/Program/Test/ApplicationMain.cs @@ -0,0 +1,40 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using Box2DX; +using Box2DX.Dynamics; +using Box2DX.Collision; +using Box2DX.Common; + +public class ApplicationMain : MonoBehaviour +{ + + + public Material material; + + void OnPostRender() + { + //绘制正四边形,提供的坐标必须是顺时针或者逆时针 + Draw(100, 100, 100, 200, 200, 200, 200, 100); + //绘制无规则四边形 + Draw(15, 5, 10, 115, 95, 110, 90, 10); + } + + //绘制四边形,四个点坐标 + void Draw(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4) + { + GL.PushMatrix(); + //material.SetPass(0);//设置该材质通道,0为默认值 + GL.LoadOrtho();//设置绘制2d图像 + GL.Begin(GL.QUADS);//绘制类型为四边形 + + GL.Vertex3(x1 / Screen.width, y1 / Screen.height, 0); + GL.Vertex3(x2 / Screen.width, y2 / Screen.height, 0); + GL.Vertex3(x3 / Screen.width, y3 / Screen.height, 0); + GL.Vertex3(x4 / Screen.width, y4 / Screen.height, 0); + + GL.End(); + GL.PopMatrix(); + } + +} |