Beispiel #1
0
 internal UniformInfo(string name, UniformType type, IntSize dimensions, int arraySize)
 {
     Name       = name;
     Type       = type;
     Dimensions = dimensions;
     ArraySize  = arraySize;
 }
Beispiel #2
0
        /// <summary>
        /// Method for setting a integer uniform value
        /// </summary>
        /// <param name="uni">The uniform to be set</param>
        /// <param name="value">The value to be assigned to the uniform</param>
        internal void insertUniform(UniformType uni, int value)
        {
            int location = uniformLocations[(int)uni];

            if (location != -1)
            {
                GL.Uniform1(location, 1, ref value);
            }
        }
 internal UniformBlockMember(
     string name,
     UniformType type,
     int offsetInBytes)
 {
     _name = name;
     _type = type;
     _offsetInBytes = offsetInBytes;
 }
        public GLSLUniformVariable(GLSLShaderProgram program, UniformType uType, int size, string name)
        {
            fShaderProgram = program;
            fName = name;
            fUniformType = uType;
            fSize = size;
            fComponents = GetComponentCountForType(fUniformType);
            fLocation = program.GetUniformLocation(name);

            InitializeSpace();
        }
 internal UniformBlockMatrixMember(
     string name,
     UniformType type,
     int offsetInBytes,
     int strideInBytes,
     bool rowMajor)
     : base(name, type, offsetInBytes)
 {
     _strideInBytes = strideInBytes;
     _rowMajor = rowMajor;
 }
 internal UniformBlockArrayMember(
     string name,
     UniformType type,
     int offsetInBytes,
     int length,
     int elementStrideInBytes)
     : base(name, type, offsetInBytes)
 {
     _length = length;
     _elementStrideInBytes = elementStrideInBytes;
 }
Beispiel #7
0
        public void SetValue <T>(ref T val)
        {
            switch (val)
            {
            case bool boolVal:
                uniformType  = UniformType.Bool;
                data.boolVal = boolVal;
                break;

            case int intVal:
                uniformType = UniformType.Int;
                data.intVal = intVal;
                break;

            case float floatVal:
                uniformType   = UniformType.Float;
                data.floatVal = floatVal;
                break;

            case vec2 vec2Val:
                uniformType  = UniformType.Vec2;
                data.vec2Val = vec2Val;
                break;

            case vec3 vec3Val:
                uniformType  = UniformType.Vec3;
                data.vec3Val = vec3Val;
                break;

            case vec4 vec4Val:
                uniformType  = UniformType.Vec4;
                data.vec4Val = vec4Val;
                break;

            case Color colorVal:
                uniformType   = UniformType.Color;
                data.colorVal = colorVal;
                break;

            default:
                System.Diagnostics.Debug.Assert(false);
                break;
            }

            if (IsBinded)
            {
                WriteData();
            }
        }
 internal UniformBlockMatrixArrayMember(
     string name,
     UniformType type,
     int offsetInBytes,
     int length,
     int elementStrideInBytes,
     int matrixStrideInBytes,
     bool rowMajor)
     : base(name, type, offsetInBytes)
 {
     _length = length;
     _elementStrideInBytes = elementStrideInBytes;
     _matrixStrideInBytes = matrixStrideInBytes;
     _rowMajor = rowMajor;
 }
Beispiel #9
0
 protected Uniform(string name, UniformType type)
 {
     _name = name;
     _type = type;
 }
