My question : does glViewPort is being called at some part of the rendering process or it doesn't being called unless the window has been resized ? and if so (if it doesn't being called unless window has been resized) how does my NDCs will be transformed to WCs ? or they won't unless i resize (and I dont think they wont because in my fragment shader i use a lerp value with 500 which is my window height so if it wasnt being transformed in somepoint to WCs that would make something look like it doesn't right but it's right since the output is as suppose to be)?

My question : does glViewPort is being called at some part of the rendering process or it doesn't being called unless the window has been resized ?

When a context is first attached to a window, the viewport will be set to the dimensions of the window, i.e. the equivalent of glViewport(0,0,width,height). So it's only necessary to call glViewport() when the window size changes or if you want to set the viewport to something other than the entire window.

When a context is first attached to a window, the viewport will be set to the dimensions of the window, i.e. the equivalent of glViewport(0,0,width,height). So it's only necessary to call glViewport() when the window size changes or if you want to set the viewport to something other than the entire window.

ok so its called after the context has been created
but in my vertex shader i transform my coords to clip coords (even tho they already are if u look they have the 4th componet) and i dont need to transform them to ndcs because they already have the same w so in what part of the rendering proccess the ndcs will translate to wcs ?

but in my vertex shader i transform my coords to clip coords (even tho they already are if u look they have the 4th componet) and i dont need to transform them to ndcs because they already have the same w so in what part of the rendering proccess the ndcs will translate to wcs ?

This occurs in the "Vertex Post-Processing" stage, after the vertex/tessellation/geometry shaders and before the fragment shader.

This occurs in the "Vertex Post-Processing" stage, after the vertex/tessellation/geometry shaders and before the fragment shader.

so after the vertices transformed to clip vertices they're being transformed (we're assuming they ndcs already) to wc ?
and how is it done exacly ? the shader call some glViewPort to sort this out ? (also glViewport transform points from ndcs to wcs / from wcs to new wcs beside changing the area we can render on right?)

so after the vertices transformed to clip vertices they're being transformed (we're assuming they ndcs already) to wc ?
and how is it done exacly ? the shader call some glViewPort to sort this out ? (also glViewport transform points from ndcs to wcs / from wcs to new wcs beside changing the area we can render on right?)

The values written to gl_Position are in clip coordinates. Clipping, conversion to NDC, conversion to window coordinates and interpolation of attributes all happen automatically.

glViewport() defines the transformation from NDC to window coordinates. It doesn't directly affect the area which can be rendered to. Geometry won't extend outside the viewport, because it's clipped to the unit cube (in NDC), which is mapped to the viewport., but the set of fragments which are rendered for e.g. wide lines and points can extend outside of the viewport. If you need to restrict rendering to a 2D rectangle, use glScissor().