public void TestUniform2i()
        {
            if (!HasVersion(2, 0) && !HasEsVersion(2, 0) && !IsGlExtensionSupported("GL_ARB_shader_objects"))
            {
                Assert.Inconclusive("required features not implemented");
            }

            using (Device device = new Device())
                using (new GLContext(device))
                {
                    uint program = CreateProgramUniform2i();

                    try {
                        Vertex2i uniformStruct;
                        int[]    uniformValue;

                        int uniformLoc = Gl.GetUniformLocation(program, "uVec");
                        if (uniformLoc < 0)
                        {
                            throw new InvalidOperationException("no uniform variable");
                        }

                        // glGetUniformiv
                        uniformValue = Array2(1);
                        Gl.GetUniform(program, uniformLoc, uniformValue);
                        CollectionAssert.AreEqual(Array2(0), uniformValue);

                        // glGetUniformiv (ref)
                        uniformStruct = new Vertex2i(1);
                        Gl.GetUniformi(program, uniformLoc, ref uniformStruct);
                        Assert.AreEqual(Vertex2i.Zero, uniformStruct);

                        // glUniform2i
                        uniformValue = Array2(0);
                        Gl.Uniform2(uniformLoc, Array2(1));
                        Gl.GetUniform(program, uniformLoc, uniformValue);
                        CollectionAssert.AreEqual(Array2(1), uniformValue);

                        // glUniform2iv
                        uniformValue = Array2(0);
                        Gl.Uniform2(uniformLoc, Array2(9));
                        Gl.GetUniform(program, uniformLoc, uniformValue);
                        CollectionAssert.AreEqual(Array2(9), uniformValue);

                        // glUniform2iv (ref)
                        uniformValue  = Array2(0);
                        uniformStruct = new Vertex2i(5);
                        Gl.Uniform2i(uniformLoc, 1, ref uniformStruct);
                        Gl.GetUniform(program, uniformLoc, uniformValue);
                        CollectionAssert.AreEqual(Array2(5), uniformValue);
                    } finally {
                        Gl.DeleteProgram(program);
                    }
                }
        }
Example #2
0
            /// <summary>
            /// Extract all information required from the specified dataset.
            /// </summary>
            /// <param name="dataset">
            /// The <see cref="Dataset"/> from which the information must be extracted.
            /// </param>
            protected void ExtractBlockInformation(Dataset dataset)
            {
                if (dataset == null)
                {
                    throw new ArgumentNullException("dataset");
                }

                // Block size
                using (Band datasetBand = dataset.GetRasterBand(1))
                {
                    datasetBand.GetBlockSize(out _BlockSize.x, out _BlockSize.y);

                    // Do not expose "rows": find a suitable block size
                    if (_BlockSize.x == 1 || _BlockSize.y == 1)
                    {
                        const int DefaultBlockSize = 2048;

                        int blockSize = Math.Min(DefaultBlockSize, GraphicsContext.CurrentCaps.Limits.MaxTexture2DSize);

                        _BlockSize = new Vertex2i(blockSize, blockSize);
                    }

                    _BlockSize.x = Math.Min(_BlockSize.x, GraphicsContext.CurrentCaps.Limits.MaxTexture2DSize);
                    _BlockSize.y = Math.Min(_BlockSize.y, GraphicsContext.CurrentCaps.Limits.MaxTexture2DSize);
                }

                // Cache blocks definitions
                for (int x = 0; x < dataset.RasterXSize; x += _BlockSize.x)
                {
                    for (int y = 0; y < dataset.RasterYSize; y += _BlockSize.y)
                    {
                        int wBlock = _BlockSize.x, hBlock = _BlockSize.y;

                        if (x + wBlock > dataset.RasterXSize)
                        {
                            wBlock = dataset.RasterXSize - x;
                        }
                        if (y + hBlock > dataset.RasterYSize)
                        {
                            hBlock = dataset.RasterYSize - y;
                        }

                        _Blocks.Add(new GeoTerrainDataset(this, dataset, new Rectangle(x, y, wBlock, hBlock)));
                    }
                }
                Debug.Assert(_Blocks.Count > 0);
            }
 void IShaderUniformContainer.SetUniform(GraphicsContext ctx, string uniformName, Vertex2i v)
 {
     throw new NotImplementedException();
 }
Example #4
0
 /// <summary>
 /// Fills a triangular area with the currently set color
 /// <para>Clockwise winding assumed for all verticies</para>
 /// </summary>
 /// <param name="v1">First vertex</param>
 /// <param name="v2">Second vertex</param>
 /// <param name="v3">Third vertex</param>
 public abstract void Fill_Tri(Vertex2i v1, Vertex2i v2, Vertex2i v3);
Example #5
0
 /// <summary>
 /// Fills a rectangular area with the currently set color
 /// <para>Clockwise winding assumed for all verticies</para>
 /// </summary>
 /// <param name="LineThickness">Thickness of the line in pixels</param>
 /// <param name="v1">Top-Left vertex</param>
 /// <param name="v2">Top-Right vertex</param>
 /// <param name="v3">Bottom-Right vertex</param>
 /// <param name="v4">Bottom-Left vertex</param>
 public abstract void Fill_Rect(Vertex2i v1, Vertex2i v2, Vertex2i v3, Vertex2i v4);
Example #6
0
 /// <summary>
 /// Outlines a triangular area with the currently set color
 /// <para>Clockwise winding assumed for all verticies</para>
 /// </summary>
 /// <param name="LineThickness">Thickness of the line in pixels</param>
 /// <param name="v1">First vertex</param>
 /// <param name="v2">Second vertex</param>
 /// <param name="v3">Third vertex</param>
 public abstract void Draw_Tri(int LineThickness, Vertex2i v1, Vertex2i v2, Vertex2i v3);
Example #7
0
 /// <summary>
 /// Outlines a rectangular area with the currently set color
 /// <para>Clockwise winding assumed for all verticies</para>
 /// </summary>
 /// <param name="LineThickness">Thickness of the line in pixels</param>
 /// <param name="v1">Top-Left vertex</param>
 /// <param name="v2">Top-Right vertex</param>
 /// <param name="v3">Bottom-Right vertex</param>
 /// <param name="v4">Bottom-Left vertex</param>
 public abstract void Draw_Rect(int LineThickness, Vertex2i v1, Vertex2i v2, Vertex2i v3, Vertex2i v4);
Example #8
0
 /// <summary>
 /// Draws a line between two given points
 /// </summary>
 /// <param name="LineThickness">Thickness of the line in pixels</param>
 /// <param name="v1">First vertex</param>
 /// <param name="v2">Second vertex</param>
 public abstract void Draw_Line(int LineThickness, Vertex2i v1, Vertex2i v2);
		/// <summary>
		/// Set uniform state variable (ivec2 variable or bvec2 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="v">
		/// A <see cref="Vertex2i"/> holding the uniform variabile data (first component).
		/// </param>
		public void SetUniform(GraphicsContext ctx, string uniformName, Vertex2i v)
		{
			SetUniform(ctx, uniformName, v.x, v.y);
		}