# How much is 1 distance unit.

Hello, I’m learning OpenGL here: https://learnopengl.com/Introduction
I’m trying to write light 3D library. Similar to SFML, but with one more Dimension.

I wanted to change those OpenGL’ unity (normalized) to pixels.
https://pastebin.com/riBk6ZKy
This is how I’m setting vertices. I’m wondering, depending on my Projection, how much is one Unit?
My viewport is 0, 0, 1280, 720.
FOV is 45 degree.

You’re using a Perspective Projection (illustration). So your object or world space distances are going to vary based on their depth into the scene.

What are you trying to do in pixel units? That would help give you the best answer to your question.

For instance, if you want to know where a vertex in your shader is transforming to in terms of pixels, take your clip-space position (gl_Position in your vertex shader), and if its within the view frustum (**) do the perspective divide (.xyz / .w) to get an NDC-space point (X,Y,Z are in [-1,1]). You can then scale and shift X and Y from [-1,1] into your [0,1280] and [0,720] range to get pixels.

** To test if the point is within the view frustum, just make sure this is true: -|w| <= x,y,z <= |w|