using System;
using UnityEngine;

namespace RenderHeads.Media.AVProVideo
{
	[AddComponentMenu("AVPro Video/Display Background", 200)]
	[HelpURL("http://renderheads.com/product/avpro-video/")]
	[ExecuteInEditMode]
	public class DisplayBackground : MonoBehaviour
	{
		private void OnRenderObject()
		{
			if (this._material == null || this._texture == null)
			{
				return;
			}
			Vector4 vector = new Vector4(0f, 0f, 1f, 1f);
			this._material.SetPass(0);
			GL.PushMatrix();
			GL.LoadOrtho();
			GL.Begin(7);
			GL.TexCoord2(vector.x, vector.y);
			GL.Vertex3(0f, 0f, 0.1f);
			GL.TexCoord2(vector.z, vector.y);
			GL.Vertex3(1f, 0f, 0.1f);
			GL.TexCoord2(vector.z, vector.w);
			GL.Vertex3(1f, 1f, 0.1f);
			GL.TexCoord2(vector.x, vector.w);
			GL.Vertex3(0f, 1f, 0.1f);
			GL.End();
			GL.PopMatrix();
		}

		public IMediaProducer _source;

		public Texture2D _texture;

		public Material _material;
	}
}
