src/video/uikit/SDL_uikitvideo.m
author Sam Lantinga <slouken@libsdl.org>
Tue, 08 Nov 2011 00:02:47 -0500
changeset 6062 2e4a1b92dc6f
parent 6044 35448a5ea044
child 6073 9738f2a8eee4
permissions -rw-r--r--
Fixed a typo, we should set the driverdata if we are 3.2 or newer.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     1
/*
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5518
diff changeset
     2
  Simple DirectMedia Layer
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5518
diff changeset
     3
  Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org>
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     4
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5518
diff changeset
     5
  This software is provided 'as-is', without any express or implied
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5518
diff changeset
     6
  warranty.  In no event will the authors be held liable for any damages
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5518
diff changeset
     7
  arising from the use of this software.
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     8
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5518
diff changeset
     9
  Permission is granted to anyone to use this software for any purpose,
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5518
diff changeset
    10
  including commercial applications, and to alter it and redistribute it
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5518
diff changeset
    11
  freely, subject to the following restrictions:
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    12
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5518
diff changeset
    13
  1. The origin of this software must not be misrepresented; you must not
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5518
diff changeset
    14
     claim that you wrote the original software. If you use this software
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5518
diff changeset
    15
     in a product, an acknowledgment in the product documentation would be
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5518
diff changeset
    16
     appreciated but is not required.
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5518
diff changeset
    17
  2. Altered source versions must be plainly marked as such, and must not be
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5518
diff changeset
    18
     misrepresented as being the original software.
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5518
diff changeset
    19
  3. This notice may not be removed or altered from any source distribution.
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    20
*/
6044
35448a5ea044 Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents: 6019
diff changeset
    21
#include "SDL_config.h"
35448a5ea044 Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents: 6019
diff changeset
    22
35448a5ea044 Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents: 6019
diff changeset
    23
#if SDL_VIDEO_DRIVER_UIKIT
4443
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
    24
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
    25
#import <UIKit/UIKit.h>
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
    26
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    27
#include "SDL_video.h"
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    28
#include "SDL_mouse.h"
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    29
#include "../SDL_sysvideo.h"
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    30
#include "../SDL_pixels_c.h"
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    31
#include "../../events/SDL_events_c.h"
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    32
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    33
#include "SDL_uikitvideo.h"
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    34
#include "SDL_uikitevents.h"
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    35
#include "SDL_uikitwindow.h"
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    36
#include "SDL_uikitopengles.h"
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    37
4443
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
    38
#include "SDL_assert.h"
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
    39
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    40
#define UIKITVID_DRIVER_NAME "uikit"
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    41
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    42
/* Initialization/Query functions */
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    43
static int UIKit_VideoInit(_THIS);
4443
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
    44
static void UIKit_GetDisplayModes(_THIS, SDL_VideoDisplay * sdl_display);
3643
41253c0fa9b3 Fixed function prototype
Sam Lantinga <slouken@libsdl.org>
parents: 3547
diff changeset
    45
static int UIKit_SetDisplayMode(_THIS, SDL_VideoDisplay * display,
41253c0fa9b3 Fixed function prototype
Sam Lantinga <slouken@libsdl.org>
parents: 3547
diff changeset
    46
                                SDL_DisplayMode * mode);
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    47
static void UIKit_VideoQuit(_THIS);
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    48
4446
8b03a20b320f Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents: 4445
diff changeset
    49
