コード例 #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)
                {
                    bool texPresent = mTexLookup.TryGetValue(data.Tid[i], out int texIdx);

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

                // set shader vars
                mShaderProg.SetUniform("diffuseColor", data.Color[i]);
                mShaderProg.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 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);
 }
コード例 #3
0
        private void FullBind(GpuModel data) // for optimization
        {
            if (data.Vbo == 0)
            {
                return;
            }

            if (mCurrentGpuModelId != data.Vbo)
            {
                EndBind();  // incase the previous was a SubBind
                BeginBind(data);
                SubBind(data);
                mCurrentGpuModelId = data.Vbo;
            }
            else
            {
                SubBind(data);
            }
        }