Esempio n. 1
0
        private void LoadShader(ref uint shader, ShaderType type, string path)
        {
            shader = gl.CreateShader(type);
            gl.ShaderSource(shader, File.ReadAllText(Util.AbsolutePath(path)));
            gl.CompileShader(shader);

            string log = gl.GetShaderInfoLog(shader);

            if (!string.IsNullOrWhiteSpace(log))
            {
                Console.WriteLine($"Shader compile error when compiling shader at {path} of type {type}: {log}");
            }
        }
Esempio n. 2
0
        private void loadCollisionModel(string path, MeshLoader loader)
        {
            var assimp = new ai.AssimpContext();

            ai.Scene scene = assimp.ImportFile(Util.AbsolutePath(path), ai.PostProcessSteps.DropNormals);

            if (scene == null || scene.RootNode == null || scene.SceneFlags.HasFlag(ai.SceneFlags.Incomplete))
            {
                Console.WriteLine($"Assimp error when importing file \'{path}\'");
                return;
            }

            directory = path.Substring(0, path.LastIndexOf("/") + 1);
            Meshes    = new List <Mesh <Vertex> >();

            proccessNode(scene.RootNode, scene, loader);
        }
Esempio n. 3
0
        private unsafe void LoadTexture(string path)
        {
            Image <Rgba32> img = (Image <Rgba32>)Image.Load(Util.AbsolutePath(path));

            img.Mutate(x => x.Flip(FlipMode.Vertical));

            Size = new GlmSharp.uvec2((uint)img.Width, (uint)img.Height);

            InternalFormat format = InternalFormat.Rgb;

            encodings.TryGetValue(TextureType, out format);

            fixed(void *i = &MemoryMarshal.GetReference(img.GetPixelRowSpan(0)))
            gl.TexImage2D(TextureTarget.Texture2D, 0, (int)format, (uint)img.Width, (uint)img.Height, 0, PixelFormat.Rgba, PixelType.UnsignedByte, i);

            img.Dispose();

            gl.GenerateMipmap(TextureTarget.Texture2D);
        }