BOOL SDL_UIKit_supports_multiple_displays = NO;
4443
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
    50
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    51
/* DUMMY driver bootstrap functions */
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    52
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    53
static int
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    54
UIKit_Available(void)
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    55
{
6003
fddf81967e2d Use a consistent source code format in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 6001
diff changeset
    56
    return 1;
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    57
}
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    58
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    59
static void UIKit_DeleteDevice(SDL_VideoDevice * device)
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    60
{
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    61
    SDL_free(device);
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    62
}
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    63
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    64
static SDL_VideoDevice *
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    65
UIKit_CreateDevice(int devindex)
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    66
{
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    67
    SDL_VideoDevice *device;
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    68
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    69
    /* Initialize all variables that we clean on shutdown */
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    70
    device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    71
    if (!device) {
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    72
        SDL_OutOfMemory();
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    73
        if (device) {
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    74
            SDL_free(device);
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    75
        }
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    76
        return (0);
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    77
    }
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    78
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    79
    /* Set the function pointers */
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    80
    device->VideoInit = UIKit_VideoInit;
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    81
    device->VideoQuit = UIKit_VideoQuit;
4443
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
    82
    device->GetDisplayModes = UIKit_GetDisplayModes;
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    83
    device->SetDisplayMode = UIKit_SetDisplayMode;
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    84
    device->PumpEvents = UIKit_PumpEvents;
5131
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5056
diff changeset
    85
    device->CreateWindow = UIKit_CreateWindow;
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5056
diff changeset
    86
    device->DestroyWindow = UIKit_DestroyWindow;
5056
8b7988f42fcb Added the ability to get the UIKit window through the SDL API.
Sam Lantinga <slouken@libsdl.org>
parents: 4446
diff changeset
    87
    device->GetWindowWMInfo = UIKit_GetWindowWMInfo;
6001
3ae3d1e58d59 Cleanup out trailing whitespace in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 5558
diff changeset
    88
3ae3d1e58d59 Cleanup out trailing whitespace in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 5558
diff changeset
    89
5131
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5056
diff changeset
    90
    /* OpenGL (ES) functions */
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5056
diff changeset
    91
    device->GL_MakeCurrent        = UIKit_GL_MakeCurrent;
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5056
diff changeset
    92
    device->GL_SwapWindow        = UIKit_GL_SwapWindow;
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5056
diff changeset
    93
    device->GL_CreateContext    = UIKit_GL_CreateContext;
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5056
diff changeset
    94
    device->GL_DeleteContext    = UIKit_GL_DeleteContext;
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5056
diff changeset
    95
    device->GL_GetProcAddress   = UIKit_GL_GetProcAddress;
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5056
diff changeset
    96
    device->GL_LoadLibrary        = UIKit_GL_LoadLibrary;
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5056
diff changeset
    97
    device->free = UIKit_DeleteDevice;
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    98
5131
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5056
diff changeset
    99
    device->gl_config.accelerated = 1;
7b7da52e8775 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 5056
diff changeset
   100
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   101
    return device;
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   102
}
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   103
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   104
VideoBootStrap UIKIT_bootstrap = {
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   105
    UIKITVID_DRIVER_NAME, "SDL UIKit video driver",
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   106
    UIKit_Available, UIKit_CreateDevice
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   107
};
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   108
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   109
4443
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
   110
/*
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
   111
!!! FIXME:
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
   112
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
   113
The main screen should list a AxB mode for portrait orientation, and then
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
   114
 also list BxA for landscape mode. When setting a given resolution, we should
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
   115
 rotate the view's transform appropriately (extra credit if you check the
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
   116
 accelerometer and rotate the display so it's never upside down).
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
   117
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
   118
  http://iphonedevelopment.blogspot.com/2008/10/starting-in-landscape-mode-without.html
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
   119
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
   120
*/
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
   121
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
   122
static void
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
   123
