I'm using GLFW to create a little game. (and by little, I mean: small, nonprofit)
After a while of puzzling, I found out that this draws a texture (from an image, for instance) to the screen:
(the syntax is in Go, but the library is the same as the C/C++ version)
gl.BindTexture(gl.TEXTURE_2D, tex) gl.Color4f(1, 1, 1, 1) gl.Begin(gl.QUADS) gl.Normal3f(0, 0, 0) gl.TexCoord2f(1, 1) // top right gl.Vertex3f(1, -1, 0) gl.TexCoord2f(0, 1) // bottom right gl.Vertex3f(-1, -1, 0) // = location gl.TexCoord2f(0, 0) // bottom left gl.Vertex3f(-1, 1, 0) gl.TexCoord2f(1, 0) // top left gl.Vertex3f(1, 1, 0) gl.End() This draws the texture perfectly. There is just one downside: as my screen is 16:9, the texture also gets rendered/displayed as 16:9. But as this is a square image (32 by 32 pixels), how do I get it to draw just those pixels, instead of defining it relative to the screen ratio? (values between -1 and 1)
My first assumption was that I can compute what the values should be, by comparing it with the actual screen size, but this feels like it's not the way to go.
glViewportto set the viewport to be square. \$\endgroup\$