Exemplo n.º 1
0
        internal void SetGLData(ref MaterialData data, ref int texCount)
        {
            switch (data.GLType) //if texture
            {
            case ActiveUniformType.Sampler2D:
            {
                // that shit took up to 6% of render time !!

                //const string textureEnumText = "Texture";
                //((Texture)data.Data).Use((TextureUnit)Enum.Parse(typeof(TextureUnit), textureEnumText + texCount));

                (data.Data as Texture).Use((TextureUnit)(33984 + texCount));

                this.SetInt(data.Location, texCount);

                texCount++;
                break;
            }

            case ActiveUniformType.Double:
                this.SetDouble(data.Location, (double)data.Data);
                break;

            case ActiveUniformType.Float:
                this.SetFloat(data.Location, (float)data.Data);
                break;

            case ActiveUniformType.Int:
            {
                if (data.GetType() == typeof(int[]))
                {
                    this.SetIntArray(data.Location, (int[])data.Data);
                }

                else
                {
                    this.SetInt(data.Location, (int)data.Data);
                }
            }
            break;

            case ActiveUniformType.FloatVec4:
                this.SetVector4(data.Location, (Vector4)data.Data);
                break;

            case ActiveUniformType.FloatVec2:
                this.SetVector2(data.Location, (Vector2)data.Data);
                break;

            case ActiveUniformType.FloatVec3:
                this.SetVector3(data.Location, (Vector3)data.Data);
                break;

            case ActiveUniformType.FloatMat4:
                this.SetMatrix4(data.Location, (Matrix4)data.Data);
                break;
            }
        }