Esempio n. 1
0
        public static Dictionary <string, BufferBinding> bindings()
        {
            if (theBindings == null)
            {
                theBindings             = new Dictionary <string, BufferBinding>();
                theBindings["position"] = new BufferBinding()
                {
                    bufferIndex = 0, dataType = BindingDataType.Float, dataFormat = (int)VertexAttribType.Float, normalize = false, numElements = 3, offset = 0
                };
                theBindings["color"] = new BufferBinding()
                {
                    bufferIndex = 0, dataType = BindingDataType.Float, dataFormat = (int)VertexAttribType.Float, normalize = true, numElements = 4, offset = 12
                };
                theBindings["size"] = new BufferBinding()
                {
                    bufferIndex = 0, dataType = BindingDataType.Float, dataFormat = (int)VertexAttribType.Float, normalize = false, numElements = 3, offset = 28
                };
                theBindings["rotation"] = new BufferBinding()
                {
                    bufferIndex = 0, dataType = BindingDataType.Float, dataFormat = (int)VertexAttribType.Float, normalize = false, numElements = 1, offset = 40
                };
            }

            return(theBindings);
        }
Esempio n. 2
0
        public static Dictionary <string, BufferBinding> bindings()
        {
            if (theBindings == null)
            {
                theBindings             = new Dictionary <string, BufferBinding>();
                theBindings["position"] = new BufferBinding()
                {
                    bufferIndex = 0, dataType = BindingDataType.Float, dataFormat = (int)VertexAttribType.Float, normalize = false, numElements = 3, offset = 0
                };
                theBindings["normal"] = new BufferBinding()
                {
                    bufferIndex = 0, dataType = BindingDataType.Float, dataFormat = (int)VertexAttribType.Float, normalize = false, numElements = 3, offset = 12
                };
                theBindings["uv"] = new BufferBinding()
                {
                    bufferIndex = 0, dataType = BindingDataType.Float, dataFormat = (int)VertexAttribType.Float, normalize = false, numElements = 2, offset = 24
                };
                theBindings["boneId"] = new BufferBinding()
                {
                    bufferIndex = 0, dataType = BindingDataType.Float, dataFormat = (int)VertexAttribType.Float, normalize = false, numElements = 4, offset = 32
                };
                theBindings["boneWeight"] = new BufferBinding()
                {
                    bufferIndex = 0, dataType = BindingDataType.Float, dataFormat = (int)VertexAttribType.Float, normalize = false, numElements = 4, offset = 48
                };
            }

            return(theBindings);
        }
Esempio n. 3
0
        public static Dictionary <string, BufferBinding> bindings()
        {
            if (theBindings == null)
            {
                theBindings       = new Dictionary <string, BufferBinding>();
                theBindings["uv"] = new BufferBinding()
                {
                    bufferIndex = 0, dataType = BindingDataType.Float, dataFormat = (int)VertexAttribType.Float, normalize = false, numElements = 2, offset = 0
                };
            }

            return(theBindings);
        }
Esempio n. 4
0
        public void bindVertexFormat(ShaderProgram sp, Dictionary <string, BufferBinding> bindings)
        {
            //make active
            bind();

            foreach (AttributeInfo attr in sp.vertexBindings.Values)
            {
                if (attr.id == -1)
                {
                    continue;
                }

                if (attr.name.StartsWith("gl_"))
                {
                    continue;
                }

                BufferBinding binding = null;
                if (bindings.TryGetValue(attr.name, out binding) == false)
                {
                    throw new Exception(String.Format("Failed to find bind point {0}", attr.name));
                }

                switch (binding.dataType)
                {
                case BindingDataType.Float:
                    GL.VertexAttribFormat(attr.id, binding.numElements, (VertexAttribType)binding.dataFormat, binding.normalize, binding.offset);
                    break;

                case BindingDataType.Integer:
                    GL.VertexAttribIFormat(attr.id, binding.numElements, (VertexAttribIntegerType)binding.dataFormat, binding.offset);
                    break;

                case BindingDataType.Double:
                    GL.VertexAttribLFormat(attr.id, binding.numElements, (VertexAttribDoubleType)binding.dataFormat, binding.offset);

                    break;
                }

                GL.VertexAttribBinding(attr.id, binding.bufferIndex);
                GL.EnableVertexAttribArray(attr.id);
            }

            //cleanup
            unbind();
        }