Skip to content

Commit

Permalink
Initial Commit for sdl2-ttf
Browse files Browse the repository at this point in the history
  • Loading branch information
Failproofshark committed Jun 15, 2015
0 parents commit 9337336
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.fasl
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# CL-SDL2-TTF

This is a wrapper for the SDL2_TTF library used for loading fonts and creating text assets.

## Usage

## Examples

## Issues
if you cannot load `cl-sdl-ttf`, please ensure you have SDL_TTF 2.0 installed and not just 1.2.

If you are sure all of this is correct, and it still will not load, please file an issue and specify
* Your platform and architecture
* Your Common Lisp implementation
* The absolute path to your installed .so, .dylib, .dll, or appropriate OSX framework
21 changes: 21 additions & 0 deletions sdl2-ttf.asd
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
(defpackage :sdl2-ttf.asdf
(:use #:cl #:asdf))

(in-package :sdl2-mixer.asdf)

(defsystem :sdl2-ttf
:description "Bindings for sdl2_ttf using autowrap"
:author "Bryan Baraoidan"
:license "MIT"
:version "1.0"
:depends-on (:alexandria :defpackage-plus :cl-autowrap :sdl2)
:pathname "src"
:serial t
:components ((:file "package")
(:file "library")
(:file "autowrap")
(:file "conditions")
(:file "general")
(:module autowrap-spec
:pathname "spec"
:components ((:static-file "SDL_ttf")))))
34 changes: 34 additions & 0 deletions src/conditions.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
;;; This file is adapted from almostly completely verbatim from cl-sdl2-mixer as I needed the same functionality for font loading
(in-package :sdl2-mixer)

(define-condition sdl-mixer-error (sdl2::sdl-rc-error) ())

;;; Note, Mix_GetError doesn't exist, it's a #define for SDL_GetError

(defmacro check-rc (form)
(with-gensyms (rc)
`(let ((,rc ,form))
(when (< ,rc 0)
(error 'sdl-ttf-error :rc ,rc :string (sdl-get-error)))
,rc)))

(defmacro check-non-zero (form)
(with-gensyms (rc)
`(let ((,rc ,form))
(unless (/= ,rc 0)
(error 'sdl-ttf-error :rc ,rc :string (sdl-get-error)))
,rc)))

(defmacro check-true (form)
(with-gensyms (rc)
`(let ((,rc ,form))
(unless (sdl-true-p ,rc)
(error 'sdl-ttf-error :rc ,rc :string (sdl-get-error)))
,rc)))

(defmacro check-null (form)
(with-gensyms (wrapper)
`(let ((,wrapper ,form))
(if (cffi:null-pointer-p (autowrap:ptr ,wrapper))
(error 'sdl-ttf-error :rc ,wrapper :string (sdl-get-error))
,wrapper))))
1 change: 1 addition & 0 deletions src/general.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(in-package :sdl2-ttf)
4 changes: 4 additions & 0 deletions src/library.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
(in-package :sdl2-mixer)

(cffi:define-foreign-library libsdl2-ttf
(:unix (:or "libSDL2_ttf-2.0.so.0" "libSDL2_ttf")))
8 changes: 8 additions & 0 deletions src/package.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
(in-package :cl-user)
(defpackage :sdl2-mixer
(:use #:cl
#:cffi
#:alexandria
#:autowrap.minimal
#:plus-c
#:sdl2-ffi.functions))
1 change: 1 addition & 0 deletions src/spec/SDL_ttf.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include <SDL2/SDL_ttf.h>

0 comments on commit 9337336

Please sign in to comment.