Skip to content

Commit 1aad0dd

Browse files
committed
Examples: Make resizable
1 parent 51f0a97 commit 1aad0dd

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

examples/boxes.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from pyglet.gl import *
2323
from pywavefront import visualization, Wavefront
2424

25-
window = pyglet.window.Window(width=1280, height=720)
25+
window = pyglet.window.Window(width=1280, height=720, resizable=True)
2626

2727
root_path = os.path.dirname(__file__)
2828

@@ -39,6 +39,9 @@
3939

4040
@window.event
4141
def on_resize(width, height):
42+
viewport_width, viewport_height = window.get_framebuffer_size()
43+
glViewport(0, 0, viewport_width, viewport_height)
44+
4245
glMatrixMode(GL_PROJECTION)
4346
glLoadIdentity()
4447
gluPerspective(45., float(width)/height, 1., 100.)

examples/globe_complex.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,16 @@
2929

3030
@window.event
3131
def on_resize(width, height):
32+
viewport_width, viewport_height = window.get_framebuffer_size()
33+
glViewport(0, 0, viewport_width, viewport_height)
34+
3235
glMatrixMode(GL_PROJECTION)
3336
glLoadIdentity()
3437
gluPerspective(40.0, float(width) / height, 1.0, 100.0)
3538
glEnable(GL_DEPTH_TEST)
3639
glMatrixMode(GL_MODELVIEW)
3740
return True
3841

39-
4042
@window.event
4143
def on_draw():
4244
window.clear()
@@ -68,7 +70,6 @@ def on_draw():
6870

6971
visualization.draw(meshes)
7072

71-
7273
def update(dt):
7374
global rotation
7475

examples/globe_simple.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,15 @@
1717

1818
rotation = 0
1919
meshes = pywavefront.Wavefront(file_abspath)
20-
window = pyglet.window.Window()
20+
window = pyglet.window.Window(resizable=True)
2121
lightfv = ctypes.c_float * 4
2222

2323

2424
@window.event
2525
def on_resize(width, height):
26+
viewport_width, viewport_height = window.get_framebuffer_size()
27+
glViewport(0, 0, viewport_width, viewport_height)
28+
2629
glMatrixMode(GL_PROJECTION)
2730
glLoadIdentity()
2831
gluPerspective(60., float(width)/height, 1., 100.)

0 commit comments

Comments
 (0)