Adding legacy/core decision in gl-config/canvas

This commit is contained in:
Jay McCarthy 2014-07-22 19:45:47 -04:00
parent ac05b99db3
commit 31001f3484
5 changed files with 38 additions and 6 deletions

View File

@ -11,9 +11,9 @@ A @racket[gl-config%] object encapsulates configuration information
@defconstructor[()]{
Creates a GL configuration that indicates double buffering, a depth
buffer of size one, no stencil buffer, no accumulation buffer, no
multisampling, and not stereo.
Creates a GL configuration that indicates legacy OpenGL, double
buffering, a depth buffer of size one, no stencil buffer, no
accumulation buffer, no multisampling, and not stereo.
}
@ -143,4 +143,20 @@ Adjusts the configuration to request a particular stencil-buffer size,
Adjusts the configuration to request stereo or not.
}}
}
@defmethod[(get-legacy?)
boolean?]{
Reports whether to use legacy, "Compatibility" OpenGL or "Core" OpenGL.
@history[#:added "1.2"]
}
@defmethod[(set-legacy? [legacy? any/c])
void?]{
Adjusts the configuration to request legacy or not.
@history[#:added "1.2"]
}
}

View File

@ -14,4 +14,4 @@
(define pkg-authors '(mflatt))
(define version "1.1")
(define version "1.2")

View File

@ -393,7 +393,9 @@
(set-multisample-size (->m (integer-in 0 256) void?))
(set-stencil-size (->m (integer-in 0 256) void?))
(set-stereo (->m any/c void?))
(set-share-context (->m (or/c (is-a?/c gl-context%) #f) void?))))
(set-share-context (->m (or/c (is-a?/c gl-context%) #f) void?))
(get-legacy? (->m boolean?))
(set-legacy? (->m any/c void?))))
(define bitmap%/c
(class/c

View File

@ -7,6 +7,10 @@
(defclass gl-config% object%
(super-new)
(define legacy? #t)
(define/public (get-legacy?) legacy?)
(define/public (set-legacy? v) (set! legacy? (and v #t)))
(define double-buffered? #t)
(define/public (get-double-buffered) double-buffered?)
(define/public (set-double-buffered v) (set! double-buffered? (and v #t)))

View File

@ -192,12 +192,22 @@
(define NSOpenGLPFASampleBuffers 55)
(define NSOpenGLPFASamples 56)
(define NSOpenGLPFAMultisample 59)
(define NSOpenGLPFAOpenGLProfile 99)
(define NSOpenGLProfileVersionLegacy #x1000)
(define NSOpenGLProfileVersion3_2Core #x3200)
(define (gl-config->pixel-format conf)
(let ([conf (or conf (new gl-config%))])
(tell (tell NSOpenGLPixelFormat alloc)
initWithAttributes: #:type (_list i _int)
(append
(if (version-10.7-or-later?)
(list NSOpenGLPFAOpenGLProfile
(if (send conf get-legacy?)
NSOpenGLProfileVersionLegacy
NSOpenGLProfileVersion3_2Core))
null)
(if (send conf get-double-buffered) (list NSOpenGLPFADoubleBuffer) null)
(if (send conf get-stereo) (list NSOpenGLPFAStereo) null)
(list