src/video/android/SDL_androidwindow.c
author Sam Lantinga <slouken@libsdl.org>
Mon, 07 Feb 2011 17:44:07 -0800
changeset 5222 c66b2a778b7e
parent 5001 77df56570442
child 5249 7a963be087ef
permissions -rw-r--r--
Try to create an OpenGL ES 2.0 context on Android and successfully fall back to OpenGL ES 1.1 if that fails.
slouken@4998
     1
/*
slouken@4998
     2
    SDL - Simple DirectMedia Layer
slouken@4998
     3
    Copyright (C) 1997-2010 Sam Lantinga
slouken@4998
     4
slouken@4998
     5
    This library is free software; you can redistribute it and/or
slouken@4998
     6
    modify it under the terms of the GNU Lesser General Public
slouken@4998
     7
    License as published by the Free Software Foundation; either
slouken@4998
     8
    version 2.1 of the License, or (at your option) any later version.
slouken@4998
     9
slouken@4998
    10
    This library is distributed in the hope that it will be useful,
slouken@4998
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
slouken@4998
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
slouken@4998
    13
    Lesser General Public License for more details.
slouken@4998
    14
slouken@4998
    15
    You should have received a copy of the GNU Lesser General Public
slouken@4998
    16
    License along with this library; if not, write to the Free Software
slouken@4998
    17
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
slouken@4998
    18
slouken@4998
    19
    Sam Lantinga
slouken@4998
    20
    slouken@libsdl.org
slouken@4998
    21
*/
slouken@4998
    22
#include "SDL_config.h"
slouken@4998
    23
slouken@4998
    24
#include "../SDL_sysvideo.h"
slouken@4998
    25
slouken@4998
    26
#include "SDL_androidvideo.h"
slouken@4998
    27
#include "SDL_androidwindow.h"
slouken@4998
    28
slouken@4998
    29
int
slouken@4998
    30
Android_CreateWindow(_THIS, SDL_Window * window)
slouken@4998
    31
{
slouken@5001
    32
    if (Android_Window) {
slouken@5001
    33
        SDL_SetError("Android only supports one window");
slouken@5001
    34
        return -1;
slouken@5001
    35
    }
slouken@5001
    36
    Android_Window = window;
slouken@5001
    37
slouken@4998
    38
    /* Adjust the window data to match the screen */
slouken@4998
    39
    window->x = 0;
slouken@4998
    40
    window->y = 0;
slouken@4998
    41
    window->w = Android_ScreenWidth;
slouken@4998
    42
    window->h = Android_ScreenHeight;
slouken@4998
    43
slouken@5222
    44
    window->flags &= ~SDL_WINDOW_RESIZABLE;     /* window is NEVER resizeable */
slouken@5222
    45
    window->flags |= SDL_WINDOW_OPENGL;         /* window is always OpenGL */
slouken@5222
    46
    window->flags |= SDL_WINDOW_FULLSCREEN;     /* window is always fullscreen */
slouken@5222
    47
    window->flags |= SDL_WINDOW_SHOWN;          /* only one window on Android */
slouken@5222
    48
    window->flags |= SDL_WINDOW_INPUT_FOCUS;    /* always has input focus */    
slouken@5222
    49
slouken@4998
    50
    return 0;
slouken@4998
    51
}
slouken@4998
    52
slouken@4998
    53
void
slouken@4998
    54
Android_SetWindowTitle(_THIS, SDL_Window * window)
slouken@4998
    55
{
slouken@4998
    56
    Android_JNI_SetActivityTitle(window->title);
slouken@4998
    57
}
slouken@4998
    58
slouken@4998
    59
void
slouken@4998
    60
Android_DestroyWindow(_THIS, SDL_Window * window)
slouken@4998
    61
{
slouken@5001
    62
    if (window == Android_Window) {
slouken@5001
    63
        Android_Window = NULL;
slouken@5001
    64
    }
slouken@4998
    65
}
slouken@4998
    66
slouken@4998
    67
/* vi: set ts=4 sw=4 expandtab: */