Guest User

Untitled

a guest
Jan 22nd, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.34 KB | None | 0 0
  1.  
  2.         public void Draw(Matrix4 modelview, Matrix4 projection)
  3.         {
  4.             if (Position != _lastPosition || Rotation != _lastRotation || Scale != _lastScale)
  5.                 UpdateTransformMatrix();
  6.  
  7.             Mesh.Bind();
  8.             Material.Bind();
  9.  
  10.             Shader shader = Material.Shader;
  11.             shader.SetUniform("uMVPT", _transform * modelview * projection); //Premultiply the matrices so the shader doesn't have to do it for every single vertex
  12.  
  13.             shader.SetUniform("uTransform", _transform);
  14.             shader.SetUniform("uModelView", modelview);
  15.             shader.SetUniform("uProjection", projection);
  16.             shader.SetUniform("uColor", Color);
  17.  
  18.             switch (BlendMode)
  19.             {
  20.                 case BlendMode.Alpha:
  21.                     GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
  22.                     break;
  23.  
  24.                 case BlendMode.Multiply:
  25.                     GL.BlendFunc(BlendingFactorSrc.Zero, BlendingFactorDest.SrcColor);
  26.                     break;
  27.             }
  28.  
  29.             if (IgnoreZ) GL.Disable(EnableCap.DepthTest);
  30.  
  31.             GL.DrawArrays(BeginMode.Triangles, 0, Mesh.VertexCount);
  32.  
  33.             if (IgnoreZ) GL.Enable(EnableCap.DepthTest);
  34.  
  35.             Material.Unbind();
  36.             Mesh.Unbind();
  37.         }
Add Comment
Please, Sign In to add comment