vpWindow(3)

πŸ’– vpWindow(3) πŸ’–

okay so bestie, welcome to the vpWindow page from the Library Functions Manual β€” this is the one where we multiply the projection matrix by a perspective or orthographic matrix. it's giving math but make it cute. let's go πŸ¦‹


✨ NAME ✨

vpWindow β€” multiply the projection matrix by a perspective or orthographic matrix πŸŽ€


🌸 SYNOPSIS 🌸

#include <volpack.h>

vpResult
vpWindow(vpc, type, left, right, bottom, top, near, far)
    vpContext *vpc;
    int type;
    double left, right;
    double bottom, top;
    double near, far;

🫢 ARGUMENTS 🫢

  • vpc β€” the VolPack context, and you get it from vpCreateContext. your whole little universe lives in here πŸ’œ
  • type β€” the projection type code. right now? it must be VP_PARALLEL. no cap, that's the only option.
  • left β€” the coordinate of the left vertical clipping plane.
  • right β€” the coordinate of the right vertical clipping plane.
  • bottom β€” the coordinate of the bottom horizontal clipping plane.
  • top β€” the coordinate of the top horizontal clipping plane.
  • near β€” the coordinate of the near depth clipping plane.
  • far β€” the coordinate of the far depth clipping plane.

πŸ‘‘ DESCRIPTION πŸ‘‘

vpWindow is here to multiply the current projection matrix by a perspective or orthographic projection matrix. iconic behavior honestly ✨

the new projection matrix is defined by the coordinates of six clipping planes, all in the eye coordinate system (peep vpCurrentMatrix(3) for that whole situation πŸ‘€). and the way this matrix works? it maps the points (left, bottom, near) and (right, top, near) to the lower left and upper right corners of the clipping window. periodt. πŸ’…

if you want an alternative means of specifying the projection matrix, go look at vpWindowPHIGS(3). choices, we love them πŸŽ€

real talk though: currently, only orthographic projections are supported. perspective projections will be added in a future release. so don't come for me about perspective yet, it's coming, we're manifesting it 🧚

the matrix for parallel projections is:

A   0   0   D
 0   B   0   E
 0   0   C   F
 0   0   0   1

and the pieces are:

A = 2 / (right - left)
B = 2 / (top - bottom)
C = 2 / (far - near)
D = (left + right) / (left - right)
E = (bottom + top) / (bottom - top)
F = (near + far) / (near - far)

so the matrix is multiplied into the projection matrix β€” and even if the projection matrix is not the current matrix. yes, that's on purpose, it's just how it is πŸ’€

by default, the matrix is post-multiplied (N = N*m where N is the current matrix and m is the argument to vpMultMatrix). if you'd rather pre-multiply, the VP_CONCAT_MODE option to vpSeti can be used to select pre-multiplication. your matrix, your rules πŸ’–

and the default window? it's a parallel projection with left = bottom = near = -0.5, and right = top = far = 0.5. so cozy. so centered. main character energy fr fr 🌈


⭐ STATE VARIABLES ⭐

the current matrix concatenation parameters can be retrieved with the following state variable codes (see vpGeti(3)):

  • VP_CONCAT_MODE

that's the whole list bestie, it's a short one 🫢


πŸ’€ ERRORS πŸ’€

the normal return value is VP_OK. the following error return values are possible:

  • VPERROR_BAD_VALUE β€” the clipping plane coordinates are invalid (left >= right, etc.). yeah. if your left is chillin' to the right of your right, we have a problem πŸ™ˆ
  • VPERROR_BAD_OPTION β€” the type argument is invalid.

πŸ”₯ SEE ALSO πŸ”₯

VolPack(3), vpCreateContext(3), vpCurrentMatrix(3), vpWindowPHIGS(3)


and that's the page!! πŸŽ€βœ¨ this little baddie comes to you from VolPack, and yes, she is still vpWindow(3) β€” slay, go multiply some matrices, ily πŸ’–πŸ¦‹πŸŒΈ

πŸ“¦ where this page comes from