public Mesh(MeshData data) { Camera3D.CameraChanged += UpdateShaderMatrix; children = new LinkedList<Mesh>(); Data = data; vertexShader = new VertexShader(); vertexShader.LoadFromSource(vertexShaderSource); fragmentShader = new FragmentShader(); fragmentShader.LoadFromSource(fragmentShaderSource); shaderProgram = new ShaderProgram(vertexShader, fragmentShader); shaderProgram.Link(); shaderProgram.Use(); shaderProgram.AddAttribLocation("position"); shaderProgram.AddAttribLocation("color"); shaderProgram.AddAttribLocation("normal"); shaderProgram.AddUniformLocation("matrix"); shaderProgram.AddUniformLocation("rotation"); rotation = Matrix4.Identity; scale = Matrix4.Identity; translation = Matrix4.Identity; projection = Matrix4.CreatePerspectiveFieldOfView((float)Math.PI / 2.5F, 1, 0.1F, 100F); shaderModelMatrix = Matrix4.Identity; shaderRotationMatrix = Matrix4.Identity; window = Matrix4.Scale(Firefly.Window.Height / (float)Firefly.Window.Width, 1, 1); UpdateShaderMatrix(); }
public override void Render() { if (!visible) { return; } base.Render(); program.Use(); }