示例#1
0
        private void SubBind(GPUModel data)
        {
            for (int i = 0; i < data.ibo.Length; i++)
            {
                int isTextured = 0;

                if (data.tid[i] != string.Empty)
                {
                    int texIdx;
                    bool texPresent = _texLookup.TryGetValue(data.tid[i], out texIdx);

                    if (texPresent)
                    {
                        isTextured = 1;
                        FullTexBind(texIdx);
                    }
                }

                // set shader vars
                _shaderProg.SetUniform("diffuseColor", data.color[i]);
                _shaderProg.SetUniform("isTextured", isTextured);

                // bind model
                GL.BindBuffer(BufferTarget.ArrayBuffer, data.vbo);
                GL.BindBuffer(BufferTarget.ElementArrayBuffer, data.ibo[i]);
                GL.DrawElements(data.strip ? BeginMode.TriangleStrip : BeginMode.Triangles, data.ic[i], DrawElementsType.UnsignedInt, 0);
            }
        }
示例#2
0
        private void FullBind(GPUModel data) // for optimization
        {
            if (data.vbo == 0)
                return;

            if (_currentGPUModelID != data.vbo)
            {
                EndBind();  // incase the previous was a SubBind
                BeginBind(data);
                SubBind(data);
                _currentGPUModelID = data.vbo;
            }
            else
            {
                SubBind(data);
            }
        }
示例#3
0
 private void BeginBind(GPUModel data)
 {
     GL.BindBuffer(BufferTarget.ArrayBuffer, data.vbo);
     GL.EnableVertexAttribArray(0);
     GL.EnableVertexAttribArray(1);
     GL.EnableVertexAttribArray(2);
     GL.EnableVertexAttribArray(3);
     GL.VertexAttribPointer(0, 3, VertexAttribPointerType.Float, false, sizeof(float) * 12, 0);
     GL.VertexAttribPointer(1, 3, VertexAttribPointerType.Float, false, sizeof(float) * 12, sizeof(float) * 3);
     GL.VertexAttribPointer(2, 2, VertexAttribPointerType.Float, false, sizeof(float) * 12, sizeof(float) * 6);
     GL.VertexAttribPointer(3, 4, VertexAttribPointerType.Float, false, sizeof(float) * 12, sizeof(float) * 8);
 }