Exemple #1
0
        public override void Render(PerspectiveCamera cam)
        {
            GL.BindVertexArray(_gfx);

            int c = 0;

            // Loop through all avalable Textures
            // Tell the Shader Use Each Texture in its respective spot
            foreach (var tex in this._textures)
            {
                if (c == 1)
                {
                    tex.Value.Use(TextureUnit.Texture1);
                }
                else
                {
                    tex.Value.Use();
                }

                c++;
            }

            // Apply the Default Shader
            _default.Use();

            // Apply Global View Matrix
            _default.SetMatrix4("model", Matrix4.CreateTranslation(this.Transform.GetPosition()));
            _default.SetMatrix4("view", cam.GetViewMatrix());
            _default.SetMatrix4("projection", cam.GetProjectionMatrix());

            // Update View Matrix
            _default.SetVector3("viewPosition", cam.Position);

            _default.SetInt("material.diffuse", 0);
            _default.SetInt("material.specular", 1);
            _default.SetFloat("material.shine", 32.0f);

            _default.SetVector3("light.direction", _light_dir);
            _default.SetVector3("light.ambient", new Vector3(0.2f));
            _default.SetVector3("light.diffuse", new Vector3(0.5f));
            _default.SetVector3("light.specular", new Vector3(1.0f));


            GL.DrawArrays(PrimitiveType.Triangles, 0, 36);
            GL.BindVertexArray(_gfx);

            base.Render(cam);
        }