Skip to content

Commit d509130

Browse files
Move window.flip outside of the on_draw handler.
on_draw event handlers should just do drawing. It is the calling code's responsibility to perform the buffer flipping.
1 parent 9884e9a commit d509130

File tree

13 files changed

+39
-39
lines changed

13 files changed

+39
-39
lines changed

examples/create_window/main.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,15 @@ def step( self, dt ):
6464
# as we patched it out of the idle loop
6565
self.window.dispatch_event( 'on_draw' )
6666

67+
# display the frame buffer
68+
self.window.flip()
69+
6770
def on_draw( self ):
6871
# clear our frame buffer and depth buffer
6972
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT )
7073

7174
# render the fps
7275
self.fps_display.draw()
73-
74-
# display the frame buffer
75-
self.window.flip()
7676

7777

7878
def main():

examples/fps_camera/main.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,9 @@ def step( self, dt ):
161161
# manually dispatch the on_draw event
162162
# as we patched it out of the idle loop
163163
self.window.dispatch_event( 'on_draw' )
164+
165+
# display the frame buffer
166+
self.window.flip()
164167

165168
def on_draw( self ):
166169
# render our scene
@@ -171,9 +174,6 @@ def on_draw( self ):
171174

172175
# render our help text
173176
self.help_label.draw()
174-
175-
# display the frame buffer
176-
self.window.flip()
177177

178178
def move_camera( self, dt ):
179179
# update the Camera

examples/low_level/main.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,15 +146,15 @@ def step( self, dt ):
146146
# as we patched it out of the idle loop
147147
self.window.dispatch_event( 'on_draw' )
148148

149+
# display the frame buffer
150+
self.window.flip()
151+
149152
def on_draw( self ):
150153
self.render()
151154

152155
# render the fps
153156
self.fps_display.draw()
154157

155-
# display the frame buffer
156-
self.window.flip()
157-
158158
def set_gl_state( self ):
159159
# enable z buffer
160160
glEnable( GL_DEPTH_TEST )

examples/mesh_md2/main.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,15 +201,15 @@ def step( self, dt ):
201201
# manually dispatch the on_draw event
202202
# as we patched it out of the idle loop
203203
self.window.dispatch_event( 'on_draw' )
204+
205+
# display the frame buffer
206+
self.window.flip()
204207

205208
def on_draw( self ):
206209
self.render()
207210

208211
# render the fps
209212
self.fps_display.draw()
210-
211-
# display the frame buffer
212-
self.window.flip()
213213

214214
def set_gl_state( self ):
215215
# enable z buffer

examples/mesh_obj/main.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,16 +130,16 @@ def step( self, dt ):
130130
# manually dispatch the on_draw event
131131
# as we patched it out of the idle loop
132132
self.window.dispatch_event( 'on_draw' )
133+
134+
# display the frame buffer
135+
self.window.flip()
133136

134137
def on_draw( self ):
135138
# render the scene
136139
self.render()
137140

138141
# render the fps
139142
self.fps_display.draw()
140-
141-
# display the frame buffer
142-
self.window.flip()
143143

144144
def initialise_mesh( self ):
145145
# load the obj mesh from the file

examples/multiple_viewports/main.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,16 +167,16 @@ def step( self, dt ):
167167
# as we patched it out of the idle loop
168168
self.window.dispatch_event( 'on_draw' )
169169

170+
# display the frame buffer
171+
self.window.flip()
172+
170173
def on_draw( self ):
171174
# render the scene
172175
self.render()
173176

174177
# render the fps
175178
self.fps_display.draw()
176179

177-
# display the frame buffer
178-
self.window.flip()
179-
180180
def set_gl_state( self ):
181181
# enable z buffer
182182
glEnable( GL_DEPTH_TEST )

examples/orthographic/main.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,16 +131,16 @@ def step( self, dt ):
131131
# as we patched it out of the idle loop
132132
self.window.dispatch_event( 'on_draw' )
133133

