Esempio n. 1
0
        protected void SetUniform1(string name, int value)
        {
            var location = GL.GetUniformLocation(Id, name);

            GL.Uniform1(location, value);
            OpenGlErrorThrower.ThrowIfAny();
        }
Esempio n. 2
0
        public void SetMatrix(Matrix4 matrix, string location)
        {
            var matrixLocation = GL.GetUniformLocation(Id, location);

            OpenGlErrorThrower.ThrowIfAny();
            GL.UniformMatrix4(matrixLocation, false, ref matrix);
            OpenGlErrorThrower.ThrowIfAny();
        }
Esempio n. 3
0
        public void SetRange(float min, float max)
        {
            var minLocation = GL.GetUniformLocation(Id, "min");

            OpenGlErrorThrower.ThrowIfAny();
            var maxLocation = GL.GetUniformLocation(Id, "max");

            OpenGlErrorThrower.ThrowIfAny();
            GL.Uniform1(maxLocation, max);
            OpenGlErrorThrower.ThrowIfAny();
            GL.Uniform1(minLocation, min);
            OpenGlErrorThrower.ThrowIfAny();
        }
        public override void Draw(ViewParametres viewParametres)
        {
//            var rel = _texture.Size.Height / viewParams.ViewportSize.Height;
//            _model = Matrix4.CreateScale(viewParams.Zoom * rel * _texture.Ratio, viewParams.Zoom * rel, 1);
//            shader.SetModelMatrix(_model);

            if (ImageHandler?.OpenGlTextureId == null) // Try upload to videocard?
            {
                return;
            }

            GL.BindTexture(TextureTarget.Texture2D, ImageHandler.OpenGlTextureId.Value);
            GL.BindVertexArray(_vao);
            GL.DrawElements(BeginMode.Triangles, 6, DrawElementsType.UnsignedInt, 0);
            GL.BindVertexArray(0);
            GL.BindTexture(TextureTarget.Texture2D, 0);
            OpenGlErrorThrower.ThrowIfAny();
        }
Esempio n. 5
0
        public void SetViewRange(float bottom, float top)
        {
            if (bottom < 0 || top > 1 || bottom > top)
            {
                throw new InvalidOperationException();
            }

            var bottomLocation = GL.GetUniformLocation(Id, "bottom");

            OpenGlErrorThrower.ThrowIfAny();
            var topLocation = GL.GetUniformLocation(Id, "top");

            OpenGlErrorThrower.ThrowIfAny();
            GL.Uniform1(topLocation, top);
            OpenGlErrorThrower.ThrowIfAny();
            GL.Uniform1(bottomLocation, bottom);
            OpenGlErrorThrower.ThrowIfAny();
        }