Ejemplo n.º 1
0
 /// <summary>
 /// Binds a buffer to this binding point.
 /// </summary>
 /// <typeparam name="T">The type of the container elements.</typeparam>
 /// <param name="buffer">The buffer to bind.</param>
 /// <param name="offset">The starting offset in basic machine units into the buffer object buffer. </param>
 /// <param name="size">The amount of data in machine units that can be read from the buffer object while used as an indexed target. </param>
 public void BindBuffer <T>(Buffer <T> buffer, int offset, int size)
     where T : struct
 {
     if (!Active)
     {
         return;
     }
     GL.BindBufferRange(BindingTarget, Binding, buffer.Handle, (IntPtr)offset, (IntPtr)size);
 }
Ejemplo n.º 2
0
 public void BindRange(int bindingPoint, IntPtr offsetBytes, IntPtr size)
 {
     GL.BindBufferRange(
         bufferTarget,
         bindingPoint,
         (int)bufferObject,
         offsetBytes,
         size
         );
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Bind a portion of this buffer at a binding point in an indexed target
        /// </summary>
        /// <param name="bindingPoint"></param>
        /// <param name="start"></param>
        /// <param name="count"></param>
        public void BindAtUniformBlockBindingPoint(UniformBlockBindingPoint bindingPoint, long start, long count)
        {
            this.Assert();

            GL.BindBufferRange(
                BufferRangeTarget.UniformBuffer, bindingPoint.Index, Handle.Handle,
                (IntPtr)(start * TypeInfo <T> .TypeSize),
                (IntPtr)(count * TypeInfo <T> .TypeSize)
                );
        }
Ejemplo n.º 4
0
        public void SetUniforms(int uniformOffset, int image)
        {
            _gl.BindBufferRange(BufferTargetARB.UniformBuffer, (uint)UniformBindings.FragBinding, _fragBuffer, uniformOffset, (nuint)Marshal.SizeOf(typeof(FragUniforms)));

            int id = _renderer.DummyTex;

            if (image != 0)
            {
                id = image;
            }
            ref var tex = ref _renderer.TextureManager.FindTexture(id);
Ejemplo n.º 5
0
 public UBO(string blockName, int location, int size)
 {
     _blockName = blockName;
     _location  = location;
     _size      = size;
     GL.GenBuffers(1, out _handle);
     using (new Bind(this))
     {
         GL.BufferData(BufferTarget.UniformBuffer, (IntPtr)(_size), (IntPtr)(null), BufferUsageHint.StreamDraw);
         GL.BindBufferRange(BufferTarget.UniformBuffer, (uint)_location, _handle, (IntPtr)0, (IntPtr)_size);
     }
 }
            public UniformBufferObject(int index, Func <T> getData)
            {
                bufferIndex  = index;
                this.getData = getData;
                size         = System.Runtime.InteropServices.Marshal.SizeOf(typeof(T));

                GL.GenBuffers(1, out bufferUBO);                                                                       // Generate the buffer
                GL.BindBuffer(BufferTarget.UniformBuffer, bufferUBO);                                                  // Bind the buffer for writing
                GL.BufferData(BufferTarget.UniformBuffer, (IntPtr)(size), (IntPtr)(null), BufferUsageHint.StreamDraw); // Request the memory to be allocated

                GL.BindBufferRange(BufferRangeTarget.UniformBuffer, bufferIndex, bufferUBO, (IntPtr)0, (IntPtr)(size));
            }
Ejemplo n.º 7
0
        public void BindBufferRange(BufferRangeTarget target, int bindingPoint, int buffer, IntPtr offset, IntPtr size)
        {
            if (!_bufferBindings.ContainsKey(target))
            {
                _bufferBindings[target] = new BufferBinding[BufferBindingPoints];
            }

            var binding = new BufferBinding(buffer, offset, size);

            if (IsBindingDifferent(target, bindingPoint, binding))
            {
                GL.BindBufferRange(target, bindingPoint, buffer, offset, size);
                _bufferBindings[target][bindingPoint] = binding;
            }
        }
Ejemplo n.º 8
0
        public void SetTransformFeedbackBuffer(int index, BufferRange buffer)
        {
            const BufferRangeTarget target = BufferRangeTarget.TransformFeedbackBuffer;

            if (_tfEnabled)
            {
                GL.PauseTransformFeedback();
                GL.BindBufferRange(target, index, buffer.Handle.ToInt32(), (IntPtr)buffer.Offset, buffer.Size);
                GL.ResumeTransformFeedback();
            }
            else
            {
                GL.BindBufferRange(target, index, buffer.Handle.ToInt32(), (IntPtr)buffer.Offset, buffer.Size);
            }
        }
Ejemplo n.º 9
0
        public static void BindBuffer(BufferTarget target, int id, int index, IntPtr off, IntPtr size)
        {
            if (target != BufferTarget.TransformFeedbackBuffer && target != BufferTarget.UniformBuffer)
            {
                throw new Exception("Incorrect Function Called, Use other Overload");
            }
            if (boundBuffers[target][index].Count == 0)
            {
                boundBuffers[target][index].Push(0);
            }

            if (boundBuffers[target][index].Peek() != id || id == 0)
            {
                GL.BindBufferRange((BufferRangeTarget)target, index, id, off, size);
            }
            boundBuffers[target][index].Push(id);
        }
Ejemplo n.º 10
0
        private void SetBuffer(int bindingPoint, BufferRange buffer, bool isStorage)
        {
            BufferRangeTarget target = isStorage
                ? BufferRangeTarget.ShaderStorageBuffer
                : BufferRangeTarget.UniformBuffer;

            if (buffer.Buffer == null)
            {
                GL.BindBufferRange(target, bindingPoint, 0, IntPtr.Zero, 0);

                return;
            }

            int bufferHandle = ((Buffer)buffer.Buffer).Handle;

            IntPtr bufferOffset = (IntPtr)buffer.Offset;

            GL.BindBufferRange(target, bindingPoint, bufferHandle, bufferOffset, buffer.Size);
        }
Ejemplo n.º 11
0
        private void CommitNewConstantBufferBindings_SingleBind()
        {
            int remainingBindings = _newConstantBuffersCount;

            for (int slot = 0; slot < _maxConstantBufferSlots; slot++)
            {
                if (remainingBindings == 0)
                {
                    return;
                }

                OpenGLConstantBuffer cb = _newConstantBuffersBySlot[slot];
                if (cb != null)
                {
                    GL.BindBufferRange(BufferRangeTarget.UniformBuffer, slot, cb.BufferID, IntPtr.Zero, cb.BufferSize);
                    remainingBindings -= 1;
                }
            }
        }
Ejemplo n.º 12
0
        private void BindBuffers()
        {
            GenerateMaterialBlock();

            foreach (ShaderAttributeIds id in VertexData.EnabledAttributes)
            {
                int buffer_id = VertexData.GetAttributeBufferId(id);

                GL.BindBuffer(BufferTarget.ArrayBuffer, buffer_id);
                GL.EnableVertexAttribArray((int)id);

                GL.VertexAttribPointer((int)id, VertexData.GetAttributeSize(id), VertexData.GetAttributePointerType(id), false, VertexData.GetStride(id), 0);
            }

            GL.BindBuffer(BufferTarget.ElementArrayBuffer, VertexData.IndexBufferId);

            GL.BindBufferRange(BufferRangeTarget.UniformBuffer, 0, UBOId, MaterialBlockOffset, Marshal.SizeOf(typeof(MaterialBlock)));
            GL.BindBufferRange(BufferRangeTarget.UniformBuffer, 1, MBOId, MatrixBlockOffset, Marshal.SizeOf(typeof(MatrixBlock)));
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Initializes the camera's matrices and Uniform Buffer.
        /// </summary>
        /// <param name="window">The dimensions of the window being used. Creates the aspect ratio. </param>
        /// <param name="z_Near">The location of the near clipping plane.</param>
        /// <param name="z_Far">The location of the far clipping plane.</param>
        /// <param name="location">The three dimensional coordinates for the camera eye.</param>
        /// <param name="target">The three dimensional coordinates where the camera is looking.</param>
        public static void Initialize(Size window, float z_Near, float z_Far, Vector3 location, Vector3 target)
        {
            cameraeyelocation = location;
            cameraeyetarget   = target;
            windowSize        = window;

            // Create the perspective and view matrices.
            matricies.Perspective = Matrix4.CreatePerspectiveFieldOfView(MathHelper.PiOver4, (float)window.Width / (float)window.Height, z_Near, z_Far);
            matricies.View        = Matrix4.LookAt(location, target, new Vector3(0.0f, 1.0f, 0.0f));

            // Create the Uniform Buffer and load our matrix data.
            GL.GenBuffers(1, out globalCameraUBO);
            GL.BindBuffer(BufferTarget.UniformBuffer, globalCameraUBO);
            GL.BufferData(BufferTarget.UniformBuffer, GlobalMatrix.SizeInBytes, ref matricies, BufferUsageHint.StreamDraw);
            GL.BindBuffer(BufferTarget.UniformBuffer, 0);

            // Set this here so that everything will error if we haven't initialize the camera
            globalCameraBindingIndex = 1;

            GL.BindBufferRange(BufferRangeTarget.UniformBuffer, globalCameraBindingIndex, globalCameraUBO, IntPtr.Zero, GlobalMatrix.SizeInBytes);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Parse command line and attach the buffer object
        /// to the specified unit (output stream).
        /// </summary>
        /// <param name="unit">Vertex output stream unit.</param>
        /// <param name="cmd">Command line to process.</param>
        /// <param name="scene">Dictionary of scene objects.</param>
        /// <param name="err">Compiler exception collector.</param>
        private void Attach(int unit, Compiler.Command cmd, Dict scene, CompileException err)
        {
            if (cmd.ArgCount == 0)
            {
                err.Add("Command buff needs at least one attribute (e.g. 'buff buff_name')", cmd);
                return;
            }

            // get buffer
            var buf = scene.GetValueOrDefault <GLBuffer>(cmd[0].Text);

            if (buf == null)
            {
                err.Add($"The name '{cmd[0]}' does not reference an object of type 'buffer'.", cmd);
                return;
            }

            // parse offset
            int offset = 0;

            if (cmd.ArgCount > 1 && int.TryParse(cmd[1].Text, out offset) == false)
            {
                err.Add($"The second parameter (offset) of buff {unit} is invalid.", cmd);
                return;
            }

            // parse size
            int size = buf.Size;

            if (cmd.ArgCount > 2 && int.TryParse(cmd[2].Text, out size) == false)
            {
                err.Add($"The third parameter (size) of buff {unit} is invalid.", cmd);
                return;
            }

            // bind buffer to transform feedback
            GL.BindBufferRange(BufferRangeTarget.TransformFeedbackBuffer,
                               unit, buf.glname, (IntPtr)offset, (IntPtr)size);
        }
        public void LoadLayout(string name)
        {
            if (!uniformBlocks.ContainsKey(name))
            {
                //Get block indices
                var uniformID = GL.GetUniformBlockIndex(program, name);

                //Link them
                GL.UniformBlockBinding(program, uniformID, 0);

                int buffer;
                GL.GenBuffers(1, out buffer);
                uniformBlocks.Add(name, buffer);

                var dataValues = new Vector4[3]
                {
                    new Vector4(1, 0, 0, 0),
                    new Vector4(0, 1, 0, 0),
                    new Vector4(0, 0, 1, 0)
                };

                var totalSize = (Vector3.SizeInBytes + 4) * dataValues.Length; //Add 4 for alignment

                GL.BindBuffer(BufferTarget.UniformBuffer, buffer);
                GL.BufferData(BufferTarget.UniformBuffer,
                              totalSize,
                              IntPtr.Zero,
                              BufferUsageHint.StaticDraw);
                GL.BindBuffer(BufferTarget.UniformBuffer, 0);

                // define the range of the buffer that links to a uniform binding point
                GL.BindBufferRange(BufferRangeTarget.UniformBuffer, 0, buffer,
                                   IntPtr.Zero, totalSize);

                GL.BindBuffer(BufferTarget.UniformBuffer, buffer);
                GL.BufferSubData <Vector4>(BufferTarget.UniformBuffer, IntPtr.Zero, (Vector3.SizeInBytes + 4) * dataValues.Length, dataValues); //Add 4 for alignment
                GL.BindBuffer(BufferTarget.UniformBuffer, 0);
            }
        }
Ejemplo n.º 16
0
        private void extractBokeh(fx_Quad quad, Texture depth_texture, Texture scene_texture)
        {
            _fHalfResolution.bind(DrawBuffersEnum.ColorAttachment5);
            GL.Clear(ClearBufferMask.ColorBufferBit);
            GL.Viewport(0, 0, _tDOF_Scene.width, _tDOF_Scene.height);

            _pBokeh_Extract.bind();

            scene_texture.bind(_pBokeh_Extract.getSamplerUniform(0), 0);
            depth_texture.bind(_pBokeh_Extract.getSamplerUniform(1), 1);
            _tCOC_Final.bind(_pBokeh_Extract.getSamplerUniform(2), 2);

            _tBokeh_Positions.bindImageUnit(_pBokeh_Extract.getSamplerUniform(3), 3, TextureAccess.WriteOnly);
            _tBokeh_Colors.bindImageUnit(_pBokeh_Extract.getSamplerUniform(4), 4, TextureAccess.WriteOnly);

            GL.BindBufferRange(BufferRangeTarget.AtomicCounterBuffer, 0, _bokeh_indirect_buffer, (IntPtr)4, (IntPtr)sizeof(uint));
            GL.Uniform1(_pBokeh_Extract.getUniform("bokeh_counter"), 0);

            quad.render();

            GL.MemoryBarrier(MemoryBarrierFlags.AllBarrierBits);
        }
Ejemplo n.º 17
0
        public static bool BufferMaterials(ComposedShader shader, List <ShaderMaterial> materials, string name)
        {
            int uboMaterial;
            int uboIndex; // Index to use for the buffer binding. All binding indicies start from 0

            ShaderMaterial[] _materials;
            ShaderMaterial[] src;

            _materials = new ShaderMaterial[16]; // finely-sharpened imposes a limit of 16 of materials per object
            src        = materials.ToArray();
            Array.Copy(src, 0, _materials, 0, src.Length);

            uboIndex    = 0;
            uboMaterial = GL.GenBuffer();

            GL.BindBuffer(BufferTarget.UniformBuffer, uboMaterial);

            // Allocate Memory Request
            GL.BufferData <ShaderMaterial>(BufferTarget.UniformBuffer,
                                           (IntPtr)(_materials.Length * ShaderMaterial.Size),
                                           _materials, BufferUsageHint.StaticDraw);


            // Bind the created Uniform Buffer to the Buffer Index
            GL.BindBufferRange(BufferRangeTarget.UniformBuffer,
                               uboIndex,
                               uboMaterial,
                               (IntPtr)0,
                               _materials.Length * ShaderMaterial.Size
                               );


            // Cleanup
            GL.BindBuffer(BufferTarget.UniformBuffer, 0);

            return(true);
        }
Ejemplo n.º 18
0
        public static bool BufferMaterial(ComposedShader shader, ShaderMaterial material, string name, out int uboMaterial)
        {
            int uboIndex; // Index to use for the buffer binding (All good things start at 0 )

            //int uniformBlockLocation;

            uboIndex = 0;

            //uniformBlockLocation = GL.GetUniformBlockIndex(shader.ShaderHandle, name);

            //if(UniformBlockLocation > -1)
            //{
            //    GL.UniformBlockBinding(shader.ShaderHandle, uniformBlockLocation, uboIndex);
            //}


            uboMaterial = GL.GenBuffer();

            GL.BindBuffer(BufferTarget.UniformBuffer, uboMaterial);

            // Allocate Memory Request
            GL.BufferData(BufferTarget.UniformBuffer,
                          (IntPtr)(ShaderMaterial.Size), (IntPtr)(null), BufferUsageHint.DynamicDraw);

            // Bind the created Uniform Buffer to the Buffer Index
            GL.BindBufferRange(BufferRangeTarget.UniformBuffer,
                               uboIndex,
                               uboMaterial,
                               (IntPtr)0, ShaderMaterial.Size
                               );


            GL.BufferSubData <ShaderMaterial>(BufferTarget.UniformBuffer, (IntPtr)0, ShaderMaterial.Size, ref material);
            GL.BindBuffer(BufferTarget.UniformBuffer, 0);

            return(true);
        }
Ejemplo n.º 19
0
        private static unsafe void OnLoad()
        {
            Gl       = GL.GetApi();
            camera   = new Camera();
            backpack = new Model(Gl, "res/backpack/backpack.obj");

            shader = new Shader(Gl, "shader.vert", "shader.frag");
            shader.Use();
            shader.SetFloat("material.shininess", 32.0f);
            Gl.UniformBlockBinding(shader.ID, Gl.GetUniformBlockIndex(shader.ID, "Matrices"), 0);

            matrices = Gl.GenBuffer();
            Gl.BindBuffer(BufferTargetARB.UniformBuffer, matrices);
            Gl.BufferData(BufferTargetARB.UniformBuffer, (uint)(2 * sizeof(Matrix4x4)), null, BufferUsageARB.StaticDraw);
            Gl.BindBufferRange(BufferTargetARB.UniformBuffer, 0, matrices, 0, (uint)(2 * sizeof(Matrix4x4)));

            Matrix4x4 projectionMat = Matrix4x4.CreatePerspectiveFieldOfView(Util.ToRadians(Fov), 800f / 600f, .1f, 100f);

            Gl.BufferSubData(BufferTargetARB.UniformBuffer, 0, (uint)sizeof(Matrix4x4), &projectionMat);

            screenShader = new Shader(Gl, "screenshader.vert", "screenshader.frag");
            depthShader  = new Shader(Gl, "depthshader.vert", "depthshader.frag");

            quadVao = Gl.GenVertexArray();
            Gl.BindVertexArray(quadVao);

            quadVbo = Gl.GenBuffer();
            Gl.BindBuffer(BufferTargetARB.ArrayBuffer, quadVbo);

            fixed(void *i = &quadVertices[0])
            Gl.BufferData(BufferTargetARB.ArrayBuffer, (uint)(quadVertices.Length * sizeof(float)), i, BufferUsageARB.StaticDraw);

            Gl.VertexAttribPointer(0, 2, VertexAttribPointerType.Float, false, 4 * sizeof(float), (void *)0);
            Gl.VertexAttribPointer(1, 2, VertexAttribPointerType.Float, false, 4 * sizeof(float), (void *)(2 * sizeof(float)));
            Gl.EnableVertexAttribArray(0);
            Gl.EnableVertexAttribArray(1);

            Gl.BindVertexArray(0);

            Gl.Enable(EnableCap.DepthTest);
            Gl.Enable(EnableCap.StencilTest);
            Gl.Enable(EnableCap.CullFace);
            Gl.CullFace(CullFaceMode.Back);

            fbo = Gl.GenFramebuffer();
            Gl.BindFramebuffer(FramebufferTarget.Framebuffer, fbo);

            screenTexture = Gl.GenTexture();
            Gl.BindTexture(TextureTarget.Texture2D, screenTexture);
            Gl.TexImage2D(TextureTarget.Texture2D, 0, (int)InternalFormat.Rgb, 800, 600, 0, PixelFormat.Rgb, PixelType.UnsignedByte, null);
            Gl.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear);
            Gl.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);
            Gl.BindTexture(TextureTarget.Texture2D, 0);

            Gl.FramebufferTexture2D(FramebufferTarget.Framebuffer, FramebufferAttachment.ColorAttachment0, TextureTarget.Texture2D, screenTexture, 0);

            rbo = Gl.GenRenderbuffer();
            Gl.BindRenderbuffer(RenderbufferTarget.Renderbuffer, rbo);
            Gl.RenderbufferStorage(RenderbufferTarget.Renderbuffer, InternalFormat.Depth24Stencil8, 800, 600);
            Gl.BindRenderbuffer(RenderbufferTarget.Renderbuffer, 0);

            Gl.FramebufferRenderbuffer(GLEnum.Framebuffer, GLEnum.DepthStencilAttachment, GLEnum.Renderbuffer, rbo);


            fboShadow = Gl.GenFramebuffer();
            Gl.BindFramebuffer(FramebufferTarget.Framebuffer, fboShadow);

            shadowMap = Gl.GenTexture();
            Gl.BindTexture(TextureTarget.Texture2D, shadowMap);
            Gl.TexImage2D(TextureTarget.Texture2D, 0, (int)InternalFormat.DepthComponent,
                          shadowMapSize, shadowMapSize, 0, PixelFormat.DepthComponent, PixelType.Float, null);
            Gl.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Nearest);
            Gl.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Nearest);
            Gl.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)TextureWrapMode.ClampToBorder);
            Gl.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)TextureWrapMode.ClampToBorder);
            float[] borderColor = new float[] { 1, 1, 1, 1 };

            fixed(float *i = &borderColor[0])
            Gl.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureBorderColor, i);

            shadowCube = Gl.GenTexture();
            Gl.BindTexture(TextureTarget.TextureCubeMap, shadowCube);
            for (int i = 0; i < 6; i++)
            {
                Gl.TexImage2D(TextureTarget.TextureCubeMapPositiveX + i, 0, (int)InternalFormat.DepthComponent,
                              shadowMapSize, shadowMapSize, 0, PixelFormat.DepthComponent, PixelType.Float, null);
            }
            Gl.TexParameter(TextureTarget.TextureCubeMap, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Nearest);
            Gl.TexParameter(TextureTarget.TextureCubeMap, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Nearest);
            Gl.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)TextureWrapMode.ClampToEdge);
            Gl.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)TextureWrapMode.ClampToEdge);
            Gl.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapR, (int)TextureWrapMode.ClampToEdge);

            //Gl.FramebufferTexture2D(GLEnum.Framebuffer, GLEnum.DepthAttachment, GLEnum.Texture2D, shadowMap, 0);
            Gl.FramebufferTexture(GLEnum.Framebuffer, GLEnum.DepthAttachment, shadowCube, 0);
            Gl.DrawBuffer(DrawBufferMode.None);
            Gl.ReadBuffer(ReadBufferMode.None);
            Gl.BindFramebuffer(FramebufferTarget.Framebuffer, 0);
            Gl.BindTexture(TextureTarget.Texture2D, 0);
            Gl.BindTexture(TextureTarget.TextureCubeMap, 0);



            if (Gl.CheckFramebufferStatus(FramebufferTarget.Framebuffer) != GLEnum.FramebufferComplete)
            {
                Console.WriteLine("Oh boy, Framebuffer bad!");
            }
            Gl.BindFramebuffer(FramebufferTarget.Framebuffer, 0);

            Sun        = new DirectionalLight(new Vector3(0.65854764f, -0.5150382f, -0.54868096f), new Vector3(0.01f, 0.01f, 0.01f), new Vector3(0.976f, 0.717f, 0.423f), new Vector3(0.976f, 0.717f, 0.423f));
            FlashLight = new SpotLight(camera.Position, (float)Math.Cos(Util.ToRadians(1.5f)), (float)Math.Cos(Util.ToRadians(20f)));

            PointLights = new PointLight[lightPositions.Length];
            for (int i = 0; i < lightPositions.Length; i++)
            {
                PointLights[i] = new PointLight(lightPositions[i]);
            }

            vec3 lightPos = new vec3(PointLights[0].Position.X, PointLights[0].Position.Y, PointLights[0].Position.Z);

            shadowCubeLookMats[0] = mat4.LookAt(lightPos, lightPos + new vec3(1, 0, 0), new vec3(0, -1, 0));
            shadowCubeLookMats[1] = mat4.LookAt(lightPos, lightPos + new vec3(-1, 0, 0), new vec3(0, -1, 0));
            shadowCubeLookMats[2] = mat4.LookAt(lightPos, lightPos + new vec3(0, 1, 0), new vec3(0, 0, 1));
            shadowCubeLookMats[3] = mat4.LookAt(lightPos, lightPos + new vec3(0, -1, 0), new vec3(0, 0, -1));
            shadowCubeLookMats[4] = mat4.LookAt(lightPos, lightPos + new vec3(0, 0, 1), new vec3(0, -1, 0));
            shadowCubeLookMats[5] = mat4.LookAt(lightPos, lightPos + new vec3(0, 0, -1), new vec3(0, -1, 0));
        }
