And, now in the fragment shader, i scale appropriately by the window size. Is this the right way to do it? Or is there a better way
to achieve the same?
To elaborate on Aleksandar’s suggestion: What you did is not obtain the window coordinates but the normalized device coordinates which are in [-1, 1] for x,y and z. Taking into accunt the current viewport, window coordinates can be computed using the formulae found here. Again, this is just for completeness. You can just as easily follow Aleksander’s advice.