您好,欢迎来到筏尚旅游网。
搜索
您的当前位置:首页unity3D技术之GL.Viewport视口

unity3D技术之GL.Viewport视口

来源:筏尚旅游网


unity3D技术之GL.Viewport视口

static function Viewport (pixelRect : Rect) : void

Description描述

Set the rendering viewport.

定义渲染的视口。【狗刨学习网】

All rendering is constrained to be inside the passed pixelRect. If the Viewport is modified, all the rendered content inside of it gets stretched.

所有渲染结果被在参数pixelRect.矩形内。如果视口大小发生变话,在视口里的内容会伸缩适应变化。

C#

JavaScript

// Draw a red Quad that covers all the view port, and the when space is pressed

// the viewport gets expanded to the whole screen and stretch the contents inside

//画一个红色的四边形,覆盖所有的视口,当按下空格键视口将扩展到整个屏幕并且

拉伸里面的内容

var mat : Material;

private var stretch : boolean = false;

function Update() {

if(Input.GetKeyDown(KeyCode.Space)) {

if(stretch) {

stretch = false;

} else {

stretch = true;

}

}

}

function OnPostRender() {

if (!mat) {

Debug.LogError(\"Please Assign a material on the inspector\");

return;

}

GL.PushMatrix();

mat.SetPass(0);

GL.LoadPixelMatrix();

if(stretch) {

GL.Viewport(Rect(0,0,Screen.width,Screen.height));

} else {

GL.Viewport(Rect(0,0,Screen.width/2,Screen.height));

}

GL.Color(Color.red);

GL.Begin(GL.QUADS);

GL.Vertex3(0,0,0);

GL.Vertex3(0,Screen.height,0);

GL.Vertex3(Screen.width,Screen.height,0);

GL.Vertex3(Screen.width,0,0);

GL.Color(Color.yellow);

GL.End();

GL.Begin(GL.TRIANGLES);

GL.Vertex3(Screen.width/2,Screen.height/4,1);

GL.Vertex3(Screen.width/4,Screen.height/2,1);

GL.Vertex3(Screen.width - Screen.width/4,Screen.height/2,1);

GL.End();

GL.PopMatrix();

}

因篇幅问题不能全部显示,请点此查看更多更全内容

热门图文

Copyright © 2019-2025 efsc.cn 版权所有 赣ICP备2024042792号-1

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务