comparison src/video/cocoa/SDL_cocoaopengl.m @ 5281:15a71bec4a55

merged
author Eric Wing <ewing . public |-at-| gmail . com>
date Sat, 12 Feb 2011 19:16:09 -0800
parents b530ef003506
children
comparison
equal deleted inserted replaced
5219:adfcdd311ae0 5281:15a71bec4a55
1 /* 1 /*
2 SDL - Simple DirectMedia Layer 2 SDL - Simple DirectMedia Layer
3 Copyright (C) 1997-2010 Sam Lantinga 3 Copyright (C) 1997-2011 Sam Lantinga
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public 6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version. 8 version 2.1 of the License, or (at your option) any later version.
70 70
71 SDL_GLContext 71 SDL_GLContext
72 Cocoa_GL_CreateContext(_THIS, SDL_Window * window) 72 Cocoa_GL_CreateContext(_THIS, SDL_Window * window)
73 { 73 {
74 NSAutoreleasePool *pool; 74 NSAutoreleasePool *pool;
75 SDL_VideoDisplay *display = window->display; 75 SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
76 SDL_DisplayData *displaydata = (SDL_DisplayData *)display->driverdata; 76 SDL_DisplayData *displaydata = (SDL_DisplayData *)display->driverdata;
77 NSOpenGLPixelFormatAttribute attr[32]; 77 NSOpenGLPixelFormatAttribute attr[32];
78 NSOpenGLPixelFormat *fmt; 78 NSOpenGLPixelFormat *fmt;
79 NSOpenGLContext *context; 79 NSOpenGLContext *context;
80 int i = 0; 80 int i = 0;
81 81
82 pool = [[NSAutoreleasePool alloc] init]; 82 pool = [[NSAutoreleasePool alloc] init];
83 83
84 #ifndef FULLSCREEN_TOGGLEABLE
84 if (window->flags & SDL_WINDOW_FULLSCREEN) { 85 if (window->flags & SDL_WINDOW_FULLSCREEN) {
85 attr[i++] = NSOpenGLPFAFullScreen; 86 attr[i++] = NSOpenGLPFAFullScreen;
86 } 87 }
88 #endif
87 89
88 attr[i++] = NSOpenGLPFAColorSize; 90 attr[i++] = NSOpenGLPFAColorSize;
89 attr[i++] = SDL_BYTESPERPIXEL(display->current_mode.format)*8; 91 attr[i++] = SDL_BYTESPERPIXEL(display->current_mode.format)*8;
90 92
91 attr[i++] = NSOpenGLPFADepthSize; 93 attr[i++] = NSOpenGLPFADepthSize;
197 199
198 if (context) { 200 if (context) {
199 SDL_WindowData *windowdata = (SDL_WindowData *)window->driverdata; 201 SDL_WindowData *windowdata = (SDL_WindowData *)window->driverdata;
200 NSOpenGLContext *nscontext = (NSOpenGLContext *)context; 202 NSOpenGLContext *nscontext = (NSOpenGLContext *)context;
201 203
204 #ifndef FULLSCREEN_TOGGLEABLE
202 if (window->flags & SDL_WINDOW_FULLSCREEN) { 205 if (window->flags & SDL_WINDOW_FULLSCREEN) {
203 [nscontext setFullScreen]; 206 [nscontext setFullScreen];
204 } else { 207 } else
208 #endif
209 {
205 [nscontext setView:[windowdata->nswindow contentView]]; 210 [nscontext setView:[windowdata->nswindow contentView]];
206 [nscontext update]; 211 [nscontext update];
207 } 212 }
208 [nscontext makeCurrentContext]; 213 [nscontext makeCurrentContext];
209 } else { 214 } else {