Beispiel #1
0
        //-----------------------------------------------------------------------------------------
        private bool _InitProgram()
        {
            int vertexShader = Shader.Load(Program.BasePath + @"Source\Listing_07L04_07L06\grass.vs.glsl",
                                           ShaderType.VertexShader);
            int fragmentShader = Shader.Load(Program.BasePath + @"Source\Listing_07L04_07L06\grass.fs.glsl",
                                             ShaderType.FragmentShader);

            _shaderProgram = Shader.Link(new int[] { vertexShader, fragmentShader }, 2);

            _vao = GL.GenVertexArray();
            GL.BindVertexArray(_vao);

            _mvpMatrixUniformLoc = GL.GetUniformLocation(_shaderProgram, "mvpMatrix");

            GL.ActiveTexture(TextureUnit.Texture1);
            KTX.Load(Program.BasePath + @"Media\Textures\grass_length.ktx", ref _textures.grassLength);

            GL.ActiveTexture(TextureUnit.Texture2);
            KTX.Load(Program.BasePath + @"Media\Textures\grass_orientation.ktx", ref _textures.grassOrientation);

            GL.ActiveTexture(TextureUnit.Texture3);
            KTX.Load(Program.BasePath + @"Media\Textures\grass_color.ktx", ref _textures.grassColor);

            GL.ActiveTexture(TextureUnit.Texture4);
            KTX.Load(Program.BasePath + @"Media\Textures\grass_bend.ktx", ref _textures.grassBend);

            return(true);
        }
Beispiel #2
0
        public IEnumerable <Color> Load(byte[] tex)
        {
            if (Width < 0 || Height < 0)
            {
                throw new InvalidDataException("Height and Width has to be set for ASTC.");
            }

            CreateTempASTCFile("tmp.astc", tex);

            var wrapper = new ASTCContext();

            wrapper.Decode("tmp.astc", "tmp.ktx", _blockMode);
            File.Delete("tmp.astc");

            var ktx    = new KTX("tmp.ktx");
            var colors = ktx.GetImageColors().Reverse().ToList();

            ktx.Dispose();
            File.Delete("tmp.ktx");

            return(colors);
        }