Skip to content

Commit

Permalink
Merge pull request #71 from pwaller/issue-65
Browse files Browse the repository at this point in the history
Fix #65 (gl21-cube appears squished)
  • Loading branch information
pwaller committed Nov 29, 2019
2 parents 3acfc45 + 22c41eb commit c307114
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions gl21-cube/cube.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ var (
rotationY float32
)

const width, height = 800, 600

func init() {
// GLFW event handling must run on the main OS thread
runtime.LockOSThread()
Expand All @@ -38,7 +40,7 @@ func main() {
glfw.WindowHint(glfw.Resizable, glfw.False)
glfw.WindowHint(glfw.ContextVersionMajor, 2)
glfw.WindowHint(glfw.ContextVersionMinor, 1)
window, err := glfw.CreateWindow(800, 600, "Cube", nil, nil)
window, err := glfw.CreateWindow(width, height, "Cube", nil, nil)
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -115,7 +117,8 @@ func setupScene() {

gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity()
gl.Frustum(-1, 1, -1, 1, 1.0, 10.0)
f := ((float64(width) / height) - 1) / 2
gl.Frustum(-1-f, 1+f, -1, 1, 1.0, 10.0)
gl.MatrixMode(gl.MODELVIEW)
gl.LoadIdentity()
}
Expand Down

0 comments on commit c307114

Please sign in to comment.