<commit_before>;;;; basic-window.lisp
;;;; OpenGL example code borrowed from cl-opengl
(in-package #:cl-glfw3-examples)

(export '(basic-window-example))

(def-key-callback key-callback (window key scancode action mod-keys)
  (declare (ignore window scancode mod-keys))
  (when (and (eq key :escape) (eq action :press))
    (set-window-should-close)))

(defvar *spin* 0.0)

(defmethod render ()
  (gl:clear :color-buffer)
  (gl:with-pushed-matrix
    (gl:rotate *spin* 0 0 1)
    (gl:color 1 1 1)
    (gl:rect -25 -25 25 25)))

(defmethod set-viewport (width height)
  (gl:viewport 0 0 width height)
  (gl:matrix-mode :projection)
  (gl:load-identity)
  (gl:ortho -50 50 -50 50 -1 1)
  (gl:matrix-mode :modelview)
  (gl:load-identity))

(def-window-size-callback window-size-callback (window w h)
  (declare (ignore window))
  (set-viewport w h))

(defun basic-window-example ()
  (with-init-window (:title "Window test" :width 600 :height 400)
    (setf %gl:*gl-get-proc-address* #'get-proc-address)
    (set-key-callback 'key-callback)
    (set-window-size-callback 'window-size-callback)
    (gl:clear-color 0 0 0 0)
    (set-viewport 600 400)
    (loop until (window-should-close-p)
       do (render)
       do (swap-buffers)
       do (poll-events))))
<commit_msg>Fix example<commit_after>;;;; basic-window.lisp
;;;; OpenGL example code borrowed from cl-opengl
(in-package #:cl-glfw3-examples)

(export '(basic-window-example))

(def-key-callback key-callback (window key scancode action mod-keys)
  (declare (ignore window scancode mod-keys))
  (when (and (eq key :escape) (eq action :press))
    (set-window-should-close)))

(defmethod render ()
  (gl:clear :color-buffer)
  (gl:with-pushed-matrix
    (gl:color 1 1 1)
    (gl:rect -25 -25 25 25)))

(defmethod set-viewport (width height)
  (gl:viewport 0 0 width height)
  (gl:matrix-mode :projection)
  (gl:load-identity)
  (gl:ortho -50 50 -50 50 -1 1)
  (gl:matrix-mode :modelview)
  (gl:load-identity))

(def-window-size-callback window-size-callback (window w h)
  (declare (ignore window))
  (set-viewport w h))

(defun basic-window-example ()
  (with-init-window (:title "Window test" :width 600 :height 400)
    (setf %gl:*gl-get-proc-address* #'get-proc-address)
    (set-key-callback 'key-callback)
    (set-window-size-callback 'window-size-callback)
    (gl:clear-color 0 0 0 0)
    (set-viewport 600 400)
    (loop until (window-should-close-p)
       do (render)
       do (swap-buffers)
       do (poll-events))))

{'fraction_non_alphanumeric': 0.15836012861736334, 'fraction_numerical': 0.034163987138263664, 'mean_word_length': 3.5586080586080584, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3595754', 'n_tokens_mistral': 995, 'n_tokens_neox': 908, 'n_words': 237}