UIKit_GetDisplayModes(_THIS, SDL_VideoDisplay * display)
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
   124
{
4446
8b03a20b320f Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents: 4445
diff changeset
   125
    UIScreen *uiscreen = (UIScreen *) display->driverdata;
4443
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
   126
    SDL_DisplayMode mode;
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
   127
    SDL_zero(mode);
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
   128
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
   129
    // availableModes showed up in 3.2 (the iPad and later). We should only
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
   130
    //  land here for at least that version of the OS.
4446
8b03a20b320f Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents: 4445
diff changeset
   131
    if (!SDL_UIKit_supports_multiple_displays) {
8b03a20b320f Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents: 4445
diff changeset
   132
        const CGRect rect = [uiscreen bounds];
4443
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
   133
        mode.format = SDL_PIXELFORMAT_ABGR8888;
6009
fb5fa3561ca9 Simplied the code a bit in uikit/SDL_uikitvideo.m
Kees Bakker <kees@ijzerbout.nl>
parents: 6007
diff changeset
   134
        mode.refresh_rate = 0;
fb5fa3561ca9 Simplied the code a bit in uikit/SDL_uikitvideo.m
Kees Bakker <kees@ijzerbout.nl>
parents: 6007
diff changeset
   135
        mode.driverdata = NULL;
fb5fa3561ca9 Simplied the code a bit in uikit/SDL_uikitvideo.m
Kees Bakker <kees@ijzerbout.nl>
parents: 6007
diff changeset
   136
4443
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
   137
        mode.w = (int) rect.size.width;
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
   138
        mode.h = (int) rect.size.height;
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
   139
        SDL_AddDisplayMode(display, &mode);
6009
fb5fa3561ca9 Simplied the code a bit in uikit/SDL_uikitvideo.m
Kees Bakker <kees@ijzerbout.nl>
parents: 6007
diff changeset
   140
5518
f84dd424d514 iOS: Report both landscape and portrait orientation as display modes.
Ryan C. Gordon <icculus@icculus.org>
parents: 5262
diff changeset
   141
        mode.w = (int) rect.size.height;  // swap the orientation, add again.
f84dd424d514 iOS: Report both landscape and portrait orientation as display modes.
Ryan C. Gordon <icculus@icculus.org>
parents: 5262
diff changeset
   142
        mode.h = (int) rect.size.width;
f84dd424d514 iOS: Report both landscape and portrait orientation as display modes.
Ryan C. Gordon <icculus@icculus.org>
parents: 5262
diff changeset
   143
        SDL_AddDisplayMode(display, &mode);
4443
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
   144
        return;
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
   145
    }
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
   146
6007
0e647f56751d Use Objective-C construct for..in instead of oldfashioned C (uikit)
Kees Bakker <kees@ijzerbout.nl>
parents: 6003
diff changeset
   147
    for (UIScreenMode *uimode in [uiscreen availableModes]) {
5518
f84dd424d514 iOS: Report both landscape and portrait orientation as display modes.
Ryan C. Gordon <icculus@icculus.org>
parents: 5262
diff changeset
   148
        CGSize size = [uimode size];
4443
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
   149
        mode.format = SDL_PIXELFORMAT_ABGR8888;
5518
f84dd424d514 iOS: Report both landscape and portrait orientation as display modes.
Ryan C. Gordon <icculus@icculus.org>
parents: 5262
diff changeset
   150
        mode.refresh_rate = 0;
f84dd424d514 iOS: Report both landscape and portrait orientation as display modes.
Ryan C. Gordon <icculus@icculus.org>
parents: 5262
diff changeset
   151
        mode.driverdata = uimode;
4443
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
   152
        mode.w = (int) size.width;
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
   153
        mode.h = (int) size.height;
5518
f84dd424d514 iOS: Report both landscape and portrait orientation as display modes.
Ryan C. Gordon <icculus@icculus.org>
parents: 5262
diff changeset
   154
        if (SDL_AddDisplayMode(display, &mode))
6009
fb5fa3561ca9 Simplied the code a bit in uikit/SDL_uikitvideo.m
Kees Bakker <kees@ijzerbout.nl>
parents: 6007
diff changeset
   155
            [uimode retain];        // retain is needed because of mode.driverdata
5518
f84dd424d514 iOS: Report both landscape and portrait orientation as display modes.
Ryan C. Gordon <icculus@icculus.org>
parents: 5262
diff changeset
   156
6009
fb5fa3561ca9 Simplied the code a bit in uikit/SDL_uikitvideo.m
Kees Bakker <kees@ijzerbout.nl>
parents: 6007
diff changeset
   157
        if (uiscreen == [UIScreen mainScreen]) {
fb5fa3561ca9 Simplied the code a bit in uikit/SDL_uikitvideo.m
Kees Bakker <kees@ijzerbout.nl>
parents: 6007
diff changeset
   158
            // Add the mode with swapped width/height
fb5fa3561ca9 Simplied the code a bit in uikit/SDL_uikitvideo.m
Kees Bakker <kees@ijzerbout.nl>
parents: 6007
diff changeset
   159
            mode.w = (int) size.height;
fb5fa3561ca9 Simplied the code a bit in uikit/SDL_uikitvideo.m
Kees Bakker <kees@ijzerbout.nl>
parents: 6007
diff changeset
   160
            mode.h = (int) size.width;
5518
f84dd424d514 iOS: Report both landscape and portrait orientation as display modes.
Ryan C. Gordon <icculus@icculus.org>
parents: 5262
diff changeset
   161
            if (SDL_AddDisplayMode(display, &mode))
f84dd424d514 iOS: Report both landscape and portrait orientation as display modes.
Ryan C. Gordon <icculus@icculus.org>
parents: 5262
diff changeset
   162
                [uimode retain];
f84dd424d514 iOS: Report both landscape and portrait orientation as display modes.
Ryan C. Gordon <icculus@icculus.org>
parents: 5262
diff changeset
   163
        }
4443
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
   164
    }
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
   165
}
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
   166
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
   167
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
   168
static void
6018
fa4a3c1d857b Eliminate UIScreenMode parameter from UIKit_AddDisplay
Kees Bakker <kees@ijzerbout.nl>
parents: 6014
diff changeset
   169
