1 #import <AppKit/NSOpenGL.h>
2 #import <AppKit/NSWindow.h>
4 #include "cocoaglcontext.h"
6 NSOpenGLPixelFormat *get_native_pixel_format(CocoaPixelFormat *);
7 NSWindow *get_native_window(CocoaWindow *);
11 NSOpenGLContext *context;
14 CocoaGLContext *create_gl_context(CocoaPixelFormat *format)
16 NSOpenGLContext *ctx = [NSOpenGLContext alloc];
17 ctx = [ctx initWithFormat:get_native_pixel_format(format) shareContext:nil];
21 CocoaGLContext *wrapper = (CocoaGLContext *)malloc(sizeof(CocoaGLContext));
22 wrapper->context = ctx;
26 void destroy_gl_context(CocoaGLContext *context)
28 [context->context release];
32 void attach_gl_context_to_window(CocoaGLContext *context, CocoaWindow *window)
34 NSWindow *nswindow = get_native_window(window);
35 [context->context setView:[nswindow contentView]];
38 void make_gl_context_current(CocoaGLContext *context)
40 [context->context makeCurrentContext];
43 void flush_gl_buffer(CocoaGLContext *context)
45 [context->context flushBuffer];