예제 #1
0
        private void InitializeShaders()
        {
            WebGLProgram shaderProgram;

            using (var vertexShaderStream = EmbeddedResourceHelper.Load("GLTFVertexShader.essl"))
                using (var fragmentShaderStream = EmbeddedResourceHelper.Load("GLTFFragmentShader.essl"))
                    using (var vertexShaderReader = new StreamReader(vertexShaderStream))
                        using (var fragmentShaderReader = new StreamReader(fragmentShaderStream))
                        {
                            var vertexShader   = vertexShaderReader.ReadToEnd();
                            var fragmentShader = fragmentShaderReader.ReadToEnd();
                            shaderProgram = gl.InitializeShaders(vertexShader, fragmentShader);
                        }

            inVarNormalAttribute   = (uint)gl.GetAttribLocation(shaderProgram, "in_var_NORMAL");
            inVarPositionAttribute = (uint)gl.GetAttribLocation(shaderProgram, "in_var_POSITION");

            worldViewProjectionUniformLocation = gl.GetUniformLocation(shaderProgram, "worldViewProj");
        }
예제 #2
0
        private void LoadGltf(string filename, out Gltf model, out byte[][] buffers)
        {
            using (var modelStream = EmbeddedResourceHelper.Load(filename))
            {
                model = Interface.LoadModel(modelStream);
            }

            var buffersLength = model.Buffers.Length;

            buffers = new byte[buffersLength][];

            for (var i = 0; i < buffersLength; i++)
            {
                byte[] bufferBytes;

                using (var modelStream = EmbeddedResourceHelper.Load(filename))
                {
                    bufferBytes = Interface.LoadBinaryBuffer(modelStream);
                }

                buffers[i] = bufferBytes;
            }
        }