Getting ready

The typical setup is needed for this example. The vertex position and normal should be provided in attributes zero and one, respectively, and you need to provide the appropriate parameters for your shading model. As usual, the standard matrices are defined as uniform variables and should be set within the OpenGL application. However, note that this time we also need the viewport matrix (the ViewportMatrix uniform variable) in order to transform into screen space. There are a few uniforms related to the mesh lines that need to be set:

  • Line.Width: This should be half the width of the mesh lines
  • Line.Color: This is the color of the mesh lines

Get OpenGL 4 Shading Language Cookbook - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.