コード例 #1
0
        public void ReadFileHeader()
        {
            int signature = ReadInt32();

            if (signature != FourCC.Make("rgxa"))
            {
                Console.WriteLine("Error: unknown file format!");
                throw new InvalidDataException();
            }

            numShaders = ReadByte();

            location = Location.VertexShaders;
        }
コード例 #2
0
        private byte[] GetConstantTableData()
        {
            int ctabToken   = FourCC.Make("CTAB");
            var ctabComment = Instructions.FirstOrDefault(x => x.Opcode == Opcode.Comment && x.Params[0] == ctabToken);

            if (ctabComment == null)
            {
                return(null);
            }

            byte[] constantTable = new byte[ctabComment.Params.Length * 4];
            for (int i = 1; i < ctabComment.Params.Length; i++)
            {
                constantTable[i * 4 - 4] = (byte)(ctabComment.Params[i] & 0xFF);
                constantTable[i * 4 - 3] = (byte)((ctabComment.Params[i] >> 8) & 0xFF);
                constantTable[i * 4 - 2] = (byte)((ctabComment.Params[i] >> 16) & 0xFF);
                constantTable[i * 4 - 1] = (byte)((ctabComment.Params[i] >> 24) & 0xFF);
            }

            return(constantTable);
        }