Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void Draw(Matrix4 modelview, Matrix4 projection)
- {
- if (Position != _lastPosition || Rotation != _lastRotation || Scale != _lastScale)
- UpdateTransformMatrix();
- Mesh.Bind();
- Material.Bind();
- Shader shader = Material.Shader;
- shader.SetUniform("uMVPT", _transform * modelview * projection); //Premultiply the matrices so the shader doesn't have to do it for every single vertex
- shader.SetUniform("uTransform", _transform);
- shader.SetUniform("uModelView", modelview);
- shader.SetUniform("uProjection", projection);
- shader.SetUniform("uColor", Color);
- switch (BlendMode)
- {
- case BlendMode.Alpha:
- GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
- break;
- case BlendMode.Multiply:
- GL.BlendFunc(BlendingFactorSrc.Zero, BlendingFactorDest.SrcColor);
- break;
- }
- if (IgnoreZ) GL.Disable(EnableCap.DepthTest);
- GL.DrawArrays(BeginMode.Triangles, 0, Mesh.VertexCount);
- if (IgnoreZ) GL.Enable(EnableCap.DepthTest);
- Material.Unbind();
- Mesh.Unbind();
- }
Add Comment
Please, Sign In to add comment