#import <AppKit/NSOpenGL.h>
#include <stdlib.h>
#include "cocoapixelformat.h"

struct _CocoaPixelFormat
{
	NSOpenGLPixelFormat *format;
};

CocoaPixelFormat *choose_pixel_format(unsigned *attribs)
{
	NSOpenGLPixelFormat *format = [NSOpenGLPixelFormat alloc];
	format = [format initWithAttributes:attribs];
	if(!format)
		return NULL;

	CocoaPixelFormat *wrapper = (CocoaPixelFormat *)malloc(sizeof(CocoaPixelFormat));
	wrapper->format = format;
	return wrapper;
}

void destroy_pixel_format(CocoaPixelFormat *format)
{
	[format->format release];
	free(format);
}

NSOpenGLPixelFormat *get_native_pixel_format(CocoaPixelFormat *format)
{
	return format->format;
}
