diff --git a/pixelgl/orphan.go b/pixelgl/orphan.go
index b67f8fc2f9a7f584791becdfce998ec466c895d3..8e4f95aefea1a7045ed01d1afe9ce702ec457c35 100644
--- a/pixelgl/orphan.go
+++ b/pixelgl/orphan.go
@@ -11,3 +11,10 @@ func Clear(r, g, b, a float32) {
 		gl.Clear(gl.COLOR_BUFFER_BIT)
 	})
 }
+
+// SetViewport sets the OpenGL viewport.
+func SetViewport(x, y, w, h int32) {
+	DoNoBlock(func() {
+		gl.Viewport(x, y, w, h)
+	})
+}
diff --git a/window.go b/window.go
index eadc0dad7fbf5d4b1adbf819337a873db2bbab9d..a85fcaa2f871cee1c8fb427e5fe84a106179e950 100644
--- a/window.go
+++ b/window.go
@@ -142,6 +142,9 @@ func (w *Window) Update() {
 			w.window.SwapBuffers()
 			glfw.PollEvents()
 		})
+
+		w, h := w.window.GetSize()
+		pixelgl.SetViewport(0, 0, int32(w), int32(h))
 	})
 }