UIKit_AddDisplay(UIScreen *uiscreen, int w, int h)
4443
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
   170
{
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
   171
    SDL_VideoDisplay display;
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
   172
    SDL_DisplayMode mode;
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
   173
    SDL_zero(mode);
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
   174
    mode.format = SDL_PIXELFORMAT_ABGR8888;
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
   175
    mode.w = w;
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
   176
    mode.h = h;
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
   177
    mode.refresh_rate = 0;
6001
3ae3d1e58d59 Cleanup out trailing whitespace in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 5558
diff changeset
   178
6018
fa4a3c1d857b Eliminate UIScreenMode parameter from UIKit_AddDisplay
Kees Bakker <kees@ijzerbout.nl>
parents: 6014
diff changeset
   179
    // UIScreenMode showed up in 3.2 (the iPad and later). We're
fa4a3c1d857b Eliminate UIScreenMode parameter from UIKit_AddDisplay
Kees Bakker <kees@ijzerbout.nl>
parents: 6014
diff changeset
   180
    //  misusing this supports_multiple_displays flag here for that.
6062
2e4a1b92dc6f Fixed a typo, we should set the driverdata if we are 3.2 or newer.
Sam Lantinga <slouken@libsdl.org>
parents: 6044
diff changeset
   181
    if (SDL_UIKit_supports_multiple_displays) {
6018
fa4a3c1d857b Eliminate UIScreenMode parameter from UIKit_AddDisplay
Kees Bakker <kees@ijzerbout.nl>
parents: 6014
diff changeset
   182
        UIScreenMode *uimode = [uiscreen currentMode];
fa4a3c1d857b Eliminate UIScreenMode parameter from UIKit_AddDisplay
Kees Bakker <kees@ijzerbout.nl>
parents: 6014
diff changeset
   183
        [uimode retain];  // once for the desktop_mode
fa4a3c1d857b Eliminate UIScreenMode parameter from UIKit_AddDisplay
Kees Bakker <kees@ijzerbout.nl>
parents: 6014
diff changeset
   184
        [uimode retain];  // once for the current_mode
fa4a3c1d857b Eliminate UIScreenMode parameter from UIKit_AddDisplay
Kees Bakker <kees@ijzerbout.nl>
parents: 6014
diff changeset
   185
        mode.driverdata = uimode;
fa4a3c1d857b Eliminate UIScreenMode parameter from UIKit_AddDisplay
Kees Bakker <kees@ijzerbout.nl>
parents: 6014
diff changeset
   186
    }
4443
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
   187
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
   188
    SDL_zero(display);
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
   189
    display.desktop_mode = mode;
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
   190
    display.current_mode = mode;
4446
8b03a20b320f Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents: 4445
diff changeset
   191
8b03a20b320f Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents: 4445
diff changeset
   192
    [uiscreen retain];
8b03a20b320f Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents: 4445
diff changeset
   193
    display.driverdata = uiscreen;
4443
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
   194
    SDL_AddVideoDisplay(&display);
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
   195
}
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
   196
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
   197
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   198
int
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   199
UIKit_VideoInit(_THIS)
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   200
{
4443
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
   201
    _this->gl_config.driver_loaded = 1;
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   202
4445
06becafcac89 Test for system version in the Apple Recommended way.
Ryan C. Gordon <icculus@icculus.org>
parents: 4443
diff changeset
   203
    NSString *reqSysVer = @"3.2";
06becafcac89 Test for system version in the Apple Recommended way.
Ryan C. Gordon <icculus@icculus.org>
parents: 4443
diff changeset
   204
    NSString *currSysVer = [[UIDevice currentDevice] systemVersion];
06becafcac89 Test for system version in the Apple Recommended way.
Ryan C. Gordon <icculus@icculus.org>
parents: 4443
diff changeset
   205
    if ([currSysVer compare:reqSysVer options:NSNumericSearch] != NSOrderedAscending)
4446
8b03a20b320f Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents: 4445
diff changeset
   206
        SDL_UIKit_supports_multiple_displays = YES;
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   207
6013
b253cc3c4276 Do not use UIScreenMode to add a iOS display, always use the boundary
Kees Bakker <kees@ijzerbout.nl>
parents: 6009
diff changeset
   208
    // Add the main screen.
b253cc3c4276 Do not use UIScreenMode to add a iOS display, always use the boundary
Kees Bakker <kees@ijzerbout.nl>
parents: 6009
diff changeset
   209
    UIScreen *uiscreen = [UIScreen mainScreen];
b253cc3c4276 Do not use UIScreenMode to add a iOS display, always use the boundary
Kees Bakker <kees@ijzerbout.nl>
parents: 6009
diff changeset
   210
    const CGSize size = [uiscreen bounds].size;
6018
fa4a3c1d857b Eliminate UIScreenMode parameter from UIKit_AddDisplay
Kees Bakker <kees@ijzerbout.nl>
parents: 6014
diff changeset
   211
    UIKit_AddDisplay(uiscreen, (int)size.width, (int)size.height);
6013
b253cc3c4276 Do not use UIScreenMode to add a iOS display, always use the boundary
Kees Bakker <kees@ijzerbout.nl>
parents: 6009
diff changeset
   212
4443
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
   213
    // If this is iPhoneOS < 3.2, all devices are one screen, 320x480 pixels.
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
   214
    //  The iPad added both a larger main screen and the ability to use
6013
b253cc3c4276 Do not use UIScreenMode to add a iOS display, always use the boundary
Kees Bakker <kees@ijzerbout.nl>
parents: 6009
diff changeset
   215
    //  external displays. So, add the other displays (screens in UI speak).
b253cc3c4276 Do not use UIScreenMode to add a iOS display, always use the boundary
Kees Bakker <kees@ijzerbout.nl>
parents: 6009
diff changeset
   216
    if (SDL_UIKit_supports_multiple_displays) {
6007
0e647f56751d Use Objective-C construct for..in instead of oldfashioned C (uikit)
Kees Bakker <kees@ijzerbout.nl>
parents: 6003
diff changeset
   217
        for (UIScreen *uiscreen in [UIScreen screens]) {
6013
b253cc3c4276 Do not use UIScreenMode to add a iOS display, always use the boundary
Kees Bakker <kees@ijzerbout.nl>
parents: 6009
diff changeset
   218
            // Only add the other screens
b253cc3c4276 Do not use UIScreenMode to add a iOS display, always use the boundary
Kees Bakker <kees@ijzerbout.nl>
parents: 6009
diff changeset
   219
            if (uiscreen != [UIScreen mainScreen]) {
b253cc3c4276 Do not use UIScreenMode to add a iOS display, always use the boundary
Kees Bakker <kees@ijzerbout.nl>
parents: 6009
diff changeset
   220
                const CGSize size = [uiscreen bounds].size;
6018
fa4a3c1d857b Eliminate UIScreenMode parameter from UIKit_AddDisplay
Kees Bakker <kees@ijzerbout.nl>
parents: 6014
diff changeset
   221
                UIKit_AddDisplay(uiscreen, (int)size.width, (int)size.height);
6013
b253cc3c4276 Do not use UIScreenMode to add a iOS display, always use the boundary
Kees Bakker <kees@ijzerbout.nl>
parents: 6009
diff changeset
   222
            }
4443
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
   223
        }
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
   224
    }
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   225
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   226
    /* We're done! */
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   227
    return 0;
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   228
}
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   229
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   230
static int
3643
41253c0fa9b3 Fixed function prototype
Sam Lantinga <slouken@libsdl.org>
parents: 3547
diff changeset
   231
