Skip to content

Commit aa4f469

Browse files
committed
use pop when you turn into 2d-mode
1 parent 7777529 commit aa4f469

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

lisp/opengl/src/glview.l

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -290,15 +290,23 @@
290290
(glEnable GL_LIGHTING)
291291
(glMatrixMode GL_MODELVIEW)
292292
(glLoadIdentity))
293-
(:2d-mode ()
293+
(:2d-mode (&key ((:push apush) nil))
294294
(glViewport 0 0 x::width x::height)
295295
(glMatrixMode GL_PROJECTION)
296+
(if apush (glPushMatrix))
296297
(glLoadIdentity)
297298
(glorthofv (float-vector 0 x::width 0 x::height -1.0 1.0))
298299
(glDisable GL_DEPTH_TEST)
299300
(glDisable GL_LIGHTING)
300301
(glMatrixMode GL_MODELVIEW)
302+
(if apush (glPushMatrix))
301303
(glLoadIdentity))
304+
(:pop-mode ()
305+
(glMatrixMode GL_PROJECTION)
306+
(glPopMatrix)
307+
(glMatrixMode GL_MODELVIEW)
308+
(glPopMatrix))
309+
302310
; (:clear (mask &key (color))
303311
; (if color
304312
; (glClearColorfv color))
@@ -331,18 +339,18 @@
331339

332340
(defmethod glviewsurface
333341
(:point (x y)
334-
(send self :2d-mode)
342+
(send self :2d-mode :push t)
335343
(glBegin GL_POINTS)
336344
(glVertex2fv (float-vector x (- x::height y)))
337345
(glEnd)
338-
(send self :3d-mode))
346+
(send self :pop-mode))
339347
(:line (x1 y1 x2 y2)
340-
(send self :2d-mode)
348+
(send self :2d-mode :push t)
341349
(glBegin GL_LINES)
342350
(glvertex2fv (float-vector x1 (- x::height y1)))
343351
(glVertex2fv (float-vector x2 (- x::height y2)))
344352
(glEnd)
345-
(send self :3d-mode))
353+
(send self :pop-mode))
346354
(:3d-point (pos)
347355
(glDisable GL_DEPTH_TEST)
348356
(glDisable GL_LIGHTING)
@@ -365,14 +373,14 @@
365373
(draw-face f nil nil))
366374
faces))
367375
(:rectangle (x y w h)
368-
(send self :2d-mode)
376+
(send self :2d-mode :push t)
369377
(glBegin GL_POLYGON)
370378
(glVertex2fv (float-vector x y))
371379
(glVertex2fv (float-vector x (+ y h)))
372380
(glVertex2fv (float-vector (+ x w) (+ y h)))
373381
(glVertex2fv (float-vector (+ x w) y))
374382
(glEnd)
375-
(send self :3d-mode))
383+
(send self :pop-mode))
376384
)
377385

378386
(defun geo::default-viewsurface (&rest args)

0 commit comments

Comments
 (0)