Ejemplo n.º 20
0
 public void Bind(BufferTargetARB target, uint bindingIndex) => GL.BindBufferRange(target, bindingIndex, Handle, GetCurrentOffset(), Size);
Ejemplo n.º 21
0
 public void BindBufferRange(int target, uint index, uint buffer, IntPtr offset, IntPtr size)
 {
     GL.BindBufferRange((BufferRangeTarget)target, index, buffer, offset, size);
 }
Ejemplo n.º 22
0
 /// <summary>
 /// Binds part of a buffer to the binding index utilized by the given transform feeedback varying.
 /// </summary>
 /// <remarks>
 /// If multiple parts of the same buffer are bound as transform feedback output targets they must not overlap.
 /// </remarks>
 /// <param name="transformOut">Specifies a transform feedback varying.</param>
 /// <param name="buffer">Specifies a buffer object to bind.</param>
 /// <param name="offset">Specifies the starting offset in bytes into the buffer object.</param>
 /// <param name="size">Specifies the amount of data in bytes that can be written to the buffer.</param>
 public void BindOutput <T>(TransformOut transformOut, Buffer <T> buffer, int offset, int size)
     where T : struct
 {
     AssertActive();
     GL.BindBufferRange(BufferRangeTarget.TransformFeedbackBuffer, transformOut.Index, buffer.Handle, (IntPtr)offset, (IntPtr)size);
 }
Ejemplo n.º 23
0
 public void BindStorageBuffer(uint binding, uint bufferId, IntPtr offset, IntPtr size)
 {
     GL.BindBufferRange(BufferRangeTarget.ShaderStorageBuffer, binding, bufferId, offset, size);
 }
Ejemplo n.º 24
0
 internal void BindToBlock(int program, int uniformBlockIndex, int dataSize, int uniformBindingIndex)
 {
     Bind();
     GL.BindBufferRange(BufferRangeTarget.UniformBuffer, uniformBindingIndex, BufferID, IntPtr.Zero, dataSize);
     GL.UniformBlockBinding(program, uniformBlockIndex, uniformBindingIndex);
 }