UIKit_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   232
{
4446
8b03a20b320f Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents: 4445
diff changeset
   233
    UIScreen *uiscreen = (UIScreen *) display->driverdata;
8b03a20b320f Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents: 4445
diff changeset
   234
    if (!SDL_UIKit_supports_multiple_displays) {
4443
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
   235
        // Not on at least iPhoneOS 3.2 (versions prior to iPad).
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
   236
        SDL_assert(mode->driverdata == NULL);
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
   237
    } else {
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
   238
        UIScreenMode *uimode = (UIScreenMode *) mode->driverdata;
4446
8b03a20b320f Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents: 4445
diff changeset
   239
        [uiscreen setCurrentMode:uimode];
4443
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
   240
    }
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
   241
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   242
    return 0;
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   243
}
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   244
6019
3d8b1ada8ad5 Use a small function to release UIScreenMode after checking it is supported
Kees Bakker <kees@ijzerbout.nl>
parents: 6018
diff changeset
   245
static void
3d8b1ada8ad5 Use a small function to release UIScreenMode after checking it is supported
Kees Bakker <kees@ijzerbout.nl>
parents: 6018
diff changeset
   246
UIKit_ReleaseUIScreenMode(SDL_DisplayMode * mode)
3d8b1ada8ad5 Use a small function to release UIScreenMode after checking it is supported
Kees Bakker <kees@ijzerbout.nl>
parents: 6018
diff changeset
   247
{
3d8b1ada8ad5 Use a small function to release UIScreenMode after checking it is supported
Kees Bakker <kees@ijzerbout.nl>
parents: 6018
diff changeset
   248
    if (!SDL_UIKit_supports_multiple_displays) {
3d8b1ada8ad5 Use a small function to release UIScreenMode after checking it is supported
Kees Bakker <kees@ijzerbout.nl>
parents: 6018
diff changeset
   249
        // Not on at least iPhoneOS 3.2 (versions prior to iPad).
3d8b1ada8ad5 Use a small function to release UIScreenMode after checking it is supported
Kees Bakker <kees@ijzerbout.nl>
parents: 6018
diff changeset
   250
        SDL_assert(mode->driverdata == NULL);
3d8b1ada8ad5 Use a small function to release UIScreenMode after checking it is supported
Kees Bakker <kees@ijzerbout.nl>
parents: 6018
diff changeset
   251
    } else {
3d8b1ada8ad5 Use a small function to release UIScreenMode after checking it is supported
Kees Bakker <kees@ijzerbout.nl>
parents: 6018
diff changeset
   252
        UIScreenMode *uimode = (UIScreenMode *) mode->driverdata;
3d8b1ada8ad5 Use a small function to release UIScreenMode after checking it is supported
Kees Bakker <kees@ijzerbout.nl>
parents: 6018
diff changeset
   253
        [uimode release];
3d8b1ada8ad5 Use a small function to release UIScreenMode after checking it is supported
Kees Bakker <kees@ijzerbout.nl>
parents: 6018
diff changeset
   254
        mode->driverdata = NULL;
3d8b1ada8ad5 Use a small function to release UIScreenMode after checking it is supported
Kees Bakker <kees@ijzerbout.nl>
parents: 6018
diff changeset
   255
    }
3d8b1ada8ad5 Use a small function to release UIScreenMode after checking it is supported
Kees Bakker <kees@ijzerbout.nl>
parents: 6018
diff changeset
   256
}
3d8b1ada8ad5 Use a small function to release UIScreenMode after checking it is supported
Kees Bakker <kees@ijzerbout.nl>
parents: 6018
diff changeset
   257
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   258
void
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   259
UIKit_VideoQuit(_THIS)
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   260
{
4443
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
   261
    // Release Objective-C objects, so higher level doesn't free() them.
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
   262
    int i, j;
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
   263
    for (i = 0; i < _this->num_displays; i++) {
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
   264
        SDL_VideoDisplay *display = &_this->displays[i];
4446
8b03a20b320f Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents: 4445
diff changeset
   265
        UIScreen *uiscreen = (UIScreen *) display->driverdata;
8b03a20b320f Much improved multi-display support for iPad.
Ryan C. Gordon <icculus@icculus.org>
parents: 4445
diff changeset
   266
        [uiscreen release];
4443
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
   267
        display->driverdata = NULL;
6019
3d8b1ada8ad5 Use a small function to release UIScreenMode after checking it is supported
Kees Bakker <kees@ijzerbout.nl>
parents: 6018
diff changeset
   268
        UIKit_ReleaseUIScreenMode(&display->desktop_mode);
3d8b1ada8ad5 Use a small function to release UIScreenMode after checking it is supported
Kees Bakker <kees@ijzerbout.nl>
parents: 6018
diff changeset
   269
        UIKit_ReleaseUIScreenMode(&display->current_mode);
4443
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
   270
        for (j = 0; j < display->num_display_modes; j++) {
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
   271
            SDL_DisplayMode *mode = &display->display_modes[j];
6019
3d8b1ada8ad5 Use a small function to release UIScreenMode after checking it is supported
Kees Bakker <kees@ijzerbout.nl>
parents: 6018
diff changeset
   272
            UIKit_ReleaseUIScreenMode(mode);
4443
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
   273
        }
c598e440c87c Implemented display mode functionality for UIKit.
Ryan C. Gordon <icculus@icculus.org>
parents: 3643
diff changeset
   274
    }
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   275
}
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   276
6044
35448a5ea044 Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents: 6019
diff changeset
   277
#endif /* SDL_VIDEO_DRIVER_UIKIT */
35448a5ea044 Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents: 6019
diff changeset
   278
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   279
/* vi: set ts=4 sw=4 expandtab: */