Is there a difference between window and screen in computer graphics? I've been reading some code which setups a ray tracer and I've realized I've a doubt regarding what's a screen and what's a window in this context. Here's the relevant code using Qt:

...

void CCanvas::paint()
{
  // check if we have something to draw on
  if (!image) return;

  // camera position
  Point3d camera (0.0, 0.0, 0.0);

  // screen resolution
  int w = image-&gt;width();
  int h = image-&gt;height();



  // horizontal opening angle
  double alpha = PI/2.0;

  // horizontal window dimension [-X,X]
  double X = tan(alpha/2.0);

  // pixel size
  double s = 2.0 * X / (double)w;

  // vertical window dimension [-Y,Y]
  double Y = s * h / 2.0;
  ...


I think I know what's the screen resolution: if we think of the screen as a matrix, w and h would be respectively the number of columns and rows in this "matrix".

After obtaining the resolution of the image, we define an opening angle $\alpha$. I interpreted this opening angle as the opening angle of the camera, i.e., it defines basically what's visible from the camera.

Then we compute X, which is half of the horizontal window (according to the comments in the code). (Note this X is not the same X representing the x axis in the picture below. Yes, whoever wrote this code had no common sense!) 



Now, mathematically I understood these calculations, what I don't understand is the difference between $2X$ and $w$. 

Is the "window" here the same thing as "screen"? 



I've this picture here



I've added the $X=\tan \left( \frac{\alpha}{2}\right)$ to the picture according to what I think $X$ is from the code above.



If the window is the same thing as the screen, I wonder why do we need $w$. I mean, couldn't we just decide how many rows and columns we have in the visible area?  

Again, it's not clear if the visible area of the camera is the same thing as the screen or window...
In this code, the "screen resolution" means the number of pixels in the output image (which happens to be a window in the windowing system), while the "window dimension" means the corresponding size in the 3D scene. Computing s tells you the ratio between one unit of 3D space in your scene and one pixel of output image. You need to do this in order to know how far apart in world-space to cast your primary rays.

These uses of "screen" and "window" aren't standard; they're specific to this code. No wonder you're confused.