-
Notifications
You must be signed in to change notification settings - Fork 0
/
sdl-opengl.lisp
44 lines (31 loc) · 1.44 KB
/
sdl-opengl.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
(in-package :handy-sdl)
(cffi:defcfun (c-sdl-gl-setattribute "SDL_GL_SetAttribute") :int
(attr :uchar) (value :int))
(cffi:defcfun (c-sdl-gl-createcontext "SDL_GL_CreateContext") :pointer
(window :pointer))
(cffi:defcfun (c-sdl-gl-deletecontext "SDL_GL_DeleteContext") :void
(context :pointer))
(cffi:defcfun (c-sdl-gl-swapwindow "SDL_GL_SwapWindow") :void
(window :pointer))
;; --------------------------------------------------------------------------
(define-enum-keyword-type sdl-glattr c-sdl-glattr)
(defun sdl-gl-setattribute (attr value)
(check-type attr sdl-glattr)
(check-type value (signed-byte 32))
(c-sdl-gl-setattribute (cffi:foreign-enum-value 'c-sdl-glattr attr)
value))
(define-enum-keyword-type sdl-glprofile c-sdl-glprofile)
(defun sdl-gl-set-context-profile-mask (flag)
(check-type flag sdl-glprofile)
(sdl-gl-setattribute :SDL_GL_CONTEXT_PROFILE_MASK (cffi:foreign-enum-value 'c-sdl-glprofile flag)))
(defstruct sdl-glcontext (ptr (null-pointer)))
(defun sdl-gl-createcontext (sdl-window)
(let ((context (c-sdl-gl-createcontext (sdl-window-ptr sdl-window))))
(make-sdl-glcontext :ptr context)))
(defun sdl-gl-deletecontext (sdl-glcontext)
(let ((ptr (sdl-glcontext-ptr sdl-glcontext)))
(setf (sdl-glcontext-ptr sdl-glcontext) (null-pointer))
(c-sdl-gl-deletecontext ptr)))
(defun sdl-gl-swapwindow (sdl-window)
(let ((ptr (sdl-window-ptr sdl-window)))
(c-sdl-gl-swapwindow ptr)))