Beispiel #10
0
 public static extern ushort bgfx_create_uniform([MarshalAs(UnmanagedType.LPStr)] string name, UniformType type, ushort arraySize);
 static string ToString(UniformType t)
 {
     switch (t)
     {
         case UniformType.@bool:
         case UniformType.@double:
         case UniformType.Vector2d:
         case UniformType.@float:
         case UniformType.@int:
         case UniformType.@uint:
             return t.ToString();
         case UniformType.Vector3d:
         case UniformType.Vector4d:
         case UniformType.Matrix2:
         case UniformType.Matrix2x3:
         case UniformType.Matrix2x4:
         case UniformType.Matrix3:
         case UniformType.Matrix3x2:
         case UniformType.Matrix3x4:
         case UniformType.Matrix4:
         case UniformType.Matrix4x2:
         case UniformType.Matrix4x3:
         case UniformType.Vector2:
         case UniformType.Vector3:
         case UniformType.Vector4:
             return "global::OpenTK." + t.ToString();
         case UniformType.Texture:
             return "global::ShaderRuntime.Texture";
         default:
             return "";
     }
 }
        public static void GetActiveUniform(uint Program, uint index, out int size, out UniformType UniformType, out string Name, int MaxUniformNameLength = 64)
        {
            //if (MaxAttributeNameLength > 0)
            {
                var sb = new StringBuilder(MaxUniformNameLength + 4);

                Delegates.glGetActiveUniform(Program, index, sb.Capacity - 2, out MaxUniformNameLength, out size, out UniformType, sb);

                Name = sb.ToString();
            }
        }
 public static void GetActiveUniform(uint Program, uint index, out int size, out UniformType UniformType, out string Name)
 {
     var maxlen = GetProgramiv(Program, GetProgramParameters.ActiveUniformMaxLength);
     GetActiveUniform(Program, index, out size, out UniformType, out Name, maxlen);
 }
 public static void GetActiveUniform(uint Program, uint index, int bufSize, out int length, out int size, out UniformType UniformType, StringBuilder Name)
 {
     Delegates.glGetActiveUniform(Program, index, bufSize, out length, out size, out UniformType, Name);
 }
 private static bool IsMatrix(UniformType type)
 {
     return
         (type == UniformType.FloatMatrix22) ||
         (type == UniformType.FloatMatrix33) ||
         (type == UniformType.FloatMatrix44) ||
         (type == UniformType.FloatMatrix23) ||
         (type == UniformType.FloatMatrix24) ||
         (type == UniformType.FloatMatrix32) ||
         (type == UniformType.FloatMatrix34) ||
         (type == UniformType.FloatMatrix42) ||
         (type == UniformType.FloatMatrix43);
 }
 private static UniformBlockMember CreateUniformBlockMember(
     string name,
     UniformType type,
     int offsetInBytes,
     int length,
     int arrayStrideInBytes,
     int matrixStrideInBytes,
     int rowMajor)
 {
     if (length == 1)
     {
         if (!IsMatrix(type))
         {
             //
             // Non array, non matrix member
             //
             return new UniformBlockMember(name, type, offsetInBytes);
         }
         else
         {
             //
             // Non array, matrix member
             //
             return new UniformBlockMatrixMember(name, type, offsetInBytes,
                 matrixStrideInBytes, Convert.ToBoolean(rowMajor));
         }
     }
     else
     {
         if (!IsMatrix(type))
         {
             //
             // Array, non matrix member
             //
             return new UniformBlockArrayMember(name, type, offsetInBytes,
                 length, arrayStrideInBytes);
         }
         else
         {
             //
             // Array, matrix member
             //
             return new UniformBlockMatrixArrayMember(name, type, offsetInBytes,
                 length, arrayStrideInBytes, matrixStrideInBytes, Convert.ToBoolean(rowMajor));
         }
     }
 }
Beispiel #17
0
 internal ShaderUniform(int location, UniformType type)
 {
     this.location = location;
     this.type = type;
 }
Beispiel #18
0
 internal ShaderSampler(int location, TextureUnit unit, UniformType type)
 {
     this.location = location;
     this.unit = unit;
     this.type = type;
 }
        public static int GetComponentCountForType(UniformType aType)
        {
            int retValue = 0;

            switch (aType)
            {
                case UniformType.Float:
                case UniformType.Int:
                case UniformType.Bool:
                case UniformType.Sampler1D:
                case UniformType.Sampler2D:
                case UniformType.Sampler3D:
                case UniformType.SamplerCube:
                case UniformType.Sampler1DShadow:
                case UniformType.Sampler2DShadow:
                    retValue = 1;
                    break;

                case UniformType.FloatVec2:
                case UniformType.IntVec2:
                case UniformType.BoolVec2:
                    retValue = 2;
                    break;

                case UniformType.FloatVec3:
                case UniformType.IntVec3:
                case UniformType.BoolVec3:
                    retValue = 3;
                    break;

                case UniformType.FloatVec4:
                case UniformType.IntVec4:
                case UniformType.BoolVec4:
                    retValue = 4;
                    break;

                case UniformType.FloatMat2:
                    retValue = 4;
                    break;

                case UniformType.FloatMat3:
                    retValue = 9;
                    break;

                case UniformType.FloatMat4:
                    retValue = 16;
                    break;
            }

            return retValue;
        }