Exemplo n.º 1
0
        void InternalBind(bool bindOnly)
        {
            lock (vaoLock)
            {
                if (ActiveVAO != this)
                {
                    state.Gl.BindVertexArray(index);
                    program.Use();
                }

                if (!bindOnly)
                {
                    bool buffersChanged = false;

                    // ensure that all buffers are up to date
                    foreach (var buffer in positionBuffers)
                    {
                        if (buffer.Value.RecreateUnbound())
                        {
                            buffersChanged = true;
                        }
                    }

                    foreach (var buffer in vectorBuffers)
                    {
                        if (buffer.Value.RecreateUnbound())
                        {
                            buffersChanged = true;
                        }
                    }

                    foreach (var buffer in wordBuffers)
                    {
                        if (buffer.Value.RecreateUnbound())
                        {
                            buffersChanged = true;
                        }
                    }

                    foreach (var buffer in colorBuffers)
                    {
                        if (buffer.Value.RecreateUnbound())
                        {
                            buffersChanged = true;
                        }
                    }

                    foreach (var buffer in byteBuffers)
                    {
                        if (buffer.Value.RecreateUnbound())
                        {
                            buffersChanged = true;
                        }
                    }

                    foreach (var buffer in floatBuffers)
                    {
                        if (buffer.Value.RecreateUnbound())
                        {
                            buffersChanged = true;
                        }
                    }

                    foreach (var buffer in indexBuffers)
                    {
                        if (buffer.Value.RecreateUnbound())
                        {
                            buffersChanged = true;
                        }
                    }

                    if (buffersChanged)
                    {
                        UnbindBuffers();
                        BindBuffers();
                    }
                }

                ActiveVAO = this;
            }
        }