Permalink
Browse files

Added more wrapper functions to the Objc 'bridge'.

  • Loading branch information...
1 parent bbd665a commit 2b55e02f0c266441e436723c4a500cbc44a315f2 @jtza8 jtza8 committed with patzy Sep 26, 2011
Showing with 153 additions and 21 deletions.
  1. +1 −0 glop.asd
  2. +40 −0 src/osx/appkit.lisp
  3. +47 −0 src/osx/bridge/appkit.m
  4. BIN src/osx/bridge/glop-bridge.dylib
  5. +18 −1 src/osx/glop-osx.lisp
  6. +22 −1 src/osx/package.lisp
  7. +22 −18 src/utils.lisp
  8. +3 −1 src/x11/glx.lisp
View
@@ -28,6 +28,7 @@
:components ((:file "package")
(:file "bridge")
(:file "foundation")
+ (:file "appkit")
(:file "quartz")
(:file "glop-osx")))
#+(or win32 windows)
View
@@ -2,9 +2,49 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; NSColor ;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+(defcfun ("NSColorBlackColor" ns-black-color) :pointer)
+(defcfun ("NSColorBlueColor" ns-blue-color) :pointer)
+(defcfun ("NSColorBrownColor" ns-brown-color) :pointer)
+(defcfun ("NSColorCyanColor" ns-cyan-color) :pointer)
+(defcfun ("NSColorDarkGrayColor" ns-dark-gray-color) :pointer)
+(defcfun ("NSColorGrayColor" ns-gray-color) :pointer)
+(defcfun ("NSColorGreenColor" ns-green-color) :pointer)
+(defcfun ("NSColorLightGrayColor" ns-light-gray-color) :pointer)
+(defcfun ("NSColorMagentaColor" ns-magenta-color) :pointer)
+(defcfun ("NSColorOrangeColor" ns-orange-color) :pointer)
+(defcfun ("NSColorPurpleColor" ns-purple-color) :pointer)
+(defcfun ("NSColorWhiteColor" ns-white-color) :pointer)
+(defcfun ("NSColorYellowColor" ns-yellow-color) :pointer)
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; NSApplication ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defcfun ("NSApplicationSharedApplication" ns-application-shared-application)
:void)
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; NSWindow ;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+(defcfun ("NSWindowAllocInit" ns-window-alloc-init) :pointer
+ (x :int)
+ (y :int)
+ (width :int)
+ (height :int))
+
+(defcfun ("NSWindowSetBackgroundColor" ns-window-set-background-color) :void
+ (window :pointer)
+ (color :pointer))
+
+(defcfun ("NSWindowMakeKeyAndOrderFront" ns-window-make-key-and-order-front)
+ :void
+ (window :pointer))
View
@@ -2,6 +2,26 @@
/******************************************************************************/
+/*** NSColor ***/
+/******************************************************************************/
+
+
+NSColor *NSColorBlackColor () { return [NSColor blackColor]; }
+NSColor *NSColorBlueColor () { return [NSColor blueColor]; }
+NSColor *NSColorBrownColor () { return [NSColor brownColor]; }
+NSColor *NSColorCyanColor () { return [NSColor cyanColor]; }
+NSColor *NSColorDarkGrayColor () { return [NSColor darkGrayColor]; }
+NSColor *NSColorGrayColor () { return [NSColor grayColor]; }
+NSColor *NSColorGreenColor () { return [NSColor greenColor]; }
+NSColor *NSColorLightGrayColor () { return [NSColor lightGrayColor]; }
+NSColor *NSColorMagentaColor () { return [NSColor magentaColor]; }
+NSColor *NSColorOrangeColor () { return [NSColor orangeColor]; }
+NSColor *NSColorPurpleColor () { return [NSColor purpleColor]; }
+NSColor *NSColorWhiteColor () { return [NSColor whiteColor]; }
+NSColor *NSColorYellowColor () { return [NSColor yellowColor]; }
+
+
+/******************************************************************************/
/*** NSApplication ***/
/******************************************************************************/
@@ -10,3 +30,30 @@ void NSApplicationSharedApplication ()
{
[NSApplication sharedApplication];
}
+
+
+/******************************************************************************/
+/*** NSWindow ***/
+/******************************************************************************/
+
+
+NSWindow *NSWindowAllocInit (int x, int y, int width, int height)
+{
+ NSWindow *window =
+ [[[NSWindow alloc]
+ initWithContentRect:NSMakeRect(x, y, width, height)
+ styleMask:NSClosableWindowMask | NSTitledWindowMask
+ backing:NSBackingStoreBuffered
+ defer:NO] autorelease];
+ return window;
+}
+
+void NSWindowSetBackgroundColor (NSWindow *window, NSColor *color)
+{
+ [window setBackgroundColor:color];
+}
+
+void NSWindowMakeKeyAndOrderFront (NSWindow *window, id sender)
+{
+ [window makeKeyAndOrderFront:sender];
+}
Binary file not shown.
View
@@ -18,4 +18,21 @@
(loop for i below (glop-bridge:ns-array-count display-modes)
collect (display-to-video-mode
(glop-bridge:ns-array-object-at-index
- display-modes i)))))
+ display-modes i)))))
+
+(defmethod open-window (window title width height
+ &key (x 0) (y 0) (rgba t) (double-buffer t) stereo
+ (red-size 4) (green-size 4) (blue-size 4) (alpha-size 4)
+ (depth-size 16) accum-buffer (accum-red-size 0)
+ (accum-green-size 0) (accum-blue-size 0) stencil-buffer
+ (stencil-size 0))
+ (declare (ignorable
+ x y rgba double-buffer stereo red-size green-size blue-size
+ alpha-size depth-size accum-buffer accum-red-size
+ accum-green-size accum-blue-size stencil-buffer
+ stencil-size))
+ (glop-bridge:with-ns-autorelease-pool
+ (let ((window (glop-bridge:ns-window-alloc-init x y width height)))
+ (glop-bridge:ns-window-set-background-color
+ window (glop-bridge:ns-blue-color))
+ (glop-bridge:ns-window-make-key-and-order-front window))))
View
@@ -10,4 +10,25 @@
#:ns-array-count
#:ns-array-object-at-index
#:ns-string-to-lisp
- #:ns-application-shared-application))
+ #:ns-application-shared-application
+ #:ns-black-color
+ #:ns-blue-color
+ #:ns-brown-color
+ #:ns-cyan-color
+ #:ns-dark-gray-color
+ #:ns-gray-color
+ #:ns-green-color
+ #:ns-light-gray-color
+ #:ns-magenta-color
+ #:ns-orange-color
+ #:ns-purple-color
+ #:ns-white-color
+ #:ns-yellow-color
+ #:ns-window-alloc-init
+ #:ns-window-set-background-color
+ #:ns-window-make-key-and-order-front
+ #:ns-autorelease-pool-alloc-init
+ #:ns-autorelease-pool-release
+ #:with-ns-autorelease-pool
+ #:ns-string-c-string-using-encoding
+ #:ns-string-to-lisp-string))
View
@@ -114,23 +114,27 @@ Otherwise, only one key-press event will be triggered.")
;; misc.
(defun load-libraries ()
- #+(and unix (not darwin))(progn (cffi:define-foreign-library xlib
- (t (:default "libX11")))
- (cffi:use-foreign-library xlib)
- (cffi:define-foreign-library opengl
- (t (:default "libGL")))
- (cffi:use-foreign-library opengl))
- #+(or win32 windows)(progn (cffi:define-foreign-library user32
- (t (:default "user32")))
- (cffi:use-foreign-library user32)
- (cffi:define-foreign-library kernel32
- (t (:default "kernel32")))
- (cffi:use-foreign-library kernel32)
- (cffi:define-foreign-library opengl
- (t (:default "opengl32")))
- (cffi:use-foreign-library opengl)
- (cffi:define-foreign-library gdi32
- (t (:default "gdi32")))
- (cffi:use-foreign-library gdi32)))
+ #+(and unix (not darwin))
+ (progn (cffi:define-foreign-library xlib
+ (t (:default "libX11")))
+ (cffi:use-foreign-library xlib)
+ (cffi:define-foreign-library opengl
+ (t (:or (:default "libGL")
+ "libGL.so.1"
+ "libGL.so.2")))
+ (cffi:use-foreign-library opengl))
+ #+(or win32 windows)
+ (progn (cffi:define-foreign-library user32
+ (t (:default "user32")))
+ (cffi:use-foreign-library user32)
+ (cffi:define-foreign-library kernel32
+ (t (:default "kernel32")))
+ (cffi:use-foreign-library kernel32)
+ (cffi:define-foreign-library opengl
+ (t (:default "opengl32")))
+ (cffi:use-foreign-library opengl)
+ (cffi:define-foreign-library gdi32
+ (t (:default "gdi32")))
+ (cffi:use-foreign-library gdi32)))
View
@@ -54,7 +54,9 @@
(:bad-enum))
(define-foreign-library opengl
- (t (:default "libGL")))
+ (t (:or (:default "libGL")
+ "libGL.so.1"
+ "libGL.so.2")))
(use-foreign-library opengl)
(defctype fb-config :pointer)

0 comments on commit 2b55e02

Please sign in to comment.