コード例 #1
0
        public virtual void Draw(Camera cam, ShaderProgram shader)
        {
            Texture?.Bind();
            shader.Bind();
            shader.SetUniform("model", Transform);

            Vao.DrawElements(PrimitiveType.Quads);
        }
コード例 #2
0
 public void Draw(Area area, Texture texture, ShaderProgram shader)
 {
     texture.Bind();
     shader.Bind();
     area.Vao.DrawArrays(PrimitiveType.TriangleStrip);
 }
コード例 #3
0
 public void Draw(Area a, Texture texture)
 {
     texture.Bind();
     shader.Bind();
     a.Vao.DrawArrays(PrimitiveType.TriangleStrip);
 }
コード例 #4
0
		/// <summary>
		/// Set uniform state variable (sampler1D, sampler2D, sampler3D, samplerCube variable).
		/// </summary>
		/// <param name="ctx">
		/// A <see cref="GraphicsContext"/> used for operations.
		/// </param>
		/// <param name="uniformName">
		/// A <see cref="String"/> that specify the variable name in the shader source.
		/// </param>
		/// <param name="tex">
		/// A <see cref="Texture"/> holding the uniform variabile data (the texture name).
		/// </param>
		/// <param name="texUnit">
		/// A <see cref="Int32"/> that specify the texture unit processing the texture <paramref name="tex"/>.
		/// </param>
		public void SetUniform(GraphicsContext ctx, string uniformName, Texture tex, uint texUnit)
		{
			if (ctx == null)
				throw new ArgumentNullException("ctx");

			UniformBinding uniform = GetUniform(uniformName);

			if (tex == null)
				throw new ArgumentNullException("tex");
			if (tex.Exists(ctx) == false)
				throw new ArgumentException("not exists", "tex");

			CheckProgramBinding();
			CheckUniformType(uniform, tex.SamplerType);

			// Activate texture unit
			Gl.ActiveTexture(Gl.TEXTURE0 + (int)texUnit);
			// Bind texture (on active texture unit)
			tex.Bind(ctx);
			// Apply texture parameters
			tex.ApplyParameters(ctx);

			// Set uniform value (sampler)
			// Cast to Int32 since the sampler type can be set only with glUniform2i
			Gl.Uniform1(uniform.Location, (int)texUnit);

			// Validate program
			Validate();
		}