Skip to content

use pop when you turn into 2d-mode #119

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions lisp/opengl/src/glview.l
Original file line number Diff line number Diff line change
Expand Up @@ -290,15 +290,23 @@
(glEnable GL_LIGHTING)
(glMatrixMode GL_MODELVIEW)
(glLoadIdentity))
(:2d-mode ()
(:2d-mode (&key ((:push apush) nil))
(glViewport 0 0 x::width x::height)
(glMatrixMode GL_PROJECTION)
(if apush (glPushMatrix))
(glLoadIdentity)
(glorthofv (float-vector 0 x::width 0 x::height -1.0 1.0))
(glDisable GL_DEPTH_TEST)
(glDisable GL_LIGHTING)
(glMatrixMode GL_MODELVIEW)
(if apush (glPushMatrix))
(glLoadIdentity))
(:pop-mode ()
(glMatrixMode GL_PROJECTION)
(glPopMatrix)
(glMatrixMode GL_MODELVIEW)
(glPopMatrix))

; (:clear (mask &key (color))
; (if color
; (glClearColorfv color))
Expand Down Expand Up @@ -331,18 +339,18 @@

(defmethod glviewsurface
(:point (x y)
(send self :2d-mode)
(send self :2d-mode :push t)
(glBegin GL_POINTS)
(glVertex2fv (float-vector x (- x::height y)))
(glEnd)
(send self :3d-mode))
(send self :pop-mode))
(:line (x1 y1 x2 y2)
(send self :2d-mode)
(send self :2d-mode :push t)
(glBegin GL_LINES)
(glvertex2fv (float-vector x1 (- x::height y1)))
(glVertex2fv (float-vector x2 (- x::height y2)))
(glEnd)
(send self :3d-mode))
(send self :pop-mode))
(:3d-point (pos)
(glDisable GL_DEPTH_TEST)
(glDisable GL_LIGHTING)
Expand All @@ -365,14 +373,14 @@
(draw-face f nil nil))
faces))
(:rectangle (x y w h)
(send self :2d-mode)
(send self :2d-mode :push t)
(glBegin GL_POLYGON)
(glVertex2fv (float-vector x y))
(glVertex2fv (float-vector x (+ y h)))
(glVertex2fv (float-vector (+ x w) (+ y h)))
(glVertex2fv (float-vector (+ x w) y))
(glEnd)
(send self :3d-mode))
(send self :pop-mode))
)

(defun geo::default-viewsurface (&rest args)
Expand Down