I'm still fairly new to the graphics field and was curious how to deal with NDCs vs pixel units in Kha. I know that say -1, 1 will be a different pixel value on different displays and thus possibly a different aspect ratio too. Lets say I wanted to make a square across all platforms (i.e. [-0.5, -0.5], [0.5, 0.5], [-0.5, 0.5], [0.5, -0.5]) in Kha, how would I make sure it doesn't get stretched on landscape views? In GL I've read you use and ortho matrix which Kha has in FastMatrix4x4, but is that it?
-
Normalized Device Coordinates vs Pixel Units
Ok, now if I wanted to work with pixels as units (i.e. for mouse clicks) is there a way to set the glViewport in Kha?
| last edited by primesoftware Reputation: 2 | Posts: 8 -
Normalized Device Coordinates vs Pixel Units
You can of course set the viewport (via the viewport function) but the viewport is already set up for that by default. Setting an orthogonal projection is all there is to it. You can also have a look at how Kha itself implements 2D graphics on top of 3D APIs: https://github.com/Kode/Kha/blob/master/Sources/kha/graphics4/Graphics2.hx