134+
# display the frame buffer
135+
self.window.flip()
136+
134137
def on_draw( self ):
135138
# render the scene
136139
self.render()
137140

138141
# render the fps
139142
self.fps_display.draw()
140143

141-
# display the frame buffer
142-
self.window.flip()
143-
144144
def set_gl_state( self ):
145145
# enable z buffer
146146
glEnable( GL_DEPTH_TEST )

examples/ray_casting/main.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,9 @@ def step( self, dt ):
226226
# manually dispatch the on_draw event
227227
# as we patched it out of the idle loop
228228
self.window.dispatch_event( 'on_draw' )
229+
230+
# display the frame buffer
231+
self.window.flip()
229232

230233
def on_draw( self ):
231234
# render the scene
@@ -236,9 +239,6 @@ def on_draw( self ):
236239

237240
# render our help text
238241
self.help_label.draw()
239-
240-
# display the frame buffer
241-
self.window.flip()
242242

243243
def set_gl_state( self ):
244244
# enable z buffer

examples/render_callbacks/main.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,15 +153,15 @@ def step( self, dt ):
153153
# as we patched it out of the idle loop
154154
self.window.dispatch_event( 'on_draw' )
155155

156+
# display the frame buffer
157+
self.window.flip()
158+
156159
def on_draw( self ):
157160
self.render()
158161

159162
# render the fps
160163
self.fps_display.draw()
161164

162-
# display the frame buffer
163-
self.window.flip()
164-
165165
def render( self ):
166166
#
167167
# setup

examples/render_methods/main.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,9 @@ def step( self, dt ):
218218
# manually dispatch the on_draw event
219219
# as we patched it out of the idle loop
220220
self.window.dispatch_event( 'on_draw' )
221+
222+
# display the frame buffer
223+
self.window.flip()
221224

222225
def on_draw( self ):
223226
# render the scene
@@ -231,9 +234,6 @@ def on_draw( self ):
231234

232235
# render our status text
233236
self.status_label.draw()
234-
235-
# display the frame buffer
236-
self.window.flip()
237237

238238
def on_key_event( self, digital, event, key ):
239239
if event == Keyboard.up:

examples/scene_graph/main.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,15 +132,15 @@ def step( self, dt ):
132132
# as we patched it out of the idle loop
133133
self.window.dispatch_event( 'on_draw' )
134134

135+
# display the frame buffer
136+
self.window.flip()
137+
135138
def on_draw( self ):
136139
self.render()
137140

138141
# render the fps
139142
self.fps_display.draw()
140143

141-
# display the frame buffer
142-
self.window.flip()
143-
144144
def set_gl_state( self ):
145145
# enable z buffer
146146
glEnable( GL_DEPTH_TEST )

examples/six_dof_camera/main.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,9 @@ def step( self, dt ):
224224
# manually dispatch the on_draw event
225225
# as we patched it out of the idle loop
226226
self.window.dispatch_event( 'on_draw' )
227+
228+
# display the frame buffer
229+
self.window.flip()
227230

228231
def on_draw( self ):
229232
# render the scene
@@ -234,9 +237,6 @@ def on_draw( self ):
234237

235238
# render the fps
236239
self.fps_display.draw()
237-
238-
# display the frame buffer
239-
self.window.flip()
240240

241241
def render( self ):
242242
#

examples/sorting/main.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,9 @@ def step( self, dt ):
234234
# manually dispatch the on_draw event
235235
# as we patched it out of the idle loop
236236
self.window.dispatch_event( 'on_draw' )
237+
238+
# display the frame buffer
239+
self.window.flip()
237240

238241
def on_draw( self ):
239242
# render the scene
@@ -249,9 +252,6 @@ def on_draw( self ):
249252
self.setup_status_text()
250253
# render it
251254
self.status_label.draw()
252-
253-
# display the frame buffer
254-
self.window.flip()
255255

256256
def on_key_event( self, digital, event, key ):
257257
if event == Keyboard.up:

0 commit comments

Comments
 (0)