4 #include "cocoaglcontext.h"
5 #include "cocoapixelformat.h"
6 #include "window_private.h"
13 typedef CocoaGLContext *ContextHandle;
15 struct GLContext::Private
17 ContextHandle context;
20 void GLContext::platform_init(const GLOptions &opts)
22 vector<unsigned> attribs;
24 attribs.push_back(CPF_DEPTH_SIZE);
29 attribs.push_back(CPF_ALPHA_SIZE);
35 attribs.push_back(CPF_STENCIL_SIZE);
40 attribs.push_back(CPF_DOUBLEBUFFER);
42 if(opts.multisample>0)
44 attribs.push_back(CPF_SAMPLE_BUFFERS);
46 attribs.push_back(CPF_SAMPLES);
47 attribs.push_back(opts.multisample);
52 CocoaPixelFormat *pixfmt = choose_pixel_format(&attribs.front());
54 throw unsupported_gl_mode(opts);
57 priv->context = create_gl_context(pixfmt);
58 destroy_pixel_format(pixfmt);
60 attach_gl_context_to_window(priv->context, window.get_private().window);
61 make_gl_context_current(priv->context);
64 GLContext::~GLContext()
66 destroy_gl_context(priv->context);
70 void GLContext::set_swap_interval(unsigned)
75 void GLContext::swap_buffers()
77 flush_gl_buffer(priv->context);
80 void GLContext::window_resized(unsigned, unsigned)
82 // XXX Call [context update] here?
85 } // namespace Graphics